Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1162744ybt; Tue, 7 Jul 2020 09:07:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyg0FIHX9kYIR+aNNSfjtro78SwDSFVlxtB3DGIh6Pmeg+Rx6ScYjqj3ciHiqc2WRl9xQyR X-Received: by 2002:a17:906:9716:: with SMTP id k22mr29291850ejx.200.1594138024827; Tue, 07 Jul 2020 09:07:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594138024; cv=none; d=google.com; s=arc-20160816; b=00Fyxd+/CTEmSAjoAUi90poL2UX5//1hwl+t0WXM+Xh34yckAfhHu/oWm8RTPDNM6F xzO8+OceR46HzzWzc15+xy6ZbsiZM+f92XGbtVLxIXvo55iVmG1/SWhO696UJK2oVEgn NH3L672MJsYD80VkB6oJkI8Hy/jSPXI0Pa4Trj7Cdu5PxH0qp2Rn7bROuIURrPetvdgz 1J2FMqayPPkfritPNm6wZDeYUzg5Lmx/JAqmQwniYPDd3wh2s89zozin+zADAdv76txG 2XL2vYkhj5YvepE/RsWLu95r8v9LCNoFeJX2g1PN3D/HHY/ETm734fLVeHALCCvs3CjK jsgg== 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=OJbygp8nUZ1z98YQ4Vo7jKJMKO1wHf3hNhg2kiKC5Zw=; b=VkBbS0byFGlXkhQ3x6y9kq8gvJfLPQilHOK/pZsSpsCgPfOT4Yxj4hmXq5N1z3XDl+ i907bWyNEqYKX9A7VWlrvCgGFn8VQfXrzvkHzhhlWV2luJ27vx5ERElYpNi6InUdaU4a HpUZUrZchSqvlYvnlJVKoBR9Nxnq9crYhSZ6sneQgiD/AY+imEavHOWJfKxvA1s4A14y SthkXTbHI/qOKsSzahHDEsQnL++YJov/GuX0wrv07UEPN4K0IHuU9YMK5mrkghCbw+00 Dj1Hue0E8nU0M/ds66btDvqcSsg7Rh8qySnNzhLRUav4Xxs1B4Y+Rlvd6S7piMxcOStP 5pXQ== 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 s25si15447651ejv.413.2020.07.07.09.06.41; Tue, 07 Jul 2020 09:07:04 -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 S1728133AbgGGQGb (ORCPT + 99 others); Tue, 7 Jul 2020 12:06:31 -0400 Received: from mga12.intel.com ([192.55.52.136]:19446 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726911AbgGGQGb (ORCPT ); Tue, 7 Jul 2020 12:06:31 -0400 IronPort-SDR: YqB4kZJO2P0zJs7uIGd3jiRTih8PbhFPvUpxfLq5pVJuC8kdzl9d2nsgDK0YE26ztSwU/m6i5J ZYM06F+IG3iw== X-IronPort-AV: E=McAfee;i="6000,8403,9675"; a="127223810" X-IronPort-AV: E=Sophos;i="5.75,324,1589266800"; d="scan'208";a="127223810" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jul 2020 09:06:30 -0700 IronPort-SDR: nWzZSRwTYFqoBfaDlAkFLsCJyfwsTGyETLYfq5n1HLZ0dF0GicOQgpoHJU44M6tg9L8HxECkUI Lekna+wYWHUg== X-IronPort-AV: E=Sophos;i="5.75,324,1589266800"; d="scan'208";a="305713010" Received: from stortizs-mobl1.amr.corp.intel.com (HELO [10.254.109.228]) ([10.254.109.228]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jul 2020 09:06:29 -0700 Subject: Re: [PATCH v5] 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: <20200703121650.547944-1-lma@semihalf.com> <20200707083404.3846-1-lma@semihalf.com> From: Pierre-Louis Bossart Message-ID: <4cb5ea5a-60b3-7f74-0f68-e66d2f2872bf@linux.intel.com> Date: Tue, 7 Jul 2020 10:47:19 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200707083404.3846-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/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 > Signed-off-by: Harsha Priya Acked-by: Pierre-Louis Bossart > --- > 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; >