[Sound-open-firmware] [PATCH v2 1/2] volume: check if ctrl cmd is for volume component
This patch adds a fix to check if the ctrl cmd is meant for the volume component and if so, the data is valid.
Signed-off-by: Ranjani Sridharan ranjani.sridharan@linux.intel.com --- src/audio/volume.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
diff --git a/src/audio/volume.c b/src/audio/volume.c index 5808bed..363055d 100644 --- a/src/audio/volume.c +++ b/src/audio/volume.c @@ -385,6 +385,11 @@ static int volume_ctrl_set_cmd(struct comp_dev *dev, struct sof_ipc_ctrl_data *c struct comp_data *cd = comp_get_drvdata(dev); int i, j;
+ if (cdata == NULL) { + trace_volume_error("Sws"); + return -EINVAL; + } + /* validate */ if (cdata->num_elems == 0 || cdata->num_elems >= SOF_IPC_MAX_CHANNELS) { trace_volume_error("gs0"); @@ -436,6 +441,11 @@ static int volume_ctrl_get_cmd(struct comp_dev *dev, struct sof_ipc_ctrl_data *c struct comp_data *cd = comp_get_drvdata(dev); int i, j;
+ if (cdata == NULL) { + trace_volume_error("Swg"); + return -EINVAL; + } + /* validate */ if (cdata->num_elems == 0 || cdata->num_elems >= SOF_IPC_MAX_CHANNELS) { trace_volume_error("gc0"); @@ -469,6 +479,10 @@ static int volume_cmd(struct comp_dev *dev, int cmd, void *data)
trace_volume("cmd");
+ /* check if the ctrl cmd is for this component */ + if ((cdata != NULL) && (cdata->comp_id != dev->comp.id)) + return 0; + switch (cmd) { case COMP_CMD_SET_VALUE: return volume_ctrl_set_cmd(dev, cdata);
This patch fixes the calculation for source/sink period_bytes to use comp_frame_bytes().
Signed-off-by: Ranjani Sridharan ranjani.sridharan@linux.intel.com --- src/audio/volume.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/audio/volume.c b/src/audio/volume.c index 363055d..b01473a 100644 --- a/src/audio/volume.c +++ b/src/audio/volume.c @@ -569,7 +569,7 @@ static int volume_prepare(struct comp_dev *dev) sconfig = COMP_GET_CONFIG(sourceb->source); cd->source_format = sconfig->frame_fmt; cd->source_period_bytes = dev->frames * - sourceb->source->frame_bytes; + comp_frame_bytes(sourceb->source); break; }
@@ -589,7 +589,7 @@ static int volume_prepare(struct comp_dev *dev) sconfig = COMP_GET_CONFIG(sinkb->sink); cd->sink_format = sconfig->frame_fmt; cd->sink_period_bytes = dev->frames * - sinkb->sink->frame_bytes; + comp_frame_bytes(sinkb->sink); break; }
On Tue, 2017-09-12 at 13:54 +0100, Ranjani Sridharan wrote:
This patch fixes the calculation for source/sink period_bytes to use comp_frame_bytes().
Signed-off-by: Ranjani Sridharan ranjani.sridharan@linux.intel.com
Applied. I've left 1/2 for the moment since it's only for test bench (and we should fix test bench instead) ?
Thanks
Liam
--------------------------------------------------------------------- Intel Corporation (UK) Limited Registered No. 1134945 (England) Registered Office: Pipers Way, Swindon SN3 1RJ VAT No: 860 2173 47
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
participants (2)
-
Liam Girdwood
-
Ranjani Sridharan