[Sound-open-firmware] [PATCH v2 1/5] component: set source buffer params for capture component .params()
Keyon Jie
yang.jie at linux.intel.com
Thu Feb 16 09:08:36 CET 2017
Considering of capture pipeline, when doing .params(), we need
set params to each component's source buffer.
This patch implement that for host/volume component, as mixer is
only for playback ATM, and dai don't have source buffer for capture,
we don't need change them ATM.
Signed-off-by: Keyon Jie <yang.jie at linux.intel.com>
---
src/audio/host.c | 7 ++++++-
src/audio/volume.c | 39 ++++++++++++++++++++++++--------------
src/include/reef/audio/component.h | 13 +++++++++++++
3 files changed, 44 insertions(+), 15 deletions(-)
diff --git a/src/audio/host.c b/src/audio/host.c
index 069c6a2..12aee59 100644
--- a/src/audio/host.c
+++ b/src/audio/host.c
@@ -535,10 +535,12 @@ static int host_params(struct comp_dev *dev, struct stream_params *params)
/* set params */
hd->params = *params;
- comp_set_sink_params(dev, params);
/* determine source and sink buffer elems */
if (params->direction == STREAM_DIRECTION_PLAYBACK) {
+ /* set sink buffer params */
+ comp_set_sink_params(dev, params);
+
hd->source = &hd->host;
hd->sink = &hd->local;
hd->dma_buffer = list_first_item(&dev->bsink_list,
@@ -546,6 +548,9 @@ static int host_params(struct comp_dev *dev, struct stream_params *params)
hd->period = &hd->dma_buffer->desc.source_period;
config->direction = DMA_DIR_HMEM_TO_LMEM;
} else {
+ /* set source buffer params */
+ comp_set_source_params(dev, params);
+
hd->source = &hd->local;
hd->sink = &hd->host;
hd->dma_buffer = list_first_item(&dev->bsource_list,
diff --git a/src/audio/volume.c b/src/audio/volume.c
index 1eb6004..bdaf87f 100644
--- a/src/audio/volume.c
+++ b/src/audio/volume.c
@@ -341,26 +341,37 @@ 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);
+ struct stream_params buffer_params = *params;
+ struct comp_buffer *next_buf;
+ struct comp_dev *next_dev;
+
+ if (params->direction == STREAM_DIRECTION_PLAYBACK) {
+ /* volume components will only ever have 1 sink buffer */
+ next_buf = list_first_item(&dev->bsink_list, struct comp_buffer, source_list);
+ next_dev = next_buf->sink;
+ } else {
+ /* volume components will only ever have 1 source buffer */
+ next_buf = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);
+ next_dev = next_buf->source;
+ }
/* hard coded until new IPC is ready */
- 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 */
+ if (next_dev->is_host) {
+ buffer_params.pcm.format = STREAM_FORMAT_S16_LE;
+ buffer_params.frame_size = 2 * params->channels; /* 16bit container */
+ } else if (next_dev->is_dai) {
+ buffer_params.pcm.format = PLATFORM_SSP_STREAM_FORMAT;
+ buffer_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 */
+ buffer_params.pcm.format = STREAM_FORMAT_S32_LE;
+ buffer_params.frame_size = 4 * params->channels; /* 32bit container */
}
/* dont do any data transformation */
- comp_set_sink_params(dev, &sink_params);
+ if (params->direction == STREAM_DIRECTION_PLAYBACK)
+ comp_set_sink_params(dev, &buffer_params);
+ else
+ comp_set_source_params(dev, &buffer_params);
return 0;
}
diff --git a/src/include/reef/audio/component.h b/src/include/reef/audio/component.h
index 1e784f5..be45d81 100644
--- a/src/include/reef/audio/component.h
+++ b/src/include/reef/audio/component.h
@@ -420,4 +420,17 @@ static inline void comp_set_sink_params(struct comp_dev *dev,
}
}
+static inline void comp_set_source_params(struct comp_dev *dev,
+ struct stream_params *params)
+{
+ struct list_item *clist;
+ struct comp_buffer *source;
+
+ list_for_item(clist, &dev->bsource_list) {
+
+ source = container_of(clist, struct comp_buffer, sink_list);
+ source->params = *params;
+ }
+}
+
#endif
--
2.7.4
More information about the Sound-open-firmware
mailing list