ASoC: SOF: ipc4-topology: Support for multiple src output formats
Subsystems (3)
Peter Ujfalusi
maintainerv2 cover ASoC: SOF: ipc4-topology: Support for multiple src output formats
Hi,
Changes since v1:
- new patch to validate the number of input/output formats to make sure that they are are least one
SRC can only change the rate, we can still allow different bit depth and channels to be handled, the only restriction is that the input and output must have matching bit depth and channel format.
In a separate patch do a sanity check for the number of formats on the input and output side as SRC/ASRC must have at least one of them.
Regards,
Peter
--
Peter Ujfalusi (2):
ASoC: SOF: ipc4-topology: Validate the number of in/out formats for
src/asrc
ASoC: SOF: ipc4-topology: Allow the use of multiple formats for src
output
sound/soc/sof/ipc4-topology.c | 64 ++++++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 16 deletions(-)
Signature · 1 line
2.54.0
Peter Ujfalusi
maintainerPATCH v2 1/2 ASoC: SOF: ipc4-topology: Validate the number of in/out formats for src/asrc
SRC and ASRC modules must have at least one input and on one output formats to be usable.
Do a sanity check during setup type and fail if either the number of input or output formats are 0.
--- sound/soc/sof/ipc4-topology.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
sound/soc/sof/ipc4-topology.c +18 -0
@@ -1121,6 +1121,15 @@ static int sof_ipc4_widget_setup_comp_src(struct snd_sof_widget *swidget)if (ret) goto err; +if (!src->available_fmt.num_input_formats || + !src->available_fmt.num_output_formats) { +dev_err (scomp->dev, +"Invalid number of formats: input: %d, output: %d\n" , + src->available_fmt.num_input_formats, + src->available_fmt.num_output_formats); + goto err; + } + ret =sof_update_ipc_object (scomp, &src->data,SOF_SRC_TOKENS , swidget->tuples, swidget->num_tuples,sizeof (*src),1 );if (ret) {
@@ -1164,6 +1173,15 @@ static int sof_ipc4_widget_setup_comp_asrc(struct snd_sof_widget *swidget)if (ret) goto err; +if (!asrc->available_fmt.num_input_formats || + !asrc->available_fmt.num_output_formats) { +dev_err (scomp->dev, +"Invalid number of formats: input: %d, output: %d\n" , + asrc->available_fmt.num_input_formats, + asrc->available_fmt.num_output_formats); + goto err; + } + ret =sof_update_ipc_object (scomp, &asrc->data,SOF_ASRC_TOKENS , swidget->tuples, swidget->num_tuples,sizeof (*asrc),1 );if (ret) {
Signature · 1 line
2.54.0
Peter Ujfalusi
maintainerPATCH v2 2/2 ASoC: SOF: ipc4-topology: Allow the use of multiple formats for src output
In reply to Peter UjfalusiThe SRC module can only change the rate, it keeps the format and channels intact, but this does not mean the num_output_formats must be 0:
The SRC module can support different formats/channels, we just need to check if the output format lists the correct combination of out rate and the input format/channels.
Change the logic to prioritize the sink_rate of the module as target rate, then the rate of the FE in case of capture or in case of playback check the single rate specified in the output formats.
--- sound/soc/sof/ipc4-topology.c | 46 +++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 16 deletions(-)
sound/soc/sof/ipc4-topology.c +30 -16
@@ -2649,16 +2649,6 @@ static int sof_ipc4_prepare_src_module(struct snd_sof_widget *swidget,if (input_fmt_index <0 )return input_fmt_index; -/* -* For playback, the SRC sink rate will be configured based on the requested output -* format, which is restricted to only deal with DAI's with a single format for now. -*/ -if (dir ==SNDRV_PCM_STREAM_PLAYBACK && available_fmt->num_output_formats >1 ) { -dev_err (sdev->dev,"Invalid number of output formats: %d for SRC %s\n" , - available_fmt->num_output_formats, swidget->widget->name); -return -EINVAL ; - } -/* * SRC does not perform format conversion, so the output channels and valid bit depth must * be the same as that of the input.
@@ -2668,12 +2658,36 @@ static int sof_ipc4_prepare_src_module(struct snd_sof_widget *swidget, out_ref_valid_bits =SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH (in_audio_fmt->fmt_cfg); out_ref_type =sof_ipc4_fmt_cfg_to_type (in_audio_fmt->fmt_cfg); -/* -* For capture, the SRC module should convert the rate to match the rate requested by the -* PCM hw_params. Set the reference params based on the fe_params unconditionally as it -* will be ignored for playback anyway. -*/ - out_ref_rate =params_rate (fe_params); +if (src->data.sink_rate) { +/* Use the sink rate as reference */ + out_ref_rate = src->data.sink_rate; + }else if (dir ==SNDRV_PCM_STREAM_CAPTURE ) { +/* +* Use the fe rate as reference for capture if the sink rate is +* not set since we need to convert to the rate the PCM device +* is openned with +*/ + out_ref_rate =params_rate (fe_params); + }else { +/* +* Otherwise try to guess what the rate should be: +* The output formats must have single rate specified if the +* sink rate is not set for an SRC in playback path. +*/ +int i; + + out_audio_fmt = &available_fmt->output_pin_fmts[0 ].audio_fmt; + out_ref_rate = out_audio_fmt->sampling_frequency; +for (i =1 ; i < available_fmt->num_output_formats; i++) { + out_audio_fmt = &available_fmt->output_pin_fmts[i].audio_fmt; +if (out_ref_rate != out_audio_fmt->sampling_frequency) { +dev_err (sdev->dev, +"Cannot determine the output rate for SRC: %s\n" , + swidget->widget->name); +return -EINVAL ; + } + } + } output_fmt_index = sof_ipc4_init_output_audio_fmt(sdev, swidget, &src->data.base_config,
Signature · 1 line
2.54.0
Mark Brown
maintainerQuoted 9 lines · Peter Ujfalusi
ASoC: SOF: ipc4-topology: Support for multiple src output formats
Hi,
Changes since v1:
- new patch to validate the number of input/output formats to make sure that they are are least one[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.2
Thanks!
[1/2] ASoC: SOF: ipc4-topology: Validate the number of in/out formats for src/asrc
https://git.kernel.org/broonie/sound/c/21a5adffad46 [2/2] ASoC: SOF: ipc4-topology: Allow the use of multiple formats for src output https://git.kernel.org/broonie/sound/c/3c3ce66b65c4
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark