Skip to content

Commit 2fcad03

Browse files
ujfalusibroonie
authored andcommitted
ASoC: SOF: ipc4-topology: Improve readability of sof_ipc4_prepare_dai_copier()
Remove the duplicated code paths to check for single bit depth and to update the params with storing the parameters needed by the function and have a single code section. No functional change but the code is easier to follow. Signed-off-by: Peter Ujfalusi <[email protected]> Reviewed-by: Pierre-Louis Bossart <[email protected]> Reviewed-by: Bard Liao <[email protected]> Reviewed-by: Seppo Ingalsuo <[email protected]> Reviewed-by: Ranjani Sridharan <[email protected]> Link: https://msgid.link/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 3b64fd2 commit 2fcad03

File tree

1 file changed

+18
-24
lines changed

1 file changed

+18
-24
lines changed

sound/soc/sof/ipc4-topology.c

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,8 +1590,10 @@ sof_ipc4_prepare_dai_copier(struct snd_sof_dev *sdev, struct snd_sof_dai *dai,
15901590
struct sof_ipc4_available_audio_format *available_fmt;
15911591
struct snd_pcm_hw_params dai_params = *params;
15921592
struct sof_ipc4_copier_data *copier_data;
1593+
struct sof_ipc4_pin_format *pin_fmts;
15931594
struct sof_ipc4_copier *ipc4_copier;
15941595
bool single_bitdepth;
1596+
u32 num_pin_fmts;
15951597
int ret;
15961598

15971599
ipc4_copier = dai->private;
@@ -1605,31 +1607,23 @@ sof_ipc4_prepare_dai_copier(struct snd_sof_dev *sdev, struct snd_sof_dai *dai,
16051607
* format lookup
16061608
*/
16071609
if (dir == SNDRV_PCM_STREAM_PLAYBACK) {
1608-
single_bitdepth = sof_ipc4_copier_is_single_bitdepth(sdev,
1609-
available_fmt->output_pin_fmts,
1610-
available_fmt->num_output_formats);
1611-
1612-
/* Update the dai_params with the only supported format */
1613-
if (single_bitdepth) {
1614-
ret = sof_ipc4_update_hw_params(sdev, &dai_params,
1615-
&available_fmt->output_pin_fmts[0].audio_fmt,
1616-
BIT(SNDRV_PCM_HW_PARAM_FORMAT));
1617-
if (ret)
1618-
return ret;
1619-
}
1610+
pin_fmts = available_fmt->output_pin_fmts;
1611+
num_pin_fmts = available_fmt->num_output_formats;
16201612
} else {
1621-
single_bitdepth = sof_ipc4_copier_is_single_bitdepth(sdev,
1622-
available_fmt->input_pin_fmts,
1623-
available_fmt->num_input_formats);
1624-
1625-
/* Update the dai_params with the only supported format */
1626-
if (single_bitdepth) {
1627-
ret = sof_ipc4_update_hw_params(sdev, &dai_params,
1628-
&available_fmt->input_pin_fmts[0].audio_fmt,
1629-
BIT(SNDRV_PCM_HW_PARAM_FORMAT));
1630-
if (ret)
1631-
return ret;
1632-
}
1613+
pin_fmts = available_fmt->input_pin_fmts;
1614+
num_pin_fmts = available_fmt->num_input_formats;
1615+
}
1616+
1617+
single_bitdepth = sof_ipc4_copier_is_single_bitdepth(sdev, pin_fmts,
1618+
num_pin_fmts);
1619+
1620+
/* Update the dai_params with the only supported format */
1621+
if (single_bitdepth) {
1622+
ret = sof_ipc4_update_hw_params(sdev, &dai_params,
1623+
&pin_fmts[0].audio_fmt,
1624+
BIT(SNDRV_PCM_HW_PARAM_FORMAT));
1625+
if (ret)
1626+
return ret;
16331627
}
16341628

16351629
ret = snd_sof_get_nhlt_endpoint_data(sdev, dai, single_bitdepth,

0 commit comments

Comments
 (0)