Skip to content

Commit afa0d6a

Browse files
committed
ASoC: SOF: ipc4-topology: Improve playback dai copier in/out format selection
The dai copier configuration for playback and capture needs to be separated because it is not correct to configure the dai copier as part of the input format selection for both direction. The input format is the dai format for capture, but it is not for playback, for playback the dai format is on the output side. Currently we configure and adjust the params based on the DAI supported formats when configuring the input side of the copier but right after the format has been adjusted we reset it for playback and loose this information. When using a nocodec passthrough topology (which is a bug) we have SSP blobs supporting 32bit only, copier supporting 16/24/32 bit then on playback the dai and copier will be incorrectly configured: host.copier.in: S16_LE host.copier.out: S16_LE dai.copier.in: S16_LE SSP.blob: S32_LE (we only have S32_LE blobs) dai.copier.out: S16_LE (the dai constraint is ignored) To handle such case the handling of capture and playback streams must be changed: The input format (no changes to previous implementation): for playback it is the pipeline_params for capture it is the adjusted fe_params The output format (no change for capture direction): for playback it is the adjusted fe_params for capture it is the fe_params with this change path format configuration will be correct: host.copier.in: S16_LE host.copier.out: S16_LE dai.copier.in: S16_LE SSP.blob: S32_LE (we only have S32_LE blobs) dai.copier.out: S32_LE Signed-off-by: Peter Ujfalusi <[email protected]>
1 parent cbadf0b commit afa0d6a

File tree

1 file changed

+46
-24
lines changed

1 file changed

+46
-24
lines changed

sound/soc/sof/ipc4-topology.c

Lines changed: 46 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,28 +2009,32 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
20092009
copier_data = &ipc4_copier->data;
20102010
available_fmt = &ipc4_copier->available_fmt;
20112011

2012-
/*
2013-
* Use the fe_params as a base for the copier configuration.
2014-
* The ref_params might get updated to reflect what format is
2015-
* supported by the copier on the DAI side.
2016-
*
2017-
* In case of capture the ref_params returned will be used to
2018-
* find the input configuration of the copier.
2019-
*/
2020-
ref_params = kmemdup(fe_params, sizeof(*ref_params), GFP_KERNEL);
2021-
if (!ref_params)
2022-
return -ENOMEM;
2023-
2024-
ret = sof_ipc4_prepare_dai_copier(sdev, dai, ref_params, dir);
2025-
if (ret < 0)
2026-
return ret;
2012+
if (dir == SNDRV_PCM_STREAM_PLAYBACK) {
2013+
/*
2014+
* For playback the pipeline_params needs to be used to
2015+
* find the input configuration of the copier.
2016+
*/
2017+
ref_params = kmemdup(pipeline_params, sizeof(*ref_params),
2018+
GFP_KERNEL);
2019+
if (!ref_params)
2020+
return -ENOMEM;
2021+
} else {
2022+
/*
2023+
* For capture the adjusted fe_params needs to be used
2024+
* to find the input configuration of the copier.
2025+
*
2026+
* The params might be updated in
2027+
* sof_ipc4_prepare_dai_copier() to reflect the supported
2028+
* input formats by the copier/dai.
2029+
*/
2030+
ref_params = kmemdup(fe_params, sizeof(*ref_params), GFP_KERNEL);
2031+
if (!ref_params)
2032+
return -ENOMEM;
20272033

2028-
/*
2029-
* For playback the pipeline_params needs to be used to find the
2030-
* input configuration of the copier.
2031-
*/
2032-
if (dir == SNDRV_PCM_STREAM_PLAYBACK)
2033-
memcpy(ref_params, pipeline_params, sizeof(*ref_params));
2034+
ret = sof_ipc4_prepare_dai_copier(sdev, dai, ref_params, dir);
2035+
if (ret < 0)
2036+
return ret;
2037+
}
20342038

20352039
break;
20362040
}
@@ -2084,10 +2088,28 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
20842088
}
20852089
case snd_soc_dapm_aif_out:
20862090
case snd_soc_dapm_dai_in:
2087-
out_ref_rate = params_rate(fe_params);
2088-
out_ref_channels = params_channels(fe_params);
2091+
/*
2092+
* For capture the fe_params needs to be used to find the output
2093+
* configuration of the copier.
2094+
*
2095+
* For playback the adjusted fe_params needs to be used
2096+
* to find the output configuration of the copier.
2097+
*
2098+
* The params might be updated in
2099+
* sof_ipc4_prepare_dai_copier() to reflect the supported
2100+
* output formats by the copier/dai.
2101+
*/
2102+
memcpy(ref_params, fe_params, sizeof(*ref_params));
2103+
if (dir == SNDRV_PCM_STREAM_PLAYBACK) {
2104+
ret = sof_ipc4_prepare_dai_copier(sdev, dai, ref_params, dir);
2105+
if (ret < 0)
2106+
return ret;
2107+
}
2108+
2109+
out_ref_rate = params_rate(ref_params);
2110+
out_ref_channels = params_channels(ref_params);
20892111
if (!single_output_bitdepth) {
2090-
out_ref_valid_bits = sof_ipc4_get_valid_bits(sdev, fe_params);
2112+
out_ref_valid_bits = sof_ipc4_get_valid_bits(sdev, ref_params);
20912113
if (out_ref_valid_bits < 0)
20922114
return out_ref_valid_bits;
20932115
}

0 commit comments

Comments
 (0)