[Sound-open-firmware] [PATCH] core: make sure we emit trace errors for when returning error values.
Makes debug easier.
Signed-off-by: Liam Girdwood liam.r.girdwood@linux.intel.com --- src/audio/component.c | 1 + src/audio/pipeline.c | 21 ++++++++++++++------- src/ipc/intel-ipc.c | 1 + 3 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/src/audio/component.c b/src/audio/component.c index 232ef02..2a397d7 100644 --- a/src/audio/component.c +++ b/src/audio/component.c @@ -148,6 +148,7 @@ int comp_set_state(struct comp_dev *dev, int cmd) break; default: trace_comp_error("CEd"); + trace_value(cmd); ret = -EINVAL; break; } diff --git a/src/audio/pipeline.c b/src/audio/pipeline.c index 9aedc21..687efe9 100644 --- a/src/audio/pipeline.c +++ b/src/audio/pipeline.c @@ -465,7 +465,7 @@ static int preload_downstream(struct comp_dev *start, struct comp_dev *current) struct list_item *clist; int i, total = 0, count = 0;
- trace_pipe("PR-"); + tracev_pipe("PR-"); tracev_value(current->comp.id);
/* reached endpoint ? */ @@ -574,8 +574,11 @@ int pipeline_cmd(struct pipeline *p, struct comp_dev *host, int cmd, ret = component_op_upstream(&op_data, host, host, NULL); }
- if (ret < 0) - trace_ipc_error("pae"); + if (ret < 0) { + trace_ipc_error("pc0"); + trace_value(host->comp.id); + trace_value(cmd); + }
spin_unlock(&p->lock); return ret; @@ -617,8 +620,10 @@ int pipeline_params(struct pipeline *p, struct comp_dev *host, ret = component_op_upstream(&op_data, host, host, NULL); }
- if (ret < 0) - trace_ipc_error("pae"); + if (ret < 0) { + trace_ipc_error("pp0"); + trace_value(host->comp.id); + }
spin_unlock(&p->lock); return ret; @@ -645,8 +650,10 @@ int pipeline_reset(struct pipeline *p, struct comp_dev *host) ret = component_op_upstream(&op_data, host, host, NULL); }
- if (ret < 0) - trace_ipc_error("pae"); + if (ret < 0) { + trace_ipc_error("pr0"); + trace_value(host->comp.id); + }
spin_unlock(&p->lock); return ret; diff --git a/src/ipc/intel-ipc.c b/src/ipc/intel-ipc.c index 3912174..18d8732 100644 --- a/src/ipc/intel-ipc.c +++ b/src/ipc/intel-ipc.c @@ -567,6 +567,7 @@ static int ipc_comp_value(uint32_t header, uint32_t cmd) stream_dev = ipc_get_comp(_ipc, data->comp_id); if (stream_dev == NULL){ trace_ipc_error("eVg"); + trace_value(data->comp_id); return -ENODEV; }
Need to add a reply to ctrl data, since the structure can be returned to host e.g. during kcontrol get() calls.
Signed-off-by: Liam Girdwood liam.r.girdwood@linux.intel.com --- src/include/uapi/ipc.h | 2 +- src/ipc/intel-ipc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/include/uapi/ipc.h b/src/include/uapi/ipc.h index fb7e3b9..cbccb55 100644 --- a/src/include/uapi/ipc.h +++ b/src/include/uapi/ipc.h @@ -470,7 +470,7 @@ struct sof_ipc_ctrl_value_comp {
/* generic control data */ struct sof_ipc_ctrl_data { - struct sof_ipc_hdr hdr; + struct sof_ipc_reply rhdr; uint32_t comp_id;
/* control access and data type */ diff --git a/src/ipc/intel-ipc.c b/src/ipc/intel-ipc.c index 18d8732..01c83b6 100644 --- a/src/ipc/intel-ipc.c +++ b/src/ipc/intel-ipc.c @@ -579,7 +579,7 @@ static int ipc_comp_value(uint32_t header, uint32_t cmd) }
/* write component values to the outbox */ - mailbox_hostbox_write(0, data, data->hdr.size); + mailbox_hostbox_write(0, data, data->rhdr.hdr.size); return 1; }
Add a volume get() callback alongside the set() callback. validate the number of channels for both get/set.
Signed-off-by: Liam Girdwood liam.r.girdwood@linux.intel.com --- src/audio/volume.c | 44 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-)
diff --git a/src/audio/volume.c b/src/audio/volume.c index 844dfe1..5808bed 100644 --- a/src/audio/volume.c +++ b/src/audio/volume.c @@ -380,11 +380,17 @@ static inline void volume_set_chan_unmute(struct comp_dev *dev, int chan) cd->tvolume[chan] = cd->mvolume[chan]; }
-static int volume_ctrl_cmd(struct comp_dev *dev, struct sof_ipc_ctrl_data *cdata) +static int volume_ctrl_set_cmd(struct comp_dev *dev, struct sof_ipc_ctrl_data *cdata) { struct comp_data *cd = comp_get_drvdata(dev); int i, j;
+ /* validate */ + if (cdata->num_elems == 0 || cdata->num_elems >= SOF_IPC_MAX_CHANNELS) { + trace_volume_error("gs0"); + return -EINVAL; + } + switch (cdata->cmd) { case SOF_CTRL_CMD_VOLUME:
@@ -418,7 +424,37 @@ static int volume_ctrl_cmd(struct comp_dev *dev, struct sof_ipc_ctrl_data *cdata work_schedule_default(&cd->volwork, VOL_RAMP_US); break; default: - trace_volume_error("ec1"); + trace_volume_error("gs1"); + return -EINVAL; + } + + return 0; +} + +static int volume_ctrl_get_cmd(struct comp_dev *dev, struct sof_ipc_ctrl_data *cdata) +{ + struct comp_data *cd = comp_get_drvdata(dev); + int i, j; + + /* validate */ + if (cdata->num_elems == 0 || cdata->num_elems >= SOF_IPC_MAX_CHANNELS) { + trace_volume_error("gc0"); + return -EINVAL; + } + + switch (cdata->cmd) { + case SOF_CTRL_CMD_VOLUME: + + for (i = 0; i < cdata->num_elems; i++) { + for (j = 0; j < cdata->num_elems; j++) { + if (cdata->chanv[j].value == cd->chan[i]) + cdata->chanv[j].value = cd->tvolume[i]; + } + } + + break; + default: + trace_volume_error("ec2"); return -EINVAL; }
@@ -435,7 +471,9 @@ static int volume_cmd(struct comp_dev *dev, int cmd, void *data)
switch (cmd) { case COMP_CMD_SET_VALUE: - return volume_ctrl_cmd(dev, cdata); + return volume_ctrl_set_cmd(dev, cdata); + case COMP_CMD_GET_VALUE: + return volume_ctrl_get_cmd(dev, cdata); case COMP_CMD_START: case COMP_CMD_STOP: case COMP_CMD_PAUSE:
participants (1)
-
Liam Girdwood