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

Commit c21bd025 authored by Takashi Iwai's avatar Takashi Iwai
Browse files

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: default avatarTakashi Iwai <tiwai@suse.de>
parent 07f80449
Loading
Loading
Loading
Loading
+27 −30
Original line number Diff line number Diff line
@@ -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,10 +4939,17 @@ 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)
	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 */
@@ -4941,30 +4959,9 @@ static int stac92xx_hp_check_power_status(struct hda_codec *codec,
		spec->gpio_data ^= spec->gpio_led;
	}

		stac_gpio_set(codec, spec->gpio_mask,
			      spec->gpio_dir,
			      spec->gpio_data);
	}

	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