From patchwork Wed Jul 10 16:04:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Handrigan X-Patchwork-Id: 13729457 Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6157194157 for ; Wed, 10 Jul 2024 16:04:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.152.168 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720627478; cv=none; b=er7LluvxizRCSSbDC4OTAsoYRwtU21O2PIcn5g+azo73LfjnjM66w9FaVBW4RsTdkO5zno+11BxdQroDzSZUfspO0dmidUZVpXzb6C+Ucih5pzA0sbnZTWj82A0/dVkC+cYEEkyCSd9MsI4z/C1I+90thC9Q+/qDYD47h093BFs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720627478; c=relaxed/simple; bh=Dr4qWcgxS5UGZeU6OEsLrDSgXgNDIl2UYde/vvMZiBs=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=D64X4c/lgjt5iHvEuF60SNRgHVmGGt6YvkK9RRX2yZ4RpnXRlppkQBTBE78peGFPInx1ZL2y/HXK+u9Kb3GKu/C+Y7Hs4hk65CF+Xy0GGCCScPoKHNiWXUxX6Zav6rTDtlL1sMUakVwy1TAyepUKC8q6wlwIiuOhuS3OjLpPzuI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com; spf=pass smtp.mailfrom=opensource.cirrus.com; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b=a3qHdpk3; arc=none smtp.client-ip=67.231.152.168 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="a3qHdpk3" Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46A4s4aG006601; Wed, 10 Jul 2024 11:04:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=cc :content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=PODMain02222019; bh=6b0A42aRW+THic22 yFT+hRNtlGiOXQ3HOeCFduWXqYU=; b=a3qHdpk3eVwqwDHXqKMJ7nttzH18QwkF dcnYs3xDjuBXBI+w2HTYjDnYpIKq5DDV7bLKuwPXQsq9X9PJyu+p3fDqvyhyhWUl FjOLcDo4V7fHI++O1hgDy7PsP1CtfJDCVSsQ3TNiymcDs8W0pFlQf3uxVNfQ4DhQ 8F42Kj6O3oA/IVbg2FxL7yQDLNMIhnhbN+ov+oLwj+Sd3AGqztCv3MwB8lKohoX0 F3brstvj1leZM6HFwPuwbPB9NBZVzOGhnQXors0iHAw0M9bnHYXKwc9rYJzcZU5M KR9gcUOPY/TNp4T2DNHKBsFPhOXFHWObKdnWumPoZQpgzvuku9KKtw== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 409c9a8vqb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Jul 2024 11:04:21 -0500 (CDT) Received: from ediex02.ad.cirrus.com (198.61.84.81) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Wed, 10 Jul 2024 17:04:19 +0100 Received: from ediswmail9.ad.cirrus.com (198.61.86.93) by anon-ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server id 15.2.1544.9 via Frontend Transport; Wed, 10 Jul 2024 17:04:19 +0100 Received: from paulha.crystal.cirrus.com (paulha.ad.cirrus.com [141.131.145.123]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id DDD0B820244; Wed, 10 Jul 2024 16:04:18 +0000 (UTC) From: Paul Handrigan To: , , CC: , Paul Handrigan Subject: [PATCH 1/2] ASoC: cs530x: Calculate proper bclk rate using TDM Date: Wed, 10 Jul 2024 11:04:15 -0500 Message-ID: <20240710160416.2617173-1-paulha@opensource.cirrus.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: SxDjhZAnfd4lBwUbORFZTJBv15XH8OXV X-Proofpoint-GUID: SxDjhZAnfd4lBwUbORFZTJBv15XH8OXV X-Proofpoint-Spam-Reason: safe Calculate the proper bclk rate using the number of tdm slots and the width of the tdm data. Fixes: 2884c29152c0 ("ASoC: cs530x: Support for cs530x ADCs") Signed-off-by: Paul Handrigan --- sound/soc/codecs/cs530x.c | 15 ++++++++++----- sound/soc/codecs/cs530x.h | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/sound/soc/codecs/cs530x.c b/sound/soc/codecs/cs530x.c index 036d0f45e3ba..195739657f4e 100644 --- a/sound/soc/codecs/cs530x.c +++ b/sound/soc/codecs/cs530x.c @@ -526,13 +526,15 @@ static int cs530x_hw_params(struct snd_pcm_substream *substream, regmap_update_bits(regmap, CS530X_CLK_CFG_1, CS530X_SAMPLE_RATE_MASK, fs_val); - if (cs530x->tdm_slots) { + + if (regmap_test_bits(regmap, CS530X_SIGNAL_PATH_CFG, + CS530X_TDM_EN_MASK)) { dev_dbg(component->dev, "Configuring for %d %d bit TDM slots\n", cs530x->tdm_slots, cs530x->tdm_width); - cs530x->bclk = snd_soc_calc_bclk(cs530x->fs, - cs530x->tdm_width, - params_channels(params), - cs530x->tdm_slots); + cs530x->bclk = snd_soc_tdm_params_to_bclk(params, + cs530x->tdm_width, + cs530x->tdm_slots, + 1); } else { cs530x->bclk = snd_soc_params_to_bclk(params); } @@ -655,6 +657,9 @@ static int cs530x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, return -EINVAL; } + cs530x->tdm_width = slot_width; + cs530x->tdm_slots = slots; + return regmap_update_bits(regmap, CS530X_SIGNAL_PATH_CFG, CS530X_ASP_TDM_SLOT_MASK, val << CS530X_ASP_TDM_SLOT_SHIFT); diff --git a/sound/soc/codecs/cs530x.h b/sound/soc/codecs/cs530x.h index 1c85310a5d03..1915a0efe829 100644 --- a/sound/soc/codecs/cs530x.h +++ b/sound/soc/codecs/cs530x.h @@ -96,6 +96,7 @@ #define CS530X_ASP_TDM_SLOT_MASK GENMASK(5, 3) #define CS530X_ASP_TDM_SLOT_SHIFT 3 #define CS530X_ASP_CH_REVERSE BIT(9) +#define CS530X_TDM_EN_MASK BIT(2) #define CS530X_ASP_FMT_I2S 0 #define CS530X_ASP_FMT_LJ 1 #define CS530X_ASP_FMT_DSP_A 0x6 From patchwork Wed Jul 10 16:04:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Handrigan X-Patchwork-Id: 13729458 Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E0477189F54 for ; Wed, 10 Jul 2024 16:04:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.152.168 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720627479; cv=none; b=QSiFdvVrKgEigWsHtal1nUI6NohqeRN8Lg7okl2C+cHBXgjwU9vHjHjfMF/RUDW5KXIycJXgX1YbDK3G9MpzaOAn597QpGMyRFtLnhcG01Sstt7N5Q6WxixWxOa8IF1/nSQCt6bw4U/y2DjiDIU5tKnvrCWi95Q1ZmcVRdYRdFk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720627479; c=relaxed/simple; bh=cUyP2tyMqUMckkhH7Osz5kbTD7djaxkuJUxSv5Aj3xw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mGcwIWZkd06JqLlkWhhguoGwWBzph8xGodNqR2N1DR78lI9bR+cFn7tLpBXPE/6LfMLT66g3Qi4kt8JGZZxaNgChRssM5bo19WmJ+k6csW29+tb3WF0zYaKaY2z1kjib4w20SS5o8zPLd2/AfYYoGxiO83lEpFNpdMvN8+mY+lQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com; spf=pass smtp.mailfrom=opensource.cirrus.com; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b=DTaYaVoD; arc=none smtp.client-ip=67.231.152.168 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="DTaYaVoD" Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46A4s4aH006601; Wed, 10 Jul 2024 11:04:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= PODMain02222019; bh=AZFe4vyOQNZSLgTUhWu4DO2tdekGbHxeclUS50no9Ac=; b= DTaYaVoDbGXswIgRPsn1oNxrDaFp5ICHhyPj33z17+vlejcm7r1ehPsqocJ6y5o4 WiGYhofG0dwERQjEs3XmV84VCNwrSHrLkp9SEwUpo/ejUBLNNxgWP5i/YKrcYxch lZwdraHY/Xw6Nj3/b/4C3ErUBpPu6EOrpmgnn8eIo5UBVA7/IUVqggZFc2hSoePF yf5Sp4xiaHDGJpKZzIM+LUISjlXA9F4R+vo02kPdS+XGgYZpPcIlQj1LzVO5uyvf DTXIeW2dkqoDkZu7KrZTvdcLMMf15fjmcRTwPz3bGVcbLg4QJEp9RfZ1ZHJdqmGa uQX45gUmLpS0OIHvbFQrGg== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 409c9a8vqb-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Jul 2024 11:04:22 -0500 (CDT) Received: from ediex01.ad.cirrus.com (198.61.84.80) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Wed, 10 Jul 2024 17:04:20 +0100 Received: from ediswmail9.ad.cirrus.com (198.61.86.93) by anon-ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.2.1544.9 via Frontend Transport; Wed, 10 Jul 2024 17:04:20 +0100 Received: from paulha.crystal.cirrus.com (paulha.ad.cirrus.com [141.131.145.123]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id F225982024D; Wed, 10 Jul 2024 16:04:19 +0000 (UTC) From: Paul Handrigan To: , , CC: , Paul Handrigan Subject: [PATCH 2/2] ASoC: cs530x: Remove bclk from private structure Date: Wed, 10 Jul 2024 11:04:16 -0500 Message-ID: <20240710160416.2617173-2-paulha@opensource.cirrus.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240710160416.2617173-1-paulha@opensource.cirrus.com> References: <20240710160416.2617173-1-paulha@opensource.cirrus.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: cQirYyR4uMMX45Y3ZXYO6ldvsFfJby20 X-Proofpoint-GUID: cQirYyR4uMMX45Y3ZXYO6ldvsFfJby20 X-Proofpoint-Spam-Reason: safe Remove the bclk int from the private structure and pass it into the set_bclk function. Signed-off-by: Paul Handrigan --- sound/soc/codecs/cs530x.c | 24 ++++++++++++------------ sound/soc/codecs/cs530x.h | 1 - 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/sound/soc/codecs/cs530x.c b/sound/soc/codecs/cs530x.c index 195739657f4e..25a86a32e936 100644 --- a/sound/soc/codecs/cs530x.c +++ b/sound/soc/codecs/cs530x.c @@ -415,13 +415,13 @@ static void cs530x_add_34_adc_widgets(struct snd_soc_component *component) ARRAY_SIZE(adc_ch3_4_routes)); } -static int cs530x_set_bclk(struct snd_soc_component *component) +static int cs530x_set_bclk(struct snd_soc_component *component, const int freq) { struct cs530x_priv *cs530x = snd_soc_component_get_drvdata(component); struct regmap *regmap = cs530x->regmap; unsigned int bclk_val; - switch (cs530x->bclk) { + switch (freq) { case 2822400: case 3072000: bclk_val = CS530X_BCLK_2P822_3P072; @@ -439,11 +439,11 @@ static int cs530x_set_bclk(struct snd_soc_component *component) bclk_val = CS530X_BCLK_24P5792_24P576; break; default: - dev_err(component->dev, "Invalid BCLK %d\n", cs530x->bclk); + dev_err(component->dev, "Invalid BCLK frequency %d\n", freq); return -EINVAL; } - dev_dbg(component->dev, "BCLK is %d\n", cs530x->bclk); + dev_dbg(component->dev, "BCLK frequency is %d\n", freq); return regmap_update_bits(regmap, CS530X_ASP_CFG, CS530X_ASP_BCLK_FREQ_MASK, bclk_val); @@ -489,7 +489,7 @@ static int cs530x_hw_params(struct snd_pcm_substream *substream, struct snd_soc_component *component = dai->component; struct cs530x_priv *cs530x = snd_soc_component_get_drvdata(component); struct regmap *regmap = cs530x->regmap; - int ret = 0, fs = params_rate(params); + int ret = 0, fs = params_rate(params), bclk; unsigned int fs_val; @@ -531,22 +531,22 @@ static int cs530x_hw_params(struct snd_pcm_substream *substream, CS530X_TDM_EN_MASK)) { dev_dbg(component->dev, "Configuring for %d %d bit TDM slots\n", cs530x->tdm_slots, cs530x->tdm_width); - cs530x->bclk = snd_soc_tdm_params_to_bclk(params, - cs530x->tdm_width, - cs530x->tdm_slots, - 1); + bclk = snd_soc_tdm_params_to_bclk(params, + cs530x->tdm_width, + cs530x->tdm_slots, + 1); } else { - cs530x->bclk = snd_soc_params_to_bclk(params); + bclk = snd_soc_params_to_bclk(params); } if (!regmap_test_bits(regmap, CS530X_CLK_CFG_0, CS530X_PLL_REFCLK_SRC_MASK)) { - ret = cs530x_set_pll_refclk(component, cs530x->bclk); + ret = cs530x_set_pll_refclk(component, bclk); if (ret) return ret; } - return cs530x_set_bclk(component); + return cs530x_set_bclk(component, bclk); } static int cs530x_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) diff --git a/sound/soc/codecs/cs530x.h b/sound/soc/codecs/cs530x.h index 1915a0efe829..f473e33eb835 100644 --- a/sound/soc/codecs/cs530x.h +++ b/sound/soc/codecs/cs530x.h @@ -211,7 +211,6 @@ struct cs530x_priv { int tdm_width; int tdm_slots; - int bclk; int fs; int adc_pairs_count;