Merge "ASoC: wcd934x: Add impedance detection controls"
This commit is contained in:
commit
ef7b2af68d
1 changed files with 32 additions and 0 deletions
|
@ -870,11 +870,41 @@ static int tavil_get_hph_type(struct snd_kcontrol *kcontrol,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int tavil_hph_impedance_get(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
uint32_t zl, zr;
|
||||
bool hphr;
|
||||
struct soc_multi_mixer_control *mc;
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(codec);
|
||||
|
||||
if (!wcd934x_mbhc) {
|
||||
dev_err(codec->dev, "%s: mbhc not initialized!\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mc = (struct soc_multi_mixer_control *)(kcontrol->private_value);
|
||||
hphr = mc->shift;
|
||||
wcd_mbhc_get_impedance(&wcd934x_mbhc->wcd_mbhc, &zl, &zr);
|
||||
dev_dbg(codec->dev, "%s: zl=%u(ohms), zr=%u(ohms)\n", __func__, zl, zr);
|
||||
ucontrol->value.integer.value[0] = hphr ? zr : zl;
|
||||
|
||||
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),
|
||||
};
|
||||
|
||||
static const struct snd_kcontrol_new impedance_detect_controls[] = {
|
||||
SOC_SINGLE_EXT("HPHL Impedance", 0, 0, UINT_MAX, 0,
|
||||
tavil_hph_impedance_get, NULL),
|
||||
SOC_SINGLE_EXT("HPHR Impedance", 0, 1, UINT_MAX, 0,
|
||||
tavil_hph_impedance_get, NULL),
|
||||
};
|
||||
|
||||
/*
|
||||
* tavil_mbhc_hs_detect: starts mbhc insertion/removal functionality
|
||||
* @codec: handle to snd_soc_codec *
|
||||
|
@ -985,6 +1015,8 @@ int tavil_mbhc_init(struct wcd934x_mbhc **mbhc, struct snd_soc_codec *codec,
|
|||
0;
|
||||
}
|
||||
|
||||
snd_soc_add_codec_controls(codec, impedance_detect_controls,
|
||||
ARRAY_SIZE(impedance_detect_controls));
|
||||
snd_soc_add_codec_controls(codec, hph_type_detect_controls,
|
||||
ARRAY_SIZE(hph_type_detect_controls));
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue