@@ -2012,10 +2012,57 @@ static void sof_ipc4_host_config(struct snd_sof_dev *sdev, struct snd_sof_widget
20122012}
20132013
20142014static int
2015- sof_ipc4_prepare_copier_module (struct snd_sof_widget * swidget ,
2016- struct snd_pcm_hw_params * fe_params ,
2017- struct snd_sof_platform_stream_params * platform_params ,
2018- struct snd_pcm_hw_params * pipeline_params , int dir )
2015+ sof_ipc4_copier_module_update_params (struct snd_sof_widget * swidget ,
2016+ struct snd_pcm_hw_params * pipeline_params )
2017+ {
2018+ struct snd_soc_component * scomp = swidget -> scomp ;
2019+ struct snd_sof_dev * sdev = snd_soc_component_get_drvdata (scomp );
2020+ struct sof_ipc4_copier_data * copier_data ;
2021+ struct sof_ipc4_copier * ipc4_copier ;
2022+
2023+ switch (swidget -> id ) {
2024+ case snd_soc_dapm_aif_in :
2025+ case snd_soc_dapm_aif_out :
2026+ case snd_soc_dapm_buffer :
2027+ ipc4_copier = swidget -> private ;
2028+ copier_data = & ipc4_copier -> data ;
2029+ break ;
2030+ case snd_soc_dapm_dai_in :
2031+ case snd_soc_dapm_dai_out :
2032+ {
2033+ struct snd_sof_widget * pipe_widget = swidget -> spipe -> pipe_widget ;
2034+ struct sof_ipc4_pipeline * pipeline = pipe_widget -> private ;
2035+ struct snd_sof_dai * dai ;
2036+
2037+ if (pipeline -> use_chain_dma )
2038+ return 0 ;
2039+
2040+ dai = swidget -> private ;
2041+
2042+ ipc4_copier = (struct sof_ipc4_copier * )dai -> private ;
2043+ copier_data = & ipc4_copier -> data ;
2044+
2045+ break ;
2046+ }
2047+ default :
2048+ dev_err (sdev -> dev , "unsupported type %d for copier %s" ,
2049+ swidget -> id , swidget -> widget -> name );
2050+ return - EINVAL ;
2051+ }
2052+
2053+ /* modify the input params for the next widget */
2054+ return sof_ipc4_update_hw_params (sdev , pipeline_params ,
2055+ & copier_data -> out_format ,
2056+ BIT (SNDRV_PCM_HW_PARAM_FORMAT ) |
2057+ BIT (SNDRV_PCM_HW_PARAM_CHANNELS ) |
2058+ BIT (SNDRV_PCM_HW_PARAM_RATE ));
2059+ }
2060+
2061+ static int
2062+ _sof_ipc4_prepare_copier_module (struct snd_sof_widget * swidget ,
2063+ struct snd_pcm_hw_params * fe_params ,
2064+ struct snd_sof_platform_stream_params * platform_params ,
2065+ struct snd_pcm_hw_params * pipeline_params , int dir )
20192066{
20202067 struct sof_ipc4_available_audio_format * available_fmt ;
20212068 struct snd_soc_component * scomp = swidget -> scomp ;
@@ -2469,6 +2516,21 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
24692516 return 0 ;
24702517}
24712518
2519+ static int
2520+ sof_ipc4_prepare_copier_module (struct snd_sof_widget * swidget ,
2521+ struct snd_pcm_hw_params * fe_params ,
2522+ struct snd_sof_platform_stream_params * platform_params ,
2523+ struct snd_pcm_hw_params * pipeline_params , int dir )
2524+ {
2525+ if (swidget -> prepared )
2526+ return sof_ipc4_copier_module_update_params (swidget ,
2527+ pipeline_params );
2528+
2529+ return _sof_ipc4_prepare_copier_module (swidget , fe_params ,
2530+ platform_params , pipeline_params ,
2531+ dir );
2532+ }
2533+
24722534static int sof_ipc4_prepare_gain_module (struct snd_sof_widget * swidget ,
24732535 struct snd_pcm_hw_params * fe_params ,
24742536 struct snd_sof_platform_stream_params * platform_params ,
@@ -2482,6 +2544,10 @@ static int sof_ipc4_prepare_gain_module(struct snd_sof_widget *swidget,
24822544 u32 out_ref_rate , out_ref_channels , out_ref_valid_bits , out_ref_type ;
24832545 int input_fmt_index , output_fmt_index ;
24842546
2547+ /* This cannot happen */
2548+ if (unlikely (swidget -> prepared ))
2549+ return 0 ;
2550+
24852551 input_fmt_index = sof_ipc4_init_input_audio_fmt (sdev , swidget ,
24862552 & gain -> data .base_config ,
24872553 pipeline_params ,
@@ -2527,6 +2593,10 @@ static int sof_ipc4_prepare_mixer_module(struct snd_sof_widget *swidget,
25272593 u32 out_ref_rate , out_ref_channels , out_ref_valid_bits , out_ref_type ;
25282594 int input_fmt_index , output_fmt_index ;
25292595
2596+ /* Already prepared, nothing to do */
2597+ if (swidget -> prepared )
2598+ return 0 ;
2599+
25302600 input_fmt_index = sof_ipc4_init_input_audio_fmt (sdev , swidget ,
25312601 & mixer -> base_config ,
25322602 pipeline_params ,
@@ -2573,6 +2643,10 @@ static int sof_ipc4_prepare_src_module(struct snd_sof_widget *swidget,
25732643 u32 out_ref_rate , out_ref_channels , out_ref_valid_bits , out_ref_type ;
25742644 int output_fmt_index , input_fmt_index ;
25752645
2646+ /* This cannot happen */
2647+ if (unlikely (swidget -> prepared ))
2648+ return 0 ;
2649+
25762650 input_fmt_index = sof_ipc4_init_input_audio_fmt (sdev , swidget ,
25772651 & src -> data .base_config ,
25782652 pipeline_params ,
@@ -2724,6 +2798,18 @@ static int sof_ipc4_prepare_process_module(struct snd_sof_widget *swidget,
27242798 int input_fmt_index = 0 ;
27252799 int ret ;
27262800
2801+ if (swidget -> prepared ) {
2802+ if (!available_fmt -> num_output_formats )
2803+ return 0 ;
2804+
2805+ /* modify the pipeline params with the output format */
2806+ return sof_ipc4_update_hw_params (sdev , pipeline_params ,
2807+ & process -> output_format ,
2808+ BIT (SNDRV_PCM_HW_PARAM_FORMAT ) |
2809+ BIT (SNDRV_PCM_HW_PARAM_CHANNELS ) |
2810+ BIT (SNDRV_PCM_HW_PARAM_RATE ));
2811+ }
2812+
27272813 input_fmt_index = sof_ipc4_init_input_audio_fmt (sdev , swidget ,
27282814 & process -> base_config ,
27292815 pipeline_params ,
0 commit comments