Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1373814ybh; Thu, 16 Jul 2020 10:16:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycR3yMy5l+uVBH3brXlw+kHb2OYvjqi3bia/fS28Yb7saCMKP5ifuoH986TfFYInGEJDzH X-Received: by 2002:a17:906:53d4:: with SMTP id p20mr4649905ejo.472.1594919812194; Thu, 16 Jul 2020 10:16:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594919812; cv=none; d=google.com; s=arc-20160816; b=jA2awDbkt7ku/QxWcbo0jIKIZofcfvTSwK7talGT+AOLjllj39oBC5D4KeYFtF1Ukn 8waWwktSSRvurDhvH4FJTP9FvwRpBIrO3PAWhdc2S8jXqkuXefY7KUL3idehWiTTi0ST jcodPwvWtUWfShEq5+eXDFiyABI0RBdry+KdlSXa30ALoeEflBs6RBWYu/cKl0bIpF7a tO0vNQnlSnIo/UogXLpjlb5my1VOU3D09VZMooQaKKVNgwMj2gEam3XttTmnGFEuzc8f 3E7Ct9Ty26XElulcUZZhkGBVa1HvTKhHDsAy6IqWAOZhPNBfdY3d9n+lHoyFGM00f90G RU9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=1JbbIWGmGv/tgsyNk3Om/Qs5JvzhITK4MKXN7A4g5Ek=; b=XDDNX9ZqIEFUoGmwV0usOcI7jlQcVgypEOOiStWefHj1HbF+OsSdygDofiZGNX4RMw b0JEl0HkCcVhIHXQzgBWtXlEld7fCvO6JL0IpY55QFLNFC2BblPamYAWdaj9rc0vRQFG L5trgZ1IjTyRBAGwTisLKb068hkA2HW0D4sgsddE81yDOR8ZuhtLOhWLuigpOJbtfdBH PDj55nqdytBgZYKIQjTtD6JBBcZtFM4hwl9tuVi2cs5uS+SViOlTF//A5GXRl8waVRb5 eEie7q9JM61wF7TbsejuLh8rkF2MNCltHUCw1YJMrIHsQjDe7S/1cNpbx7X4kY3nLHnH SKRw== 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 m26si4395826ejn.40.2020.07.16.10.16.27; Thu, 16 Jul 2020 10:16:52 -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 S1728707AbgGPROI (ORCPT + 99 others); Thu, 16 Jul 2020 13:14:08 -0400 Received: from mga18.intel.com ([134.134.136.126]:3242 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728237AbgGPROI (ORCPT ); Thu, 16 Jul 2020 13:14:08 -0400 IronPort-SDR: V7I+Fu9P0xR6n8pnXJ7lmTTRCZHOX/MV7eEMu8i9R6iGjBZajrzku09Scyl/nIm+k7BtxHds8D dq/HQ552JHEw== X-IronPort-AV: E=McAfee;i="6000,8403,9684"; a="136896015" X-IronPort-AV: E=Sophos;i="5.75,360,1589266800"; d="scan'208";a="136896015" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jul 2020 10:14:07 -0700 IronPort-SDR: 6R0t2Qz3xSDnnYjKm0gNGfTjzRigT680d016xG8ijHFG4kqpS3pVSpC4YV+DWV4U1Pt2CT/GuN Ad4BlzF4EQGA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,360,1589266800"; d="scan'208";a="308707428" Received: from joycetoh-desk.sc.intel.com ([172.25.206.187]) by fmsmga004.fm.intel.com with ESMTP; 16 Jul 2020 10:14:06 -0700 From: Harsha Priya To: alsa-devel@alsa-project.org, broonie@kernel.org, pierre-louis.bossart@linux.intel.com Cc: lma@semihalf.com, yang.jie@linux.intel.com, liam.r.girdwood@linux.intel.com, rad@semihalf.com, zwisler@google.com, linux-kernel@vger.kernel.org, sathya.prakash.m.r@intel.com, brndt@google.com, mw@semihalf.com, levinale@chromium.org, Vamshi Krishna Gopal , Harsha Priya Subject: [PATCH v6] ASoC: Intel: kbl_rt5663_rt5514_max98927: Fix kabylake_ssp_fixup function Date: Thu, 16 Jul 2020 10:13:57 -0700 Message-Id: <1594919637-31460-1-git-send-email-harshapriya.n@intel.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vamshi Krishna Gopal kabylake_ssp_fixup function uses snd_soc_dpcm to identify the codecs DAIs. The hw parameters are changed based on the codec DAI, the stream is intended for. 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. The snd_soc_pcm_runtime holds 2 dpcm instances (one for playback and one for capture). The 2 codecs on this SSP are dmic and speakers. One is for capture and one is for playback respectively. Based on the direction of the stream, the snd_soc_dpcm is extracted from the snd_soc_pcm_runtime structure. Tested for all use cases of the driver. Signed-off-by: Harsha Priya Signed-off-by: Vamshi Krishna Gopal Tested-by: Lukasz Majczak --- 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 v4 -> v5: - Cosmetic Changes v5 -> v6: - Dmic regression seen with v4 fixed - Using available routines for obtaining dpcm information --- --- .../intel/boards/kbl_rt5663_rt5514_max98927.c | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c index 584e4f9cedc2..b261b1c466a8 100644 --- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c +++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c @@ -379,22 +379,30 @@ 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; + + /* + * This macro will be called for playback stream + */ + for_each_dpcm_fe(rtd, SNDRV_PCM_STREAM_PLAYBACK, dpcm) + rtd_dpcm = dpcm; + /* + * This macro will be called for capture stream + */ + for_each_dpcm_fe(rtd, SNDRV_PCM_STREAM_CAPTURE, dpcm) + rtd_dpcm = dpcm; /* * 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); snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE); - } else if (!strcmp(fe_dai_link->name, "Kbl Audio DMIC cap")) { + } else if (!strcmp(rtd_dpcm->fe->dai_link->name, "Kbl Audio DMIC cap")) { if (params_channels(params) == 2 || DMIC_CH(dmic_constraints) == 2) chan->min = chan->max = 2; @@ -405,7 +413,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; -- 2.17.1