[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <BY5PR11MB4307B232AF066572F8037934FD7F0@BY5PR11MB4307.namprd11.prod.outlook.com>
Date: Thu, 16 Jul 2020 15:00:22 +0000
From: "N, Harshapriya" <harshapriya.n@...el.com>
To: Pierre-Louis Bossart <pierre-louis.bossart@...ux.intel.com>,
"Lukasz Majczak" <lma@...ihalf.com>,
Jie Yang <yang.jie@...ux.intel.com>,
"Liam Girdwood" <liam.r.girdwood@...ux.intel.com>
CC: "alsa-devel@...a-project.org" <alsa-devel@...a-project.org>,
"Radoslaw Biernacki" <rad@...ihalf.com>,
Ross Zwisler <zwisler@...gle.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"M R, Sathya Prakash" <sathya.prakash.m.r@...el.com>,
Bob Brandt <brndt@...gle.com>, Marcin Wojtas <mw@...ihalf.com>,
Alex Levin <levinale@...omium.org>,
"Gopal, Vamshi Krishna" <vamshi.krishna.gopal@...el.com>
Subject: RE: [PATCH v5] ASoC: Intel: kbl_rt5663_rt5514_max98927: Fix
kabylake_ssp_fixup function
>
>
> On 7/7/20 3:34 AM, Lukasz Majczak wrote:
> > Fix kabylake_ssp_fixup function to distinguish codecs DAIs by names,
> > as current approach, leads to crash while trying to get snd_soc_dpcm
> > with
> > container_of() macro in kabylake_ssp_fixup().
> > The crash call path looks as below:
> > soc_pcm_hw_params()
> > snd_soc_dai_hw_params(codec_dai, substream, &codec_params);
> > rtd->dai_link->be_hw_params_fixup(rtd, params)
> > kabylake_ssp_fixup()
> > In this case, codec_params is just a copy of an internal structure and
> > is not embedded into struct snd_soc_dpcm thus we cannot use
> > container_of() on it.
> >
> > Signed-off-by: Lukasz Majczak <lma@...ihalf.com>
> > Signed-off-by: Harsha Priya <harshapriya.n@...el.com>
>
> Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@...ux.intel.com>
This fix is not complete as the asoc_rtd_to_codec(rtd,0) returns the codec instance
at 0th location. Instead we need to use the dpcm in the snd_pcm_runtime structure.
I will need another version of this patch.
>
> > ---
> > v1 -> v2:
> > - Extract dmic from SSP0 as every BE should have own fixup function.
> > v2 -> v3:
> > - Restore naming in the dapm route table to not confuse with other
> > drivers
> > - Fixed indentations
> > v3 -> v4:
> > - Updated code and commit description according to solution proposed
> > by Harsha
> > ---
> > .../intel/boards/kbl_rt5663_rt5514_max98927.c | 28 ++++++++-----------
> > 1 file changed, 12 insertions(+), 16 deletions(-)
> >
> > diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
> > b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
> > index b34cf6cf11395..df454de40739a 100644
> > --- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
> > +++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
> > @@ -333,36 +333,32 @@ static int kabylake_ssp_fixup(struct
> snd_soc_pcm_runtime *rtd,
> > {
> > struct snd_interval *rate = hw_param_interval(params,
> > SNDRV_PCM_HW_PARAM_RATE);
> > - struct snd_interval *chan = hw_param_interval(params,
> > + struct snd_interval *channels = 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_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
> >
> > /*
> > * 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(codec_dai->name, KBL_REALTEK_DMIC_CODEC_DAI)) {
> > + if (params_channels(params) == 2 ||
> > + DMIC_CH(dmic_constraints) == 2)
> > + channels->min = channels->max = 2;
> > + else
> > + channels->min = channels->max = 4;
> > + } else {
> > rate->min = rate->max = 48000;
> > - chan->min = chan->max = 2;
> > + channels->min = channels->max = 2;
> > snd_mask_none(fmt);
> > snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
> > - } else if (!strcmp(fe_dai_link->name, "Kbl Audio DMIC cap")) {
> > - if (params_channels(params) == 2 ||
> > - DMIC_CH(dmic_constraints) == 2)
> > - chan->min = chan->max = 2;
> > - else
> > - chan->min = chan->max = 4;
> > }
> > /*
> > * 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(codec_dai->name, KBL_MAXIM_CODEC_DAI))
> > snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S16_LE);
> >
> > return 0;
> >
Powered by blists - more mailing lists