Skip to content

Commit 6546623

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 <peter.ujfalusi@linux.intel.com>
1 parent fadedeb commit 6546623

1 file changed

Lines changed: 47 additions & 25 deletions

File tree

sound/soc/sof/ipc4-topology.c

Lines changed: 47 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2117,28 +2117,32 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
21172117
copier_data = &ipc4_copier->data;
21182118
available_fmt = &ipc4_copier->available_fmt;
21192119

2120-
/*
2121-
* Use the fe_params as a base for the copier configuration.
2122-
* The ref_params might get updated to reflect what format is
2123-
* supported by the copier on the DAI side.
2124-
*
2125-
* In case of capture the ref_params returned will be used to
2126-
* find the input configuration of the copier.
2127-
*/
2128-
ref_params = kmemdup(fe_params, sizeof(*ref_params), GFP_KERNEL);
2129-
if (!ref_params)
2130-
return -ENOMEM;
2131-
2132-
ret = sof_ipc4_prepare_dai_copier(sdev, dai, ref_params, dir);
2133-
if (ret < 0)
2134-
return ret;
2120+
if (dir == SNDRV_PCM_STREAM_PLAYBACK) {
2121+
/*
2122+
* For playback the pipeline_params needs to be used to
2123+
* find the input configuration of the copier.
2124+
*/
2125+
ref_params = kmemdup(pipeline_params, sizeof(*ref_params),
2126+
GFP_KERNEL);
2127+
if (!ref_params)
2128+
return -ENOMEM;
2129+
} else {
2130+
/*
2131+
* For capture the adjusted fe_params needs to be used
2132+
* to find the input configuration of the copier.
2133+
*
2134+
* The params might be updated in
2135+
* sof_ipc4_prepare_dai_copier() to reflect the supported
2136+
* input formats by the copier/dai.
2137+
*/
2138+
ref_params = kmemdup(fe_params, sizeof(*ref_params), GFP_KERNEL);
2139+
if (!ref_params)
2140+
return -ENOMEM;
21352141

2136-
/*
2137-
* For playback the pipeline_params needs to be used to find the
2138-
* input configuration of the copier.
2139-
*/
2140-
if (dir == SNDRV_PCM_STREAM_PLAYBACK)
2141-
memcpy(ref_params, pipeline_params, sizeof(*ref_params));
2142+
ret = sof_ipc4_prepare_dai_copier(sdev, dai, ref_params, dir);
2143+
if (ret < 0)
2144+
return ret;
2145+
}
21422146

21432147
break;
21442148
}
@@ -2193,14 +2197,32 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
21932197
}
21942198
case snd_soc_dapm_aif_out:
21952199
case snd_soc_dapm_dai_in:
2196-
out_ref_rate = params_rate(fe_params);
2197-
out_ref_channels = params_channels(fe_params);
2198-
out_ref_type = sof_ipc4_get_sample_type(sdev, fe_params);
2200+
/*
2201+
* For capture the fe_params needs to be used to find the output
2202+
* configuration of the copier.
2203+
*
2204+
* For playback the adjusted fe_params needs to be used
2205+
* to find the output configuration of the copier.
2206+
*
2207+
* The params might be updated in
2208+
* sof_ipc4_prepare_dai_copier() to reflect the supported
2209+
* output formats by the copier/dai.
2210+
*/
2211+
memcpy(ref_params, fe_params, sizeof(*ref_params));
2212+
if (dir == SNDRV_PCM_STREAM_PLAYBACK) {
2213+
ret = sof_ipc4_prepare_dai_copier(sdev, dai, ref_params, dir);
2214+
if (ret < 0)
2215+
return ret;
2216+
}
2217+
2218+
out_ref_rate = params_rate(ref_params);
2219+
out_ref_channels = params_channels(ref_params);
2220+
out_ref_type = sof_ipc4_get_sample_type(sdev, ref_params);
21992221
if (out_ref_type < 0)
22002222
return out_ref_type;
22012223

22022224
if (!single_output_bitdepth) {
2203-
out_ref_valid_bits = sof_ipc4_get_valid_bits(sdev, fe_params);
2225+
out_ref_valid_bits = sof_ipc4_get_valid_bits(sdev, ref_params);
22042226
if (out_ref_valid_bits < 0)
22052227
return out_ref_valid_bits;
22062228
}

0 commit comments

Comments
 (0)