From 07b8dc90a9633c53ae5e237fd9db5731086d4657 Mon Sep 17 00:00:00 2001 From: Mangesh Kunchamwar Date: Mon, 16 Jul 2018 19:46:25 +0530 Subject: [PATCH] asoc: Update mixer control for island mode setting Fix overwriting of port ID in island mode mixer control. Change-Id: Ibf650e94519ffde7655e14a88ccc9042b3a3544b Signed-off-by: Mangesh Kunchamwar --- asoc/msm-dai-q6-v2.c | 57 +++++++++++++++++++++++++----------------- dsp/q6afe.c | 26 +++++++++++++++++++ include/dsp/q6afe-v2.h | 1 + 3 files changed, 61 insertions(+), 23 deletions(-) diff --git a/asoc/msm-dai-q6-v2.c b/asoc/msm-dai-q6-v2.c index 2c1eea17ff4a..529f0df9bb2a 100644 --- a/asoc/msm-dai-q6-v2.c +++ b/asoc/msm-dai-q6-v2.c @@ -206,7 +206,6 @@ struct msm_dai_q6_dai_data { u16 afe_in_bitformat; struct afe_enc_config enc_config; struct afe_dec_config dec_config; - u32 island_enable; union afe_port_config port_config; u16 vi_feed_mono; }; @@ -1131,36 +1130,32 @@ static int msm_dai_q6_dai_auxpcm_remove(struct snd_soc_dai *dai) static int msm_dai_q6_island_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data; int value = ucontrol->value.integer.value[0]; - u16 port_id = ((struct soc_enum *) kcontrol->private_value)->reg; + u16 port_id = (u16)kcontrol->private_value; - dai_data->island_enable = value; pr_debug("%s: island mode = %d\n", __func__, value); - afe_set_island_mode_cfg(port_id, dai_data->island_enable); + afe_set_island_mode_cfg(port_id, value); return 0; } static int msm_dai_q6_island_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data; + int value; + u16 port_id = (u16)kcontrol->private_value; - ucontrol->value.integer.value[0] = dai_data->island_enable; + afe_get_island_mode_cfg(port_id, &value); + ucontrol->value.integer.value[0] = value; return 0; } -static struct snd_kcontrol_new island_config_controls[] = { - { - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "?", - .info = snd_ctl_boolean_mono_info, - .get = msm_dai_q6_island_mode_get, - .put = msm_dai_q6_island_mode_put, - .private_value = SOC_SINGLE_VALUE(0, 0, 1, 0, 0) - }, -}; +static void island_mx_ctl_private_free(struct snd_kcontrol *kcontrol) +{ + struct snd_kcontrol_new *knew = snd_kcontrol_chip(kcontrol); + + kfree(knew); +} static int msm_dai_q6_add_island_mx_ctls(struct snd_card *card, const char *dai_name, @@ -1170,6 +1165,8 @@ static int msm_dai_q6_add_island_mx_ctls(struct snd_card *card, char *mixer_str = NULL; int dai_str_len = 0, ctl_len = 0; int rc = 0; + struct snd_kcontrol_new *knew = NULL; + struct snd_kcontrol *kctl = NULL; dai_str_len = strlen(dai_name) + 1; @@ -1180,12 +1177,26 @@ static int msm_dai_q6_add_island_mx_ctls(struct snd_card *card, return -ENOMEM; snprintf(mixer_str, ctl_len, "%s %s", dai_name, mx_ctl_name); - island_config_controls[0].name = mixer_str; - ((struct soc_enum *) island_config_controls[0].private_value)->reg - = dai_id; - rc = snd_ctl_add(card, - snd_ctl_new1(&island_config_controls[0], - dai_data)); + + knew = kzalloc(sizeof(struct snd_kcontrol_new), GFP_KERNEL); + if (!knew) { + kfree(mixer_str); + return -ENOMEM; + } + knew->iface = SNDRV_CTL_ELEM_IFACE_MIXER; + knew->info = snd_ctl_boolean_mono_info; + knew->get = msm_dai_q6_island_mode_get; + knew->put = msm_dai_q6_island_mode_put; + knew->name = mixer_str; + knew->private_value = dai_id; + kctl = snd_ctl_new1(knew, knew); + if (!kctl) { + kfree(knew); + kfree(mixer_str); + return -ENOMEM; + } + kctl->private_free = island_mx_ctl_private_free; + rc = snd_ctl_add(card, kctl); if (rc < 0) pr_err("%s: err add config ctl, DAI = %s\n", __func__, dai_name); diff --git a/dsp/q6afe.c b/dsp/q6afe.c index 03fbdb76dc19..53a9c9beed08 100644 --- a/dsp/q6afe.c +++ b/dsp/q6afe.c @@ -3048,6 +3048,25 @@ void afe_set_vad_cfg(u32 vad_enable, u32 preroll_config, } EXPORT_SYMBOL(afe_set_vad_cfg); +/** + * afe_get_island_mode_cfg - + * get island mode configuration + * + * @port_id: AFE port id number + * @enable_flag: Enable or Disable + * + */ +void afe_get_island_mode_cfg(u16 port_id, u32 *enable_flag) +{ + uint16_t port_index; + + if (enable_flag) { + port_index = afe_get_port_index(port_id); + *enable_flag = this_afe.island_mode[port_index]; + } +} +EXPORT_SYMBOL(afe_get_island_mode_cfg); + /** * afe_set_island_mode_cfg - * set island mode configuration @@ -6239,6 +6258,13 @@ int afe_validate_port(u16 port_id) case AFE_PORT_ID_INT4_MI2S_TX: case AFE_PORT_ID_INT5_MI2S_TX: case AFE_PORT_ID_INT6_MI2S_TX: + case AFE_PORT_ID_WSA_CODEC_DMA_RX_0: + case AFE_PORT_ID_WSA_CODEC_DMA_TX_0: + case AFE_PORT_ID_WSA_CODEC_DMA_RX_1: + case AFE_PORT_ID_WSA_CODEC_DMA_TX_1: + case AFE_PORT_ID_WSA_CODEC_DMA_TX_2: + case AFE_PORT_ID_VA_CODEC_DMA_TX_0: + case AFE_PORT_ID_VA_CODEC_DMA_TX_1: { ret = 0; break; diff --git a/include/dsp/q6afe-v2.h b/include/dsp/q6afe-v2.h index e39d0b89d578..f94ede4b7927 100644 --- a/include/dsp/q6afe-v2.h +++ b/include/dsp/q6afe-v2.h @@ -342,6 +342,7 @@ void afe_set_cal_mode(u16 port_id, enum afe_cal_mode afe_cal_mode); void afe_set_vad_cfg(u32 vad_enable, u32 preroll_config, u32 port_id); void afe_set_island_mode_cfg(u16 port_id, u32 enable_flag); +void afe_get_island_mode_cfg(u16 port_id, u32 *enable_flag); int afe_port_start(u16 port_id, union afe_port_config *afe_config, u32 rate); int afe_port_start_v2(u16 port_id, union afe_port_config *afe_config,