diff options
author | Walter Yang <yandongy@codeaurora.org> | 2016-07-18 18:28:08 -0700 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2016-08-18 19:59:20 -0700 |
commit | fd30be8fdb4d8134da58e451636139b6f6860f87 (patch) | |
tree | 107fbec5ce322e11cb5433c96ea4608bb2ec65dd | |
parent | 30a5b12e27de61cf7b00778dc0147badfae5979c (diff) |
ASoC: wcd-mbhc: add kcontrol to get hph type for wcd934x
Add kcontrol in wcd934x mbhc driver so that userspace can get the
hph type.
Change-Id: I9ff0a8a5c968c9b8a085fbe79ab9a690206df564
Signed-off-by: Walter Yang <yandongy@codeaurora.org>
-rw-r--r-- | sound/soc/codecs/wcd934x/wcd934x-mbhc.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/sound/soc/codecs/wcd934x/wcd934x-mbhc.c b/sound/soc/codecs/wcd934x/wcd934x-mbhc.c index 22712d163c6f..20f3043656e5 100644 --- a/sound/soc/codecs/wcd934x/wcd934x-mbhc.c +++ b/sound/soc/codecs/wcd934x/wcd934x-mbhc.c @@ -821,6 +821,31 @@ static struct regulator *tavil_codec_find_ondemand_regulator( return NULL; } +static int tavil_get_hph_type(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(codec); + struct wcd_mbhc *mbhc; + + if (!wcd934x_mbhc) { + dev_err(codec->dev, "%s: mbhc not initialized!\n", __func__); + return -EINVAL; + } + + mbhc = &wcd934x_mbhc->wcd_mbhc; + + ucontrol->value.integer.value[0] = (u32) mbhc->hph_type; + dev_dbg(codec->dev, "%s: hph_type = %u\n", __func__, mbhc->hph_type); + + return 0; +} + +static const struct snd_kcontrol_new hph_type_detect_controls[] = { + SOC_SINGLE_EXT("HPH Type", 0, 0, UINT_MAX, 0, + tavil_get_hph_type, NULL), +}; + /* * tavil_mbhc_hs_detect: starts mbhc insertion/removal functionality * @codec: handle to snd_soc_codec * @@ -900,6 +925,9 @@ int tavil_mbhc_init(struct wcd934x_mbhc **mbhc, struct snd_soc_codec *codec, 0; } + snd_soc_add_codec_controls(codec, hph_type_detect_controls, + ARRAY_SIZE(hph_type_detect_controls)); + snd_soc_update_bits(codec, WCD934X_MBHC_NEW_CTL_1, 0x04, 0x04); snd_soc_update_bits(codec, WCD934X_MBHC_CTL_BCS, 0x01, 0x01); |