aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiguel de Barros <miguel.de.barros@bluewin.ch>2009-09-27 16:11:21 -0400
committerTakashi Iwai <tiwai@suse.de>2009-09-29 03:15:05 -0400
commita72cb4bc8590d222ac27205444d7f0dcf47ab1d5 (patch)
tree51a970a008a166192e20c71c7f3a3f626672eecd
parent3d80dcaca1fb6a718f1d4a381e0017d525fdf321 (diff)
ALSA: hda - Analog Devices AD1984A add HP Touchsmart model
Reference: ALSA bug #0004614 https://bugtrack.alsa-project.org/alsa-bug/view.php?id=4614 port-A (0x11) - front hp-out port-D (0x12) - rear line out port-E (0x1c) - front mic-in port-F (0x16) - Internal speakers digital-mic (0x17) - Internal mic init verbs, mixers, jack sensing and PCI_QUIRK to support this hardware Signed-off-by: Miguel de Barros <miguel.de.barros@bluewin.ch> Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--Documentation/sound/alsa/HD-Audio-Models.txt1
-rw-r--r--sound/pci/hda/patch_analog.c139
2 files changed, 140 insertions, 0 deletions
diff --git a/Documentation/sound/alsa/HD-Audio-Models.txt b/Documentation/sound/alsa/HD-Audio-Models.txt
index 97eebd63bedc..a2643cfe7938 100644
--- a/Documentation/sound/alsa/HD-Audio-Models.txt
+++ b/Documentation/sound/alsa/HD-Audio-Models.txt
@@ -209,6 +209,7 @@ AD1884A / AD1883 / AD1984A / AD1984B
209 laptop laptop with HP jack sensing 209 laptop laptop with HP jack sensing
210 mobile mobile devices with HP jack sensing 210 mobile mobile devices with HP jack sensing
211 thinkpad Lenovo Thinkpad X300 211 thinkpad Lenovo Thinkpad X300
212 touchsmart HP Touchsmart
212 213
213AD1884 214AD1884
214====== 215======
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index 215e72a87113..2d603f6aba63 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -4032,6 +4032,127 @@ static int ad1984a_thinkpad_init(struct hda_codec *codec)
4032} 4032}
4033 4033
4034/* 4034/*
4035 * HP Touchsmart
4036 * port-A (0x11) - front hp-out
4037 * port-B (0x14) - unused
4038 * port-C (0x15) - unused
4039 * port-D (0x12) - rear line out
4040 * port-E (0x1c) - front mic-in
4041 * port-F (0x16) - Internal speakers
4042 * digital-mic (0x17) - Internal mic
4043 */
4044
4045static struct hda_verb ad1984a_touchsmart_verbs[] = {
4046 /* DACs; unmute as default */
4047 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */
4048 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */
4049 /* Port-A (HP) mixer - route only from analog mixer */
4050 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4051 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4052 /* Port-A pin */
4053 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4054 /* Port-A (HP) pin - always unmuted */
4055 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4056 /* Port-E (int speaker) mixer - route only from analog mixer */
4057 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, 0x03},
4058 /* Port-E pin */
4059 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4060 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4061 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4062 /* Port-F (int speaker) mixer - route only from analog mixer */
4063 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4064 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4065 /* Port-F pin */
4066 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4067 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4068 /* Analog mixer; mute as default */
4069 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4070 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4071 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4072 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4073 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4074 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
4075 /* Analog Mix output amp */
4076 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4077 /* capture sources */
4078 /* {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0}, */ /* set via unsol */
4079 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4080 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
4081 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4082 /* unsolicited event for pin-sense */
4083 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT},
4084 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_MIC_EVENT},
4085 /* allow to touch GPIO1 (for mute control) */
4086 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
4087 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
4088 {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, /* first muted */
4089 /* internal mic - dmic */
4090 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4091 /* set magic COEFs for dmic */
4092 {0x01, AC_VERB_SET_COEF_INDEX, 0x13f7},
4093 {0x01, AC_VERB_SET_PROC_COEF, 0x08},
4094 { } /* end */
4095};
4096
4097static struct snd_kcontrol_new ad1984a_touchsmart_mixers[] = {
4098 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT),
4099/* HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),*/
4100 {
4101 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4102 .name = "Master Playback Switch",
4103 .info = snd_hda_mixer_amp_switch_info,
4104 .get = snd_hda_mixer_amp_switch_get,
4105 .put = ad1884a_mobile_master_sw_put,
4106 .private_value = HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
4107 },
4108 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
4109 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
4110 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
4111 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
4112 HDA_CODEC_VOLUME("Mic Boost", 0x25, 0x0, HDA_OUTPUT),
4113 HDA_CODEC_VOLUME("Internal Mic Boost", 0x17, 0x0, HDA_INPUT),
4114 { } /* end */
4115};
4116
4117/* switch to external mic if plugged */
4118static void ad1984a_touchsmart_automic(struct hda_codec *codec)
4119{
4120 if (snd_hda_codec_read(codec, 0x1c, 0,
4121 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000) {
4122 snd_hda_codec_write(codec, 0x0c, 0,
4123 AC_VERB_SET_CONNECT_SEL, 0x4);
4124 } else {
4125 snd_hda_codec_write(codec, 0x0c, 0,
4126 AC_VERB_SET_CONNECT_SEL, 0x5);
4127 }
4128}
4129
4130
4131/* unsolicited event for HP jack sensing */
4132static void ad1984a_touchsmart_unsol_event(struct hda_codec *codec,
4133 unsigned int res)
4134{
4135 switch (res >> 26) {
4136 case AD1884A_HP_EVENT:
4137 ad1884a_hp_automute(codec);
4138 break;
4139 case AD1884A_MIC_EVENT:
4140 ad1984a_touchsmart_automic(codec);
4141 break;
4142 }
4143}
4144
4145/* initialize jack-sensing, too */
4146static int ad1984a_touchsmart_init(struct hda_codec *codec)
4147{
4148 ad198x_init(codec);
4149 ad1884a_hp_automute(codec);
4150 ad1984a_touchsmart_automic(codec);
4151 return 0;
4152}
4153
4154
4155/*
4035 */ 4156 */
4036 4157
4037enum { 4158enum {
@@ -4039,6 +4160,7 @@ enum {
4039 AD1884A_LAPTOP, 4160 AD1884A_LAPTOP,
4040 AD1884A_MOBILE, 4161 AD1884A_MOBILE,
4041 AD1884A_THINKPAD, 4162 AD1884A_THINKPAD,
4163 AD1984A_TOUCHSMART,
4042 AD1884A_MODELS 4164 AD1884A_MODELS
4043}; 4165};
4044 4166
@@ -4047,6 +4169,7 @@ static const char *ad1884a_models[AD1884A_MODELS] = {
4047 [AD1884A_LAPTOP] = "laptop", 4169 [AD1884A_LAPTOP] = "laptop",
4048 [AD1884A_MOBILE] = "mobile", 4170 [AD1884A_MOBILE] = "mobile",
4049 [AD1884A_THINKPAD] = "thinkpad", 4171 [AD1884A_THINKPAD] = "thinkpad",
4172 [AD1984A_TOUCHSMART] = "touchsmart",
4050}; 4173};
4051 4174
4052static struct snd_pci_quirk ad1884a_cfg_tbl[] = { 4175static struct snd_pci_quirk ad1884a_cfg_tbl[] = {
@@ -4059,6 +4182,7 @@ static struct snd_pci_quirk ad1884a_cfg_tbl[] = {
4059 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3600, "HP laptop", AD1884A_LAPTOP), 4182 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3600, "HP laptop", AD1884A_LAPTOP),
4060 SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x7010, "HP laptop", AD1884A_MOBILE), 4183 SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x7010, "HP laptop", AD1884A_MOBILE),
4061 SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X300", AD1884A_THINKPAD), 4184 SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X300", AD1884A_THINKPAD),
4185 SND_PCI_QUIRK(0x103c, 0x2a82, "Touchsmart", AD1984A_TOUCHSMART),
4062 {} 4186 {}
4063}; 4187};
4064 4188
@@ -4142,6 +4266,21 @@ static int patch_ad1884a(struct hda_codec *codec)
4142 codec->patch_ops.unsol_event = ad1984a_thinkpad_unsol_event; 4266 codec->patch_ops.unsol_event = ad1984a_thinkpad_unsol_event;
4143 codec->patch_ops.init = ad1984a_thinkpad_init; 4267 codec->patch_ops.init = ad1984a_thinkpad_init;
4144 break; 4268 break;
4269 case AD1984A_TOUCHSMART:
4270 spec->mixers[0] = ad1984a_touchsmart_mixers;
4271 spec->init_verbs[0] = ad1984a_touchsmart_verbs;
4272 spec->multiout.dig_out_nid = 0;
4273 codec->patch_ops.unsol_event = ad1984a_touchsmart_unsol_event;
4274 codec->patch_ops.init = ad1984a_touchsmart_init;
4275 /* set the upper-limit for mixer amp to 0dB for avoiding the
4276 * possible damage by overloading
4277 */
4278 snd_hda_override_amp_caps(codec, 0x20, HDA_INPUT,
4279 (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
4280 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4281 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4282 (1 << AC_AMPCAP_MUTE_SHIFT));
4283 break;
4145 } 4284 }
4146 4285
4147 return 0; 4286 return 0;