ASoC: Add mixer control to configure port specific channel map
Add mixer control to configure multi channel map for
each backend separately.
Change-Id: Ie114fa38ee5ce47841cda4cd7f31349905f5c2c7
Signed-off-by: Rohit kumar <rohitkr@codeaurora.org>
diff --git a/asoc/msm-pcm-routing-v2.c b/asoc/msm-pcm-routing-v2.c
index 35b2bdb..417cbc0 100644
--- a/asoc/msm-pcm-routing-v2.c
+++ b/asoc/msm-pcm-routing-v2.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -17445,6 +17445,33 @@
msm_aptx_dec_license_control_put),
};
+static int msm_routing_put_port_chmap_mixer(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ uint8_t channel_map[PCM_FORMAT_MAX_NUM_CHANNEL];
+ uint32_t be_idx = ucontrol->value.integer.value[0];
+ int i;
+
+ for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL; i++) {
+ channel_map[i] = (char)(ucontrol->value.integer.value[i + 1]);
+ if (channel_map[i] > PCM_MAX_CHMAP_ID) {
+ pr_err("%s: Invalid channel map %d\n",
+ __func__, channel_map[i]);
+ return -EINVAL;
+ }
+ }
+ adm_set_port_multi_ch_map(channel_map, msm_bedais[be_idx].port_id);
+
+ return 0;
+}
+
+static const struct snd_kcontrol_new port_multi_channel_map_mixer_controls[] = {
+ SOC_SINGLE_MULTI_EXT("Backend Device Channel Map", SND_SOC_NOPM, 0,
+ MSM_BACKEND_DAI_MAX, 0,
+ PCM_FORMAT_MAX_NUM_CHANNEL + 1, NULL,
+ msm_routing_put_port_chmap_mixer),
+};
+
static int msm_routing_be_dai_name_table_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
{
@@ -17636,6 +17663,10 @@
ARRAY_SIZE(aptx_dec_license_controls));
snd_soc_add_platform_controls(platform, stereo_channel_reverse_control,
ARRAY_SIZE(stereo_channel_reverse_control));
+ snd_soc_add_platform_controls(platform,
+ port_multi_channel_map_mixer_controls,
+ ARRAY_SIZE(port_multi_channel_map_mixer_controls));
+
return 0;
}
diff --git a/include/dsp/apr_audio-v2.h b/include/dsp/apr_audio-v2.h
index d313d64..dbeb6de 100644
--- a/include/dsp/apr_audio-v2.h
+++ b/include/dsp/apr_audio-v2.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -4306,9 +4306,14 @@
/* Rear left of center. */
#define PCM_CHANNEL_RLC 15
-/* Rear right of center. */
+/* Rear right of center. Update PCM_MAX_CHMAP_ID when
+ * this list is extended.
+ */
#define PCM_CHANNEL_RRC 16
+/* Max valid channel map index */
+#define PCM_MAX_CHMAP_ID PCM_CHANNEL_RRC
+
#define PCM_FORMAT_MAX_NUM_CHANNEL 8
#define ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V2 0x00010DA5