From: sashiko-bot@kernel.org
To: "Abel Vesa" <abel.vesa@oss.qualcomm.com>
Cc: linux-sound@vger.kernel.org
Subject: Re: [PATCH v4 4/4] ASoC: qcom: x1e80100: Allow userspace WSA RX chmap override
Date: Tue, 24 Nov 2026 11:19:47 +0000 [thread overview]
Message-ID: <sashiko-outbox-231036@kernel.org> (raw)
In-Reply-To: <20261124-b4-sound-qcom-x1e80100-allow-ucm-channel-map-v4-4-1197ac8eacd2@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] ASoC: qcom: x1e80100: wsa_prepared left true on
x1e80100_snd_prepare() error
- [Medium] ASoC: qcom: x1e80100: 6-channel WSA playback fails in
AudioReach prepare
- [Low] ASoC: qcom: x1e80100: unvalidated 5-channel map in
x1e80100_wsa_chmap_ctl_put()
--
commit 4f20a2b7a20905953c2178f9804669a43500020c
Author: Abel Vesa <abel.vesa@oss.qualcomm.com>
ASoC: qcom: x1e80100: Allow userspace WSA RX chmap override
This commit adds writable ALSA channel map controls for the WSA RX
backends so userspace can override the default channel slot mapping, and
extends the maximum WSA channel count to six for Glymur.
> diff --git a/sound/soc/qcom/x1e80100.c b/sound/soc/qcom/x1e80100.c
> index c927672eaede7..4fe86ec062c40 100644
> --- a/sound/soc/qcom/x1e80100.c
> +++ b/sound/soc/qcom/x1e80100.c
> @@ -15,14 +16,151 @@
> #include "qdsp6/q6dsp-common.h"
> #include "sdw.h"
>
> +#define X1E80100_WSA_MAX_CHANNELS 6
> +#define X1E80100_WSA_PORTS 2
> +
> struct x1e80100_snd_data {
> bool stream_prepared[AFE_PORT_MAX];
> struct snd_soc_card *card;
> struct snd_soc_jack jack;
> struct snd_soc_jack dp_jack[8];
> bool jack_setup;
> + /* Protects the WSA channel map state below */
> + spinlock_t wsa_chmap_lock;
> + /* Userspace-selected SNDRV_CHMAP_* positions, 0 means unset */
> + unsigned int wsa_chmap[X1E80100_WSA_PORTS][X1E80100_WSA_MAX_CHANNELS];
> + /* Channel count of the last prepared stream */
> + unsigned int wsa_channels[X1E80100_WSA_PORTS];
> + bool wsa_prepared[X1E80100_WSA_PORTS];
> +};
> +
> +/* Default WSA RX channel maps, indexed by channel count */
> +static const unsigned int
> +x1e80100_wsa_default_chmap[X1E80100_WSA_MAX_CHANNELS + 1][X1E80100_WSA_MAX_CHANNELS] = {
> + [1] = { SNDRV_CHMAP_MONO },
> + [2] = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR },
> + [3] = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_FC },
> + [4] = { SNDRV_CHMAP_FL, SNDRV_CHMAP_RL, SNDRV_CHMAP_FR, SNDRV_CHMAP_RR },
> + [6] = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_RL,
> + SNDRV_CHMAP_RR, SNDRV_CHMAP_FC, SNDRV_CHMAP_LFE },
> };
[Severity: Medium]
Can a 6-channel WSA playback stream succeed on AudioReach?
x1e80100_snd_build_wsa_slots() only uses a 6-channel map when
substream->runtime->channels is 6, and x1e80100_be_hw_params_fixup() leaves
the channel count unchanged for WSA_CODEC_DMA_RX_0 and WSA_CODEC_DMA_RX_1.
When a 6-channel stream is prepared, q6apm_dai_prepare() and
q6apm_lpass_dai_prepare() pass num_channels == 6 into
audioreach_shmem_set_media_format() and audioreach_pcm_set_media_format(),
both of which reject num_channels > 4 with -EINVAL (and
audioreach_set_default_channel_mapping() only populates 1, 2 and 4
channels):
sound/soc/qcom/qdsp6/audioreach.c:audioreach_pcm_set_media_format() {
...
if (num_channels > 4) {
dev_err(graph->dev, "Error: Invalid channels (%d)!\n", num_channels);
return -EINVAL;
}
...
}
[ ... ]
> +static int x1e80100_wsa_chmap_ctl_put(struct snd_kcontrol *kcontrol,
> + struct snd_ctl_elem_value *ucontrol)
> +{
> + unsigned int map[X1E80100_WSA_MAX_CHANNELS];
> + struct x1e80100_snd_data *data;
> + bool changed = false;
> + int i, idx;
> +
> + data = x1e80100_wsa_chmap_kcontrol_data(kcontrol, &idx);
> + if (!data)
> + return -EINVAL;
> +
> + for (i = 0; i < X1E80100_WSA_MAX_CHANNELS; i++) {
> + map[i] = ucontrol->value.integer.value[i];
> +
> + if (map[i] && qcom_snd_chmap_to_q6(map[i]) < 0)
> + return -EINVAL;
> +
> + /* Unset positions are allowed only as a suffix of the map */
> + if (map[i] && i && !map[i - 1])
> + return -EINVAL;
> + }
[Severity: Low]
Should x1e80100_wsa_chmap_ctl_put() reject a 5-channel map?
Because x1e80100_wsa_default_chmap[5][0] is 0,
x1e80100_snd_build_wsa_slots() rejects 5-channel streams with -EINVAL and
falls back to the default map for any other channel count. However,
x1e80100_wsa_chmap_ctl_put() accepts and stores a 5-element map, causing
x1e80100_wsa_chmap_ctl_get() to report a map that can never be applied.
[ ... ]
> @@ -109,29 +247,43 @@ static int x1e80100_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
> return 0;
> }
>
> -static int x1e80100_snd_hw_map_channels(unsigned int *ch_map, int num)
> +static int x1e80100_snd_build_wsa_slots(struct x1e80100_snd_data *data,
> + unsigned int dai_id,
> + unsigned int channels,
> + unsigned int *rx_slot)
> {
> + unsigned int map[X1E80100_WSA_MAX_CHANNELS];
> + unsigned int i, set = 0;
> + int idx;
> +
> + idx = x1e80100_wsa_port_index(dai_id);
> + if (idx < 0)
> + return idx;
> +
> + if (channels > X1E80100_WSA_MAX_CHANNELS ||
> + !x1e80100_wsa_default_chmap[channels][0])
> return -EINVAL;
> +
> + scoped_guard(spinlock, &data->wsa_chmap_lock) {
> + memcpy(map, data->wsa_chmap[idx], sizeof(map));
> + data->wsa_channels[idx] = channels;
> + data->wsa_prepared[idx] = true;
> + }
[ ... ]
> @@ -143,13 +295,14 @@ static int x1e80100_snd_prepare(struct snd_pcm_substream *substream)
> struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
> struct x1e80100_snd_data *data = snd_soc_card_get_drvdata(rtd->card);
> unsigned int channels = substream->runtime->channels;
> - unsigned int rx_slot[4];
> + unsigned int rx_slot[X1E80100_WSA_MAX_CHANNELS];
> int ret;
>
> switch (cpu_dai->id) {
> case WSA_CODEC_DMA_RX_0:
> case WSA_CODEC_DMA_RX_1:
> - ret = x1e80100_snd_hw_map_channels(rx_slot, channels);
> + ret = x1e80100_snd_build_wsa_slots(data, cpu_dai->id,
> + channels, rx_slot);
> if (ret)
> return ret;
>
> ret = snd_soc_dai_set_channel_map(cpu_dai, 0, NULL,
> channels, rx_slot);
> if (ret)
> return ret;
> break;
> default:
> break;
> }
>
> return qcom_snd_sdw_prepare(substream, &data->stream_prepared[cpu_dai->id]);
> }
[Severity: Medium]
Does x1e80100_snd_prepare() leave data->wsa_prepared[idx] set to true if
snd_soc_dai_set_channel_map() or qcom_snd_sdw_prepare() fails?
dpcm_fe_dai_prepare() does not call dpcm_be_dai_hw_free() when backend
prepare fails, so data->wsa_prepared[idx] stays true while the stream
remains in SNDRV_PCM_STATE_SETUP, and subsequent writes to the channel map
control via x1e80100_wsa_chmap_ctl_put() fail with -EBUSY until hw_free or
close.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124-b4-sound-qcom-x1e80100-allow-ucm-channel-map-v4-0-1197ac8eacd2@oss.qualcomm.com?part=4
prev parent reply other threads:[~2026-11-24 11:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 10:57 [PATCH v4 0/4] ASoC: qcom: x1e80100: allow WSA channel map override Abel Vesa
2026-11-24 10:57 ` [PATCH v4 1/4] ALSA: pcm: Add snd_pcm_add_named_chmap_ctls() for custom control names Abel Vesa
2026-11-24 10:57 ` [PATCH v4 2/4] ALSA: pcm: Report writable chmap controls as variable Abel Vesa
2026-11-24 10:57 ` [PATCH v4 3/4] ASoC: qcom: common: Add SNDRV channel map to Q6 slot helper Abel Vesa
2026-11-24 10:57 ` [PATCH v4 4/4] ASoC: qcom: x1e80100: Allow userspace WSA RX chmap override Abel Vesa
2026-11-24 11:19 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-231036@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=abel.vesa@oss.qualcomm.com \
--cc=linux-sound@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox