[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250215-apple-codec-changes-v1-13-723569b21b19@gmail.com>
Date: Sat, 15 Feb 2025 10:02:46 +1000
From: James Calligeros <jcalligeros99@...il.com>
To: Liam Girdwood <lgirdwood@...il.com>, Mark Brown <broonie@...nel.org>,
Jaroslav Kysela <perex@...ex.cz>, Takashi Iwai <tiwai@...e.com>,
Shenghao Ding <shenghao-ding@...com>, Kevin Lu <kevin-lu@...com>,
Baojun Xu <baojun.xu@...com>, Dan Murphy <dmurphy@...com>,
Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>, Shi Fu <shifu0704@...ndersoft.com>
Cc: Alyssa Rosenzweig <alyssa@...enzweig.io>,
Martin Povišer <povik+lin@...ebit.org>,
Hector Martin <marcan@...can.st>, linux-sound@...r.kernel.org,
linux-kernel@...r.kernel.org, devicetree@...r.kernel.org,
asahi@...ts.linux.dev, James Calligeros <jcalligeros99@...il.com>
Subject: [PATCH 13/27] ASoC: tas2764: Crop SDOUT zero-out mask based on
BCLK ratio
From: Martin Povišer <povik+lin@...ebit.org>
Signed-off-by: Martin Povišer <povik+lin@...ebit.org>
Signed-off-by: James Calligeros <jcalligeros99@...il.com>
---
sound/soc/codecs/tas2764.c | 56 +++++++++++++++++--------
1 file changed, 39 insertions(+), 17 deletions(-)
diff --git a/sound/soc/codecs/tas2764.c b/sound/soc/codecs/tas2764.c
index 25238d3721a21d5af8434490acfdb7ba53de9ce0..439e5bbd372cd467966ac9cac1c92e3e300fed54 100644
--- a/sound/soc/codecs/tas2764.c
+++ b/sound/soc/codecs/tas2764.c
@@ -375,6 +375,44 @@ static int tas2764_hw_params(struct snd_pcm_substream *substream,
return tas2764_set_samplerate(tas2764, params_rate(params));
}
+static int tas2764_write_sdout_zero_mask(struct tas2764_priv *tas2764, int bclk_ratio)
+{
+ struct snd_soc_component *component = tas2764->component;
+ int nsense_slots = bclk_ratio / 8;
+ u32 cropped_mask;
+ int i, ret;
+
+ if (!tas2764->sdout_zero_mask)
+ return 0;
+
+ cropped_mask = tas2764->sdout_zero_mask & GENMASK(nsense_slots - 1, 0);
+
+ for (i = 0; i < 4; i++) {
+ ret = snd_soc_component_write(component, TAS2764_SDOUT_HIZ_1 + i,
+ (cropped_mask >> (i * 8)) & 0xff);
+
+ if (ret < 0)
+ return ret;
+ }
+
+ ret = snd_soc_component_update_bits(component, TAS2764_SDOUT_HIZ_9,
+ TAS2764_SDOUT_HIZ_9_FORCE_0_EN,
+ TAS2764_SDOUT_HIZ_9_FORCE_0_EN);
+
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+static int tas2764_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio)
+{
+ struct snd_soc_component *component = dai->component;
+ struct tas2764_priv *tas2764 = snd_soc_component_get_drvdata(component);
+
+ return tas2764_write_sdout_zero_mask(tas2764, ratio);
+}
+
static int tas2764_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{
struct snd_soc_component *component = dai->component;
@@ -506,6 +544,7 @@ static int tas2764_set_dai_tdm_slot(struct snd_soc_dai *dai,
static const struct snd_soc_dai_ops tas2764_dai_ops = {
.mute_stream = tas2764_mute,
.hw_params = tas2764_hw_params,
+ .set_bclk_ratio = tas2764_set_bclk_ratio,
.set_fmt = tas2764_set_fmt,
.set_tdm_slot = tas2764_set_dai_tdm_slot,
.no_capture_mute = 1,
@@ -658,23 +697,6 @@ static int tas2764_codec_probe(struct snd_soc_component *component)
if (ret < 0)
return ret;
- if (tas2764->sdout_zero_mask) {
- for (i = 0; i < 4; i++) {
- ret = snd_soc_component_write(component, TAS2764_SDOUT_HIZ_1 + i,
- (tas2764->sdout_zero_mask >> (i * 8)) & 0xff);
-
- if (ret < 0)
- return ret;
- }
-
- ret = snd_soc_component_update_bits(component, TAS2764_SDOUT_HIZ_9,
- TAS2764_SDOUT_HIZ_9_FORCE_0_EN,
- TAS2764_SDOUT_HIZ_9_FORCE_0_EN);
-
- if (ret < 0)
- return ret;
- }
-
if (tas2764->devid == DEVID_SN012776) {
ret = snd_soc_component_update_bits(component, TAS2764_PWR_CTRL,
TAS2764_PWR_CTRL_BOP_SRC,
--
2.48.1
Powered by blists - more mailing lists