@@ -1300,10 +1300,27 @@ static int sof_ipc4_update_hw_params(struct snd_sof_dev *sdev, struct snd_pcm_hw
13001300
13011301 if (param_to_update & BIT (SNDRV_PCM_HW_PARAM_FORMAT )) {
13021302 int valid_bits = SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH (fmt -> fmt_cfg );
1303+ int type = SOF_IPC4_AUDIO_FORMAT_CFG_SAMPLE_TYPE (fmt -> fmt_cfg );
13031304 snd_pcm_format_t snd_fmt ;
13041305 struct snd_mask * m ;
13051306
13061307 switch (valid_bits ) {
1308+ case 8 :
1309+ switch (type ) {
1310+ case SOF_IPC4_TYPE_A_LAW :
1311+ snd_fmt = SNDRV_PCM_FORMAT_A_LAW ;
1312+ break ;
1313+ case SOF_IPC4_TYPE_MU_LAW :
1314+ snd_fmt = SNDRV_PCM_FORMAT_MU_LAW ;
1315+ break ;
1316+ case SOF_IPC4_TYPE_UNSIGNED_INTEGER :
1317+ snd_fmt = SNDRV_PCM_FORMAT_U8 ;
1318+ break ;
1319+ default :
1320+ dev_err (sdev -> dev , "Unsupported PCM 8-bit IPC4 type %d\n" , type );
1321+ return - EINVAL ;
1322+ }
1323+ break ;
13071324 case 16 :
13081325 snd_fmt = SNDRV_PCM_FORMAT_S16_LE ;
13091326 break ;
@@ -1375,7 +1392,7 @@ static int sof_ipc4_init_output_audio_fmt(struct snd_sof_dev *sdev,
13751392 struct sof_ipc4_base_module_cfg * base_config ,
13761393 struct sof_ipc4_available_audio_format * available_fmt ,
13771394 u32 out_ref_rate , u32 out_ref_channels ,
1378- u32 out_ref_valid_bits )
1395+ u32 out_ref_valid_bits , u32 out_ref_type )
13791396{
13801397 struct sof_ipc4_pin_format * pin_fmts = available_fmt -> output_pin_fmts ;
13811398 u32 pin_fmts_size = available_fmt -> num_output_formats ;
@@ -1398,17 +1415,24 @@ static int sof_ipc4_init_output_audio_fmt(struct snd_sof_dev *sdev,
13981415 * if there are multiple output formats, then choose the output format that matches
13991416 * the reference params
14001417 */
1418+
1419+ dev_err (sdev -> dev , "Seeking for type %d" , out_ref_type ); // Remove me
1420+
14011421 for (i = 0 ; i < pin_fmts_size ; i ++ ) {
14021422 struct sof_ipc4_audio_format * fmt = & pin_fmts [i ].audio_fmt ;
14031423
1404- u32 _out_rate , _out_channels , _out_valid_bits ;
1424+ u32 _out_rate , _out_channels , _out_valid_bits , _out_type ;
14051425
14061426 _out_rate = fmt -> sampling_frequency ;
14071427 _out_channels = SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT (fmt -> fmt_cfg );
14081428 _out_valid_bits = SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH (fmt -> fmt_cfg );
1429+ _out_type = SOF_IPC4_AUDIO_FORMAT_CFG_SAMPLE_TYPE (fmt -> fmt_cfg );
1430+
1431+ dev_err (sdev -> dev , "Candidate rate %d, channels %d, bits %d, type %d\n" ,
1432+ _out_rate , _out_channels , _out_valid_bits , _out_type ); // Remove me
14091433
14101434 if (_out_rate == out_ref_rate && _out_channels == out_ref_channels &&
1411- _out_valid_bits == out_ref_valid_bits )
1435+ _out_valid_bits == out_ref_valid_bits && _out_type == out_ref_type )
14121436 goto out_fmt ;
14131437 }
14141438
@@ -1931,7 +1955,7 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
19311955 int * ipc_config_size ;
19321956 u32 * * data ;
19331957 int ipc_size , ret , out_ref_valid_bits ;
1934- u32 out_ref_rate , out_ref_channels ;
1958+ u32 out_ref_rate , out_ref_channels , out_ref_type ;
19351959 u32 deep_buffer_dma_ms = 0 ;
19361960 bool single_output_bitdepth ;
19371961 int i ;
@@ -2120,6 +2144,10 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
21202144 case snd_soc_dapm_dai_in :
21212145 out_ref_rate = params_rate (fe_params );
21222146 out_ref_channels = params_channels (fe_params );
2147+ out_ref_type = sof_ipc4_get_sample_type (sdev , fe_params );
2148+ if (out_ref_type < 0 )
2149+ return out_ref_type ;
2150+
21232151 if (!single_output_bitdepth ) {
21242152 out_ref_valid_bits = sof_ipc4_get_valid_bits (sdev , fe_params );
21252153 if (out_ref_valid_bits < 0 )
@@ -2149,7 +2177,8 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
21492177 output_fmt_index = sof_ipc4_init_output_audio_fmt (sdev , swidget ,
21502178 & copier_data -> base_config ,
21512179 available_fmt , out_ref_rate ,
2152- out_ref_channels , out_ref_valid_bits );
2180+ out_ref_channels , out_ref_valid_bits ,
2181+ out_ref_type );
21532182 if (output_fmt_index < 0 )
21542183 return output_fmt_index ;
21552184
@@ -2378,7 +2407,7 @@ static int sof_ipc4_prepare_gain_module(struct snd_sof_widget *swidget,
23782407 struct sof_ipc4_gain * gain = swidget -> private ;
23792408 struct sof_ipc4_available_audio_format * available_fmt = & gain -> available_fmt ;
23802409 struct sof_ipc4_audio_format * in_fmt ;
2381- u32 out_ref_rate , out_ref_channels , out_ref_valid_bits ;
2410+ u32 out_ref_rate , out_ref_channels , out_ref_valid_bits , out_ref_type ;
23822411 int input_fmt_index , output_fmt_index ;
23832412
23842413 input_fmt_index = sof_ipc4_init_input_audio_fmt (sdev , swidget ,
@@ -2392,13 +2421,15 @@ static int sof_ipc4_prepare_gain_module(struct snd_sof_widget *swidget,
23922421 out_ref_rate = in_fmt -> sampling_frequency ;
23932422 out_ref_channels = SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT (in_fmt -> fmt_cfg );
23942423 out_ref_valid_bits = SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH (in_fmt -> fmt_cfg );
2424+ out_ref_type = SOF_IPC4_AUDIO_FORMAT_CFG_SAMPLE_TYPE (in_fmt -> fmt_cfg );
23952425
23962426 output_fmt_index = sof_ipc4_init_output_audio_fmt (sdev , swidget ,
23972427 & gain -> data .base_config ,
23982428 available_fmt ,
23992429 out_ref_rate ,
24002430 out_ref_channels ,
2401- out_ref_valid_bits );
2431+ out_ref_valid_bits ,
2432+ out_ref_type );
24022433 if (output_fmt_index < 0 )
24032434 return output_fmt_index ;
24042435
@@ -2421,7 +2452,7 @@ static int sof_ipc4_prepare_mixer_module(struct snd_sof_widget *swidget,
24212452 struct sof_ipc4_mixer * mixer = swidget -> private ;
24222453 struct sof_ipc4_available_audio_format * available_fmt = & mixer -> available_fmt ;
24232454 struct sof_ipc4_audio_format * in_fmt ;
2424- u32 out_ref_rate , out_ref_channels , out_ref_valid_bits ;
2455+ u32 out_ref_rate , out_ref_channels , out_ref_valid_bits , out_ref_type ;
24252456 int input_fmt_index , output_fmt_index ;
24262457
24272458 input_fmt_index = sof_ipc4_init_input_audio_fmt (sdev , swidget ,
@@ -2435,13 +2466,15 @@ static int sof_ipc4_prepare_mixer_module(struct snd_sof_widget *swidget,
24352466 out_ref_rate = in_fmt -> sampling_frequency ;
24362467 out_ref_channels = SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT (in_fmt -> fmt_cfg );
24372468 out_ref_valid_bits = SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH (in_fmt -> fmt_cfg );
2469+ out_ref_type = SOF_IPC4_AUDIO_FORMAT_CFG_SAMPLE_TYPE (in_fmt -> fmt_cfg );
24382470
24392471 output_fmt_index = sof_ipc4_init_output_audio_fmt (sdev , swidget ,
24402472 & mixer -> base_config ,
24412473 available_fmt ,
24422474 out_ref_rate ,
24432475 out_ref_channels ,
2444- out_ref_valid_bits );
2476+ out_ref_valid_bits ,
2477+ out_ref_type );
24452478 if (output_fmt_index < 0 )
24462479 return output_fmt_index ;
24472480
@@ -2465,7 +2498,7 @@ static int sof_ipc4_prepare_src_module(struct snd_sof_widget *swidget,
24652498 struct sof_ipc4_available_audio_format * available_fmt = & src -> available_fmt ;
24662499 struct sof_ipc4_audio_format * out_audio_fmt ;
24672500 struct sof_ipc4_audio_format * in_audio_fmt ;
2468- u32 out_ref_rate , out_ref_channels , out_ref_valid_bits ;
2501+ u32 out_ref_rate , out_ref_channels , out_ref_valid_bits , out_ref_type ;
24692502 int output_fmt_index , input_fmt_index ;
24702503
24712504 input_fmt_index = sof_ipc4_init_input_audio_fmt (sdev , swidget ,
@@ -2492,6 +2525,7 @@ static int sof_ipc4_prepare_src_module(struct snd_sof_widget *swidget,
24922525 in_audio_fmt = & available_fmt -> input_pin_fmts [input_fmt_index ].audio_fmt ;
24932526 out_ref_channels = SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT (in_audio_fmt -> fmt_cfg );
24942527 out_ref_valid_bits = SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH (in_audio_fmt -> fmt_cfg );
2528+ out_ref_type = SOF_IPC4_AUDIO_FORMAT_CFG_SAMPLE_TYPE (in_audio_fmt -> fmt_cfg );
24952529
24962530 /*
24972531 * For capture, the SRC module should convert the rate to match the rate requested by the
@@ -2505,7 +2539,8 @@ static int sof_ipc4_prepare_src_module(struct snd_sof_widget *swidget,
25052539 available_fmt ,
25062540 out_ref_rate ,
25072541 out_ref_channels ,
2508- out_ref_valid_bits );
2542+ out_ref_valid_bits ,
2543+ out_ref_type );
25092544 if (output_fmt_index < 0 )
25102545 return output_fmt_index ;
25112546
@@ -2629,20 +2664,22 @@ static int sof_ipc4_prepare_process_module(struct snd_sof_widget *swidget,
26292664 struct sof_ipc4_audio_format * in_fmt ;
26302665 struct sof_ipc4_pin_format * pin_fmt ;
26312666 u32 out_ref_rate , out_ref_channels ;
2632- int out_ref_valid_bits ;
2667+ int out_ref_valid_bits , out_ref_type ;
26332668
26342669 in_fmt = & available_fmt -> input_pin_fmts [input_fmt_index ].audio_fmt ;
26352670
26362671 out_ref_rate = in_fmt -> sampling_frequency ;
26372672 out_ref_channels = SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT (in_fmt -> fmt_cfg );
26382673 out_ref_valid_bits = SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH (in_fmt -> fmt_cfg );
2674+ out_ref_type = SOF_IPC4_AUDIO_FORMAT_CFG_SAMPLE_TYPE (in_fmt -> fmt_cfg );
26392675
26402676 output_fmt_index = sof_ipc4_init_output_audio_fmt (sdev , swidget ,
26412677 & process -> base_config ,
26422678 available_fmt ,
26432679 out_ref_rate ,
26442680 out_ref_channels ,
2645- out_ref_valid_bits );
2681+ out_ref_valid_bits ,
2682+ out_ref_type );
26462683 if (output_fmt_index < 0 )
26472684 return output_fmt_index ;
26482685
0 commit comments