ASoC: msm: add mbhc support for wcd934x

Add wcd934x mbhc support in machine driver, so that headset
accessories can be detected properly.

Change-Id: I0a1ec6570848b8164cf46f8365b18d4c488f78f6
Signed-off-by: Walter Yang <yandongy@codeaurora.org>
This commit is contained in:
Walter Yang 2016-07-07 09:43:23 -07:00 committed by Gerrit - the friendly Code Review server
parent 5962d6e409
commit 031202970b

View file

@ -36,6 +36,7 @@
#include "qdsp6v2/msm-pcm-routing-v2.h" #include "qdsp6v2/msm-pcm-routing-v2.h"
#include "../codecs/wcd9335.h" #include "../codecs/wcd9335.h"
#include "../codecs/wcd934x/wcd934x.h" #include "../codecs/wcd934x/wcd934x.h"
#include "../codecs/wcd934x/wcd934x-mbhc.h"
#include "../codecs/wsa881x.h" #include "../codecs/wsa881x.h"
#define DRV_NAME "msmcobalt-asoc-snd" #define DRV_NAME "msmcobalt-asoc-snd"
@ -222,6 +223,7 @@ static struct msm_asoc_wcd93xx_codec msm_codec_fn;
static void *adsp_state_notifier; static void *adsp_state_notifier;
static void *def_tasha_mbhc_cal(void); static void *def_tasha_mbhc_cal(void);
static void *def_tavil_mbhc_cal(void);
static int msm_snd_enable_codec_ext_clk(struct snd_soc_codec *codec, static int msm_snd_enable_codec_ext_clk(struct snd_soc_codec *codec,
int enable, bool dapm); int enable, bool dapm);
static int msm_wsa881x_init(struct snd_soc_component *component); static int msm_wsa881x_init(struct snd_soc_component *component);
@ -1815,6 +1817,40 @@ static void *def_tasha_mbhc_cal(void)
return tasha_wcd_cal; return tasha_wcd_cal;
} }
static void *def_tavil_mbhc_cal(void)
{
void *tavil_wcd_cal;
struct wcd_mbhc_btn_detect_cfg *btn_cfg;
u16 *btn_high;
tavil_wcd_cal = kzalloc(WCD_MBHC_CAL_SIZE(WCD_MBHC_DEF_BUTTONS,
WCD9XXX_MBHC_DEF_RLOADS), GFP_KERNEL);
if (!tavil_wcd_cal)
return NULL;
#define S(X, Y) ((WCD_MBHC_CAL_PLUG_TYPE_PTR(tavil_wcd_cal)->X) = (Y))
S(v_hs_max, 1600);
#undef S
#define S(X, Y) ((WCD_MBHC_CAL_BTN_DET_PTR(tavil_wcd_cal)->X) = (Y))
S(num_btn, WCD_MBHC_DEF_BUTTONS);
#undef S
btn_cfg = WCD_MBHC_CAL_BTN_DET_PTR(tavil_wcd_cal);
btn_high = ((void *)&btn_cfg->_v_btn_low) +
(sizeof(btn_cfg->_v_btn_low[0]) * btn_cfg->num_btn);
btn_high[0] = 75;
btn_high[1] = 150;
btn_high[2] = 237;
btn_high[3] = 500;
btn_high[4] = 500;
btn_high[5] = 500;
btn_high[6] = 500;
btn_high[7] = 500;
return tavil_wcd_cal;
}
static int msm_snd_hw_params(struct snd_pcm_substream *substream, static int msm_snd_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params) struct snd_pcm_hw_params *params)
{ {
@ -3270,6 +3306,43 @@ err_pcm_runtime:
return ret; return ret;
} }
static int msm_snd_card_tavil_late_probe(struct snd_soc_card *card)
{
const char *be_dl_name = LPASS_BE_SLIMBUS_0_RX;
struct snd_soc_pcm_runtime *rtd;
int ret = 0;
void *mbhc_calibration;
rtd = snd_soc_get_pcm_runtime(card, be_dl_name);
if (!rtd) {
dev_err(card->dev,
"%s: snd_soc_get_pcm_runtime for %s failed!\n",
__func__, be_dl_name);
ret = -EINVAL;
goto err_pcm_runtime;
}
mbhc_calibration = def_tavil_mbhc_cal();
if (!mbhc_calibration) {
ret = -ENOMEM;
goto err_mbhc_cal;
}
wcd_mbhc_cfg.calibration = mbhc_calibration;
ret = tavil_mbhc_hs_detect(rtd->codec, &wcd_mbhc_cfg);
if (ret) {
dev_err(card->dev, "%s: mbhc hs detect failed, err:%d\n",
__func__, ret);
goto err_hs_detect;
}
return 0;
err_hs_detect:
kfree(mbhc_calibration);
err_mbhc_cal:
err_pcm_runtime:
return ret;
}
struct snd_soc_card snd_soc_card_tasha_msm = { struct snd_soc_card snd_soc_card_tasha_msm = {
.name = "msmcobalt-tasha-snd-card", .name = "msmcobalt-tasha-snd-card",
.late_probe = msm_snd_card_late_probe, .late_probe = msm_snd_card_late_probe,
@ -3277,6 +3350,7 @@ struct snd_soc_card snd_soc_card_tasha_msm = {
struct snd_soc_card snd_soc_card_tavil_msm = { struct snd_soc_card snd_soc_card_tavil_msm = {
.name = "msmcobalt-tavil-snd-card", .name = "msmcobalt-tavil-snd-card",
.late_probe = msm_snd_card_tavil_late_probe,
}; };
static int msm_populate_dai_link_component_of_node( static int msm_populate_dai_link_component_of_node(