From: Lukasz Majczak <lma@semihalf.com>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
Jie Yang <yang.jie@linux.intel.com>,
Liam Girdwood <liam.r.girdwood@linux.intel.com>,
Harsha Priya <harshapriya.n@intel.com>
Cc: Gopal Vamshi Krishna <vamshi.krishna.gopal@intel.com>,
Sathya Prakash <sathya.prakash.m.r@intel.com>,
Bob Brandt <brndt@google.com>, Alex Levin <levinale@chromium.org>,
Ross Zwisler <zwisler@google.com>,
Marcin Wojtas <mw@semihalf.com>,
Radoslaw Biernacki <rad@semihalf.com>,
linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org
Subject: [PATCH v5] ASoC: Intel: kbl_rt5663_rt5514_max98927: Fix kabylake_ssp_fixup function
Date: Tue, 7 Jul 2020 10:34:04 +0200 [thread overview]
Message-ID: <20200707083404.3846-1-lma@semihalf.com> (raw)
In-Reply-To: <20200703121650.547944-1-lma@semihalf.com>
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@semihalf.com>
Signed-off-by: Harsha Priya <harshapriya.n@intel.com>
---
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;
--
2.25.1
next prev parent reply other threads:[~2020-07-07 8:35 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-21 16:25 [PATCH v3] ASoC: Intel: kbl_rt5663_rt5514_max98927: Split be_hw_params_fixup function Lukasz Majczak
2020-05-21 16:32 ` Pierre-Louis Bossart
2020-05-21 17:08 ` Łukasz Majczak
2020-05-21 17:17 ` Pierre-Louis Bossart
2020-05-21 17:30 ` Łukasz Majczak
2020-05-21 18:10 ` Pierre-Louis Bossart
2020-06-29 11:11 ` Łukasz Majczak
2020-06-29 16:51 ` N, Harshapriya
2020-06-29 18:19 ` Łukasz Majczak
2020-06-29 22:30 ` N, Harshapriya
2020-07-01 16:37 ` N, Harshapriya
2020-07-01 16:48 ` Pierre-Louis Bossart
2020-07-01 17:00 ` N, Harshapriya
2020-07-01 17:08 ` Pierre-Louis Bossart
2020-07-02 10:09 ` Łukasz Majczak
2020-07-03 12:16 ` [PATCH v4] ASoC: Intel: kbl_rt5663_rt5514_max98927: Fix kabylake_ssp_fixup function Lukasz Majczak
2020-07-06 15:41 ` Pierre-Louis Bossart
2020-07-07 8:34 ` Lukasz Majczak [this message]
2020-07-07 15:47 ` [PATCH v5] " Pierre-Louis Bossart
2020-07-16 15:00 ` N, Harshapriya
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200707083404.3846-1-lma@semihalf.com \
--to=lma@semihalf.com \
--cc=alsa-devel@alsa-project.org \
--cc=brndt@google.com \
--cc=harshapriya.n@intel.com \
--cc=levinale@chromium.org \
--cc=liam.r.girdwood@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mw@semihalf.com \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=rad@semihalf.com \
--cc=sathya.prakash.m.r@intel.com \
--cc=vamshi.krishna.gopal@intel.com \
--cc=yang.jie@linux.intel.com \
--cc=zwisler@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®