@@ -2007,10 +2007,57 @@ static void sof_ipc4_host_config(struct snd_sof_dev *sdev, struct snd_sof_widget
20072007}
20082008
20092009static int
2010- sof_ipc4_prepare_copier_module (struct snd_sof_widget * swidget ,
2011- struct snd_pcm_hw_params * fe_params ,
2012- struct snd_sof_platform_stream_params * platform_params ,
2013- struct snd_pcm_hw_params * pipeline_params , int dir )
2010+ sof_ipc4_copier_module_update_params (struct snd_sof_widget * swidget ,
2011+ struct snd_pcm_hw_params * pipeline_params )
2012+ {
2013+ struct snd_soc_component * scomp = swidget -> scomp ;
2014+ struct snd_sof_dev * sdev = snd_soc_component_get_drvdata (scomp );
2015+ struct sof_ipc4_copier_data * copier_data ;
2016+ struct sof_ipc4_copier * ipc4_copier ;
2017+
2018+ switch (swidget -> id ) {
2019+ case snd_soc_dapm_aif_in :
2020+ case snd_soc_dapm_aif_out :
2021+ case snd_soc_dapm_buffer :
2022+ ipc4_copier = swidget -> private ;
2023+ copier_data = & ipc4_copier -> data ;
2024+ break ;
2025+ case snd_soc_dapm_dai_in :
2026+ case snd_soc_dapm_dai_out :
2027+ {
2028+ struct snd_sof_widget * pipe_widget = swidget -> spipe -> pipe_widget ;
2029+ struct sof_ipc4_pipeline * pipeline = pipe_widget -> private ;
2030+ struct snd_sof_dai * dai ;
2031+
2032+ if (pipeline -> use_chain_dma )
2033+ return 0 ;
2034+
2035+ dai = swidget -> private ;
2036+
2037+ ipc4_copier = (struct sof_ipc4_copier * )dai -> private ;
2038+ copier_data = & ipc4_copier -> data ;
2039+
2040+ break ;
2041+ }
2042+ default :
2043+ dev_err (sdev -> dev , "unsupported type %d for copier %s" ,
2044+ swidget -> id , swidget -> widget -> name );
2045+ return - EINVAL ;
2046+ }
2047+
2048+ /* modify the input params for the next widget */
2049+ return sof_ipc4_update_hw_params (sdev , pipeline_params ,
2050+ & copier_data -> out_format ,
2051+ BIT (SNDRV_PCM_HW_PARAM_FORMAT ) |
2052+ BIT (SNDRV_PCM_HW_PARAM_CHANNELS ) |
2053+ BIT (SNDRV_PCM_HW_PARAM_RATE ));
2054+ }
2055+
2056+ static int
2057+ _sof_ipc4_prepare_copier_module (struct snd_sof_widget * swidget ,
2058+ struct snd_pcm_hw_params * fe_params ,
2059+ struct snd_sof_platform_stream_params * platform_params ,
2060+ struct snd_pcm_hw_params * pipeline_params , int dir )
20142061{
20152062 struct sof_ipc4_available_audio_format * available_fmt ;
20162063 struct snd_soc_component * scomp = swidget -> scomp ;
@@ -2463,6 +2510,21 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
24632510 return 0 ;
24642511}
24652512
2513+ static int
2514+ sof_ipc4_prepare_copier_module (struct snd_sof_widget * swidget ,
2515+ struct snd_pcm_hw_params * fe_params ,
2516+ struct snd_sof_platform_stream_params * platform_params ,
2517+ struct snd_pcm_hw_params * pipeline_params , int dir )
2518+ {
2519+ if (swidget -> prepared )
2520+ return sof_ipc4_copier_module_update_params (swidget ,
2521+ pipeline_params );
2522+
2523+ return _sof_ipc4_prepare_copier_module (swidget , fe_params ,
2524+ platform_params , pipeline_params ,
2525+ dir );
2526+ }
2527+
24662528static int sof_ipc4_prepare_gain_module (struct snd_sof_widget * swidget ,
24672529 struct snd_pcm_hw_params * fe_params ,
24682530 struct snd_sof_platform_stream_params * platform_params ,
@@ -2476,6 +2538,10 @@ static int sof_ipc4_prepare_gain_module(struct snd_sof_widget *swidget,
24762538 u32 out_ref_rate , out_ref_channels , out_ref_valid_bits , out_ref_type ;
24772539 int input_fmt_index , output_fmt_index ;
24782540
2541+ /* This cannot happen */
2542+ if (unlikely (swidget -> prepared ))
2543+ return 0 ;
2544+
24792545 input_fmt_index = sof_ipc4_init_input_audio_fmt (sdev , swidget ,
24802546 & gain -> data .base_config ,
24812547 pipeline_params ,
@@ -2521,6 +2587,10 @@ static int sof_ipc4_prepare_mixer_module(struct snd_sof_widget *swidget,
25212587 u32 out_ref_rate , out_ref_channels , out_ref_valid_bits , out_ref_type ;
25222588 int input_fmt_index , output_fmt_index ;
25232589
2590+ /* Already prepared, nothing to do */
2591+ if (swidget -> prepared )
2592+ return 0 ;
2593+
25242594 input_fmt_index = sof_ipc4_init_input_audio_fmt (sdev , swidget ,
25252595 & mixer -> base_config ,
25262596 pipeline_params ,
@@ -2567,6 +2637,10 @@ static int sof_ipc4_prepare_src_module(struct snd_sof_widget *swidget,
25672637 u32 out_ref_rate , out_ref_channels , out_ref_valid_bits , out_ref_type ;
25682638 int output_fmt_index , input_fmt_index ;
25692639
2640+ /* This cannot happen */
2641+ if (unlikely (swidget -> prepared ))
2642+ return 0 ;
2643+
25702644 input_fmt_index = sof_ipc4_init_input_audio_fmt (sdev , swidget ,
25712645 & src -> data .base_config ,
25722646 pipeline_params ,
@@ -2718,6 +2792,18 @@ static int sof_ipc4_prepare_process_module(struct snd_sof_widget *swidget,
27182792 int input_fmt_index = 0 ;
27192793 int ret ;
27202794
2795+ if (swidget -> prepared ) {
2796+ if (!available_fmt -> num_output_formats )
2797+ return 0 ;
2798+
2799+ /* modify the pipeline params with the output format */
2800+ return sof_ipc4_update_hw_params (sdev , pipeline_params ,
2801+ & process -> output_format ,
2802+ BIT (SNDRV_PCM_HW_PARAM_FORMAT ) |
2803+ BIT (SNDRV_PCM_HW_PARAM_CHANNELS ) |
2804+ BIT (SNDRV_PCM_HW_PARAM_RATE ));
2805+ }
2806+
27212807 input_fmt_index = sof_ipc4_init_input_audio_fmt (sdev , swidget ,
27222808 & process -> base_config ,
27232809 pipeline_params ,
0 commit comments