@@ -2753,12 +2753,14 @@ static int sof_ipc4_prepare_process_module(struct snd_sof_widget *swidget,
27532753 int input_fmt_index = 0 ;
27542754 int ret ;
27552755
2756- input_fmt_index = sof_ipc4_init_input_audio_fmt (sdev , swidget ,
2757- & process -> base_config ,
2758- pipeline_params ,
2759- available_fmt );
2760- if (input_fmt_index < 0 )
2761- return input_fmt_index ;
2756+ if (available_fmt -> num_input_formats ) {
2757+ input_fmt_index = sof_ipc4_init_input_audio_fmt (sdev , swidget ,
2758+ & process -> base_config ,
2759+ pipeline_params ,
2760+ available_fmt );
2761+ if (input_fmt_index < 0 )
2762+ return input_fmt_index ;
2763+ }
27622764
27632765 /* Configure output audio format only if the module supports output */
27642766 if (available_fmt -> num_output_formats ) {
@@ -2767,12 +2769,28 @@ static int sof_ipc4_prepare_process_module(struct snd_sof_widget *swidget,
27672769 u32 out_ref_rate , out_ref_channels ;
27682770 int out_ref_valid_bits , out_ref_type ;
27692771
2770- in_fmt = & available_fmt -> input_pin_fmts [input_fmt_index ].audio_fmt ;
2772+ if (available_fmt -> num_input_formats ) {
2773+ in_fmt = & available_fmt -> input_pin_fmts [input_fmt_index ].audio_fmt ;
27712774
2772- out_ref_rate = in_fmt -> sampling_frequency ;
2773- out_ref_channels = SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT (in_fmt -> fmt_cfg );
2774- out_ref_valid_bits = SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH (in_fmt -> fmt_cfg );
2775- out_ref_type = sof_ipc4_fmt_cfg_to_type (in_fmt -> fmt_cfg );
2775+ out_ref_rate = in_fmt -> sampling_frequency ;
2776+ out_ref_channels =
2777+ SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT (in_fmt -> fmt_cfg );
2778+ out_ref_valid_bits =
2779+ SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH (in_fmt -> fmt_cfg );
2780+ out_ref_type = sof_ipc4_fmt_cfg_to_type (in_fmt -> fmt_cfg );
2781+ } else {
2782+ /* for modules without input formats, use FE params as reference */
2783+ out_ref_rate = params_rate (fe_params );
2784+ out_ref_channels = params_channels (fe_params );
2785+ ret = sof_ipc4_get_sample_type (sdev , fe_params );
2786+ if (ret < 0 )
2787+ return ret ;
2788+ out_ref_type = (u32 )ret ;
2789+
2790+ out_ref_valid_bits = sof_ipc4_get_valid_bits (sdev , fe_params );
2791+ if (out_ref_valid_bits < 0 )
2792+ return out_ref_valid_bits ;
2793+ }
27762794
27772795 output_fmt_index = sof_ipc4_init_output_audio_fmt (sdev , swidget ,
27782796 & process -> base_config ,
@@ -2800,6 +2818,16 @@ static int sof_ipc4_prepare_process_module(struct snd_sof_widget *swidget,
28002818 if (ret )
28012819 return ret ;
28022820 }
2821+
2822+ /* set base cfg to match the first output format if there are no input formats */
2823+ if (!available_fmt -> num_input_formats ) {
2824+ struct sof_ipc4_audio_format * out_fmt ;
2825+
2826+ out_fmt = & available_fmt -> output_pin_fmts [0 ].audio_fmt ;
2827+
2828+ /* copy output format */
2829+ memcpy (& process -> base_config .audio_fmt , out_fmt , sizeof (* out_fmt ));
2830+ }
28032831 }
28042832
28052833 sof_ipc4_dbg_module_audio_format (sdev -> dev , swidget , available_fmt ,
0 commit comments