summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Woithe <jwoithe@physics.adelaide.edu.au>2008-01-08 12:16:54 +0100
committerJaroslav Kysela <perex@perex.cz>2008-01-31 17:29:46 +0100
commitf8225f6d1f68c3d0a0fe844dc40a11cd432a853b (patch)
tree99500452a75b84da8e1ec4317a0c4356991c18df
parenta713b5834731f32757b30de038dcb995afac2ad1 (diff)
[ALSA] hda-codec - Add EAPD controls for ALC260 test model
This implements a switch control for the EAPD signal output by the ALC26x chips. Since some laptops may utilise this to activate useful things it is handy to have a control for this in the ALC26x test models. The patch includes the control in the ALC260 test model. Signed-off-by: Jonathan Woithe <jwoithe@physics.adelaide.edu.au> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
-rw-r--r--sound/pci/hda/patch_realtek.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 617f3ee304b..0a64d24e7fd 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -608,6 +608,59 @@ static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
.private_value = nid | (mask<<16) }
#endif /* CONFIG_SND_DEBUG */
+/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
+ * Again, this is only used in the ALC26x test models to help identify when
+ * the EAPD line must be asserted for features to work.
+ */
+#ifdef CONFIG_SND_DEBUG
+#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
+
+static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+ hda_nid_t nid = kcontrol->private_value & 0xffff;
+ unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
+ long *valp = ucontrol->value.integer.value;
+ unsigned int val = snd_hda_codec_read(codec, nid, 0,
+ AC_VERB_GET_EAPD_BTLENABLE, 0x00);
+
+ *valp = (val & mask) != 0;
+ return 0;
+}
+
+static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ int change;
+ struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+ hda_nid_t nid = kcontrol->private_value & 0xffff;
+ unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
+ long val = *ucontrol->value.integer.value;
+ unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
+ AC_VERB_GET_EAPD_BTLENABLE,
+ 0x00);
+
+ /* Set/unset the masked control bit(s) as needed */
+ change = (!val ? 0 : mask) != (ctrl_data & mask);
+ if (!val)
+ ctrl_data &= ~mask;
+ else
+ ctrl_data |= mask;
+ snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
+ ctrl_data);
+
+ return change;
+}
+
+#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
+ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
+ .info = alc_eapd_ctrl_info, \
+ .get = alc_eapd_ctrl_get, \
+ .put = alc_eapd_ctrl_put, \
+ .private_value = nid | (mask<<16) }
+#endif /* CONFIG_SND_DEBUG */
+
/*
* set up from the preset table
*/
@@ -4332,6 +4385,12 @@ static struct snd_kcontrol_new alc260_test_mixer[] = {
ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
+ /* A switch allowing EAPD to be enabled. Some laptops seem to use
+ * this output to turn on an external amplifier.
+ */
+ ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
+ ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
+
{ } /* end */
};
static struct hda_verb alc260_test_init_verbs[] = {