* [PATCH RFC 0/6] Speakers for Pixel 3 / 3 XL
@ 2026-07-05 20:06 David Heidelberg via B4 Relay
2026-07-05 20:06 ` [PATCH RFC 1/6] ASoC: qcom: sdm845: Demystify TDM masks a bit David Heidelberg via B4 Relay
` (5 more replies)
0 siblings, 6 replies; 22+ messages in thread
From: David Heidelberg via B4 Relay @ 2026-07-05 20:06 UTC (permalink / raw)
To: Srinivas Kandagatla, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, David Rhodes, Richard Fitzgerald, Bjorn Andersson,
Konrad Dybcio, Rob Herring, Krzysztof Kozlowski, David Rhodes,
Conor Dooley
Cc: linux-sound, linux-arm-msm, linux-kernel, patches, devicetree,
phone-devel, David Heidelberg
This series address:
0. demistify the hex to BIT() macro and add left/right rx spk
1. most likely wrongly set DSP_B in sdm845.c
my guess this is because TDM was never used in the mainline with
sdm845
2. applying correct mask to left/right speaker for the TDM in sdm845.c,
so both speakers can work simultaneusly
3. setting sysclk at startups, which some codecs need (such as cs35l36)
4. setting proper tdm slot in the cs35l36 driver
5. device-tree wiring for Pixel 3 / 3 XL
Consider my knowledge here limited, thus sending RFC. Some parts we're
heavily assisted by LLM - I believe I understand what I'm doing, but
my knowledge within audio realm is limited.
David
Signed-off-by: David Heidelberg <david@ixit.cz>
---
David Heidelberg (6):
ASoC: qcom: sdm845: Demystify TDM masks a bit
ASoC: qcom: sdm845: use DSP_A format for TDM codec DAIs
ASoC: qcom: sdm845: Use per-speaker RX masks for TDM slot assignment
ASoC: qcom: sdm845: Set codec dai and component sysclk during startup
ASoC: cs35l36: Implement set_tdm_slot to program RX slot register
arm64: dts: qcom: sdm845-google: Add basic audio support
arch/arm64/boot/dts/qcom/sdm845-google-common.dtsi | 133 ++++++++++++++++++++-
sound/soc/codecs/cs35l36.c | 16 +++
sound/soc/qcom/sdm845.c | 46 +++++--
3 files changed, 183 insertions(+), 12 deletions(-)
---
base-commit: 2b763db0c2763d6bf73d7d3e69665222d1f377cf
change-id: 20260613-pixel3-audio-bdbfb49e8037
Best regards,
--
David Heidelberg <david@ixit.cz>
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH RFC 1/6] ASoC: qcom: sdm845: Demystify TDM masks a bit
2026-07-05 20:06 [PATCH RFC 0/6] Speakers for Pixel 3 / 3 XL David Heidelberg via B4 Relay
@ 2026-07-05 20:06 ` David Heidelberg via B4 Relay
2026-07-05 20:19 ` sashiko-bot
2026-07-05 20:06 ` [PATCH RFC 2/6] ASoC: qcom: sdm845: use DSP_A format for TDM codec DAIs David Heidelberg via B4 Relay
` (4 subsequent siblings)
5 siblings, 1 reply; 22+ messages in thread
From: David Heidelberg via B4 Relay @ 2026-07-05 20:06 UTC (permalink / raw)
To: Srinivas Kandagatla, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, David Rhodes, Richard Fitzgerald, Bjorn Andersson,
Konrad Dybcio, Rob Herring, Krzysztof Kozlowski, David Rhodes,
Conor Dooley
Cc: linux-sound, linux-arm-msm, linux-kernel, patches, devicetree,
phone-devel, David Heidelberg
From: David Heidelberg <david@ixit.cz>
Describe the mask with the bits used for each RX/TX.
Signed-off-by: David Heidelberg <david@ixit.cz>
---
sound/soc/qcom/sdm845.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c
index 0ce9dff4dc525..edd2cc7a1c74f 100644
--- a/sound/soc/qcom/sdm845.c
+++ b/sound/soc/qcom/sdm845.c
@@ -18,19 +18,21 @@
#include "sdw.h"
#include "../codecs/rt5663.h"
#define DRIVER_NAME "sdm845"
#define DEFAULT_SAMPLE_RATE_48K 48000
#define DEFAULT_MCLK_RATE 24576000
#define TDM_BCLK_RATE 6144000
#define MI2S_BCLK_RATE 1536000
-#define LEFT_SPK_TDM_TX_MASK 0x30
-#define RIGHT_SPK_TDM_TX_MASK 0xC0
-#define SPK_TDM_RX_MASK 0x03
+#define LEFT_SPK_TDM_RX_MASK BIT(0)
+#define RIGHT_SPK_TDM_RX_MASK BIT(1)
+#define SPK_TDM_RX_MASK (LEFT_SPK_TDM_RX_MASK | RIGHT_SPK_TDM_RX_MASK)
+#define LEFT_SPK_TDM_TX_MASK (BIT(4) | BIT(5))
+#define RIGHT_SPK_TDM_TX_MASK (BIT(6) | BIT(7))
#define NUM_TDM_SLOTS 8
#define SLIM_MAX_TX_PORTS 16
#define SLIM_MAX_RX_PORTS 13
#define WCD934X_DEFAULT_MCLK_RATE 9600000
struct sdm845_snd_data {
struct snd_soc_jack jack;
bool jack_setup;
@@ -108,34 +110,36 @@ static int sdm845_tdm_snd_hw_params(struct snd_pcm_substream *substream,
default:
dev_err(rtd->dev, "%s: invalid param format 0x%x\n",
__func__, params_format(params));
return -EINVAL;
}
channels = params_channels(params);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
- ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, 0x3,
- 8, slot_width);
+ ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, SPK_TDM_RX_MASK,
+ NUM_TDM_SLOTS, slot_width);
if (ret < 0) {
dev_err(rtd->dev, "%s: failed to set tdm slot, err:%d\n",
__func__, ret);
goto end;
}
ret = snd_soc_dai_set_channel_map(cpu_dai, 0, NULL,
channels, tdm_slot_offset);
if (ret < 0) {
dev_err(rtd->dev, "%s: failed to set channel map, err:%d\n",
__func__, ret);
goto end;
}
} else {
- ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0xf, 0,
- 8, slot_width);
+ ret = snd_soc_dai_set_tdm_slot(cpu_dai,
+ SPK_TDM_RX_MASK | BIT(2) |
+ BIT(3), 0,
+ NUM_TDM_SLOTS, slot_width);
if (ret < 0) {
dev_err(rtd->dev, "%s: failed to set tdm slot, err:%d\n",
__func__, ret);
goto end;
}
ret = snd_soc_dai_set_channel_map(cpu_dai, channels,
tdm_slot_offset, 0, NULL);
--
2.53.0
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH RFC 2/6] ASoC: qcom: sdm845: use DSP_A format for TDM codec DAIs
2026-07-05 20:06 [PATCH RFC 0/6] Speakers for Pixel 3 / 3 XL David Heidelberg via B4 Relay
2026-07-05 20:06 ` [PATCH RFC 1/6] ASoC: qcom: sdm845: Demystify TDM masks a bit David Heidelberg via B4 Relay
@ 2026-07-05 20:06 ` David Heidelberg via B4 Relay
2026-07-05 20:18 ` sashiko-bot
2026-07-06 8:33 ` Konrad Dybcio
2026-07-05 20:06 ` [PATCH RFC 3/6] ASoC: qcom: sdm845: Use per-speaker RX masks for TDM slot assignment David Heidelberg via B4 Relay
` (3 subsequent siblings)
5 siblings, 2 replies; 22+ messages in thread
From: David Heidelberg via B4 Relay @ 2026-07-05 20:06 UTC (permalink / raw)
To: Srinivas Kandagatla, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, David Rhodes, Richard Fitzgerald, Bjorn Andersson,
Konrad Dybcio, Rob Herring, Krzysztof Kozlowski, David Rhodes,
Conor Dooley
Cc: linux-sound, linux-arm-msm, linux-kernel, patches, devicetree,
phone-devel, David Heidelberg
From: David Heidelberg <david@ixit.cz>
Before the DSP_B only worked because the only close-to-mainline consumer
cs35l36 codec was patched to map both DSP_A and DSP_B to the same
hardware register value (asp_fmt = 0), which is inherently DSP_A timing.
Use the right codec (DSP_A) which works as expected.
Signed-off-by: David Heidelberg <david@ixit.cz>
---
sound/soc/qcom/sdm845.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c
index edd2cc7a1c74f..9de3282bda4be 100644
--- a/sound/soc/qcom/sdm845.c
+++ b/sound/soc/qcom/sdm845.c
@@ -380,17 +380,17 @@ static int sdm845_snd_startup(struct snd_pcm_substream *substream)
case QUATERNARY_TDM_RX_0:
case QUATERNARY_TDM_TX_0:
if (++(data->quat_tdm_clk_count) == 1) {
snd_soc_dai_set_sysclk(cpu_dai,
Q6AFE_LPASS_CLK_ID_QUAD_TDM_IBIT,
TDM_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK);
}
- codec_dai_fmt |= SND_SOC_DAIFMT_IB_NF | SND_SOC_DAIFMT_DSP_B;
+ codec_dai_fmt |= SND_SOC_DAIFMT_IB_NF | SND_SOC_DAIFMT_DSP_A;
for_each_rtd_codec_dais(rtd, j, codec_dai) {
if (!strcmp(codec_dai->component->name_prefix,
"Left")) {
ret = snd_soc_dai_set_fmt(
codec_dai, codec_dai_fmt);
if (ret < 0) {
--
2.53.0
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH RFC 3/6] ASoC: qcom: sdm845: Use per-speaker RX masks for TDM slot assignment
2026-07-05 20:06 [PATCH RFC 0/6] Speakers for Pixel 3 / 3 XL David Heidelberg via B4 Relay
2026-07-05 20:06 ` [PATCH RFC 1/6] ASoC: qcom: sdm845: Demystify TDM masks a bit David Heidelberg via B4 Relay
2026-07-05 20:06 ` [PATCH RFC 2/6] ASoC: qcom: sdm845: use DSP_A format for TDM codec DAIs David Heidelberg via B4 Relay
@ 2026-07-05 20:06 ` David Heidelberg via B4 Relay
2026-07-05 20:25 ` sashiko-bot
2026-07-05 20:06 ` [PATCH RFC 4/6] ASoC: qcom: sdm845: Set codec dai and component sysclk during startup David Heidelberg via B4 Relay
` (2 subsequent siblings)
5 siblings, 1 reply; 22+ messages in thread
From: David Heidelberg via B4 Relay @ 2026-07-05 20:06 UTC (permalink / raw)
To: Srinivas Kandagatla, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, David Rhodes, Richard Fitzgerald, Bjorn Andersson,
Konrad Dybcio, Rob Herring, Krzysztof Kozlowski, David Rhodes,
Conor Dooley
Cc: linux-sound, linux-arm-msm, linux-kernel, patches, devicetree,
phone-devel, David Heidelberg
From: David Heidelberg <david@ixit.cz>
Both Left and Right codec DAIs were passing the same SPK_TDM_RX_MASK,
both speakers ended up on slot 0, breaking the one speaker in
configuration such as on Pixel 3.
Split SPK_TDM_RX_MASK into per-speaker masks so that the Left codec
gets slot 0 (rx_mask=0x01) and the Right codec gets slot 1
(rx_mask=0x02).
This commit is here, so later CS35L36 receives correct slot for right
and left speakers.
Assisted-by: Claude:claude-4.6-opus
Signed-off-by: David Heidelberg <david@ixit.cz>
---
sound/soc/qcom/sdm845.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c
index 9de3282bda4be..8b65aa3982d47 100644
--- a/sound/soc/qcom/sdm845.c
+++ b/sound/soc/qcom/sdm845.c
@@ -150,29 +150,29 @@ static int sdm845_tdm_snd_hw_params(struct snd_pcm_substream *substream,
}
}
for_each_rtd_codec_dais(rtd, j, codec_dai) {
if (!strcmp(codec_dai->component->name_prefix, "Left")) {
ret = snd_soc_dai_set_tdm_slot(
codec_dai, LEFT_SPK_TDM_TX_MASK,
- SPK_TDM_RX_MASK, NUM_TDM_SLOTS,
+ LEFT_SPK_TDM_RX_MASK, NUM_TDM_SLOTS,
slot_width);
if (ret < 0) {
dev_err(rtd->dev,
"DEV0 TDM slot err:%d\n", ret);
return ret;
}
}
if (!strcmp(codec_dai->component->name_prefix, "Right")) {
ret = snd_soc_dai_set_tdm_slot(
codec_dai, RIGHT_SPK_TDM_TX_MASK,
- SPK_TDM_RX_MASK, NUM_TDM_SLOTS,
+ RIGHT_SPK_TDM_RX_MASK, NUM_TDM_SLOTS,
slot_width);
if (ret < 0) {
dev_err(rtd->dev,
"DEV1 TDM slot err:%d\n", ret);
return ret;
}
}
}
--
2.53.0
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH RFC 4/6] ASoC: qcom: sdm845: Set codec dai and component sysclk during startup
2026-07-05 20:06 [PATCH RFC 0/6] Speakers for Pixel 3 / 3 XL David Heidelberg via B4 Relay
` (2 preceding siblings ...)
2026-07-05 20:06 ` [PATCH RFC 3/6] ASoC: qcom: sdm845: Use per-speaker RX masks for TDM slot assignment David Heidelberg via B4 Relay
@ 2026-07-05 20:06 ` David Heidelberg via B4 Relay
2026-07-05 20:19 ` sashiko-bot
2026-07-05 20:06 ` [PATCH RFC 5/6] ASoC: cs35l36: Implement set_tdm_slot to program RX slot register David Heidelberg via B4 Relay
2026-07-05 20:06 ` [PATCH RFC 6/6] arm64: dts: qcom: sdm845-google: Add basic audio support David Heidelberg via B4 Relay
5 siblings, 1 reply; 22+ messages in thread
From: David Heidelberg via B4 Relay @ 2026-07-05 20:06 UTC (permalink / raw)
To: Srinivas Kandagatla, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, David Rhodes, Richard Fitzgerald, Bjorn Andersson,
Konrad Dybcio, Rob Herring, Krzysztof Kozlowski, David Rhodes,
Conor Dooley
Cc: linux-sound, linux-arm-msm, linux-kernel, patches, devicetree,
phone-devel, David Heidelberg
From: David Heidelberg <david@ixit.cz>
The cs35l36 codec needs the codec dai and component sysclk to be set
during TDM startup. Set these for all codec DAIs on the QUATERNARY_TDM
path, gracefully handling codecs that don't support sysclk by ignoring
-ENOTSUPP returns.
Based on work of Joel Selvaraj.
Signed-off-by: David Heidelberg <david@ixit.cz>
---
sound/soc/qcom/sdm845.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c
index 8b65aa3982d47..b2d51e472bc26 100644
--- a/sound/soc/qcom/sdm845.c
+++ b/sound/soc/qcom/sdm845.c
@@ -405,16 +405,38 @@ static int sdm845_snd_startup(struct snd_pcm_substream *substream)
ret = snd_soc_dai_set_fmt(
codec_dai, codec_dai_fmt);
if (ret < 0) {
dev_err(rtd->dev,
"Right TDM slot err:%d\n", ret);
return ret;
}
}
+
+ /* Set codec sysclk needed by codecs like cs35l36. */
+ ret = snd_soc_dai_set_sysclk(codec_dai, 0,
+ TDM_BCLK_RATE,
+ SND_SOC_CLOCK_IN);
+ if (ret < 0 && ret != -ENOTSUPP) {
+ dev_err(codec_dai->dev,
+ "Failed to set codec dai sysclk: %d\n",
+ ret);
+ return ret;
+ }
+
+ ret = snd_soc_component_set_sysclk(codec_dai->component,
+ 0, 0,
+ TDM_BCLK_RATE,
+ SND_SOC_CLOCK_IN);
+ if (ret < 0 && ret != -ENOTSUPP) {
+ dev_err(codec_dai->dev,
+ "Failed to set codec component sysclk: %d\n",
+ ret);
+ return ret;
+ }
}
break;
case SLIMBUS_0_RX...SLIMBUS_6_TX:
break;
default:
pr_err("%s: invalid dai id 0x%x\n", __func__, cpu_dai->id);
break;
--
2.53.0
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH RFC 5/6] ASoC: cs35l36: Implement set_tdm_slot to program RX slot register
2026-07-05 20:06 [PATCH RFC 0/6] Speakers for Pixel 3 / 3 XL David Heidelberg via B4 Relay
` (3 preceding siblings ...)
2026-07-05 20:06 ` [PATCH RFC 4/6] ASoC: qcom: sdm845: Set codec dai and component sysclk during startup David Heidelberg via B4 Relay
@ 2026-07-05 20:06 ` David Heidelberg via B4 Relay
2026-07-05 20:20 ` sashiko-bot
` (2 more replies)
2026-07-05 20:06 ` [PATCH RFC 6/6] arm64: dts: qcom: sdm845-google: Add basic audio support David Heidelberg via B4 Relay
5 siblings, 3 replies; 22+ messages in thread
From: David Heidelberg via B4 Relay @ 2026-07-05 20:06 UTC (permalink / raw)
To: Srinivas Kandagatla, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, David Rhodes, Richard Fitzgerald, Bjorn Andersson,
Konrad Dybcio, Rob Herring, Krzysztof Kozlowski, David Rhodes,
Conor Dooley
Cc: linux-sound, linux-arm-msm, linux-kernel, patches, devicetree,
phone-devel, David Heidelberg
From: David Heidelberg <david@ixit.cz>
Program ASP_RX1_SLOT with the first set bit of rx_mask so the
amplifier listens on the correct TDM slot when configured by
machine drivers.
Assisted-by: Claude:claude-4.6-opus
Signed-off-by: David Heidelberg <david@ixit.cz>
---
sound/soc/codecs/cs35l36.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/sound/soc/codecs/cs35l36.c b/sound/soc/codecs/cs35l36.c
index 89645327945f1..944f4cb5763e4 100644
--- a/sound/soc/codecs/cs35l36.c
+++ b/sound/soc/codecs/cs35l36.c
@@ -942,20 +942,36 @@ static const struct cs35l36_pll_config *cs35l36_get_clk_config(
for (i = 0; i < ARRAY_SIZE(cs35l36_pll_sysclk); i++) {
if (cs35l36_pll_sysclk[i].freq == freq)
return &cs35l36_pll_sysclk[i];
}
return NULL;
}
+static int cs35l36_set_tdm_slot(struct snd_soc_dai *dai,
+ unsigned int tx_mask, unsigned int rx_mask,
+ int slots, int slot_width)
+{
+ struct cs35l36_private *cs35l36 =
+ snd_soc_component_get_drvdata(dai->component);
+
+ if (rx_mask)
+ regmap_update_bits(cs35l36->regmap, CS35L36_ASP_RX1_SLOT,
+ CS35L36_ASP_RX1_SLOT_MASK,
+ ffs(rx_mask) - 1);
+
+ return 0;
+}
+
static const struct snd_soc_dai_ops cs35l36_ops = {
.set_fmt = cs35l36_set_dai_fmt,
.hw_params = cs35l36_pcm_hw_params,
.set_sysclk = cs35l36_dai_set_sysclk,
+ .set_tdm_slot = cs35l36_set_tdm_slot,
};
#define CS35L36_RATES ( \
SNDRV_PCM_RATE_8000_48000 | \
SNDRV_PCM_RATE_12000 | \
SNDRV_PCM_RATE_24000 | \
SNDRV_PCM_RATE_88200 | \
SNDRV_PCM_RATE_96000 | \
--
2.53.0
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH RFC 6/6] arm64: dts: qcom: sdm845-google: Add basic audio support
2026-07-05 20:06 [PATCH RFC 0/6] Speakers for Pixel 3 / 3 XL David Heidelberg via B4 Relay
` (4 preceding siblings ...)
2026-07-05 20:06 ` [PATCH RFC 5/6] ASoC: cs35l36: Implement set_tdm_slot to program RX slot register David Heidelberg via B4 Relay
@ 2026-07-05 20:06 ` David Heidelberg via B4 Relay
2026-07-05 20:18 ` sashiko-bot
` (2 more replies)
5 siblings, 3 replies; 22+ messages in thread
From: David Heidelberg via B4 Relay @ 2026-07-05 20:06 UTC (permalink / raw)
To: Srinivas Kandagatla, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, David Rhodes, Richard Fitzgerald, Bjorn Andersson,
Konrad Dybcio, Rob Herring, Krzysztof Kozlowski, David Rhodes,
Conor Dooley
Cc: linux-sound, linux-arm-msm, linux-kernel, patches, devicetree,
phone-devel, David Heidelberg
From: David Heidelberg <david@ixit.cz>
Introduce support for sound card and wire two CS35L36 audio codecs for
top and bottom speakers.
Inspired by commit from Joel Selvaraj.
Signed-off-by: David Heidelberg <david@ixit.cz>
---
arch/arm64/boot/dts/qcom/sdm845-google-common.dtsi | 133 ++++++++++++++++++++-
1 file changed, 131 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/boot/dts/qcom/sdm845-google-common.dtsi b/arch/arm64/boot/dts/qcom/sdm845-google-common.dtsi
index b2dc0327dff85..d00fee7ebd424 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-google-common.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-google-common.dtsi
@@ -2,16 +2,18 @@
/dts-v1/;
#include <dt-bindings/arm/qcom,ids.h>
#include <dt-bindings/dma/qcom-gpi.h>
#include <dt-bindings/input/linux-event-codes.h>
#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/regulator/qcom,rpmh-regulator.h>
+#include <dt-bindings/sound/qcom,q6afe.h>
+#include <dt-bindings/sound/qcom,q6asm.h>
#include "sdm845.dtsi"
#include "pm8998.dtsi"
#include "pmi8998.dtsi"
/delete-node/ &mpss_region;
/delete-node/ &venus_mem;
/delete-node/ &cdsp_mem;
@@ -404,19 +406,63 @@ nfc@28 {
firmware-gpios = <&tlmm 79 GPIO_ACTIVE_HIGH>;
pinctrl-0 = <&nfc_int_default &nfc_enable_default>;
pinctrl-names = "default";
};
};
&i2c12 {
- /* Bottom spkr (right) CS35L36 @ 40 */
+ status = "okay";
+
+ /* CS35L36, Bottom Speaker */
+ cs35l36_bottom: audio-codec@40 {
+ compatible = "cirrus,cs35l36";
+ reg = <0x40>;
+ reset-gpios = <&tlmm 112 GPIO_ACTIVE_HIGH>;
+ #sound-dai-cells = <0>;
+ sound-name-prefix = "Right"; /* Bottom */
+ VA-supply = <&vreg_s4a_1p8>;
+ interrupts-extended = <&tlmm 115 IRQ_TYPE_LEVEL_LOW>;
+
+ pinctrl-0 = <&cs35l36_bottom_default_state>;
+ pinctrl-names = "default";
+
+ cirrus,boost-ind-nanohenry = <1000>;
+ cirrus,boost-ctl-select = <1>;
+ cirrus,boost-ctl-millivolt = <10000>;
+ cirrus,boost-peak-milliamp = <3700>;
+ cirrus,temp-warn-threshold = <1>;
+ cirrus,multi-amp-mode;
+ cirrus,irq-drive-select = <0>;
+ cirrus,irq-gpio-select = <0>;
+ };
- /* Top spkr (left) CS35L36 @ 41 */
+ /* CS35L36, Top Speaker */
+ cs35l36_top: audio-codec@41 {
+ compatible = "cirrus,cs35l36";
+ reg = <0x41>;
+ reset-gpios = <&tlmm 75 GPIO_ACTIVE_HIGH>;
+ #sound-dai-cells = <0>;
+ sound-name-prefix = "Left"; /* Top */
+ VA-supply = <&vreg_s4a_1p8>;
+ interrupts-extended = <&tlmm 40 IRQ_TYPE_LEVEL_LOW>;
+
+ pinctrl-0 = <&cs35l36_top_default_state>;
+ pinctrl-names = "default";
+
+ cirrus,boost-ind-nanohenry = <1000>;
+ cirrus,boost-ctl-select = <0x01>;
+ cirrus,boost-ctl-millivolt = <10000>;
+ cirrus,boost-peak-milliamp = <3700>;
+ cirrus,temp-warn-threshold = <1>;
+ cirrus,multi-amp-mode;
+ cirrus,irq-drive-select = <0>;
+ cirrus,irq-gpio-select = <0>;
+ };
};
&ipa {
firmware-name = "qcom/sdm845/Google/blueline/ipa_fws.mbn";
memory-region = <&ipa_fw_mem>;
status = "okay";
};
@@ -449,16 +495,35 @@ &pm8998_resin {
};
&pmi8998_charger {
monitored-battery = <&battery>;
status = "okay";
};
+&q6afedai {
+ dai@72 {
+ reg = <QUATERNARY_TDM_RX_0>;
+
+ qcom,tdm-sync-mode = <0>;
+ qcom,tdm-sync-src = <1>;
+ qcom,tdm-data-out = <0>;
+ qcom,tdm-invert-sync = <0>;
+ qcom,tdm-data-delay = <1>;
+ qcom,tdm-data-align = <0>;
+ };
+};
+
+&q6asmdai {
+ dai@0 {
+ reg = <MSM_FRONTEND_DAI_MULTIMEDIA1>;
+ };
+};
+
&qupv3_id_0 {
status = "okay";
};
&qupv3_id_1 {
status = "okay";
};
@@ -467,16 +532,48 @@ &qup_uart9_rx {
bias-pull-up;
};
&qup_uart9_tx {
drive-strength = <2>;
bias-disable;
};
+&sound {
+ compatible = "qcom,sdm845-sndcard";
+ model = "Google Pixel 3";
+ pinctrl-0 = <&quat_mi2s_active>, <&quat_mi2s_sd0_active>,
+ <&quat_mi2s_sd1_active>;
+ pinctrl-names = "default";
+
+ mm1-dai-link {
+ link-name = "MultiMedia1";
+
+ cpu {
+ sound-dai = <&q6asmdai MSM_FRONTEND_DAI_MULTIMEDIA1>;
+ };
+ };
+
+ cs35l36-dai-link {
+ link-name = "Speaker Playback";
+
+ cpu {
+ sound-dai = <&q6afedai QUATERNARY_TDM_RX_0>;
+ };
+
+ platform {
+ sound-dai = <&q6routing>;
+ };
+
+ codec {
+ sound-dai = <&cs35l36_bottom>, <&cs35l36_top>;
+ };
+ };
+};
+
&tlmm {
gpio-reserved-ranges = < 0 4>, /* SPI (Intel MNH Pixel Visual Core) */
<81 4>; /* SPI (most likely Fingerprint Cards FPC1075) */
nfc_int_default: nfc-int-default-state {
pins = "gpio63";
function = "gpio";
drive-strength = <2>;
@@ -505,16 +602,48 @@ touchscreen_pins: ts-pins-gpio-state {
};
touchscreen_i2c_pins: qup-i2c2-gpio-state {
pins = "gpio27", "gpio28";
function = "gpio";
drive-strength = <2>;
bias-disable;
};
+
+ cs35l36_bottom_default_state: cs35l36-bottom-default-state {
+ reset-pins {
+ pins = "gpio112";
+ function = "gpio";
+ drive-strength = <2>;
+ bias-disable;
+ };
+
+ irq-pins {
+ pins = "gpio115";
+ function = "gpio";
+ drive-strength = <2>;
+ bias-pull-up;
+ };
+ };
+
+ cs35l36_top_default_state: cs35l36-top-default-state {
+ irq-pins {
+ pins = "gpio40";
+ function = "gpio";
+ drive-strength = <2>;
+ bias-pull-up;
+ };
+
+ reset-pins {
+ pins = "gpio75";
+ function = "gpio";
+ drive-strength = <2>;
+ bias-disable;
+ };
+ };
};
&uart6 {
pinctrl-0 = <&qup_uart6_4pin>;
status = "okay";
bluetooth {
--
2.53.0
^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [PATCH RFC 6/6] arm64: dts: qcom: sdm845-google: Add basic audio support
2026-07-05 20:06 ` [PATCH RFC 6/6] arm64: dts: qcom: sdm845-google: Add basic audio support David Heidelberg via B4 Relay
@ 2026-07-05 20:18 ` sashiko-bot
2026-07-06 9:14 ` Konrad Dybcio
2026-07-06 12:00 ` Konrad Dybcio
2 siblings, 0 replies; 22+ messages in thread
From: sashiko-bot @ 2026-07-05 20:18 UTC (permalink / raw)
To: David Heidelberg; +Cc: robh, conor+dt, devicetree
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The `reset-gpios` property for the CS35L36 codecs incorrectly specifies `GPIO_ACTIVE_HIGH` to work around a logical bug in the CS35L36 driver.
--
commit 380e434eaeea6507428e5e193d27e7812369af1c
Author: David Heidelberg <david@ixit.cz>
arm64: dts: qcom: sdm845-google: Add basic audio support
This commit introduces audio support for the sdm845-google devices. It adds
the sound card and wires up two CS35L36 audio codecs for the top and bottom
speakers.
> diff --git a/arch/arm64/boot/dts/qcom/sdm845-google-common.dtsi b/arch/arm64/boot/dts/qcom/sdm845-google-common.dtsi
> index b2dc0327dff85..d00fee7ebd424 100644
> --- a/arch/arm64/boot/dts/qcom/sdm845-google-common.dtsi
> +++ b/arch/arm64/boot/dts/qcom/sdm845-google-common.dtsi
[ ... ]
> @@ -409,9 +411,53 @@ nfc@28 {
> };
>
> &i2c12 {
> - /* Bottom spkr (right) CS35L36 @ 40 */
> + status = "okay";
> +
> + /* CS35L36, Bottom Speaker */
> + cs35l36_bottom: audio-codec@40 {
> + compatible = "cirrus,cs35l36";
> + reg = <0x40>;
> + reset-gpios = <&tlmm 112 GPIO_ACTIVE_HIGH>;
[Severity: Low]
Is this reset-gpios polarity intentionally set to GPIO_ACTIVE_HIGH to work
around the cs35l36 driver bug?
Since the CS35L36 hardware reset pin is active-low, shouldn't devicetree
accurately describe the hardware rather than encode a software workaround?
The driver in sound/soc/codecs/cs35l36.c currently treats the GPIO as an
enable signal, requesting it with GPIOD_OUT_LOW and writing a logical 1
to run. Setting GPIO_ACTIVE_HIGH in the DT translates this into a physical
high voltage, taking the device out of reset.
Would it be better to specify this as active-low to match the hardware and
address the bug in the driver instead?
> + #sound-dai-cells = <0>;
[ ... ]
> + /* CS35L36, Top Speaker */
> + cs35l36_top: audio-codec@41 {
> + compatible = "cirrus,cs35l36";
> + reg = <0x41>;
> + reset-gpios = <&tlmm 75 GPIO_ACTIVE_HIGH>;
[Severity: Low]
Are we encoding the same driver workaround in the devicetree here for the
top speaker?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260705-pixel3-audio-v1-0-3b66f33859f1@ixit.cz?part=6
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH RFC 2/6] ASoC: qcom: sdm845: use DSP_A format for TDM codec DAIs
2026-07-05 20:06 ` [PATCH RFC 2/6] ASoC: qcom: sdm845: use DSP_A format for TDM codec DAIs David Heidelberg via B4 Relay
@ 2026-07-05 20:18 ` sashiko-bot
2026-07-06 8:33 ` Konrad Dybcio
1 sibling, 0 replies; 22+ messages in thread
From: sashiko-bot @ 2026-07-05 20:18 UTC (permalink / raw)
To: David Heidelberg; +Cc: devicetree, robh, conor+dt
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Missing NULL check on `codec_dai->component->name_prefix` causes a kernel panic if the device tree omits the `sound-name-prefix` property.
--
commit 34e4567f69218c8e1f7099e3d2b65d5ada37de5a
Author: David Heidelberg <david@ixit.cz>
ASoC: qcom: sdm845: use DSP_A format for TDM codec DAIs
This commit modifies sdm845_snd_startup() to use the DSP_A timing format
instead of DSP_B for TDM codec DAIs to match the expected hardware behavior.
> diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c
> --- a/sound/soc/qcom/sdm845.c
> +++ b/sound/soc/qcom/sdm845.c
> @@ -385,7 +385,7 @@ static int sdm845_snd_startup(struct snd_pcm_substream *substream)
> TDM_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK);
> }
>
> - codec_dai_fmt |= SND_SOC_DAIFMT_IB_NF | SND_SOC_DAIFMT_DSP_B;
> + codec_dai_fmt |= SND_SOC_DAIFMT_IB_NF | SND_SOC_DAIFMT_DSP_A;
>
> for_each_rtd_codec_dais(rtd, j, codec_dai) {
>
> if (!strcmp(codec_dai->component->name_prefix,
> "Left")) {
[Severity: High]
This is a pre-existing issue, but can this lead to a NULL pointer dereference?
If a codec's device tree node omits the sound-name-prefix property, the ASoC
core sets component->name_prefix to NULL. Passing this directly to strcmp()
will cause a kernel panic during driver startup.
The same pattern appears immediately below this for the "Right" channel
prefix, and also in sdm845_tdm_snd_hw_params(). Should there be a NULL check
added before comparing these prefixes?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260705-pixel3-audio-v1-0-3b66f33859f1@ixit.cz?part=2
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH RFC 4/6] ASoC: qcom: sdm845: Set codec dai and component sysclk during startup
2026-07-05 20:06 ` [PATCH RFC 4/6] ASoC: qcom: sdm845: Set codec dai and component sysclk during startup David Heidelberg via B4 Relay
@ 2026-07-05 20:19 ` sashiko-bot
0 siblings, 0 replies; 22+ messages in thread
From: sashiko-bot @ 2026-07-05 20:19 UTC (permalink / raw)
To: David Heidelberg; +Cc: conor+dt, devicetree, robh
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Error paths in `sdm845_snd_startup()` fail to decrement clock reference counters, causing permanent resource leaks.
- [High] Un-guarded `strcmp()` on potentially NULL `name_prefix` causes a kernel panic.
--
commit 6324d11aea931e9e3bac52b9aaf6e703b5d354f0
Author: David Heidelberg <david@ixit.cz>
ASoC: qcom: sdm845: Set codec dai and component sysclk during startup
This commit sets the codec dai and component sysclk during TDM startup
for all codec DAIs on the QUATERNARY_TDM path. It gracefully ignores
-ENOTSUPP errors for codecs that do not support sysclk configuration.
> diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c
> index 8b65aa3982d47..b2d51e472bc26 100644
> --- a/sound/soc/qcom/sdm845.c
> +++ b/sound/soc/qcom/sdm845.c
> @@ -410,6 +410,28 @@ static int sdm845_snd_startup(struct snd_pcm_substream *substream)
[Severity: High]
This isn't a bug introduced by this patch, but does the pre-existing strcmp()
slightly earlier in this loop safely handle missing device tree properties?
Looking at the code just before this diff in sdm845_snd_startup():
if (!strcmp(codec_dai->component->name_prefix, "Left")) {
If a device tree is missing the sound-name-prefix property, the component's
name_prefix pointer is left as NULL. Since strcmp() doesn't gracefully handle
NULL pointers, does this cause a direct kernel panic during stream startup?
> return ret;
> }
> }
> +
> + /* Set codec sysclk needed by codecs like cs35l36. */
> + ret = snd_soc_dai_set_sysclk(codec_dai, 0,
> + TDM_BCLK_RATE,
> + SND_SOC_CLOCK_IN);
> + if (ret < 0 && ret != -ENOTSUPP) {
> + dev_err(codec_dai->dev,
> + "Failed to set codec dai sysclk: %d\n",
> + ret);
> + return ret;
[Severity: High]
This is a pre-existing issue, but do these early returns (both the new ones
and the pre-existing format setup checks) leak the clock reference?
At the start of the QUATERNARY_TDM_RX_0 case in sdm845_snd_startup(),
data->quat_tdm_clk_count is incremented and the clock is enabled.
If snd_soc_dai_set_sysclk() fails and returns early here, the ASoC core
handles the .startup failure by calling soc_pcm_clean(), which in turn calls
snd_soc_link_shutdown().
However, snd_soc_link_shutdown() skips the machine driver's .shutdown
callback if the .startup callback itself failed.
Since .shutdown is skipped, the clock reference counts are never decremented,
leaving the CPU DAI clocks permanently enabled. Could we add a cleanup path
to decrement the counters before returning?
> + }
> +
> + ret = snd_soc_component_set_sysclk(codec_dai->component,
> + 0, 0,
> + TDM_BCLK_RATE,
> + SND_SOC_CLOCK_IN);
> + if (ret < 0 && ret != -ENOTSUPP) {
> + dev_err(codec_dai->dev,
> + "Failed to set codec component sysclk: %d\n",
> + ret);
> + return ret;
> + }
> }
> break;
> case SLIMBUS_0_RX...SLIMBUS_6_TX:
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260705-pixel3-audio-v1-0-3b66f33859f1@ixit.cz?part=4
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH RFC 1/6] ASoC: qcom: sdm845: Demystify TDM masks a bit
2026-07-05 20:06 ` [PATCH RFC 1/6] ASoC: qcom: sdm845: Demystify TDM masks a bit David Heidelberg via B4 Relay
@ 2026-07-05 20:19 ` sashiko-bot
0 siblings, 0 replies; 22+ messages in thread
From: sashiko-bot @ 2026-07-05 20:19 UTC (permalink / raw)
To: David Heidelberg; +Cc: conor+dt, robh, devicetree
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The CPU DAI's capture mask is incorrectly configured to 0x0F (slots 0-3) instead of 0xF0 (slots 4-7), breaking the V/I sense capture path. The patch exacerbates this by using the playback macro `SPK_TDM_RX_MASK` to construct the capture mask, which creates a false semantic link and obfuscates the underlying bug.
--
commit 7636e0a7627a4449334c3af3eda079faca90b76e
Author: David Heidelberg <david@ixit.cz>
ASoC: qcom: sdm845: Demystify TDM masks a bit
This commit updates the hardcoded TDM masks in the sdm845 machine driver
by defining them as bitmasks and utilizing them in the hw_params function.
It aims to describe which bits are used for each RX/TX slot.
> diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c
> index 0ce9dff4dc525..edd2cc7a1c74f 100644
> --- a/sound/soc/qcom/sdm845.c
> +++ b/sound/soc/qcom/sdm845.c
[ ... ]
> @@ -129,8 +131,10 @@ static int sdm845_tdm_snd_hw_params(struct snd_pcm_substream *substream,
> goto end;
> }
> } else {
> - ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0xf, 0,
> - 8, slot_width);
> + ret = snd_soc_dai_set_tdm_slot(cpu_dai,
> + SPK_TDM_RX_MASK | BIT(2) |
> + BIT(3), 0,
> + NUM_TDM_SLOTS, slot_width);
[Severity: High]
This is a pre-existing issue, but does using SPK_TDM_RX_MASK here conflate
the CPU DAI capture mask with the playback RX macros?
Looking at the capture path in sdm845_tdm_snd_hw_params(), the CPU DAI's
capture mask is currently configured to 0x0F (slots 0-3), but the codecs
are configured to transmit on slots 4-7 (mask 0xF0). This mismatch causes
the V/I sense capture path to receive silence.
Since the DSP channel mapping maps channels to slots 0, 4, 8, and 12, an
active mask of 0x0F completely disables slots 4 and 8 on the TDM port.
Could the capture mask be updated to use LEFT_SPK_TDM_TX_MASK and
RIGHT_SPK_TDM_TX_MASK to correctly configure 0xF0, rather than building
0x0F out of the playback mask?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260705-pixel3-audio-v1-0-3b66f33859f1@ixit.cz?part=1
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH RFC 5/6] ASoC: cs35l36: Implement set_tdm_slot to program RX slot register
2026-07-05 20:06 ` [PATCH RFC 5/6] ASoC: cs35l36: Implement set_tdm_slot to program RX slot register David Heidelberg via B4 Relay
@ 2026-07-05 20:20 ` sashiko-bot
2026-07-06 8:52 ` Charles Keepax
2026-07-06 9:11 ` Konrad Dybcio
2 siblings, 0 replies; 22+ messages in thread
From: sashiko-bot @ 2026-07-05 20:20 UTC (permalink / raw)
To: David Heidelberg; +Cc: conor+dt, robh, devicetree
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] The newly added set_tdm_slot function conflicts with the existing DAPM 'Channel Mux' kcontrol, causing TDM slot state corruption.
- [High] The set_tdm_slot callback silently ignores the tx_mask parameter, failing to configure TX TDM slots and causing potential DOUT bus contention.
- [Medium] The return value of regmap_update_bits is ignored, masking potential hardware communication failures.
--
commit 0a6a2457481eab4ef7efac8df4098277de0088c1
Author: David Heidelberg <david@ixit.cz>
ASoC: cs35l36: Implement set_tdm_slot to program RX slot register
Program ASP_RX1_SLOT with the first set bit of rx_mask so the amplifier
listens on the correct TDM slot when configured by machine drivers.
> diff --git a/sound/soc/codecs/cs35l36.c b/sound/soc/codecs/cs35l36.c
> index 89645327945f1..944f4cb5763e4 100644
> --- a/sound/soc/codecs/cs35l36.c
> +++ b/sound/soc/codecs/cs35l36.c
> @@ -947,10 +947,26 @@ static const struct cs35l36_pll_config *cs35l36_get_clk_config(
> return NULL;
> }
>
> +static int cs35l36_set_tdm_slot(struct snd_soc_dai *dai,
> + unsigned int tx_mask, unsigned int rx_mask,
> + int slots, int slot_width)
> +{
[Severity: High]
Does this safely handle scenarios where multiple codecs share a TDM bus?
The function accepts a tx_mask parameter but doesn't use it, nor does it
return an error if a non-default tx_mask is requested.
If a machine driver sets up multiple CS35L36 codecs on a shared TDM bus and
calls set_tdm_slot with distinct tx_mask values, the codecs will remain on
their overlapping default TX slots. This could cause multiple codecs to drive
the I2S DOUT line simultaneously when the capture stream starts.
> + struct cs35l36_private *cs35l36 =
> + snd_soc_component_get_drvdata(dai->component);
> +
> + if (rx_mask)
> + regmap_update_bits(cs35l36->regmap, CS35L36_ASP_RX1_SLOT,
> + CS35L36_ASP_RX1_SLOT_MASK,
> + ffs(rx_mask) - 1);
[Severity: High]
Will this conflict with the existing DAPM channel mux kcontrol?
The preexisting chansel_enum DAPM mux targets the exact same register field:
sound/soc/codecs/cs35l36.c:
static SOC_ENUM_SINGLE_DECL(chansel_enum, CS35L36_ASP_RX1_SLOT, 0,
cs35l36_chan_text);
Since chansel_enum uses a 1-bit mask and set_tdm_slot uses a 6-bit mask
(CS35L36_ASP_RX1_SLOT_MASK), these interfaces seem incompatible.
If a machine driver sets the slot to 4, later toggling the DAPM kcontrol
from userspace will flip only bit 0, corrupting the slot configuration.
[Severity: Medium]
Should the return value of regmap_update_bits be checked here?
If the hardware write fails with an error like -EIO, the function still
returns 0. This falsely reports success to the ALSA core, allowing the stream
to proceed with the amplifier listening to the wrong TDM slot instead of
gracefully aborting.
> +
> + return 0;
> +}
> +
> static const struct snd_soc_dai_ops cs35l36_ops = {
> .set_fmt = cs35l36_set_dai_fmt,
> .hw_params = cs35l36_pcm_hw_params,
> .set_sysclk = cs35l36_dai_set_sysclk,
> + .set_tdm_slot = cs35l36_set_tdm_slot,
> };
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260705-pixel3-audio-v1-0-3b66f33859f1@ixit.cz?part=5
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH RFC 3/6] ASoC: qcom: sdm845: Use per-speaker RX masks for TDM slot assignment
2026-07-05 20:06 ` [PATCH RFC 3/6] ASoC: qcom: sdm845: Use per-speaker RX masks for TDM slot assignment David Heidelberg via B4 Relay
@ 2026-07-05 20:25 ` sashiko-bot
0 siblings, 0 replies; 22+ messages in thread
From: sashiko-bot @ 2026-07-05 20:25 UTC (permalink / raw)
To: David Heidelberg; +Cc: robh, conor+dt, devicetree
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
New issues:
- [Medium] Changing the TDM `rx_mask` reduces the codec's capture stream channel count fixup to 1, mismatching the 2 TX slots.
Pre-existing issues:
- [High] Unsafe use of `strcmp` with potentially NULL `codec_dai->component->name_prefix`.
- [High] Incorrect TDM slot mapping offset for CPU DAI drops right channel audio.
- [High] Mismatch between CPU DAI TDM capture mask and Codec TX masks.
--
commit a3245c8cb8ad225800a041e09ecebd46b152d459
Author: David Heidelberg <david@ixit.cz>
ASoC: qcom: sdm845: Use per-speaker RX masks for TDM slot assignment
This commit splits the playback receive mask into per-speaker masks for the
Left and Right codec DAIs. This ensures that the Left codec gets assigned
to slot 0 and the Right codec gets slot 1, addressing an issue where both
were mapped to slot 0.
> diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c
> index 9de3282bda4be..8b65aa3982d47 100644
> --- a/sound/soc/qcom/sdm845.c
> +++ b/sound/soc/qcom/sdm845.c
> @@ -155,7 +155,7 @@ static int sdm845_tdm_snd_hw_params(struct snd_pcm_substream *substream,
> if (!strcmp(codec_dai->component->name_prefix, "Left")) {
[Severity: High]
This is a pre-existing issue, but is it possible for the name_prefix to be
null here?
If the device tree is misconfigured and lacks a sound-name-prefix property
for any of the codecs on this DAI link, the name_prefix string will be null.
When unprivileged userspace opens the ALSA PCM stream, this function iterates
over the codec DAIs and directly dereferences name_prefix via the standard
kernel strcmp function.
Could this lead to a kernel panic, and should there be a check to ensure
the prefix is valid before comparison?
> ret = snd_soc_dai_set_tdm_slot(
> codec_dai, LEFT_SPK_TDM_TX_MASK,
> - SPK_TDM_RX_MASK, NUM_TDM_SLOTS,
> + LEFT_SPK_TDM_RX_MASK, NUM_TDM_SLOTS,
[Severity: Medium]
Does passing this 1-bit receive mask into snd_soc_dai_set_tdm_slot() cause
issues with capture streams?
The ASoC core unilaterally maps the receive mask parameter to the capture
stream mask. By splitting the playback mask and passing the 1-bit
LEFT_SPK_TDM_RX_MASK here, soc_pcm_codec_params_fixup() uses this mask to
override the capture channel count to 1.
Since the codecs transmit on 2 slots using LEFT_SPK_TDM_TX_MASK, could this
mismatch lead to incorrect channel count parameters being passed to the
codec hardware parameters and DAPM widgets?
> slot_width);
> if (ret < 0) {
> dev_err(rtd->dev,
> @@ -167,7 +167,7 @@ static int sdm845_tdm_snd_hw_params(struct snd_pcm_substream *substream,
> if (!strcmp(codec_dai->component->name_prefix, "Right")) {
> ret = snd_soc_dai_set_tdm_slot(
> codec_dai, RIGHT_SPK_TDM_TX_MASK,
> - SPK_TDM_RX_MASK, NUM_TDM_SLOTS,
> + RIGHT_SPK_TDM_RX_MASK, NUM_TDM_SLOTS,
[Severity: High]
This is a pre-existing issue, but does the CPU DAI capture mask match the
codec transmit masks?
The CPU DAI is configured earlier in this function with a capture mask of
SPK_TDM_RX_MASK | BIT(2) | BIT(3), which evaluates to 0x0F, instructing
the DSP to capture on TDM slots 0-3.
However, the left and right codecs are configured to transmit on
LEFT_SPK_TDM_TX_MASK (0x30, slots 4-5) and RIGHT_SPK_TDM_TX_MASK (0xC0,
slots 6-7).
Since the CPU does not listen on the slots that the codecs are actively
transmitting on, is speaker protection feedback data being permanently lost
during capture streams?
[Severity: High]
This is another pre-existing issue, but is the TDM slot mapping offset for
the CPU DAI dropping the right channel audio?
Looking at the tdm_slot_offset array definition:
static unsigned int tdm_slot_offset[8] = {0, 4, 8, 12, 16, 20, 24, 28};
This array maps the left channel to offset 0 and the right channel to offset
4. When passed to snd_soc_dai_set_channel_map() for the CPU DAI, the S16_LE
format forces the slot width to 16.
Whether the DSP interprets 4 as a slot index or a byte offset (which for
16-bit slots evaluates to slot 2), channel 1 is placed outside the active
CPU DAI transmit mask SPK_TDM_RX_MASK (0x03) that only enables slots 0 and 1.
Does this cause the DSP to drop the right channel audio entirely during
standard stereo playback?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260705-pixel3-audio-v1-0-3b66f33859f1@ixit.cz?part=3
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH RFC 2/6] ASoC: qcom: sdm845: use DSP_A format for TDM codec DAIs
2026-07-05 20:06 ` [PATCH RFC 2/6] ASoC: qcom: sdm845: use DSP_A format for TDM codec DAIs David Heidelberg via B4 Relay
2026-07-05 20:18 ` sashiko-bot
@ 2026-07-06 8:33 ` Konrad Dybcio
2026-07-06 9:15 ` David Heidelberg
1 sibling, 1 reply; 22+ messages in thread
From: Konrad Dybcio @ 2026-07-06 8:33 UTC (permalink / raw)
To: david, Srinivas Kandagatla, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, David Rhodes, Richard Fitzgerald,
Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski,
David Rhodes, Conor Dooley
Cc: linux-sound, linux-arm-msm, linux-kernel, patches, devicetree,
phone-devel
On 7/5/26 10:06 PM, David Heidelberg via B4 Relay wrote:
> From: David Heidelberg <david@ixit.cz>
>
> Before the DSP_B only worked because the only close-to-mainline consumer
> cs35l36 codec was patched to map both DSP_A and DSP_B to the same
> hardware register value (asp_fmt = 0), which is inherently DSP_A timing.
> Use the right codec (DSP_A) which works as expected.
>
> Signed-off-by: David Heidelberg <david@ixit.cz>
> ---
Fixes?
Konrad
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH RFC 5/6] ASoC: cs35l36: Implement set_tdm_slot to program RX slot register
2026-07-05 20:06 ` [PATCH RFC 5/6] ASoC: cs35l36: Implement set_tdm_slot to program RX slot register David Heidelberg via B4 Relay
2026-07-05 20:20 ` sashiko-bot
@ 2026-07-06 8:52 ` Charles Keepax
2026-07-06 9:11 ` Konrad Dybcio
2 siblings, 0 replies; 22+ messages in thread
From: Charles Keepax @ 2026-07-06 8:52 UTC (permalink / raw)
To: david
Cc: Srinivas Kandagatla, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, David Rhodes, Richard Fitzgerald, Bjorn Andersson,
Konrad Dybcio, Rob Herring, Krzysztof Kozlowski, David Rhodes,
Conor Dooley, linux-sound, linux-arm-msm, linux-kernel, patches,
devicetree, phone-devel
On Sun, Jul 05, 2026 at 10:06:55PM +0200, David Heidelberg via B4 Relay wrote:
> From: David Heidelberg <david@ixit.cz>
>
> Program ASP_RX1_SLOT with the first set bit of rx_mask so the
> amplifier listens on the correct TDM slot when configured by
> machine drivers.
>
> Assisted-by: Claude:claude-4.6-opus
> Signed-off-by: David Heidelberg <david@ixit.cz>
> ---
> +static int cs35l36_set_tdm_slot(struct snd_soc_dai *dai,
> + unsigned int tx_mask, unsigned int rx_mask,
> + int slots, int slot_width)
> +{
> + struct cs35l36_private *cs35l36 =
> + snd_soc_component_get_drvdata(dai->component);
> +
> + if (rx_mask)
> + regmap_update_bits(cs35l36->regmap, CS35L36_ASP_RX1_SLOT,
> + CS35L36_ASP_RX1_SLOT_MASK,
> + ffs(rx_mask) - 1);
It is more normal for the masks to specify the slot number rather
than the bit number, it would probably be nicer to stick with
that convention even though it will complicate the code here a
little.
Thanks,
Charles
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH RFC 5/6] ASoC: cs35l36: Implement set_tdm_slot to program RX slot register
2026-07-05 20:06 ` [PATCH RFC 5/6] ASoC: cs35l36: Implement set_tdm_slot to program RX slot register David Heidelberg via B4 Relay
2026-07-05 20:20 ` sashiko-bot
2026-07-06 8:52 ` Charles Keepax
@ 2026-07-06 9:11 ` Konrad Dybcio
2 siblings, 0 replies; 22+ messages in thread
From: Konrad Dybcio @ 2026-07-06 9:11 UTC (permalink / raw)
To: david, Srinivas Kandagatla, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, David Rhodes, Richard Fitzgerald,
Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski,
David Rhodes, Conor Dooley
Cc: linux-sound, linux-arm-msm, linux-kernel, patches, devicetree,
phone-devel
On 7/5/26 10:06 PM, David Heidelberg via B4 Relay wrote:
> From: David Heidelberg <david@ixit.cz>
>
> Program ASP_RX1_SLOT with the first set bit of rx_mask so the
> amplifier listens on the correct TDM slot when configured by
> machine drivers.
>
> Assisted-by: Claude:claude-4.6-opus
> Signed-off-by: David Heidelberg <david@ixit.cz>
> ---
> sound/soc/codecs/cs35l36.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/sound/soc/codecs/cs35l36.c b/sound/soc/codecs/cs35l36.c
> index 89645327945f1..944f4cb5763e4 100644
> --- a/sound/soc/codecs/cs35l36.c
> +++ b/sound/soc/codecs/cs35l36.c
> @@ -942,20 +942,36 @@ static const struct cs35l36_pll_config *cs35l36_get_clk_config(
> for (i = 0; i < ARRAY_SIZE(cs35l36_pll_sysclk); i++) {
> if (cs35l36_pll_sysclk[i].freq == freq)
> return &cs35l36_pll_sysclk[i];
> }
>
> return NULL;
> }
>
> +static int cs35l36_set_tdm_slot(struct snd_soc_dai *dai,
> + unsigned int tx_mask, unsigned int rx_mask,
> + int slots, int slot_width)
> +{
> + struct cs35l36_private *cs35l36 =
> + snd_soc_component_get_drvdata(dai->component);
> +
> + if (rx_mask)
> + regmap_update_bits(cs35l36->regmap, CS35L36_ASP_RX1_SLOT,
> + CS35L36_ASP_RX1_SLOT_MASK,
> + ffs(rx_mask) - 1);
if (!rx_mask)
return 0;
(or does the field need to be cleared?)
return regmap_update_bits
Konrad
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH RFC 6/6] arm64: dts: qcom: sdm845-google: Add basic audio support
2026-07-05 20:06 ` [PATCH RFC 6/6] arm64: dts: qcom: sdm845-google: Add basic audio support David Heidelberg via B4 Relay
2026-07-05 20:18 ` sashiko-bot
@ 2026-07-06 9:14 ` Konrad Dybcio
2026-07-06 9:17 ` David Heidelberg
2026-07-06 12:00 ` Konrad Dybcio
2 siblings, 1 reply; 22+ messages in thread
From: Konrad Dybcio @ 2026-07-06 9:14 UTC (permalink / raw)
To: david, Srinivas Kandagatla, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, David Rhodes, Richard Fitzgerald,
Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski,
David Rhodes, Conor Dooley
Cc: linux-sound, linux-arm-msm, linux-kernel, patches, devicetree,
phone-devel
On 7/5/26 10:06 PM, David Heidelberg via B4 Relay wrote:
> From: David Heidelberg <david@ixit.cz>
>
> Introduce support for sound card and wire two CS35L36 audio codecs for
> top and bottom speakers.
>
> Inspired by commit from Joel Selvaraj.
>
> Signed-off-by: David Heidelberg <david@ixit.cz>
> ---
This looks good, but since the binding is not YAML, it introduces:
failed to match any schema with compatible: ['cirrus,cs35l36']
so please also fix that up
Konrad
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH RFC 2/6] ASoC: qcom: sdm845: use DSP_A format for TDM codec DAIs
2026-07-06 8:33 ` Konrad Dybcio
@ 2026-07-06 9:15 ` David Heidelberg
2026-07-06 9:40 ` Konrad Dybcio
0 siblings, 1 reply; 22+ messages in thread
From: David Heidelberg @ 2026-07-06 9:15 UTC (permalink / raw)
To: Konrad Dybcio, Srinivas Kandagatla, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, David Rhodes, Richard Fitzgerald,
Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski,
David Rhodes, Conor Dooley
Cc: linux-sound, linux-arm-msm, linux-kernel, patches, devicetree,
phone-devel
On 06/07/2026 10:33, Konrad Dybcio wrote:
> On 7/5/26 10:06 PM, David Heidelberg via B4 Relay wrote:
>> From: David Heidelberg <david@ixit.cz>
>>
>> Before the DSP_B only worked because the only close-to-mainline consumer
>> cs35l36 codec was patched to map both DSP_A and DSP_B to the same
>> hardware register value (asp_fmt = 0), which is inherently DSP_A timing.
>> Use the right codec (DSP_A) which works as expected.
>>
>> Signed-off-by: David Heidelberg <david@ixit.cz>
>> ---
>
> Fixes?
>
I was thinking about it, but I don't see any mainline consumer of TDM within the
sdm845 arch.
If you think it make sense, I'll mark it.
David
> Konrad
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH RFC 6/6] arm64: dts: qcom: sdm845-google: Add basic audio support
2026-07-06 9:14 ` Konrad Dybcio
@ 2026-07-06 9:17 ` David Heidelberg
2026-07-06 11:59 ` Konrad Dybcio
0 siblings, 1 reply; 22+ messages in thread
From: David Heidelberg @ 2026-07-06 9:17 UTC (permalink / raw)
To: Konrad Dybcio, Srinivas Kandagatla, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, David Rhodes, Richard Fitzgerald,
Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski,
David Rhodes, Conor Dooley
Cc: linux-sound, linux-arm-msm, linux-kernel, patches, devicetree,
phone-devel
On 06/07/2026 11:14, Konrad Dybcio wrote:
> On 7/5/26 10:06 PM, David Heidelberg via B4 Relay wrote:
>> From: David Heidelberg <david@ixit.cz>
>>
>> Introduce support for sound card and wire two CS35L36 audio codecs for
>> top and bottom speakers.
>>
>> Inspired by commit from Joel Selvaraj.
>>
>> Signed-off-by: David Heidelberg <david@ixit.cz>
>> ---
>
> This looks good, but since the binding is not YAML, it introduces:
>
> failed to match any schema with compatible: ['cirrus,cs35l36']
>
> so please also fix that up
I did :) bff7fad1010eea6f183fb110b54171cf8700ef8e , at this moment in the -next.
David
>
> Konrad
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH RFC 2/6] ASoC: qcom: sdm845: use DSP_A format for TDM codec DAIs
2026-07-06 9:15 ` David Heidelberg
@ 2026-07-06 9:40 ` Konrad Dybcio
0 siblings, 0 replies; 22+ messages in thread
From: Konrad Dybcio @ 2026-07-06 9:40 UTC (permalink / raw)
To: David Heidelberg, Srinivas Kandagatla, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, David Rhodes, Richard Fitzgerald,
Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski,
David Rhodes, Conor Dooley
Cc: linux-sound, linux-arm-msm, linux-kernel, patches, devicetree,
phone-devel
On 7/6/26 11:15 AM, David Heidelberg wrote:
> On 06/07/2026 10:33, Konrad Dybcio wrote:
>> On 7/5/26 10:06 PM, David Heidelberg via B4 Relay wrote:
>>> From: David Heidelberg <david@ixit.cz>
>>>
>>> Before the DSP_B only worked because the only close-to-mainline consumer
>>> cs35l36 codec was patched to map both DSP_A and DSP_B to the same
>>> hardware register value (asp_fmt = 0), which is inherently DSP_A timing.
>>> Use the right codec (DSP_A) which works as expected.
>>>
>>> Signed-off-by: David Heidelberg <david@ixit.cz>
>>> ---
>>
>> Fixes?
>>
>
> I was thinking about it, but I don't see any mainline consumer of TDM within the sdm845 arch.
>
> If you think it make sense, I'll mark it.
I personally think Fixes makes sense whenever the code is fixed,
not only if there's a user-visible bug. Up to you.
Konrad
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH RFC 6/6] arm64: dts: qcom: sdm845-google: Add basic audio support
2026-07-06 9:17 ` David Heidelberg
@ 2026-07-06 11:59 ` Konrad Dybcio
0 siblings, 0 replies; 22+ messages in thread
From: Konrad Dybcio @ 2026-07-06 11:59 UTC (permalink / raw)
To: David Heidelberg, Srinivas Kandagatla, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, David Rhodes, Richard Fitzgerald,
Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski,
David Rhodes, Conor Dooley
Cc: linux-sound, linux-arm-msm, linux-kernel, patches, devicetree,
phone-devel
On 7/6/26 11:17 AM, David Heidelberg wrote:
> On 06/07/2026 11:14, Konrad Dybcio wrote:
>> On 7/5/26 10:06 PM, David Heidelberg via B4 Relay wrote:
>>> From: David Heidelberg <david@ixit.cz>
>>>
>>> Introduce support for sound card and wire two CS35L36 audio codecs for
>>> top and bottom speakers.
>>>
>>> Inspired by commit from Joel Selvaraj.
>>>
>>> Signed-off-by: David Heidelberg <david@ixit.cz>
>>> ---
>>
>> This looks good, but since the binding is not YAML, it introduces:
>>
>> failed to match any schema with compatible: ['cirrus,cs35l36']
>>
>> so please also fix that up
>
> I did :) bff7fad1010eea6f183fb110b54171cf8700ef8e , at this moment in the -next.
I didn't run git fetch at the time, you're right!
Konrad
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH RFC 6/6] arm64: dts: qcom: sdm845-google: Add basic audio support
2026-07-05 20:06 ` [PATCH RFC 6/6] arm64: dts: qcom: sdm845-google: Add basic audio support David Heidelberg via B4 Relay
2026-07-05 20:18 ` sashiko-bot
2026-07-06 9:14 ` Konrad Dybcio
@ 2026-07-06 12:00 ` Konrad Dybcio
2 siblings, 0 replies; 22+ messages in thread
From: Konrad Dybcio @ 2026-07-06 12:00 UTC (permalink / raw)
To: david, Srinivas Kandagatla, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, David Rhodes, Richard Fitzgerald,
Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski,
David Rhodes, Conor Dooley
Cc: linux-sound, linux-arm-msm, linux-kernel, patches, devicetree,
phone-devel
On 7/5/26 10:06 PM, David Heidelberg via B4 Relay wrote:
> From: David Heidelberg <david@ixit.cz>
>
> Introduce support for sound card and wire two CS35L36 audio codecs for
> top and bottom speakers.
>
> Inspired by commit from Joel Selvaraj.
>
> Signed-off-by: David Heidelberg <david@ixit.cz>
> ---
[...]
> + /* CS35L36, Bottom Speaker */
> + cs35l36_bottom: audio-codec@40 {
> + compatible = "cirrus,cs35l36";
> + reg = <0x40>;
> + reset-gpios = <&tlmm 112 GPIO_ACTIVE_HIGH>;
> + #sound-dai-cells = <0>;
> + sound-name-prefix = "Right"; /* Bottom */
One comment's enough (either above the node or here)
[...]
> + mm1-dai-link {
> + link-name = "MultiMedia1";
> +
> + cpu {
> + sound-dai = <&q6asmdai MSM_FRONTEND_DAI_MULTIMEDIA1>;
> + };
> + };
> +
> + cs35l36-dai-link {
> + link-name = "Speaker Playback";
> +
> + cpu {
> + sound-dai = <&q6afedai QUATERNARY_TDM_RX_0>;
> + };
> +
> + platform {
> + sound-dai = <&q6routing>;
> + };
> +
> + codec {
> + sound-dai = <&cs35l36_bottom>, <&cs35l36_top>;
> + };
nit: 'co'dec < 'cp'u < 'p'latform
also 'c's35l36-dai-link < `m`m1-dai-link
otherwise:
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Konrad
^ permalink raw reply [flat|nested] 22+ messages in thread
end of thread, other threads:[~2026-07-06 12:00 UTC | newest]
Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-05 20:06 [PATCH RFC 0/6] Speakers for Pixel 3 / 3 XL David Heidelberg via B4 Relay
2026-07-05 20:06 ` [PATCH RFC 1/6] ASoC: qcom: sdm845: Demystify TDM masks a bit David Heidelberg via B4 Relay
2026-07-05 20:19 ` sashiko-bot
2026-07-05 20:06 ` [PATCH RFC 2/6] ASoC: qcom: sdm845: use DSP_A format for TDM codec DAIs David Heidelberg via B4 Relay
2026-07-05 20:18 ` sashiko-bot
2026-07-06 8:33 ` Konrad Dybcio
2026-07-06 9:15 ` David Heidelberg
2026-07-06 9:40 ` Konrad Dybcio
2026-07-05 20:06 ` [PATCH RFC 3/6] ASoC: qcom: sdm845: Use per-speaker RX masks for TDM slot assignment David Heidelberg via B4 Relay
2026-07-05 20:25 ` sashiko-bot
2026-07-05 20:06 ` [PATCH RFC 4/6] ASoC: qcom: sdm845: Set codec dai and component sysclk during startup David Heidelberg via B4 Relay
2026-07-05 20:19 ` sashiko-bot
2026-07-05 20:06 ` [PATCH RFC 5/6] ASoC: cs35l36: Implement set_tdm_slot to program RX slot register David Heidelberg via B4 Relay
2026-07-05 20:20 ` sashiko-bot
2026-07-06 8:52 ` Charles Keepax
2026-07-06 9:11 ` Konrad Dybcio
2026-07-05 20:06 ` [PATCH RFC 6/6] arm64: dts: qcom: sdm845-google: Add basic audio support David Heidelberg via B4 Relay
2026-07-05 20:18 ` sashiko-bot
2026-07-06 9:14 ` Konrad Dybcio
2026-07-06 9:17 ` David Heidelberg
2026-07-06 11:59 ` Konrad Dybcio
2026-07-06 12:00 ` Konrad Dybcio
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox