@@ -1119,42 +1119,50 @@ static int sof_ipc4_widget_assign_instance_id(struct snd_sof_dev *sdev,
1119
1119
1120
1120
/* update hw_params based on the audio stream format */
1121
1121
static int sof_ipc4_update_hw_params (struct snd_sof_dev * sdev , struct snd_pcm_hw_params * params ,
1122
- struct sof_ipc4_audio_format * fmt )
1122
+ struct sof_ipc4_audio_format * fmt , u32 param_to_update )
1123
1123
{
1124
- snd_pcm_format_t snd_fmt ;
1125
1124
struct snd_interval * i ;
1126
- struct snd_mask * m ;
1127
- int valid_bits = SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH (fmt -> fmt_cfg );
1128
- unsigned int channels , rate ;
1129
1125
1130
- switch (valid_bits ) {
1131
- case 16 :
1132
- snd_fmt = SNDRV_PCM_FORMAT_S16_LE ;
1133
- break ;
1134
- case 24 :
1135
- snd_fmt = SNDRV_PCM_FORMAT_S24_LE ;
1136
- break ;
1137
- case 32 :
1138
- snd_fmt = SNDRV_PCM_FORMAT_S32_LE ;
1139
- break ;
1140
- default :
1141
- dev_err (sdev -> dev , "invalid PCM valid_bits %d\n" , valid_bits );
1142
- return - EINVAL ;
1126
+ if (param_to_update & BIT (SNDRV_PCM_HW_PARAM_FORMAT )) {
1127
+ int valid_bits = SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH (fmt -> fmt_cfg );
1128
+ snd_pcm_format_t snd_fmt ;
1129
+ struct snd_mask * m ;
1130
+
1131
+ switch (valid_bits ) {
1132
+ case 16 :
1133
+ snd_fmt = SNDRV_PCM_FORMAT_S16_LE ;
1134
+ break ;
1135
+ case 24 :
1136
+ snd_fmt = SNDRV_PCM_FORMAT_S24_LE ;
1137
+ break ;
1138
+ case 32 :
1139
+ snd_fmt = SNDRV_PCM_FORMAT_S32_LE ;
1140
+ break ;
1141
+ default :
1142
+ dev_err (sdev -> dev , "invalid PCM valid_bits %d\n" , valid_bits );
1143
+ return - EINVAL ;
1144
+ }
1145
+
1146
+ m = hw_param_mask (params , SNDRV_PCM_HW_PARAM_FORMAT );
1147
+ snd_mask_none (m );
1148
+ snd_mask_set_format (m , snd_fmt );
1143
1149
}
1144
1150
1145
- m = hw_param_mask (params , SNDRV_PCM_HW_PARAM_FORMAT );
1146
- snd_mask_none (m );
1147
- snd_mask_set_format (m , snd_fmt );
1151
+ if (param_to_update & BIT (SNDRV_PCM_HW_PARAM_RATE )) {
1152
+ unsigned int rate = fmt -> sampling_frequency ;
1148
1153
1149
- rate = fmt -> sampling_frequency ;
1150
- i = hw_param_interval ( params , SNDRV_PCM_HW_PARAM_RATE ) ;
1151
- i -> min = rate ;
1152
- i -> max = rate ;
1154
+ i = hw_param_interval ( params , SNDRV_PCM_HW_PARAM_RATE ) ;
1155
+ i -> min = rate ;
1156
+ i -> max = rate ;
1157
+ }
1153
1158
1154
- channels = SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT (fmt -> fmt_cfg );
1155
- i = hw_param_interval (params , SNDRV_PCM_HW_PARAM_CHANNELS );
1156
- i -> min = channels ;
1157
- i -> max = channels ;
1159
+ if (param_to_update & BIT (SNDRV_PCM_HW_PARAM_CHANNELS )) {
1160
+ unsigned int channels = SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT (fmt -> fmt_cfg );
1161
+
1162
+ i = hw_param_interval (params , SNDRV_PCM_HW_PARAM_CHANNELS );
1163
+ i -> min = channels ;
1164
+ i -> max = channels ;
1165
+ }
1158
1166
1159
1167
return 0 ;
1160
1168
}
@@ -1844,7 +1852,11 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
1844
1852
}
1845
1853
1846
1854
/* modify the input params for the next widget */
1847
- ret = sof_ipc4_update_hw_params (sdev , pipeline_params , & copier_data -> out_format );
1855
+ ret = sof_ipc4_update_hw_params (sdev , pipeline_params ,
1856
+ & copier_data -> out_format ,
1857
+ BIT (SNDRV_PCM_HW_PARAM_FORMAT ) |
1858
+ BIT (SNDRV_PCM_HW_PARAM_CHANNELS ) |
1859
+ BIT (SNDRV_PCM_HW_PARAM_RATE ));
1848
1860
if (ret )
1849
1861
return ret ;
1850
1862
@@ -2069,7 +2081,10 @@ static int sof_ipc4_prepare_src_module(struct snd_sof_widget *swidget,
2069
2081
src -> data .sink_rate = out_audio_fmt -> sampling_frequency ;
2070
2082
2071
2083
/* update pipeline_params for sink widgets */
2072
- return sof_ipc4_update_hw_params (sdev , pipeline_params , out_audio_fmt );
2084
+ return sof_ipc4_update_hw_params (sdev , pipeline_params , out_audio_fmt ,
2085
+ BIT (SNDRV_PCM_HW_PARAM_FORMAT ) |
2086
+ BIT (SNDRV_PCM_HW_PARAM_CHANNELS ) |
2087
+ BIT (SNDRV_PCM_HW_PARAM_RATE ));
2073
2088
}
2074
2089
2075
2090
static int
@@ -2193,7 +2208,11 @@ static int sof_ipc4_prepare_process_module(struct snd_sof_widget *swidget,
2193
2208
sizeof (struct sof_ipc4_audio_format ));
2194
2209
2195
2210
/* modify the pipeline params with the pin 0 output format */
2196
- ret = sof_ipc4_update_hw_params (sdev , pipeline_params , & process -> output_format );
2211
+ ret = sof_ipc4_update_hw_params (sdev , pipeline_params ,
2212
+ & process -> output_format ,
2213
+ BIT (SNDRV_PCM_HW_PARAM_FORMAT ) |
2214
+ BIT (SNDRV_PCM_HW_PARAM_CHANNELS ) |
2215
+ BIT (SNDRV_PCM_HW_PARAM_RATE ));
2197
2216
if (ret )
2198
2217
return ret ;
2199
2218
}
0 commit comments