Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp261522ybt; Mon, 6 Jul 2020 08:42:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxri0kakteawfZ1aD2N1BMFmnjvOLErAHeJgV+70CSZoXQ/p2TsY9QPrtgpRmnAjM9cn1Qu X-Received: by 2002:a17:906:fac1:: with SMTP id lu1mr39406909ejb.427.1594050174195; Mon, 06 Jul 2020 08:42:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594050174; cv=none; d=google.com; s=arc-20160816; b=M3tGxFivTXiDT3oycH+/jsSefQ1lD5WLQgAAU4NdcyvShNktXxAOPtxG5do7rkcaIg mE0NsOKuwFUruhfrYnPOmeHyil4KkmC6bMvIe4uyHV1VPJMkCLOYKvmsRhhMOKW7qkCl 0h4iIQO6Ty1S9sMRM76JoSqmHuJUQ2w1U7n3tbRLeOapuSXLxxdupR1iash0TUfINajg VPmk5GIhgDvXlvwAEHkeuvSpCbTBbuzcWETylO10NddUoYWMMcpFgJRpuiIjJf5H8yyp NHyhScgvQCbctK6phGIJ/V14aB+X5SSZpdCG2lk2Qo2ENwYpQNv/5Vx5SIcoTRIN0CwL I4tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:ironport-sdr:ironport-sdr; bh=EgHG/Ns5nvxyTyInm1T8bsuBrO4uDcI3QgqyEmHwhyw=; b=No/iJjQeyjCvC9LF2GhaaBv2iVOpUS4FMrjKV9KaC5J4m+2wXmSwEEnKFda5+1jNNa iZhTWI859HJxF5MbdZEls5VhIJ2+vaPkq7e7rcp1BGJpOnMyL8tu3Rqs6c88GwvXBO6L EqSGHzc1L1FBKw9nvxVk6XiheGcbhdrr1HDTAPe0nQdyHayiS/XEDGJ7cpnzH80Hgh06 mhd7FfzQ2EUmou3j9q5Qn4+kb/iNcweofzIJR9hu9effAR7g0LIgRLgrK86KkeFf3dtH QKobdbY90KW1uR+L0ChFZ4xgSC8v/78ZZB9z2ba5vZywgz25kr7VSto0TBgsjleKTvyF WD8Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id zh8si12856618ejb.305.2020.07.06.08.42.31; Mon, 06 Jul 2020 08:42:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729297AbgGFPlt (ORCPT + 99 others); Mon, 6 Jul 2020 11:41:49 -0400 Received: from mga03.intel.com ([134.134.136.65]:51569 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729197AbgGFPlt (ORCPT ); Mon, 6 Jul 2020 11:41:49 -0400 IronPort-SDR: vv1X7PVlbeKfqyLy7laK+6GyqVqLvMvtXVaOPA4QFd0nadVwLHC4WfZkCwiu/f5F9aZfaBPz54 QCEitdglni2w== X-IronPort-AV: E=McAfee;i="6000,8403,9673"; a="147442225" X-IronPort-AV: E=Sophos;i="5.75,320,1589266800"; d="scan'208";a="147442225" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2020 08:41:49 -0700 IronPort-SDR: AS0HeRsqQZt0NvwtBpVT084SnSxbfpTRzLF4kAisPpb/x+Zo9438wtNF1Cuj6SmOBZvJiBxi/V RbpnIUrH4/lg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,320,1589266800"; d="scan'208";a="313997880" Received: from aislam-mobl1.amr.corp.intel.com ([10.212.167.133]) by orsmga008.jf.intel.com with ESMTP; 06 Jul 2020 08:41:47 -0700 Subject: Re: [PATCH v4] ASoC: Intel: kbl_rt5663_rt5514_max98927: Fix kabylake_ssp_fixup function To: Lukasz Majczak , Jie Yang , Liam Girdwood , Harsha Priya Cc: alsa-devel@alsa-project.org, Radoslaw Biernacki , Ross Zwisler , linux-kernel@vger.kernel.org, Sathya Prakash , Bob Brandt , Marcin Wojtas , Alex Levin , Gopal Vamshi Krishna References: <20200521162518.1809995-1-lma@semihalf.com> <20200703121650.547944-1-lma@semihalf.com> From: Pierre-Louis Bossart Message-ID: <5dfc3678-0f12-7823-2571-ab0dff250d15@linux.intel.com> Date: Mon, 6 Jul 2020 10:41:47 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.8.1 MIME-Version: 1.0 In-Reply-To: <20200703121650.547944-1-lma@semihalf.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/3/20 7:16 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. > > 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 Looks good Lukasz but you need to move the information on changes below the --- marker (~4 lines below). > > Signed-off-by: Lukasz Majczak > Signed-off-by: Harsha Priya > --- > .../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; >