Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4643330pxj; Wed, 12 May 2021 09:55:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1jFQRA93cZTLBaQWBWcA57C8kEdVKzWA5Ng2NrzBmLJKsyIN2B5XsCAaFNjG0dHSuqjiE X-Received: by 2002:a50:eb94:: with SMTP id y20mr6416532edr.85.1620838521419; Wed, 12 May 2021 09:55:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620838521; cv=none; d=google.com; s=arc-20160816; b=NQUr08YlY627bZ/g6YdxQ0hqQNM49tMzPulwvjBHv42FUDn+8yysW6fxk6NRoP7zVs yyXK/fAexqxhJwQHZH7eTqrmg6KhxGHBa4XqVjmx8E4h0qqfIa+HLKN/02LRvJ3hcepN PdnWPXFEk4uwHhs//O+rEdEFIFmk60hE7A6DtBC/tApMBgUzVumqJyWV4dQxDcXLVmWu l4TLs1W09DJPaXScGSZ4LntuOitUkrcBHvdhLajBZk/rmv1qOKyCJmE0hfWsgMZCdgVY 5T/CAaM1iqdp86QsMFrUO4ePVzIfmU9Mex+aVxRv+AQCAbKqS41UlUxTYqW+poL1I4MI 3MfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=e/WL1MD0DsASvSiQQtOJLY7P0TL17G3bNfXu+l6fX7U=; b=xFuXwiqzzti6Lcbsi5o+u0he22kTtcHeXtyuc65UeowddxVLCdCWClLBn4bjQ3yDr/ F2770uHmKAplmkVDoQahWPeHMAOkm6clRg4d33Jyeg977bs4ngg+DowQk5mz21KpzxOt LBd1nB+UszBUZ2nJUZ0wOqOOJz5+TRADfiDaSgbQRmfa0yM5CUPUJ4c/VfsQuWM7BocM WdjQnJnqQzKcj4nSp4/usjjqBZFQf2LabFkXxnjvTI6SkIcO9l+sbaSQsCxIHQHOsP+i zS4ow7Ergi09nOqZzbEc4kukZtZbLCf3fLPM4BN1Fumkn4kGIuqGZHttTww9f/bG+1af exXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=J2p4r8bO; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n20si243240edr.379.2021.05.12.09.54.50; Wed, 12 May 2021 09:55:21 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=J2p4r8bO; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243179AbhELQuZ (ORCPT + 99 others); Wed, 12 May 2021 12:50:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:50380 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236466AbhELPtC (ORCPT ); Wed, 12 May 2021 11:49:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B96BD619C5; Wed, 12 May 2021 15:25:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620833113; bh=ArmF81P6mJStWlID/0NztaMf49BKkt5jRM1AxtrZkeQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J2p4r8bOeSNQt6NaSHkfsMrV963GEqIeUxwZ3q9MvXNGLgXC+yIFgaTP6e9/kOK7w gAHGtHbvAJy6qP7FZkA7+awMW02jmf7tJXxIVj8iqQZLAvRu2Vhml4sOoswKkZgx4O ayvHkN6v/+Z31qfUO4jCXBQ/7S/ewIvWIsEyjgpY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lukasz Majczak , Pierre-Louis Bossart , Mark Brown Subject: [PATCH 5.11 022/601] ASoC: Intel: kbl_da7219_max98927: Fix kabylake_ssp_fixup function Date: Wed, 12 May 2021 16:41:39 +0200 Message-Id: <20210512144828.552321471@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144827.811958675@linuxfoundation.org> References: <20210512144827.811958675@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lukasz Majczak commit a523ef731ac6674dc07574f31bf44cc5bfa14e4d upstream. 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 Acked-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20210415124347.475432-1-lma@semihalf.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- sound/soc/intel/boards/kbl_da7219_max98927.c | 38 +++++++++++++++++++++------ 1 file changed, 30 insertions(+), 8 deletions(-) --- a/sound/soc/intel/boards/kbl_da7219_max98927.c +++ b/sound/soc/intel/boards/kbl_da7219_max98927.c @@ -282,12 +282,34 @@ static int kabylake_ssp_fixup(struct snd 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. * Skipping the port wise FE and BE configuration for kblda7219m98373 & @@ -309,9 +331,9 @@ static int kabylake_ssp_fixup(struct snd /* * 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); @@ -322,7 +344,7 @@ static int kabylake_ssp_fixup(struct snd * 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;