mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-27 06:30:56 +07:00
ALSA: hda - Merge HP mute-LED status callback on both IDT 92HD7x and 8x codecs
Merge the mute-LED status callback function for both IDT 92HD7x and 8x codecs to one function. Also it's changed to check all DACs, and called in the initialization to sync with the current status. Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
07f804495c
commit
c21bd02543
@ -4363,6 +4363,12 @@ static int stac92xx_init(struct hda_codec *codec)
|
||||
if (enable_pin_detect(codec, nid, STAC_PWR_EVENT))
|
||||
stac_issue_unsol_event(codec, nid);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SND_HDA_POWER_SAVE
|
||||
/* sync mute LED */
|
||||
if (spec->gpio_led && codec->patch_ops.check_power_status)
|
||||
codec->patch_ops.check_power_status(codec, 0x01);
|
||||
#endif
|
||||
if (spec->dac_list)
|
||||
stac92xx_power_down(codec);
|
||||
return 0;
|
||||
@ -4909,6 +4915,11 @@ static int stac92xx_resume(struct hda_codec *codec)
|
||||
stac_issue_unsol_event(codec,
|
||||
spec->autocfg.line_out_pins[0]);
|
||||
}
|
||||
#ifdef CONFIG_SND_HDA_POWER_SAVE
|
||||
/* sync mute LED */
|
||||
if (spec->gpio_led && codec->patch_ops.check_power_status)
|
||||
codec->patch_ops.check_power_status(codec, 0x01);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -4928,43 +4939,29 @@ static int stac92xx_hp_check_power_status(struct hda_codec *codec,
|
||||
hda_nid_t nid)
|
||||
{
|
||||
struct sigmatel_spec *spec = codec->spec;
|
||||
int i, muted = 1;
|
||||
|
||||
if (nid == 0x10) {
|
||||
if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
|
||||
HDA_AMP_MUTE)
|
||||
spec->gpio_data &= ~spec->gpio_led; /* orange */
|
||||
else
|
||||
spec->gpio_data |= spec->gpio_led; /* white */
|
||||
|
||||
if (!spec->gpio_led_polarity) {
|
||||
/* LED state is inverted on these systems */
|
||||
spec->gpio_data ^= spec->gpio_led;
|
||||
for (i = 0; i < spec->multiout.num_dacs; i++) {
|
||||
nid = spec->multiout.dac_nids[i];
|
||||
if (!(snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
|
||||
HDA_AMP_MUTE)) {
|
||||
muted = 0; /* something heard */
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (muted)
|
||||
spec->gpio_data &= ~spec->gpio_led; /* orange */
|
||||
else
|
||||
spec->gpio_data |= spec->gpio_led; /* white */
|
||||
|
||||
stac_gpio_set(codec, spec->gpio_mask,
|
||||
spec->gpio_dir,
|
||||
spec->gpio_data);
|
||||
if (!spec->gpio_led_polarity) {
|
||||
/* LED state is inverted on these systems */
|
||||
spec->gpio_data ^= spec->gpio_led;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int idt92hd83xxx_hp_check_power_status(struct hda_codec *codec,
|
||||
hda_nid_t nid)
|
||||
{
|
||||
struct sigmatel_spec *spec = codec->spec;
|
||||
|
||||
if (nid != 0x13)
|
||||
return 0;
|
||||
if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) & HDA_AMP_MUTE)
|
||||
spec->gpio_data |= spec->gpio_led; /* mute LED on */
|
||||
else
|
||||
spec->gpio_data &= ~spec->gpio_led; /* mute LED off */
|
||||
stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
|
||||
@ -5361,7 +5358,7 @@ static int patch_stac92hd83xxx(struct hda_codec *codec)
|
||||
spec->gpio_data |= spec->gpio_led;
|
||||
/* register check_power_status callback. */
|
||||
codec->patch_ops.check_power_status =
|
||||
idt92hd83xxx_hp_check_power_status;
|
||||
stac92xx_hp_check_power_status;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user