[PATCH v2 1/2] ASoC: qcom: common: Add SNDRV channel map to Q6 slot helper
Abel Vesa <[email protected]>
| Newsgroups | org.kernel.vger.linux-sound,org.kernel.vger.linux-arm-msm,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <20260724-b4-sound-qcom-x1e80100-allow-ucm-channel-map-v2-1-2ca3c1250018@oss.qualcomm.com> |
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. Assisted-by: Codex:GPT-5.5 Signed-off-by: Abel Vesa <[email protected]> --- 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 e4ff247ea47f..bba0cff6f4cd 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 @@ -172,6 +174,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 ee6662885593..1e8edc7e1b87 100644 --- a/sound/soc/qcom/common.h +++ b/sound/soc/qcom/common.h @@ -14,6 +14,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