From 39cfae525b4b4d35afac7544e3f675a753984952 Mon Sep 17 00:00:00 2001 From: Bartosz Kokoszko Date: Thu, 20 Feb 2020 14:27:25 +0100 Subject: [PATCH 1/4] eq_iir: remove unnecessary code in prepare() function We do not have to rewrite source/sink frame_fmt. It has been set in eq_iir_verify_params() function. Signed-off-by: Bartosz Kokoszko --- src/audio/eq_iir/eq_iir.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/audio/eq_iir/eq_iir.c b/src/audio/eq_iir/eq_iir.c index ed5d14ccd8c7..13b6cf7be402 100644 --- a/src/audio/eq_iir/eq_iir.c +++ b/src/audio/eq_iir/eq_iir.c @@ -829,12 +829,6 @@ static int eq_iir_prepare(struct comp_dev *dev) sink_period_bytes = audio_stream_period_bytes(&sinkb->stream, dev->frames); - /* Rewrite params format for this component to match the host side. */ - if (dev->direction == SOF_IPC_STREAM_PLAYBACK) - sourceb->stream.frame_fmt = cd->source_format; - else - sinkb->stream.frame_fmt = cd->sink_format; - if (sinkb->stream.size < config->periods_sink * sink_period_bytes) { comp_err(dev, "eq_iir_prepare(), sink buffer size %d is insufficient", sinkb->stream.size); From b3102990fd839031862d282fd5016841ed566006 Mon Sep 17 00:00:00 2001 From: Bartosz Kokoszko Date: Thu, 20 Feb 2020 14:49:51 +0100 Subject: [PATCH 2/4] eq_fir: remove unnecessary code in prepare() function We do not have to rewrite source/sink frame_fmt. It has been set in eq_fir_verify_params() function. Signed-off-by: Bartosz Kokoszko --- src/audio/eq_fir/eq_fir.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/audio/eq_fir/eq_fir.c b/src/audio/eq_fir/eq_fir.c index 5284d47c1aca..8a30a0ce85d4 100644 --- a/src/audio/eq_fir/eq_fir.c +++ b/src/audio/eq_fir/eq_fir.c @@ -770,12 +770,6 @@ static int eq_fir_prepare(struct comp_dev *dev) sink_period_bytes = audio_stream_period_bytes(&sinkb->stream, dev->frames); - /* Rewrite params format for this component to match the host side. */ - if (dev->direction == SOF_IPC_STREAM_PLAYBACK) - sourceb->stream.frame_fmt = cd->source_format; - else - sinkb->stream.frame_fmt = cd->sink_format; - if (sinkb->stream.size < config->periods_sink * sink_period_bytes) { comp_err(dev, "eq_fir_prepare() error: sink buffer size is insufficient"); ret = -ENOMEM; From 9ead97a931ff891246e8787489643226cc6a13f9 Mon Sep 17 00:00:00 2001 From: Bartosz Kokoszko Date: Thu, 20 Feb 2020 14:52:40 +0100 Subject: [PATCH 3/4] eq_fir: refine eq_fir_verify_params() function eq_fir component is not able to change stream format, so we should invoke comp_verify_function() with flag equal to 0. Signed-off-by: Bartosz Kokoszko --- src/audio/eq_fir/eq_fir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio/eq_fir/eq_fir.c b/src/audio/eq_fir/eq_fir.c index 8a30a0ce85d4..03134c73ca7b 100644 --- a/src/audio/eq_fir/eq_fir.c +++ b/src/audio/eq_fir/eq_fir.c @@ -481,7 +481,7 @@ static int eq_fir_verify_params(struct comp_dev *dev, comp_dbg(dev, "eq_fir_verify_params()"); - ret = comp_verify_params(dev, BUFF_PARAMS_FRAME_FMT, params); + ret = comp_verify_params(dev, 0, params); if (ret < 0) { comp_err(dev, "eq_fir_verify_params() error: comp_verify_params() failed."); return ret; From 650e166dc7c1fb0ad80f74a2c6b5c425028f10c9 Mon Sep 17 00:00:00 2001 From: Bartosz Kokoszko Date: Thu, 20 Feb 2020 14:24:04 +0100 Subject: [PATCH 4/4] eq_iir: add supported formats check in verify function We should check whether we can support frame_fmt conversion due to source and sink buffer frame_fmt's. If not, we should overwrite sink (playback) and source (capture) with pcm frame_fmt and not make any conversion (sink and source frame_fmt will be equal). Signed-off-by: Bartosz Kokoszko --- src/audio/eq_iir/eq_iir.c | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/src/audio/eq_iir/eq_iir.c b/src/audio/eq_iir/eq_iir.c index 13b6cf7be402..ccb285defa9c 100644 --- a/src/audio/eq_iir/eq_iir.c +++ b/src/audio/eq_iir/eq_iir.c @@ -309,7 +309,8 @@ const struct eq_iir_func_map fm_passthrough[] = { #endif /* CONFIG_FORMAT_S32LE */ }; -static eq_iir_func eq_iir_find_func(struct comp_data *cd, +static eq_iir_func eq_iir_find_func(enum sof_ipc_frame source_format, + enum sof_ipc_frame sink_format, const struct eq_iir_func_map *map, int n) { @@ -317,9 +318,9 @@ static eq_iir_func eq_iir_find_func(struct comp_data *cd, /* Find suitable processing function from map. */ for (i = 0; i < n; i++) { - if ((uint8_t)cd->source_format != map[i].source) + if ((uint8_t)source_format != map[i].source) continue; - if ((uint8_t)cd->sink_format != map[i].sink) + if ((uint8_t)sink_format != map[i].sink) continue; return map[i].func; @@ -581,11 +582,31 @@ static void eq_iir_free(struct comp_dev *dev) static int eq_iir_verify_params(struct comp_dev *dev, struct sof_ipc_stream_params *params) { + struct comp_buffer *sourceb; + struct comp_buffer *sinkb; + uint32_t buffer_flag; int ret; comp_dbg(dev, "eq_iir_verify_params()"); - ret = comp_verify_params(dev, BUFF_PARAMS_FRAME_FMT, params); + /* EQ component will only ever have 1 source and 1 sink buffer */ + sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, + sink_list); + sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, + source_list); + + /* we check whether we can support frame_fmt conversion (whether we have + * such conversion function) due to source and sink buffer frame_fmt's. + * If not, we will overwrite sink (playback) and source (capture) with + * pcm frame_fmt and will not make any conversion (sink and source + * frame_fmt will be equal). + */ + buffer_flag = eq_iir_find_func(sourceb->stream.frame_fmt, + sinkb->stream.frame_fmt, fm_configured, + ARRAY_SIZE(fm_configured)) ? + BUFF_PARAMS_FRAME_FMT : 0; + + ret = comp_verify_params(dev, buffer_flag, params); if (ret < 0) { comp_err(dev, "eq_iir_verify_params() error: comp_verify_params() failed."); return ret; @@ -845,7 +866,9 @@ static int eq_iir_prepare(struct comp_dev *dev) comp_err(dev, "eq_iir_prepare(), setup failed."); goto err; } - cd->eq_iir_func = eq_iir_find_func(cd, fm_configured, + cd->eq_iir_func = eq_iir_find_func(cd->source_format, + cd->sink_format, + fm_configured, ARRAY_SIZE(fm_configured)); if (!cd->eq_iir_func) { comp_err(dev, "eq_iir_prepare(), No proc func"); @@ -854,7 +877,9 @@ static int eq_iir_prepare(struct comp_dev *dev) } comp_info(dev, "eq_iir_prepare(), IIR is configured."); } else { - cd->eq_iir_func = eq_iir_find_func(cd, fm_passthrough, + cd->eq_iir_func = eq_iir_find_func(cd->source_format, + cd->sink_format, + fm_passthrough, ARRAY_SIZE(fm_passthrough)); if (!cd->eq_iir_func) { comp_err(dev, "eq_iir_prepare(), No pass func");