From ee6367c5607fbf7b1b242fa78aab9c0d368f87ba Mon Sep 17 00:00:00 2001 From: Aditya Bavanari Date: Thu, 12 Mar 2020 12:30:10 +0530 Subject: [PATCH] asoc: Add support for rouleur codec in machine driver Add rouleur codec support in bengal machine driver to create codec entry and invoke mbhc hs detect functions for respective codecs. Correct the logic for headset detection pull up current and volatile registers for digital part of rouleur codec. Change-Id: I22545dc796c215c1501e883796546c97d8ca8698 Signed-off-by: Aditya Bavanari --- asoc/bengal.c | 45 ++++++++++++++++++++++++++-- asoc/codecs/rouleur/rouleur-mbhc.c | 4 +-- asoc/codecs/rouleur/rouleur-regmap.c | 2 -- asoc/codecs/rouleur/rouleur.c | 2 +- asoc/codecs/wcd937x/wcd937x.c | 2 +- 5 files changed, 47 insertions(+), 8 deletions(-) diff --git a/asoc/bengal.c b/asoc/bengal.c index bbf5413be861..22677cb258f8 100644 --- a/asoc/bengal.c +++ b/asoc/bengal.c @@ -31,8 +31,10 @@ #include "asoc/msm-cdc-pinctrl.h" #include "asoc/wcd-mbhc-v2.h" #include "codecs/wcd937x/wcd937x-mbhc.h" +#include "codecs/rouleur/rouleur-mbhc.h" #include "codecs/wsa881x-analog.h" #include "codecs/wcd937x/wcd937x.h" +#include "codecs/rouleur/rouleur.h" #include "codecs/bolero/bolero-cdc.h" #include #include "bengal-port-config.h" @@ -6054,9 +6056,13 @@ static int msm_aux_codec_init(struct snd_soc_component *component) struct snd_info_entry *entry; struct snd_card *card = component->card->snd_card; struct msm_asoc_mach_data *pdata; + struct platform_device *pdev = NULL; + char *data = NULL; + int i = 0; snd_soc_dapm_ignore_suspend(dapm, "EAR"); snd_soc_dapm_ignore_suspend(dapm, "AUX"); + snd_soc_dapm_ignore_suspend(dapm, "LO"); snd_soc_dapm_ignore_suspend(dapm, "HPHL"); snd_soc_dapm_ignore_suspend(dapm, "HPHR"); snd_soc_dapm_ignore_suspend(dapm, "AMIC1"); @@ -6077,14 +6083,49 @@ static int msm_aux_codec_init(struct snd_soc_component *component) } pdata->codec_root = entry; } - wcd937x_info_create_codec_entry(pdata->codec_root, component); + + for (i = 0; i < component->card->num_aux_devs; i++) + { + if (msm_aux_dev[i].name != NULL ) { + if (strstr(msm_aux_dev[i].name, "wsa")) + continue; + } + + if (msm_aux_dev[i].codec_of_node) { + pdev = of_find_device_by_node( + msm_aux_dev[i].codec_of_node); + if (pdev) + data = (char*) of_device_get_match_data( + &pdev->dev); + + if (data != NULL) { + if (!strncmp(data, "wcd937x", + sizeof("wcd937x"))) { + wcd937x_info_create_codec_entry( + pdata->codec_root, component); + break; + } else if (!strncmp(data, "rouleur", + sizeof("rouleur"))) { + rouleur_info_create_codec_entry( + pdata->codec_root, component); + break; + } + } + } + } mbhc_cfg_cal: mbhc_calibration = def_wcd_mbhc_cal(); if (!mbhc_calibration) return -ENOMEM; wcd_mbhc_cfg.calibration = mbhc_calibration; - ret = wcd937x_mbhc_hs_detect(component, &wcd_mbhc_cfg); + if (data != NULL) { + if (!strncmp(data, "wcd937x", sizeof("wcd937x"))) + ret = wcd937x_mbhc_hs_detect(component, &wcd_mbhc_cfg); + else if (!strncmp( data, "rouleur", sizeof("rouleur"))) + ret = rouleur_mbhc_hs_detect(component, &wcd_mbhc_cfg); + } + if (ret) { dev_err(component->dev, "%s: mbhc hs detect failed, err:%d\n", __func__, ret); diff --git a/asoc/codecs/rouleur/rouleur-mbhc.c b/asoc/codecs/rouleur/rouleur-mbhc.c index 3e3ef51140bf..2e1db78df68e 100644 --- a/asoc/codecs/rouleur/rouleur-mbhc.c +++ b/asoc/codecs/rouleur/rouleur-mbhc.c @@ -291,14 +291,14 @@ static void rouleur_mbhc_hph_l_pull_up_control( /* Default pull up current to 2uA */ if (pull_up_cur < I_OFF || pull_up_cur > I_3P0_UA || pull_up_cur == I_DEFAULT) - pull_up_cur = I_2P0_UA; + pull_up_cur = I_3P0_UA; dev_dbg(component->dev, "%s: HS pull up current:%d\n", __func__, pull_up_cur); snd_soc_component_update_bits(component, ROULEUR_ANA_MBHC_PLUG_DETECT_CTL, - 0xC0, pull_up_cur); + 0xC0, pull_up_cur << 6); } static int rouleur_mbhc_request_micbias(struct snd_soc_component *component, diff --git a/asoc/codecs/rouleur/rouleur-regmap.c b/asoc/codecs/rouleur/rouleur-regmap.c index 62502140ee99..39982bd20537 100644 --- a/asoc/codecs/rouleur/rouleur-regmap.c +++ b/asoc/codecs/rouleur/rouleur-regmap.c @@ -134,13 +134,11 @@ static bool rouleur_volatile_register(struct device *dev, unsigned int reg) if ((rouleur_reg_access_analog[ROULEUR_REG(reg)] & RD_REG) && !(rouleur_reg_access_analog[ROULEUR_REG(reg)] & WR_REG)) return true; - return false; if (reg > ROULEUR_DIG_BASE_ADDR && reg < ROULEUR_DIGITAL_REGISTERS_MAX_SIZE) if ((rouleur_reg_access_digital[ROULEUR_REG(reg)] & RD_REG) && !(rouleur_reg_access_digital[ROULEUR_REG(reg)] & WR_REG)) return true; - return false; return 0; } diff --git a/asoc/codecs/rouleur/rouleur.c b/asoc/codecs/rouleur/rouleur.c index 14dfd52f49fb..768b5e3455f2 100644 --- a/asoc/codecs/rouleur/rouleur.c +++ b/asoc/codecs/rouleur/rouleur.c @@ -2392,7 +2392,7 @@ static void rouleur_unbind(struct device *dev) } static const struct of_device_id rouleur_dt_match[] = { - { .compatible = "qcom,rouleur-codec" }, + { .compatible = "qcom,rouleur-codec" , .data = "rouleur" }, {} }; diff --git a/asoc/codecs/wcd937x/wcd937x.c b/asoc/codecs/wcd937x/wcd937x.c index c14480ac6ce9..725fef85b474 100644 --- a/asoc/codecs/wcd937x/wcd937x.c +++ b/asoc/codecs/wcd937x/wcd937x.c @@ -3132,7 +3132,7 @@ static void wcd937x_unbind(struct device *dev) } static const struct of_device_id wcd937x_dt_match[] = { - { .compatible = "qcom,wcd937x-codec" }, + { .compatible = "qcom,wcd937x-codec" , .data = "wcd937x" }, {} };