mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 03:15:31 +09:00
ASoC: rockchip: multicodecs: add hp and sp switch for user switch setting
Signed-off-by: Shunhua Lan <lsh@rock-chips.com> Change-Id: I49503453158fca5568af5975ad42a20809d4bd1c
This commit is contained in:
@@ -326,7 +326,31 @@ static const struct snd_soc_dapm_widget mc_dapm_widgets[] = {
|
||||
SND_SOC_DAPM_PRE_PMD),
|
||||
};
|
||||
|
||||
static int mc_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
|
||||
struct multicodecs_data *mc_data = snd_soc_card_get_drvdata(card);
|
||||
struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value;
|
||||
struct gpio_desc *gpio = mc->reg == 1 ? mc_data->hp_ctl_gpio : mc_data->spk_ctl_gpio;
|
||||
|
||||
ucontrol->value.integer.value[0] = gpiod_get_value_cansleep(gpio);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mc_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
|
||||
struct multicodecs_data *mc_data = snd_soc_card_get_drvdata(card);
|
||||
struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value;
|
||||
struct gpio_desc *gpio = mc->reg == 1 ? mc_data->hp_ctl_gpio : mc_data->spk_ctl_gpio;
|
||||
|
||||
gpiod_set_value_cansleep(gpio, ucontrol->value.integer.value[0] ? 1 : 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct snd_kcontrol_new mc_controls[] = {
|
||||
SOC_SINGLE_EXT("spk switch", 0, 0, 1, 0, mc_switch_get, mc_switch_put),
|
||||
SOC_SINGLE_EXT("hp switch", 1, 0, 1, 0, mc_switch_get, mc_switch_put),
|
||||
SOC_DAPM_PIN_SWITCH("Headphone"),
|
||||
SOC_DAPM_PIN_SWITCH("Speaker"),
|
||||
SOC_DAPM_PIN_SWITCH("Main Mic"),
|
||||
|
||||
Reference in New Issue
Block a user