From 7be67e5fba5223e2ec40a34dad81ccefab2d67a3 Mon Sep 17 00:00:00 2001 From: Vatsal Bucha Date: Thu, 12 Oct 2017 09:14:03 +0530 Subject: [PATCH] ASoC: wcd: set analog gain mode to manual when compander is off If compander DRE isn't turned on, ensure analog gain mode is set to manual mode. This also resolves low volume at one channel. CRs-Fixed: 2102126 Change-Id: Id29b7055fe4f7fa7b3853c26770df38d10539d8c Signed-off-by: Vatsal Bucha --- asoc/codecs/sdm660_cdc/msm-analog-cdc.c | 13 +++++++++++++ asoc/codecs/sdm660_cdc/msm-analog-cdc.h | 1 + asoc/codecs/sdm660_cdc/msm-digital-cdc.c | 7 +++++++ asoc/codecs/sdm660_cdc/msm-digital-cdc.h | 2 ++ 4 files changed, 23 insertions(+) diff --git a/asoc/codecs/sdm660_cdc/msm-analog-cdc.c b/asoc/codecs/sdm660_cdc/msm-analog-cdc.c index 623303c3adca..c292b9116f50 100644 --- a/asoc/codecs/sdm660_cdc/msm-analog-cdc.c +++ b/asoc/codecs/sdm660_cdc/msm-analog-cdc.c @@ -2620,6 +2620,18 @@ static int msm_anlg_cdc_codec_enable_micbias(struct snd_soc_dapm_widget *w, return 0; } +static void set_compander_mode(void *handle, int val) +{ + struct sdm660_cdc_priv *handle_cdc = handle; + struct snd_soc_codec *codec = handle_cdc->codec; + + if (get_codec_version(handle_cdc) >= DIANGU) { + snd_soc_update_bits(codec, + MSM89XX_PMIC_ANALOG_RX_COM_BIAS_DAC, + 0x08, val); + }; +} + static void update_clkdiv(void *handle, int val) { struct sdm660_cdc_priv *handle_cdc = handle; @@ -4653,6 +4665,7 @@ static int msm_anlg_cdc_probe(struct platform_device *pdev) BLOCKING_INIT_NOTIFIER_HEAD(&sdm660_cdc->notifier_mbhc); sdm660_cdc->dig_plat_data.handle = (void *) sdm660_cdc; + sdm660_cdc->dig_plat_data.set_compander_mode = set_compander_mode; sdm660_cdc->dig_plat_data.update_clkdiv = update_clkdiv; sdm660_cdc->dig_plat_data.get_cdc_version = get_cdc_version; sdm660_cdc->dig_plat_data.register_notifier = diff --git a/asoc/codecs/sdm660_cdc/msm-analog-cdc.h b/asoc/codecs/sdm660_cdc/msm-analog-cdc.h index 9591487b57b8..3ee3dee743d5 100644 --- a/asoc/codecs/sdm660_cdc/msm-analog-cdc.h +++ b/asoc/codecs/sdm660_cdc/msm-analog-cdc.h @@ -168,6 +168,7 @@ struct msm_dig_ctrl_data { struct msm_dig_ctrl_platform_data { void *handle; + void (*set_compander_mode)(void *handle, int val); void (*update_clkdiv)(void *handle, int val); int (*get_cdc_version)(void *handle); int (*register_notifier)(void *handle, diff --git a/asoc/codecs/sdm660_cdc/msm-digital-cdc.c b/asoc/codecs/sdm660_cdc/msm-digital-cdc.c index 4ab203750303..00a969935d1a 100644 --- a/asoc/codecs/sdm660_cdc/msm-digital-cdc.c +++ b/asoc/codecs/sdm660_cdc/msm-digital-cdc.c @@ -231,6 +231,12 @@ static int msm_dig_cdc_codec_config_compander(struct snd_soc_codec *codec, } if (SND_SOC_DAPM_EVENT_ON(event)) { + /* compander is not enabled */ + if (!dig_cdc->comp_enabled[interp_n]) { + dig_cdc->set_compander_mode(dig_cdc->handle, 0x00); + return 0; + }; + dig_cdc->set_compander_mode(dig_cdc->handle, 0x08); /* Enable Compander Clock */ snd_soc_update_bits(codec, MSM89XX_CDC_CORE_COMP0_B2_CTL, 0x0F, 0x09); @@ -2080,6 +2086,7 @@ static int msm_dig_cdc_probe(struct platform_device *pdev) msm_dig_cdc->dig_base, &msm_digital_regmap_config); msm_dig_cdc->update_clkdiv = pdata->update_clkdiv; + msm_dig_cdc->set_compander_mode = pdata->set_compander_mode; msm_dig_cdc->get_cdc_version = pdata->get_cdc_version; msm_dig_cdc->handle = pdata->handle; msm_dig_cdc->register_notifier = pdata->register_notifier; diff --git a/asoc/codecs/sdm660_cdc/msm-digital-cdc.h b/asoc/codecs/sdm660_cdc/msm-digital-cdc.h index cb6cfe2f538e..7abb2045b79c 100644 --- a/asoc/codecs/sdm660_cdc/msm-digital-cdc.h +++ b/asoc/codecs/sdm660_cdc/msm-digital-cdc.h @@ -55,6 +55,7 @@ struct msm_dig_priv { u32 mute_mask; int dapm_bias_off; void *handle; + void (*set_compander_mode)(void *handle, int val); void (*update_clkdiv)(void *handle, int val); int (*get_cdc_version)(void *handle); int (*register_notifier)(void *handle, @@ -65,6 +66,7 @@ struct msm_dig_priv { struct dig_ctrl_platform_data { void *handle; + void (*set_compander_mode)(void *handle, int val); void (*update_clkdiv)(void *handle, int val); int (*get_cdc_version)(void *handle); int (*register_notifier)(void *handle,