@@ -401,17 +401,40 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
401401 struct snd_interval * chan = hw_param_interval (params ,
402402 SNDRV_PCM_HW_PARAM_CHANNELS );
403403 struct snd_mask * fmt = hw_param_mask (params , SNDRV_PCM_HW_PARAM_FORMAT );
404- struct snd_soc_dpcm * dpcm = container_of (
405- params , struct snd_soc_dpcm , hw_params );
406- struct snd_soc_dai_link * fe_dai_link = dpcm -> fe -> dai_link ;
407- struct snd_soc_dai_link * be_dai_link = dpcm -> be -> dai_link ;
404+ struct snd_soc_dpcm * dpcm , * rtd_dpcm = NULL ;
405+
406+ /*
407+ * The following loop will be called only for playback stream
408+ * In this platform, there is only one playback device on every SSP
409+ */
410+ for_each_dpcm_fe (rtd , SNDRV_PCM_STREAM_PLAYBACK , dpcm ) {
411+ rtd_dpcm = dpcm ;
412+ break ;
413+ }
414+
415+ /*
416+ * This following loop will be called only for capture stream
417+ * In this platform, there is only one capture device on every SSP
418+ */
419+ for_each_dpcm_fe (rtd , SNDRV_PCM_STREAM_CAPTURE , dpcm ) {
420+ rtd_dpcm = dpcm ;
421+ break ;
422+ }
423+
424+ if (!rtd_dpcm )
425+ return - EINVAL ;
426+
427+ /*
428+ * The above 2 loops are mutually exclusive based on the stream direction,
429+ * thus rtd_dpcm variable will never be overwritten
430+ */
408431
409432 /*
410433 * The ADSP will convert the FE rate to 48k, stereo, 24 bit
411434 */
412- if (!strcmp (fe_dai_link -> name , "Kbl Audio Port" ) ||
413- !strcmp (fe_dai_link -> name , "Kbl Audio Headset Playback" ) ||
414- !strcmp (fe_dai_link -> name , "Kbl Audio Capture Port" )) {
435+ if (!strcmp (rtd_dpcm -> fe -> dai_link -> name , "Kbl Audio Port" ) ||
436+ !strcmp (rtd_dpcm -> fe -> dai_link -> name , "Kbl Audio Headset Playback" ) ||
437+ !strcmp (rtd_dpcm -> fe -> dai_link -> name , "Kbl Audio Capture Port" )) {
415438 rate -> min = rate -> max = 48000 ;
416439 chan -> min = chan -> max = 2 ;
417440 snd_mask_none (fmt );
@@ -421,7 +444,7 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
421444 * The speaker on the SSP0 supports S16_LE and not S24_LE.
422445 * thus changing the mask here
423446 */
424- if (!strcmp (be_dai_link -> name , "SSP0-Codec" ))
447+ if (!strcmp (rtd_dpcm -> be -> dai_link -> name , "SSP0-Codec" ))
425448 snd_mask_set_format (fmt , SNDRV_PCM_FORMAT_S16_LE );
426449
427450 return 0 ;
0 commit comments