Skip to content

Commit 86aa6e9

Browse files
ujfalusibardliao
authored andcommitted
fixup! ASoC: SOF: ipc4-topology: Add support for 8-bit formats
Only use the type from fmt for 8/32 bit formats, 16/20/24 should report LSB Update also the error prints to reveal the type. Signed-off-by: Peter Ujfalusi <[email protected]>
1 parent 7a79ba9 commit 86aa6e9

File tree

1 file changed

+33
-13
lines changed

1 file changed

+33
-13
lines changed

sound/soc/sof/ipc4-topology.c

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,22 @@ static int sof_ipc4_widget_assign_instance_id(struct snd_sof_dev *sdev,
13341334
return 0;
13351335
}
13361336

1337+
static u32 sof_ipc4_fmt_cfg_to_type(u32 fmt_cfg)
1338+
{
1339+
/* Fetch the sample type from the fmt for 8 and 32 bit formats */
1340+
u32 __bits = SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH(fmt_cfg);
1341+
if (__bits == 8 || __bits == 32)
1342+
return SOF_IPC4_AUDIO_FORMAT_CFG_SAMPLE_TYPE(fmt_cfg);
1343+
1344+
/*
1345+
* Return LSB integer type for 20 and 24 formats as the firmware is
1346+
* handling the LSB/MSB alignement internally, for the kernel this
1347+
* should not be taken into account, we treat them as LSB to match with
1348+
* the format we support on the PCM side.
1349+
*/
1350+
return SOF_IPC4_TYPE_LSB_INTEGER;
1351+
}
1352+
13371353
/* update hw_params based on the audio stream format */
13381354
static int sof_ipc4_update_hw_params(struct snd_sof_dev *sdev, struct snd_pcm_hw_params *params,
13391355
struct sof_ipc4_audio_format *fmt, u32 param_to_update)
@@ -1342,7 +1358,7 @@ static int sof_ipc4_update_hw_params(struct snd_sof_dev *sdev, struct snd_pcm_hw
13421358

13431359
if (param_to_update & BIT(SNDRV_PCM_HW_PARAM_FORMAT)) {
13441360
int valid_bits = SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH(fmt->fmt_cfg);
1345-
int type = SOF_IPC4_AUDIO_FORMAT_CFG_SAMPLE_TYPE(fmt->fmt_cfg);
1361+
int type = sof_ipc4_fmt_cfg_to_type(fmt->fmt_cfg);
13461362
snd_pcm_format_t snd_fmt;
13471363
struct snd_mask *m;
13481364

@@ -1475,15 +1491,17 @@ static int sof_ipc4_init_output_audio_fmt(struct snd_sof_dev *sdev,
14751491
_out_rate = fmt->sampling_frequency;
14761492
_out_channels = SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT(fmt->fmt_cfg);
14771493
_out_valid_bits = SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH(fmt->fmt_cfg);
1478-
_out_type = SOF_IPC4_AUDIO_FORMAT_CFG_SAMPLE_TYPE(fmt->fmt_cfg);
1494+
_out_type = sof_ipc4_fmt_cfg_to_type(fmt->fmt_cfg);
14791495

14801496
if (_out_rate == out_ref_rate && _out_channels == out_ref_channels &&
14811497
_out_valid_bits == out_ref_valid_bits && _out_type == out_ref_type)
14821498
goto out_fmt;
14831499
}
14841500

1485-
dev_err(sdev->dev, "%s: Unsupported audio format: %uHz, %ubit, %u channels\n",
1486-
__func__, out_ref_rate, out_ref_valid_bits, out_ref_channels);
1501+
dev_err(sdev->dev,
1502+
"%s: Unsupported audio format: %uHz, %ubit, %u channels, type: %d\n",
1503+
__func__, out_ref_rate, out_ref_valid_bits, out_ref_channels,
1504+
out_ref_type);
14871505

14881506
return -EINVAL;
14891507

@@ -1583,15 +1601,17 @@ static int sof_ipc4_init_input_audio_fmt(struct snd_sof_dev *sdev,
15831601
rate = fmt->sampling_frequency;
15841602
channels = SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT(fmt->fmt_cfg);
15851603
valid_bits = SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH(fmt->fmt_cfg);
1586-
type = SOF_IPC4_AUDIO_FORMAT_CFG_SAMPLE_TYPE(fmt->fmt_cfg);
1604+
type = sof_ipc4_fmt_cfg_to_type(fmt->fmt_cfg);
15871605
if (params_rate(params) == rate && params_channels(params) == channels &&
15881606
sample_valid_bits == valid_bits && sample_type == type)
15891607
break;
15901608
}
15911609

15921610
if (i == pin_fmts_size) {
1593-
dev_err(sdev->dev, "%s: Unsupported audio format: %uHz, %ubit, %u channels\n",
1594-
__func__, params_rate(params), sample_valid_bits, params_channels(params));
1611+
dev_err(sdev->dev,
1612+
"%s: Unsupported audio format: %uHz, %ubit, %u channels, type: %d\n",
1613+
__func__, params_rate(params), sample_valid_bits,
1614+
params_channels(params), sample_type);
15951615
return -EINVAL;
15961616
}
15971617

@@ -2178,7 +2198,7 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
21782198
in_fmt = &available_fmt->input_pin_fmts[input_fmt_index].audio_fmt;
21792199
out_ref_rate = in_fmt->sampling_frequency;
21802200
out_ref_channels = SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT(in_fmt->fmt_cfg);
2181-
out_ref_type = SOF_IPC4_AUDIO_FORMAT_CFG_SAMPLE_TYPE(in_fmt->fmt_cfg);
2201+
out_ref_type = sof_ipc4_fmt_cfg_to_type(in_fmt->fmt_cfg);
21822202

21832203
if (!single_output_bitdepth)
21842204
out_ref_valid_bits =
@@ -2217,7 +2237,7 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
22172237
out_fmt = &available_fmt->output_pin_fmts[0].audio_fmt;
22182238
out_ref_valid_bits =
22192239
SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH(out_fmt->fmt_cfg);
2220-
out_ref_type = SOF_IPC4_AUDIO_FORMAT_CFG_SAMPLE_TYPE(out_fmt->fmt_cfg);
2240+
out_ref_type = sof_ipc4_fmt_cfg_to_type(out_fmt->fmt_cfg);
22212241
}
22222242

22232243
output_fmt_index = sof_ipc4_init_output_audio_fmt(sdev, swidget,
@@ -2467,7 +2487,7 @@ static int sof_ipc4_prepare_gain_module(struct snd_sof_widget *swidget,
24672487
out_ref_rate = in_fmt->sampling_frequency;
24682488
out_ref_channels = SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT(in_fmt->fmt_cfg);
24692489
out_ref_valid_bits = SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH(in_fmt->fmt_cfg);
2470-
out_ref_type = SOF_IPC4_AUDIO_FORMAT_CFG_SAMPLE_TYPE(in_fmt->fmt_cfg);
2490+
out_ref_type = sof_ipc4_fmt_cfg_to_type(in_fmt->fmt_cfg);
24712491

24722492
output_fmt_index = sof_ipc4_init_output_audio_fmt(sdev, swidget,
24732493
&gain->data.base_config,
@@ -2512,7 +2532,7 @@ static int sof_ipc4_prepare_mixer_module(struct snd_sof_widget *swidget,
25122532
out_ref_rate = in_fmt->sampling_frequency;
25132533
out_ref_channels = SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT(in_fmt->fmt_cfg);
25142534
out_ref_valid_bits = SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH(in_fmt->fmt_cfg);
2515-
out_ref_type = SOF_IPC4_AUDIO_FORMAT_CFG_SAMPLE_TYPE(in_fmt->fmt_cfg);
2535+
out_ref_type = sof_ipc4_fmt_cfg_to_type(in_fmt->fmt_cfg);
25162536

25172537
output_fmt_index = sof_ipc4_init_output_audio_fmt(sdev, swidget,
25182538
&mixer->base_config,
@@ -2571,7 +2591,7 @@ static int sof_ipc4_prepare_src_module(struct snd_sof_widget *swidget,
25712591
in_audio_fmt = &available_fmt->input_pin_fmts[input_fmt_index].audio_fmt;
25722592
out_ref_channels = SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT(in_audio_fmt->fmt_cfg);
25732593
out_ref_valid_bits = SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH(in_audio_fmt->fmt_cfg);
2574-
out_ref_type = SOF_IPC4_AUDIO_FORMAT_CFG_SAMPLE_TYPE(in_audio_fmt->fmt_cfg);
2594+
out_ref_type = sof_ipc4_fmt_cfg_to_type(in_audio_fmt->fmt_cfg);
25752595

25762596
/*
25772597
* For capture, the SRC module should convert the rate to match the rate requested by the
@@ -2717,7 +2737,7 @@ static int sof_ipc4_prepare_process_module(struct snd_sof_widget *swidget,
27172737
out_ref_rate = in_fmt->sampling_frequency;
27182738
out_ref_channels = SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT(in_fmt->fmt_cfg);
27192739
out_ref_valid_bits = SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH(in_fmt->fmt_cfg);
2720-
out_ref_type = SOF_IPC4_AUDIO_FORMAT_CFG_SAMPLE_TYPE(in_fmt->fmt_cfg);
2740+
out_ref_type = sof_ipc4_fmt_cfg_to_type(in_fmt->fmt_cfg);
27212741

27222742
output_fmt_index = sof_ipc4_init_output_audio_fmt(sdev, swidget,
27232743
&process->base_config,

0 commit comments

Comments
 (0)