[Sound-open-firmware] [PATCH 16/25] volume: volume_params(): set the sink buffer params depending on its sink

Keyon Jie yang.jie at linux.intel.com
Tue Feb 7 15:03:03 CET 2017


If its sink is host, we need set it to 16bit(hard coded ATM);
if its sink is dai, we need set it to 32bit SSP format;
otherwise, for internal component, we uses STREAM_FORMAT_S32_LE.

Signed-off-by: Keyon Jie <yang.jie at linux.intel.com>
---
 src/audio/volume.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/audio/volume.c b/src/audio/volume.c
index 24a9d11..ddab23b 100644
--- a/src/audio/volume.c
+++ b/src/audio/volume.c
@@ -341,8 +341,26 @@ static void volume_free(struct comp_dev *dev)
 /* set component audio stream paramters */
 static int volume_params(struct comp_dev *dev, struct stream_params *params)
 {
+	struct stream_params sink_params = *params;
+	struct comp_buffer *sink;
+
+	/* volume components will only ever have 1 source and 1 sink buffer */
+	sink = list_first_item(&dev->bsink_list, struct comp_buffer, source_list);
+
+	/* hard coded now */
+	if (sink->sink->is_host) {
+		sink_params.pcm.format = STREAM_FORMAT_S16_LE;
+		sink_params.frame_size = 2 * params->channels; /* 16bit container */
+	} else if (sink->sink->is_dai) {
+		sink_params.pcm.format = PLATFORM_SSP_STREAM_FORMAT;
+		sink_params.frame_size = 4 * params->channels; /* 32bit container */
+	} else {
+		sink_params.pcm.format = STREAM_FORMAT_S32_LE;
+		sink_params.frame_size = 4 * params->channels; /* 32bit container */
+	}
+
 	/* dont do any data transformation */
-	comp_set_sink_params(dev, params);
+	comp_set_sink_params(dev, &sink_params);
 
 	return 0;
 }
-- 
2.7.4



More information about the Sound-open-firmware mailing list