[PATCH v3 2/3] ASoC: qcom: common: Add SNDRV channel map to Q6 slot helper
From: Abel Vesa
Date: Thu Nov 05 2026 - 11:15:51 EST
Add a small helper that converts ALSA channel map positions to the Q6 PCM
channel identifiers used by Qualcomm machine drivers.
The mapping is useful beyond a single machine driver when exposing
writable channel-map controls.
Signed-off-by: Abel Vesa <abel.vesa@xxxxxxxxxxxxxxxx>
---
sound/soc/qcom/common.c | 30 ++++++++++++++++++++++++++++++
sound/soc/qcom/common.h | 1 +
2 files changed, 31 insertions(+)
diff --git a/sound/soc/qcom/common.c b/sound/soc/qcom/common.c
index 83b745f617a8..29b2df21b765 100644
--- a/sound/soc/qcom/common.c
+++ b/sound/soc/qcom/common.c
@@ -6,7 +6,9 @@
#include <linux/module.h>
#include <sound/jack.h>
#include <linux/input-event-codes.h>
+#include <sound/pcm.h>
#include "common.h"
+#include "qdsp6/q6dsp-common.h"
#define NAME_SIZE 32
@@ -327,6 +329,34 @@ int qcom_snd_parse_of(struct snd_soc_card *card)
}
EXPORT_SYMBOL_GPL(qcom_snd_parse_of);
+int qcom_snd_chmap_to_q6(unsigned int pos)
+{
+ switch (pos) {
+ case SNDRV_CHMAP_FL:
+ return PCM_CHANNEL_FL;
+ case SNDRV_CHMAP_FR:
+ return PCM_CHANNEL_FR;
+ case SNDRV_CHMAP_MONO:
+ case SNDRV_CHMAP_FC:
+ return PCM_CHANNEL_FC;
+ case SNDRV_CHMAP_LFE:
+ return PCM_CHANNEL_LFE;
+ case SNDRV_CHMAP_RL:
+ return PCM_CHANNEL_LB;
+ case SNDRV_CHMAP_RR:
+ return PCM_CHANNEL_RB;
+ case SNDRV_CHMAP_SL:
+ return PCM_CHANNEL_LS;
+ case SNDRV_CHMAP_SR:
+ return PCM_CHANNEL_RS;
+ case SNDRV_CHMAP_RC:
+ return PCM_CHANNEL_CS;
+ default:
+ return -EINVAL;
+ }
+}
+EXPORT_SYMBOL_GPL(qcom_snd_chmap_to_q6);
+
static struct snd_soc_jack_pin qcom_headset_jack_pins[] = {
/* Headset */
{
diff --git a/sound/soc/qcom/common.h b/sound/soc/qcom/common.h
index 37b185a4968f..2b1d30230d77 100644
--- a/sound/soc/qcom/common.h
+++ b/sound/soc/qcom/common.h
@@ -31,6 +31,7 @@ int qcom_snd_wcd_jack_setup(struct snd_soc_pcm_runtime *rtd,
struct snd_soc_jack *jack, bool *jack_setup);
int qcom_snd_dp_jack_setup(struct snd_soc_pcm_runtime *rtd,
struct snd_soc_jack *dp_jack, int id);
+int qcom_snd_chmap_to_q6(unsigned int pos);
#endif
--
2.54.0