Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fd30be8f authored by Walter Yang's avatar Walter Yang Committed by Gerrit - the friendly Code Review server
Browse files

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: default avatarWalter Yang <yandongy@codeaurora.org>
parent 30a5b12e
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -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);