ASoC: Intel: kbl_da7219_max98927: Fix kabylake_ssp_fixup function
Subsystems (4)
PATCH 1/1 ASoC: Intel: kbl_da7219_max98927: Fix kabylake_ssp_fixup function
kabylake_ssp_fixup function uses snd_soc_dpcm to identify the codecs DAIs. The HW parameters are changed based on the codec DAI of the stream. The earlier approach to get snd_soc_dpcm was using container_of() macro on snd_pcm_hw_params.
The structures have been modified over time and snd_soc_dpcm does not have snd_pcm_hw_params as a reference but as a copy. This causes the current driver to crash when used.
This patch changes the way snd_soc_dpcm is extracted. snd_soc_pcm_runtime holds 2 dpcm instances (one for playback and one for capture). 2 codecs on the SSP are dmic (capture) and speakers (playback). Based on the stream direction, snd_soc_dpcm is extracted from snd_soc_pcm_runtime.
Tested for all use cases of the driver.
Based on similar fix in kbl_rt5663_rt5514_max98927.c from Harsha Priya <[email protected]> and Vamshi Krishna Gopal <[email protected]>
---
Hi,
This is basically a cherry-pick of this change:
https://patchwork.kernel.org/project/alsa-devel/patch/[email protected]/
just applied to the kbl_da7219_max98927.
Best regards,
Lukasz
sound/soc/intel/boards/kbl_da7219_max98927.c | 38 +++++++++++++++----- 1 file changed, 30 insertions(+), 8 deletions(-)
sound/soc/intel/boards/kbl_da7219_max98927.c +30 -8
@@ -284,11 +284,33 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,struct snd_interval *chan =hw_param_interval (params,SNDRV_PCM_HW_PARAM_CHANNELS );struct snd_mask *fmt =hw_param_mask (params,SNDRV_PCM_HW_PARAM_FORMAT ); -struct snd_soc_dpcm *dpcm =container_of ( - params, struct snd_soc_dpcm, hw_params); -struct snd_soc_dai_link *fe_dai_link = dpcm->fe->dai_link; -struct snd_soc_dai_link *be_dai_link = dpcm->be->dai_link; +struct snd_soc_dpcm *dpcm, *rtd_dpcm =NULL ; +/* +* The following loop will be called only for playback stream +* In this platform, there is only one playback device on every SSP +*/ +for_each_dpcm_fe (rtd,SNDRV_PCM_STREAM_PLAYBACK , dpcm) { + rtd_dpcm = dpcm; +break ; + } + +/* +* This following loop will be called only for capture stream +* In this platform, there is only one capture device on every SSP +*/ +for_each_dpcm_fe (rtd,SNDRV_PCM_STREAM_CAPTURE , dpcm) { + rtd_dpcm = dpcm; +break ; + } + +if (!rtd_dpcm) +return -EINVAL ; + +/* +* The above 2 loops are mutually exclusive based on the stream direction, +* thus rtd_dpcm variable will never be overwritten +*/ /* * Topology for kblda7219m98373 & kblmax98373 supports only S24_LE, * where as kblda7219m98927 & kblmax98927 supports S16_LE by default.
@@ -311,9 +333,9 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,/* * The ADSP will convert the FE rate to 48k, stereo, 24 bit */ -if (!strcmp (fe_dai_link->name,"Kbl Audio Port" ) || - !strcmp (fe_dai_link->name,"Kbl Audio Headset Playback" ) || - !strcmp (fe_dai_link->name,"Kbl Audio Capture Port" )) { +if (!strcmp (rtd_dpcm->fe->dai_link->name,"Kbl Audio Port" ) || + !strcmp (rtd_dpcm->fe->dai_link->name,"Kbl Audio Headset Playback" ) || + !strcmp (rtd_dpcm->fe->dai_link->name,"Kbl Audio Capture Port" )) { rate->min = rate->max =48000 ; chan->min = chan->max =2 ;snd_mask_none (fmt);
@@ -324,7 +346,7 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,* The speaker on the SSP0 supports S16_LE and not S24_LE. * thus changing the mask here */ -if (!strcmp (be_dai_link->name,"SSP0-Codec" )) +if (!strcmp (rtd_dpcm->be->dai_link->name,"SSP0-Codec" ))snd_mask_set_format (fmt,SNDRV_PCM_FORMAT_S16_LE );return 0 ;
Signature · 1 line
2.25.1
Quoted 21 lines · Lukasz Majczak
kabylake_ssp_fixupfunction usessnd_soc_dpcmto identify the codecs DAIs. The HW parameters are changed based on the codec DAI of the stream. The earlier approach to getsnd_soc_dpcmwas usingcontainer_of()macro onsnd_pcm_hw_params.The structures have been modified over time and
snd_soc_dpcmdoes not havesnd_pcm_hw_paramsas a reference but as a copy. This causes the current driver to crash when used.This patch changes the way
snd_soc_dpcmis extracted.snd_soc_pcm_runtimeholds 2 dpcm instances (one for playback and one for capture). 2 codecs on the SSP are dmic (capture) and speakers (playback). Based on the stream direction,snd_soc_dpcmis extracted fromsnd_soc_pcm_runtime.Tested for all use cases of the driver.
Based on similar fix inkbl_rt5663_rt5514_max98927.cfrom Harsha Priya <[email protected]> and Vamshi Krishna Gopal <[email protected]>Cc <[email protected]> # 5.4+Signed-off-by Lukasz Majczak <[email protected]>
Quoted 7 lines
---
Hi,
This is basically a cherry-pick of this change:
https://patchwork.kernel.org/project/alsa-devel/patch/[email protected]/
just applied to thekbl_da7219_max98927.
Best regards,
Lukasz
Quoted 69 lines
sound/soc/intel/boards/kbl_da7219_max98927.c | 38 +++++++++++++++----- 1 file changed, 30 insertions(+), 8 deletions(-)sound/soc/intel/boards/kbl_da7219_max98927.c +30
-8@@ -284,11 +284,33 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,struct snd_interval *chan =hw_param_interval (params,SNDRV_PCM_HW_PARAM_CHANNELS );struct snd_mask *fmt =hw_param_mask (params,SNDRV_PCM_HW_PARAM_FORMAT ); -struct snd_soc_dpcm *dpcm =container_of ( - params, struct snd_soc_dpcm, hw_params); -struct snd_soc_dai_link *fe_dai_link = dpcm->fe->dai_link; -struct snd_soc_dai_link *be_dai_link = dpcm->be->dai_link; +struct snd_soc_dpcm *dpcm, *rtd_dpcm =NULL ; +/* +* The following loop will be called only for playback stream +* In this platform, there is only one playback device on every SSP +*/ +for_each_dpcm_fe (rtd,SNDRV_PCM_STREAM_PLAYBACK , dpcm) { + rtd_dpcm = dpcm; +break ; + } + +/* +* This following loop will be called only for capture stream +* In this platform, there is only one capture device on every SSP +*/ +for_each_dpcm_fe (rtd,SNDRV_PCM_STREAM_CAPTURE , dpcm) { + rtd_dpcm = dpcm; +break ; + } + +if (!rtd_dpcm) +return -EINVAL ; + +/* +* The above 2 loops are mutually exclusive based on the stream direction, +* thus rtd_dpcm variable will never be overwritten +*/ /* * Topology for kblda7219m98373 & kblmax98373 supports only S24_LE, * where as kblda7219m98927 & kblmax98927 supports S16_LE by default. @@ -311,9 +333,9 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,/* * The ADSP will convert the FE rate to 48k, stereo, 24 bit */ -if (!strcmp (fe_dai_link->name,"Kbl Audio Port" ) || - !strcmp (fe_dai_link->name,"Kbl Audio Headset Playback" ) || - !strcmp (fe_dai_link->name,"Kbl Audio Capture Port" )) { +if (!strcmp (rtd_dpcm->fe->dai_link->name,"Kbl Audio Port" ) || + !strcmp (rtd_dpcm->fe->dai_link->name,"Kbl Audio Headset Playback" ) || + !strcmp (rtd_dpcm->fe->dai_link->name,"Kbl Audio Capture Port" )) { rate->min = rate->max =48000 ; chan->min = chan->max =2 ;snd_mask_none (fmt);@@ -324,7 +346,7 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,* The speaker on the SSP0 supports S16_LE and not S24_LE. * thus changing the mask here */ -if (!strcmp (be_dai_link->name,"SSP0-Codec" )) +if (!strcmp (rtd_dpcm->be->dai_link->name,"SSP0-Codec" ))snd_mask_set_format (fmt,SNDRV_PCM_FORMAT_S16_LE );return 0 ;
Mark Brown
maintainerQuoted 10 lines · Lukasz Majczak
kabylake_ssp_fixupfunction usessnd_soc_dpcmto identify the codecs DAIs. The HW parameters are changed based on the codec DAI of the stream. The earlier approach to getsnd_soc_dpcmwas usingcontainer_of()macro onsnd_pcm_hw_params.The structures have been modified over time and
snd_soc_dpcmdoes not havesnd_pcm_hw_paramsas a reference but as a copy. This causes the current driver to crash when used.[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/1] ASoC: Intel: kbl_da7219_max98927: Fix kabylake_ssp_fixup function
commit: a523ef731ac6674dc07574f31bf44cc5bfa14e4d
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark