* [PATCH v2 v2 1/2] ASoC: qcom: sdm845: apply the SLIMbus channel map to wcd934x only
2026-11-05 11:10 [PATCH v2 0/2] soundwire: qcom: Restore and fix set_channel_map support for SWR master Mohammad Rafi Shaik
@ 2026-11-05 11:10 ` Mohammad Rafi Shaik
2026-11-05 11:10 ` [PATCH v2 v2 2/2] soundwire: qcom: Add set_channel_map support to SWR master DAI Mohammad Rafi Shaik
1 sibling, 0 replies; 3+ messages in thread
From: Mohammad Rafi Shaik @ 2026-11-05 11:10 UTC (permalink / raw)
To: Srinivas Kandagatla, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, Vinod Koul, Bard Liao, Pierre-Louis Bossart,
Mohammad Rafi Shaik
Cc: Mohammad Rafi Shaik, Yongqin Liu, Jie Gan, linux-sound,
linux-arm-msm, linux-kernel
On sdm845 boards the SLIMbus backends are described in DT with several
codec DAIs on the same DAI link. The SLIM playback link lists the two
WSA881x speakers and the SoundWire master embedded in wcd934x next to
the wcd934x SLIMbus AIF:
codec {
sound-dai = <&left_spkr>, <&right_spkr>,
<&swm 0>, <&wcd9340 AIF1_PB>;
};
sdm845_dai_init() walks all codec DAIs of such a link and calls
snd_soc_dai_set_channel_map() on each of them with the hardcoded wcd934x
SLIMbus channel numbers, 128..143 for TX and 144..156 for RX. Those
channel numbers are only meaningful for a codec attached over SLIMbus,
and programming them into the SoundWire master DAI configures bogus port
channel masks on it.
So far this has been harmless only because neither the qcom SoundWire
master nor the WSA881x codecs implement .set_channel_map, so the call
returns -ENOTSUPP and is silently ignored. It starts corrupting the
SoundWire port configuration as soon as the master DAI implements that
op, which the next patch does.
The channel map is not the only wcd934x specific setup in this loop. The
codec MCLK rate (WCD934X_DEFAULT_MCLK_RATE) and the headset jack belong
to wcd934x as well and are broadcast to the SoundWire DAIs for the same
reason, relying on them returning -ENOTSUPP.
Match the wcd934x codec explicitly by its driver name and skip the other
codec DAIs of the link, so that each codec only gets the setup that is
meant for it.
The bus type of the DAI device cannot be used to tell these codecs
apart: wcd934x is a SLIMbus device driven by an MFD driver that creates
the ASoC component and the SoundWire master as platform children of it
(wcd934x_devices[] in drivers/mfd/wcd934x.c), so both DAIs live on the
platform bus with the same SLIMbus parent.
Signed-off-by: Mohammad Rafi Shaik <mohammad.rafi.shaik@oss.qualcomm.com>
---
sound/soc/qcom/sdm845.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c
index 85951397cb2b..7137c9c14d8f 100644
--- a/sound/soc/qcom/sdm845.c
+++ b/sound/soc/qcom/sdm845.c
@@ -234,6 +234,19 @@ static void sdm845_jack_free(struct snd_jack *jack)
snd_soc_component_set_jack(component, NULL, NULL);
}
+/*
+ * The SLIMbus backends list the wcd934x codec, the SoundWire master
+ * embedded in wcd934x and its SoundWire speaker codecs as codec DAIs of
+ * the same DAI link. Only the wcd934x DAIs take the SLIMbus channel map
+ * and the codec clock and jack setup below.
+ */
+static bool sdm845_dai_is_wcd934x(struct snd_soc_dai *dai)
+{
+ struct device_driver *drv = dai->dev->driver;
+
+ return drv && !strcmp(drv->name, "wcd934x-codec");
+}
+
static int sdm845_dai_init(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_component *component;
@@ -301,6 +314,9 @@ static int sdm845_dai_init(struct snd_soc_pcm_runtime *rtd)
return 0;
for_each_rtd_codec_dais(rtd, i, codec_dai) {
+ if (!sdm845_dai_is_wcd934x(codec_dai))
+ continue;
+
rval = snd_soc_dai_set_channel_map(codec_dai,
ARRAY_SIZE(tx_ch),
tx_ch,
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH v2 v2 2/2] soundwire: qcom: Add set_channel_map support to SWR master DAI
2026-11-05 11:10 [PATCH v2 0/2] soundwire: qcom: Restore and fix set_channel_map support for SWR master Mohammad Rafi Shaik
2026-11-05 11:10 ` [PATCH v2 v2 1/2] ASoC: qcom: sdm845: apply the SLIMbus channel map to wcd934x only Mohammad Rafi Shaik
@ 2026-11-05 11:10 ` Mohammad Rafi Shaik
1 sibling, 0 replies; 3+ messages in thread
From: Mohammad Rafi Shaik @ 2026-11-05 11:10 UTC (permalink / raw)
To: Srinivas Kandagatla, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, Vinod Koul, Bard Liao, Pierre-Louis Bossart,
Mohammad Rafi Shaik
Cc: Mohammad Rafi Shaik, Yongqin Liu, Jie Gan, linux-sound,
linux-arm-msm, linux-kernel
Add .set_channel_map support to the SWR master DAI so the ASoC
layer can program per-port channel masks used by port_enable().
Fix several issues in channel map handling: clip programming to
available ports to avoid out-of-bounds access, use 1-based port
indexing, and store TX/RX masks separately. Also track per-direction
validity and select the effective mask based on port role to avoid
incorrect precedence and ensure full-width masks are preserved.
Fall back to the SDW stream-provided channel mask when no mapping is
configured, preserving existing behaviour.
Fixes: 7796c97df6b1 ("soundwire: qcom: Add set_channel_map api support")
Reported-by: Yongqin Liu <yongqin.liu@linaro.org>
Closes: https://lore.kernel.org/all/4ddd6855-3817-4dc4-81c4-d8ddaa039865@oss.qualcomm.com/
Reported-by: Jie Gan <jie.gan@oss.qualcomm.com>
Closes: https://lore.kernel.org/all/CAMSo37U1kJq_gK8jiW9iMbhHXtn=Chr7NawiK4fPUPj4kyqH2w@mail.gmail.com/
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/all/33fe8fe7-719a-405a-9ed2-d9f816ce1d57@sabinyo.mountain/
Signed-off-by: Mohammad Rafi Shaik <mohammad.rafi.shaik@oss.qualcomm.com>
---
drivers/soundwire/qcom.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
index 147e55b7a600..c411c3628dee 100644
--- a/drivers/soundwire/qcom.c
+++ b/drivers/soundwire/qcom.c
@@ -162,6 +162,10 @@ struct qcom_swrm_port_config {
u8 word_length;
u8 blk_group_count;
u8 lane_control;
+ u8 tx_ch_mask;
+ u8 rx_ch_mask;
+ bool tx_ch_map_valid;
+ bool rx_ch_map_valid;
};
/*
@@ -1188,12 +1192,28 @@ static int qcom_swrm_port_enable(struct sdw_bus *bus,
{
u32 reg;
struct qcom_swrm_ctrl *ctrl = to_qcom_sdw(bus);
+ struct qcom_swrm_port_config *pcfg;
u32 val;
u32 offset = ctrl->reg_layout[SWRM_OFFSET_DP_PORT_CTRL_BANK];
reg = SWRM_DPn_PORT_CTRL_BANK(offset, enable_ch->port_num, bank);
ctrl->reg_read(ctrl, reg, &val);
+ pcfg = &ctrl->pconfig[enable_ch->port_num];
+
+ mutex_lock(&ctrl->port_lock);
+ if (enable_ch->port_num <= ctrl->num_dout_ports) {
+ if (pcfg->rx_ch_map_valid)
+ enable_ch->ch_mask = pcfg->rx_ch_mask;
+ else if (pcfg->tx_ch_map_valid)
+ enable_ch->ch_mask = pcfg->tx_ch_mask;
+ } else {
+ if (pcfg->tx_ch_map_valid)
+ enable_ch->ch_mask = pcfg->tx_ch_mask;
+ else if (pcfg->rx_ch_map_valid)
+ enable_ch->ch_mask = pcfg->rx_ch_mask;
+ }
+ mutex_unlock(&ctrl->port_lock);
if (enable_ch->enable)
val |= (enable_ch->ch_mask << SWRM_DP_PORT_CTRL_EN_CHAN_SHFT);
@@ -1413,6 +1433,39 @@ static void *qcom_swrm_get_sdw_stream(struct snd_soc_dai *dai, int direction)
return ctrl->sruntime[dai->id];
}
+static int qcom_swrm_set_channel_map(struct snd_soc_dai *dai,
+ unsigned int tx_num, const unsigned int *tx_slot,
+ unsigned int rx_num, const unsigned int *rx_slot)
+{
+ struct qcom_swrm_ctrl *ctrl = dev_get_drvdata(dai->dev);
+ unsigned int max_ports = ctrl->nports;
+ unsigned int i;
+
+ if ((tx_num && !tx_slot) || (rx_num && !rx_slot))
+ return -EINVAL;
+
+ mutex_lock(&ctrl->port_lock);
+ for (i = 1; i <= max_ports; i++) {
+ ctrl->pconfig[i].tx_ch_map_valid = false;
+ ctrl->pconfig[i].rx_ch_map_valid = false;
+
+ /* TX setup */
+ if (tx_slot && i < tx_num) {
+ ctrl->pconfig[i].tx_ch_mask = tx_slot[i];
+ ctrl->pconfig[i].tx_ch_map_valid = true;
+ }
+
+ /* RX setup */
+ if (rx_slot && i < rx_num) {
+ ctrl->pconfig[i].rx_ch_mask = rx_slot[i];
+ ctrl->pconfig[i].rx_ch_map_valid = true;
+ }
+ }
+ mutex_unlock(&ctrl->port_lock);
+
+ return 0;
+}
+
static int qcom_swrm_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
@@ -1449,6 +1502,7 @@ static const struct snd_soc_dai_ops qcom_swrm_pdm_dai_ops = {
.shutdown = qcom_swrm_shutdown,
.set_stream = qcom_swrm_set_sdw_stream,
.get_stream = qcom_swrm_get_sdw_stream,
+ .set_channel_map = qcom_swrm_set_channel_map,
};
static const struct snd_soc_component_driver qcom_swrm_dai_component = {
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread