Skip to content

Commit 7836cb7

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 a599fc4 commit 7836cb7

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
@@ -2226,28 +2226,32 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
22262226
copier_data = &ipc4_copier->data;
22272227
available_fmt = &ipc4_copier->available_fmt;
22282228

2229-
/*
2230-
* Use the fe_params as a base for the copier configuration.
2231-
* The ref_params might get updated to reflect what format is
2232-
* supported by the copier on the DAI side.
2233-
*
2234-
* In case of capture the ref_params returned will be used to
2235-
* find the input configuration of the copier.
2236-
*/
2237-
ref_params = kmemdup(fe_params, sizeof(*ref_params), GFP_KERNEL);
2238-
if (!ref_params)
2239-
return -ENOMEM;
2240-
2241-
ret = sof_ipc4_prepare_dai_copier(sdev, dai, ref_params, dir);
2242-
if (ret < 0)
2243-
return ret;
2229+
if (dir == SNDRV_PCM_STREAM_PLAYBACK) {
2230+
/*
2231+
* For playback the pipeline_params needs to be used to
2232+
* find the input configuration of the copier.
2233+
*/
2234+
ref_params = kmemdup(pipeline_params, sizeof(*ref_params),
2235+
GFP_KERNEL);
2236+
if (!ref_params)
2237+
return -ENOMEM;
2238+
} else {
2239+
/*
2240+
* For capture the adjusted fe_params needs to be used
2241+
* to find the input configuration of the copier.
2242+
*
2243+
* The params might be updated in
2244+
* sof_ipc4_prepare_dai_copier() to reflect the supported
2245+
* input formats by the copier/dai.
2246+
*/
2247+
ref_params = kmemdup(fe_params, sizeof(*ref_params), GFP_KERNEL);
2248+
if (!ref_params)
2249+
return -ENOMEM;
22442250

2245-
/*
2246-
* For playback the pipeline_params needs to be used to find the
2247-
* input configuration of the copier.
2248-
*/
2249-
if (dir == SNDRV_PCM_STREAM_PLAYBACK)
2250-
memcpy(ref_params, pipeline_params, sizeof(*ref_params));
2251+
ret = sof_ipc4_prepare_dai_copier(sdev, dai, ref_params, dir);
2252+
if (ret < 0)
2253+
return ret;
2254+
}
22512255

22522256
break;
22532257
}
@@ -2302,15 +2306,33 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
23022306
}
23032307
case snd_soc_dapm_aif_out:
23042308
case snd_soc_dapm_dai_in:
2305-
out_ref_rate = params_rate(fe_params);
2306-
out_ref_channels = params_channels(fe_params);
2307-
ret = sof_ipc4_get_sample_type(sdev, fe_params);
2309+
/*
2310+
* For capture the fe_params needs to be used to find the output
2311+
* configuration of the copier.
2312+
*
2313+
* For playback the adjusted fe_params needs to be used
2314+
* to find the output configuration of the copier.
2315+
*
2316+
* The params might be updated in
2317+
* sof_ipc4_prepare_dai_copier() to reflect the supported
2318+
* output formats by the copier/dai.
2319+
*/
2320+
memcpy(ref_params, fe_params, sizeof(*ref_params));
2321+
if (dir == SNDRV_PCM_STREAM_PLAYBACK) {
2322+
ret = sof_ipc4_prepare_dai_copier(sdev, dai, ref_params, dir);
2323+
if (ret < 0)
2324+
return ret;
2325+
}
2326+
2327+
out_ref_rate = params_rate(ref_params);
2328+
out_ref_channels = params_channels(ref_params);
2329+
ret = sof_ipc4_get_sample_type(sdev, ref_params);
23082330
if (ret < 0)
23092331
return ret;
23102332
out_ref_type = (u32)ret;
23112333

23122334
if (!single_output_bitdepth) {
2313-
out_ref_valid_bits = sof_ipc4_get_valid_bits(sdev, fe_params);
2335+
out_ref_valid_bits = sof_ipc4_get_valid_bits(sdev, ref_params);
23142336
if (out_ref_valid_bits < 0)
23152337
return out_ref_valid_bits;
23162338
}

0 commit comments

Comments
 (0)