Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp824047pxb; Thu, 15 Apr 2021 07:28:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJ5vBmf/mfLbqe85wccXRrIOn3ODf0ycH6Nd2WCc/y1UUsMCFi2aBFEwU6jGb8zp14H4Mw X-Received: by 2002:a17:907:7690:: with SMTP id jv16mr3763159ejc.529.1618496886649; Thu, 15 Apr 2021 07:28:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618496886; cv=none; d=google.com; s=arc-20160816; b=sy47lzw8ZvJConOIApRsnDd1qxbBSc3vgD/VmaRTojlQ7jDd2v4zONR5rAKYjRbH6Y Y0Sziq2ZNc+VO2BhuJQC3y6nGbtIu4z2T1QcwBjUoQ45TAzKo21mmAA5wPjvgUQC/FK8 e36Z6BCrEiqtGefHKypdLCelBAb3dqU5eEtdzd9zfdudU+xWYyO1XODXiNngVErwXi0Z JGqT3gZbCf8a+AHBcdlCeY3D6XwbRloFQOhnbfrWTrZJ/Vxr9nrWRrjsvk6oQErPuCST 56eYrBwwq/WV2Qiu9txwUJssPEFBYtTLFUmRYE5Qo8EzJd2oaihMoIlgS7nj8hGsUfTW RGkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence: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=gDmFvrgRB/cW6jF2m7pVyc5SwYMa/ITwwRceOwWk2Ao=; b=icULGmzR88lLXHrhD2lXOu8rzJgOngmnbgqki0ON/2qWzLFn4JMjIFDfOijnSu6Z6k iltReieINMgJ3TBTNq0DBxG2tw2GKNIMtwNr42yHLhLN+N2jLRDMVCGVFeXlMgDwqZ3d 634q8iZKDqhPtDefSOMqS3O2AWM0PkgjJJBF1wUEHROLsaYnnnriX6aw09z0gxXcFjpT C8ju387bXVl+8CFKY19DatfQFkWZ4F2hXgwn05IOdF+ILe0fHTm9h5cIYB+/ri2FAHdh ytP++CrxU5vbNjSaq3e7eyChOVxR8+R9v49tIuOmyq+POcjYt83uCpF9sAtk6o3WeIEn LznQ== 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 k6si2505206edn.359.2021.04.15.07.27.43; Thu, 15 Apr 2021 07:28:06 -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 S233344AbhDOOZN (ORCPT + 99 others); Thu, 15 Apr 2021 10:25:13 -0400 Received: from mga17.intel.com ([192.55.52.151]:62920 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230056AbhDOOZK (ORCPT ); Thu, 15 Apr 2021 10:25:10 -0400 IronPort-SDR: TdxjJHzQITVLo5uBwxZtafqy8hTojAzqkFJBj9d1oxpcWrYRI7wj24QHYB98UhP1dYDVHHqiET rC0Yw6IT/V7Q== X-IronPort-AV: E=McAfee;i="6200,9189,9955"; a="174966822" X-IronPort-AV: E=Sophos;i="5.82,225,1613462400"; d="scan'208";a="174966822" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2021 07:24:47 -0700 IronPort-SDR: pKDKQflmVg1fjr500lbZygAhcwhvaDcQaREdvysUl4WeM6ChjHgiUhoUT4ljOeQBl2hJZ5fzGO VJ6yiDlb2oSg== X-IronPort-AV: E=Sophos;i="5.82,225,1613462400"; d="scan'208";a="452932231" Received: from allanagx-mobl.amr.corp.intel.com (HELO [10.213.172.37]) ([10.213.172.37]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2021 07:24:47 -0700 Subject: Re: [PATCH v1] ASoC: Intel: kbl_da7219_max98927: Fix kabylake_ssp_fixup function To: Lukasz Majczak , Mark Brown , Harsha Priya , Vamshi Krishna Gopal Cc: upstream@semihalf.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <20210415124347.475432-1-lma@semihalf.com> From: Pierre-Louis Bossart Message-ID: Date: Thu, 15 Apr 2021 09:24:45 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210415124347.475432-1-lma@semihalf.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/15/21 7:43 AM, Lukasz Majczak wrote: > 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 and > Vamshi Krishna Gopal > > Cc: # 5.4+ > Signed-off-by: Lukasz Majczak > --- > Hi, > This is basically a cherry-pick of this change: > https://patchwork.kernel.org/project/alsa-devel/patch/1595432147-11166-1-git-send-email-harshapriya.n@intel.com/ > just applied to the kbl_da7219_max98927. > Best regards, > Lukasz Acked-by: Pierre-Louis Bossart > > sound/soc/intel/boards/kbl_da7219_max98927.c | 38 +++++++++++++++----- > 1 file changed, 30 insertions(+), 8 deletions(-) > > diff --git a/sound/soc/intel/boards/kbl_da7219_max98927.c b/sound/soc/intel/boards/kbl_da7219_max98927.c > index 9dfe5bd9180d..4b7b4a044f81 100644 > --- a/sound/soc/intel/boards/kbl_da7219_max98927.c > +++ b/sound/soc/intel/boards/kbl_da7219_max98927.c > @@ -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; >