Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions src/audio/dai.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,81 @@ static int dai_config(struct comp_dev *dev, struct sof_ipc_dai_config *config)
return 0;
}

static int dai_ctrl_set_cmd(struct comp_dev *dev,
struct sof_ipc_ctrl_data *cdata)
{
struct dai_data *dd = comp_get_drvdata(dev);
int ret = 0;
int val;

/* validate */
if (cdata->num_elems != 1) {
trace_dai_error("xs0");
return -EINVAL;
}

switch (cdata->cmd) {
case SOF_CTRL_CMD_SWITCH:
val = cdata->compv[0].uvalue;
trace_dai("dcs");
trace_value(cdata->comp_id);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will flow easier when using ioctl as the cmd can be passed directly in most cases.

trace_value(val);
dai_set_loopback_mode(dd->dai, val);
break;

default:
trace_dai_error("gs1");
return -EINVAL;
}

return ret;
}

static int dai_ctrl_get_cmd(struct comp_dev *dev,
struct sof_ipc_ctrl_data *cdata)
{
struct dai_data *dd = comp_get_drvdata(dev);
int val;

/* validate */
if (cdata->num_elems != 1) {
trace_dai_error("xg0");
return -EINVAL;
}
switch (cdata->cmd) {
case SOF_CTRL_CMD_SWITCH:
val = dai_get_loopback_mode(dd->dai);
trace_dai("dcg");
trace_value(cdata->comp_id);
trace_value(val);
cdata->compv[0].uvalue = val;
break;

default:
trace_dai_error("xcc");
return -EINVAL;
}

return 0;
}

/* used to pass standard and bespoke commands (with data) to component */
static int dai_cmd(struct comp_dev *dev, int cmd, void *data)
{
struct sof_ipc_ctrl_data *cdata = data;

trace_dai("cmd");

switch (cmd) {
case COMP_CMD_SET_VALUE:
return dai_ctrl_set_cmd(dev, cdata);
case COMP_CMD_GET_VALUE:
return dai_ctrl_get_cmd(dev, cdata);
default:
return -EINVAL;
}
}

static struct comp_driver comp_dai = {
.type = SOF_COMP_DAI,
.ops = {
Expand All @@ -700,6 +775,7 @@ static struct comp_driver comp_dai = {
.reset = dai_reset,
.dai_config = dai_config,
.position = dai_position,
.cmd = dai_cmd,
},
};

Expand Down