Skip to content

Commit 26f4500

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 0ce5e4f commit 26f4500

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
@@ -2175,28 +2175,32 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
21752175
copier_data = &ipc4_copier->data;
21762176
available_fmt = &ipc4_copier->available_fmt;
21772177

2178-
/*
2179-
* Use the fe_params as a base for the copier configuration.
2180-
* The ref_params might get updated to reflect what format is
2181-
* supported by the copier on the DAI side.
2182-
*
2183-
* In case of capture the ref_params returned will be used to
2184-
* find the input configuration of the copier.
2185-
*/
2186-
ref_params = kmemdup(fe_params, sizeof(*ref_params), GFP_KERNEL);
2187-
if (!ref_params)
2188-
return -ENOMEM;
2189-
2190-
ret = sof_ipc4_prepare_dai_copier(sdev, dai, ref_params, dir);
2191-
if (ret < 0)
2192-
return ret;
2178+
if (dir == SNDRV_PCM_STREAM_PLAYBACK) {
2179+
/*
2180+
* For playback the pipeline_params needs to be used to
2181+
* find the input configuration of the copier.
2182+
*/
2183+
ref_params = kmemdup(pipeline_params, sizeof(*ref_params),
2184+
GFP_KERNEL);
2185+
if (!ref_params)
2186+
return -ENOMEM;
2187+
} else {
2188+
/*
2189+
* For capture the adjusted fe_params needs to be used
2190+
* to find the input configuration of the copier.
2191+
*
2192+
* The params might be updated in
2193+
* sof_ipc4_prepare_dai_copier() to reflect the supported
2194+
* input formats by the copier/dai.
2195+
*/
2196+
ref_params = kmemdup(fe_params, sizeof(*ref_params), GFP_KERNEL);
2197+
if (!ref_params)
2198+
return -ENOMEM;
21932199

2194-
/*
2195-
* For playback the pipeline_params needs to be used to find the
2196-
* input configuration of the copier.
2197-
*/
2198-
if (dir == SNDRV_PCM_STREAM_PLAYBACK)
2199-
memcpy(ref_params, pipeline_params, sizeof(*ref_params));
2200+
ret = sof_ipc4_prepare_dai_copier(sdev, dai, ref_params, dir);
2201+
if (ret < 0)
2202+
return ret;
2203+
}
22002204

22012205
break;
22022206
}
@@ -2251,15 +2255,33 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
22512255
}
22522256
case snd_soc_dapm_aif_out:
22532257
case snd_soc_dapm_dai_in:
2254-
out_ref_rate = params_rate(fe_params);
2255-
out_ref_channels = params_channels(fe_params);
2256-
ret = sof_ipc4_get_sample_type(sdev, fe_params);
2258+
/*
2259+
* For capture the fe_params needs to be used to find the output
2260+
* configuration of the copier.
2261+
*
2262+
* For playback the adjusted fe_params needs to be used
2263+
* to find the output configuration of the copier.
2264+
*
2265+
* The params might be updated in
2266+
* sof_ipc4_prepare_dai_copier() to reflect the supported
2267+
* output formats by the copier/dai.
2268+
*/
2269+
memcpy(ref_params, fe_params, sizeof(*ref_params));
2270+
if (dir == SNDRV_PCM_STREAM_PLAYBACK) {
2271+
ret = sof_ipc4_prepare_dai_copier(sdev, dai, ref_params, dir);
2272+
if (ret < 0)
2273+
return ret;
2274+
}
2275+
2276+
out_ref_rate = params_rate(ref_params);
2277+
out_ref_channels = params_channels(ref_params);
2278+
ret = sof_ipc4_get_sample_type(sdev, ref_params);
22572279
if (ret < 0)
22582280
return ret;
22592281
out_ref_type = (u32)ret;
22602282

22612283
if (!single_output_bitdepth) {
2262-
out_ref_valid_bits = sof_ipc4_get_valid_bits(sdev, fe_params);
2284+
out_ref_valid_bits = sof_ipc4_get_valid_bits(sdev, ref_params);
22632285
if (out_ref_valid_bits < 0)
22642286
return out_ref_valid_bits;
22652287
}

0 commit comments

Comments
 (0)