Commit 8a503555 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: hda/realtek: Convert to cdev-variant of mic-mute LED controls

This patch converts the remaining user of
snd_hda_gen_add_micmute_led() in Realtek codec driver into the new
snd_hda_gen_add_micmute_led_cdev().

The Thinkpad helper code is updated accordingly, too.

Also, the usage of snd_hda_gen_fixup_micmute_led() is replaced with
either the local alc_fixup_micmute_led() or the explicit call of
snd_hda_gen_add_micmute_led_cdev() with NULL callback.
Tested-by: default avatarKai-Heng Feng <kai.heng.feng@canonical.com>
Link: https://lore.kernel.org/r/20200618110842.27238-4-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 7cdf8c49
...@@ -287,6 +287,13 @@ static void alc_fixup_gpio4(struct hda_codec *codec, ...@@ -287,6 +287,13 @@ static void alc_fixup_gpio4(struct hda_codec *codec,
alc_fixup_gpio(codec, action, 0x04); alc_fixup_gpio(codec, action, 0x04);
} }
static void alc_fixup_micmute_led(struct hda_codec *codec,
const struct hda_fixup *fix, int action)
{
if (action == HDA_FIXUP_ACT_PROBE)
snd_hda_gen_add_micmute_led_cdev(codec, NULL);
}
/* /*
* Fix hardware PLL issue * Fix hardware PLL issue
* On some codecs, the analog PLL gating control must be off while * On some codecs, the analog PLL gating control must be off while
...@@ -4155,21 +4162,24 @@ static void alc286_fixup_hp_gpio_led(struct hda_codec *codec, ...@@ -4155,21 +4162,24 @@ static void alc286_fixup_hp_gpio_led(struct hda_codec *codec,
alc_fixup_hp_gpio_led(codec, action, 0x02, 0x20); alc_fixup_hp_gpio_led(codec, action, 0x02, 0x20);
} }
/* turn on/off mic-mute LED per capture hook */ /* turn on/off mic-mute LED per capture hook via VREF change */
static void alc_cap_micmute_update(struct hda_codec *codec) static int vref_micmute_led_set(struct led_classdev *led_cdev,
enum led_brightness brightness)
{ {
struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
struct alc_spec *spec = codec->spec; struct alc_spec *spec = codec->spec;
unsigned int pinval; unsigned int pinval;
if (!spec->cap_mute_led_nid) if (!spec->cap_mute_led_nid)
return; return 0;
pinval = snd_hda_codec_get_pin_target(codec, spec->cap_mute_led_nid); pinval = snd_hda_codec_get_pin_target(codec, spec->cap_mute_led_nid);
pinval &= ~AC_PINCTL_VREFEN; pinval &= ~AC_PINCTL_VREFEN;
if (spec->gen.micmute_led.led_value) if (brightness)
pinval |= AC_PINCTL_VREF_80; pinval |= AC_PINCTL_VREF_80;
else else
pinval |= AC_PINCTL_VREF_HIZ; pinval |= AC_PINCTL_VREF_HIZ;
snd_hda_set_pin_ctl_cache(codec, spec->cap_mute_led_nid, pinval); snd_hda_set_pin_ctl_cache(codec, spec->cap_mute_led_nid, pinval);
return 0;
} }
static void alc269_fixup_hp_gpio_mic1_led(struct hda_codec *codec, static void alc269_fixup_hp_gpio_mic1_led(struct hda_codec *codec,
...@@ -4185,7 +4195,7 @@ static void alc269_fixup_hp_gpio_mic1_led(struct hda_codec *codec, ...@@ -4185,7 +4195,7 @@ static void alc269_fixup_hp_gpio_mic1_led(struct hda_codec *codec,
spec->gpio_mask |= 0x10; spec->gpio_mask |= 0x10;
spec->gpio_dir |= 0x10; spec->gpio_dir |= 0x10;
spec->cap_mute_led_nid = 0x18; spec->cap_mute_led_nid = 0x18;
snd_hda_gen_add_micmute_led(codec, alc_cap_micmute_update); snd_hda_gen_add_micmute_led_cdev(codec, vref_micmute_led_set);
codec->power_filter = led_power_filter; codec->power_filter = led_power_filter;
} }
} }
...@@ -4198,7 +4208,7 @@ static void alc280_fixup_hp_gpio4(struct hda_codec *codec, ...@@ -4198,7 +4208,7 @@ static void alc280_fixup_hp_gpio4(struct hda_codec *codec,
alc_fixup_hp_gpio_led(codec, action, 0x08, 0); alc_fixup_hp_gpio_led(codec, action, 0x08, 0);
if (action == HDA_FIXUP_ACT_PRE_PROBE) { if (action == HDA_FIXUP_ACT_PRE_PROBE) {
spec->cap_mute_led_nid = 0x18; spec->cap_mute_led_nid = 0x18;
snd_hda_gen_add_micmute_led(codec, alc_cap_micmute_update); snd_hda_gen_add_micmute_led_cdev(codec, vref_micmute_led_set);
codec->power_filter = led_power_filter; codec->power_filter = led_power_filter;
} }
} }
...@@ -4254,16 +4264,19 @@ static void alc236_fixup_hp_mute_led_coefbit(struct hda_codec *codec, ...@@ -4254,16 +4264,19 @@ static void alc236_fixup_hp_mute_led_coefbit(struct hda_codec *codec,
} }
/* turn on/off mic-mute LED per capture hook by coef bit */ /* turn on/off mic-mute LED per capture hook by coef bit */
static void alc_hp_cap_micmute_update(struct hda_codec *codec) static int coef_micmute_led_set(struct led_classdev *led_cdev,
enum led_brightness brightness)
{ {
struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
struct alc_spec *spec = codec->spec; struct alc_spec *spec = codec->spec;
if (spec->gen.micmute_led.led_value) if (brightness)
alc_update_coef_idx(codec, spec->mic_led_coef_idx, alc_update_coef_idx(codec, spec->mic_led_coef_idx,
spec->mic_led_coefbit_mask, spec->mic_led_coefbit_on); spec->mic_led_coefbit_mask, spec->mic_led_coefbit_on);
else else
alc_update_coef_idx(codec, spec->mic_led_coef_idx, alc_update_coef_idx(codec, spec->mic_led_coef_idx,
spec->mic_led_coefbit_mask, spec->mic_led_coefbit_off); spec->mic_led_coefbit_mask, spec->mic_led_coefbit_off);
return 0;
} }
static void alc285_fixup_hp_coef_micmute_led(struct hda_codec *codec, static void alc285_fixup_hp_coef_micmute_led(struct hda_codec *codec,
...@@ -4276,7 +4289,7 @@ static void alc285_fixup_hp_coef_micmute_led(struct hda_codec *codec, ...@@ -4276,7 +4289,7 @@ static void alc285_fixup_hp_coef_micmute_led(struct hda_codec *codec,
spec->mic_led_coefbit_mask = 1<<13; spec->mic_led_coefbit_mask = 1<<13;
spec->mic_led_coefbit_on = 1<<13; spec->mic_led_coefbit_on = 1<<13;
spec->mic_led_coefbit_off = 0; spec->mic_led_coefbit_off = 0;
snd_hda_gen_add_micmute_led(codec, alc_hp_cap_micmute_update); snd_hda_gen_add_micmute_led_cdev(codec, coef_micmute_led_set);
} }
} }
...@@ -4290,7 +4303,7 @@ static void alc236_fixup_hp_coef_micmute_led(struct hda_codec *codec, ...@@ -4290,7 +4303,7 @@ static void alc236_fixup_hp_coef_micmute_led(struct hda_codec *codec,
spec->mic_led_coefbit_mask = 3<<2; spec->mic_led_coefbit_mask = 3<<2;
spec->mic_led_coefbit_on = 2<<2; spec->mic_led_coefbit_on = 2<<2;
spec->mic_led_coefbit_off = 1<<2; spec->mic_led_coefbit_off = 1<<2;
snd_hda_gen_add_micmute_led(codec, alc_hp_cap_micmute_update); snd_hda_gen_add_micmute_led_cdev(codec, coef_micmute_led_set);
} }
} }
...@@ -4430,7 +4443,7 @@ static void alc269_fixup_hp_line1_mic1_led(struct hda_codec *codec, ...@@ -4430,7 +4443,7 @@ static void alc269_fixup_hp_line1_mic1_led(struct hda_codec *codec,
alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x1a); alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x1a);
if (action == HDA_FIXUP_ACT_PRE_PROBE) { if (action == HDA_FIXUP_ACT_PRE_PROBE) {
spec->cap_mute_led_nid = 0x18; spec->cap_mute_led_nid = 0x18;
snd_hda_gen_add_micmute_led(codec, alc_cap_micmute_update); snd_hda_gen_add_micmute_led_cdev(codec, vref_micmute_led_set);
} }
} }
...@@ -6660,7 +6673,7 @@ static const struct hda_fixup alc269_fixups[] = { ...@@ -6660,7 +6673,7 @@ static const struct hda_fixup alc269_fixups[] = {
}, },
[ALC255_FIXUP_MIC_MUTE_LED] = { [ALC255_FIXUP_MIC_MUTE_LED] = {
.type = HDA_FIXUP_FUNC, .type = HDA_FIXUP_FUNC,
.v.func = snd_hda_gen_fixup_micmute_led, .v.func = alc_fixup_micmute_led,
}, },
[ALC282_FIXUP_ASPIRE_V5_PINS] = { [ALC282_FIXUP_ASPIRE_V5_PINS] = {
.type = HDA_FIXUP_PINS, .type = HDA_FIXUP_PINS,
...@@ -6763,7 +6776,7 @@ static const struct hda_fixup alc269_fixups[] = { ...@@ -6763,7 +6776,7 @@ static const struct hda_fixup alc269_fixups[] = {
}, },
[ALC292_FIXUP_DELL_E7X] = { [ALC292_FIXUP_DELL_E7X] = {
.type = HDA_FIXUP_FUNC, .type = HDA_FIXUP_FUNC,
.v.func = snd_hda_gen_fixup_micmute_led, .v.func = alc_fixup_micmute_led,
/* micmute fixup must be applied at last */ /* micmute fixup must be applied at last */
.chained_before = true, .chained_before = true,
.chain_id = ALC292_FIXUP_DELL_E7X_AAMIX, .chain_id = ALC292_FIXUP_DELL_E7X_AAMIX,
......
...@@ -35,7 +35,7 @@ static void hda_fixup_thinkpad_acpi(struct hda_codec *codec, ...@@ -35,7 +35,7 @@ static void hda_fixup_thinkpad_acpi(struct hda_codec *codec,
return; return;
old_vmaster_hook = spec->vmaster_mute.hook; old_vmaster_hook = spec->vmaster_mute.hook;
spec->vmaster_mute.hook = update_tpacpi_mute_led; spec->vmaster_mute.hook = update_tpacpi_mute_led;
snd_hda_gen_fixup_micmute_led(codec, fix, action); snd_hda_gen_add_micmute_led_cdev(codec, NULL);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment