Skip to content

Commit

Permalink
ALSA: hda - Merge HP mute-LED status callback on both IDT 92HD7x and …
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
Takashi Iwai committed Feb 8, 2010
1 parent 07f8044 commit c21bd02
Showing 1 changed file with 27 additions and 30 deletions.
57 changes: 27 additions & 30 deletions sound/pci/hda/patch_sigmatel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

stac_gpio_set(codec, spec->gpio_mask,
spec->gpio_dir,
spec->gpio_data);
}
if (muted)
spec->gpio_data &= ~spec->gpio_led; /* orange */
else
spec->gpio_data |= spec->gpio_led; /* white */

return 0;
}

static int idt92hd83xxx_hp_check_power_status(struct hda_codec *codec,
hda_nid_t nid)
{
struct sigmatel_spec *spec = codec->spec;
if (!spec->gpio_led_polarity) {
/* LED state is inverted on these systems */
spec->gpio_data ^= spec->gpio_led;
}

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)
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit c21bd02

Please sign in to comment.