2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for ALC 260/880/882 codecs
6 * Copyright (c) 2004 PeiSen Hou <pshou@realtek.com.tw>
7 * Takashi Iwai <tiwai@suse.de>
9 * This driver is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This driver is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include <sound/driver.h>
25 #include <linux/init.h>
26 #include <linux/delay.h>
27 #include <linux/slab.h>
28 #include <linux/pci.h>
29 #include <sound/core.h>
30 #include "hda_codec.h"
31 #include "hda_local.h"
34 /* ALC880 board config type */
50 #ifdef CONFIG_SND_DEBUG
53 ALC880_MODEL_LAST
/* last tag */
61 ALC260_MODEL_LAST
/* last tag */
65 #define AMP_IN_MUTE(idx) (0x7080 | ((idx)<<8))
66 #define AMP_IN_UNMUTE(idx) (0x7000 | ((idx)<<8))
67 #define AMP_OUT_MUTE 0xb080
68 #define AMP_OUT_UNMUTE 0xb000
69 #define AMP_OUT_ZERO 0xb000
72 #define PIN_VREF80 0x24
73 #define PIN_VREF50 0x21
76 #define PIN_HP_AMP 0x80
79 /* codec parameterization */
80 snd_kcontrol_new_t
*mixers
[3]; /* mixer arrays */
81 unsigned int num_mixers
;
83 const struct hda_verb
*init_verbs
[3]; /* initialization verbs
84 * don't forget NULL termination!
86 unsigned int num_init_verbs
;
88 char *stream_name_analog
; /* analog PCM stream */
89 struct hda_pcm_stream
*stream_analog_playback
;
90 struct hda_pcm_stream
*stream_analog_capture
;
92 char *stream_name_digital
; /* digital PCM stream */
93 struct hda_pcm_stream
*stream_digital_playback
;
94 struct hda_pcm_stream
*stream_digital_capture
;
97 struct hda_multi_out multiout
; /* playback set-up
98 * max_channels, dacs must be set
99 * dig_out_nid and hp_nid are optional
103 unsigned int num_adc_nids
;
105 hda_nid_t dig_in_nid
; /* digital-in NID; optional */
108 const struct hda_input_mux
*input_mux
;
109 unsigned int cur_mux
[3];
112 const struct alc_channel_mode
*channel_mode
;
113 int num_channel_mode
;
115 /* PCM information */
116 struct hda_pcm pcm_rec
[2]; /* used in alc_build_pcms() */
118 /* dynamic controls, init_verbs and input_mux */
119 struct auto_pin_cfg autocfg
;
120 unsigned int num_kctl_alloc
, num_kctl_used
;
121 snd_kcontrol_new_t
*kctl_alloc
;
122 struct hda_input_mux private_imux
;
123 hda_nid_t private_dac_nids
[4];
130 static int alc_mux_enum_info(snd_kcontrol_t
*kcontrol
, snd_ctl_elem_info_t
*uinfo
)
132 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
133 struct alc_spec
*spec
= codec
->spec
;
134 return snd_hda_input_mux_info(spec
->input_mux
, uinfo
);
137 static int alc_mux_enum_get(snd_kcontrol_t
*kcontrol
, snd_ctl_elem_value_t
*ucontrol
)
139 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
140 struct alc_spec
*spec
= codec
->spec
;
141 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
143 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
147 static int alc_mux_enum_put(snd_kcontrol_t
*kcontrol
, snd_ctl_elem_value_t
*ucontrol
)
149 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
150 struct alc_spec
*spec
= codec
->spec
;
151 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
152 return snd_hda_input_mux_put(codec
, spec
->input_mux
, ucontrol
,
153 spec
->adc_nids
[adc_idx
], &spec
->cur_mux
[adc_idx
]);
158 * channel mode setting
160 struct alc_channel_mode
{
162 const struct hda_verb
*sequence
;
165 static int alc880_ch_mode_info(snd_kcontrol_t
*kcontrol
, snd_ctl_elem_info_t
*uinfo
)
167 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
168 struct alc_spec
*spec
= codec
->spec
;
169 int items
= kcontrol
->private_value
? (int)kcontrol
->private_value
: 2;
171 snd_assert(spec
->channel_mode
, return -ENXIO
);
172 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
174 uinfo
->value
.enumerated
.items
= items
;
175 if (uinfo
->value
.enumerated
.item
>= items
)
176 uinfo
->value
.enumerated
.item
= items
- 1;
177 sprintf(uinfo
->value
.enumerated
.name
, "%dch",
178 spec
->channel_mode
[uinfo
->value
.enumerated
.item
].channels
);
182 static int alc880_ch_mode_get(snd_kcontrol_t
*kcontrol
, snd_ctl_elem_value_t
*ucontrol
)
184 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
185 struct alc_spec
*spec
= codec
->spec
;
186 int items
= kcontrol
->private_value
? (int)kcontrol
->private_value
: 2;
189 snd_assert(spec
->channel_mode
, return -ENXIO
);
190 for (i
= 0; i
< items
; i
++) {
191 if (spec
->multiout
.max_channels
== spec
->channel_mode
[i
].channels
) {
192 ucontrol
->value
.enumerated
.item
[0] = i
;
199 static int alc880_ch_mode_put(snd_kcontrol_t
*kcontrol
, snd_ctl_elem_value_t
*ucontrol
)
201 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
202 struct alc_spec
*spec
= codec
->spec
;
205 snd_assert(spec
->channel_mode
, return -ENXIO
);
206 mode
= ucontrol
->value
.enumerated
.item
[0] ? 1 : 0;
207 if (spec
->multiout
.max_channels
== spec
->channel_mode
[mode
].channels
&&
211 /* change the current channel setting */
212 spec
->multiout
.max_channels
= spec
->channel_mode
[mode
].channels
;
213 if (spec
->channel_mode
[mode
].sequence
)
214 snd_hda_sequence_write(codec
, spec
->channel_mode
[mode
].sequence
);
221 * Control of pin widget settings via the mixer. Only boolean settings are
222 * supported, so VrefEn can't be controlled using these functions as they
225 static int alc_pinctl_switch_info(snd_kcontrol_t
*kcontrol
, snd_ctl_elem_info_t
*uinfo
)
227 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_BOOLEAN
;
229 uinfo
->value
.integer
.min
= 0;
230 uinfo
->value
.integer
.max
= 1;
234 static int alc_pinctl_switch_get(snd_kcontrol_t
*kcontrol
, snd_ctl_elem_value_t
*ucontrol
)
236 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
237 hda_nid_t nid
= kcontrol
->private_value
& 0xffff;
238 long mask
= (kcontrol
->private_value
>> 16) & 0xff;
239 long *valp
= ucontrol
->value
.integer
.value
;
242 if (snd_hda_codec_read(codec
,nid
,0,AC_VERB_GET_PIN_WIDGET_CONTROL
,0x00) & mask
)
247 static int alc_pinctl_switch_put(snd_kcontrol_t
*kcontrol
, snd_ctl_elem_value_t
*ucontrol
)
249 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
250 hda_nid_t nid
= kcontrol
->private_value
& 0xffff;
251 long mask
= (kcontrol
->private_value
>> 16) & 0xff;
252 long *valp
= ucontrol
->value
.integer
.value
;
253 unsigned int pinctl
= snd_hda_codec_read(codec
,nid
,0,AC_VERB_GET_PIN_WIDGET_CONTROL
,0x00);
254 int change
= ((pinctl
& mask
)!=0) != *valp
;
257 snd_hda_codec_write(codec
,nid
,0,AC_VERB_SET_PIN_WIDGET_CONTROL
,
258 *valp
?(pinctl
|mask
):(pinctl
&~mask
));
262 #define ALC_PINCTL_SWITCH(xname, nid, mask) \
263 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
264 .info = alc_pinctl_switch_info, \
265 .get = alc_pinctl_switch_get, \
266 .put = alc_pinctl_switch_put, \
267 .private_value = (nid) | (mask<<16) }
270 * ALC880 3-stack model
272 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
273 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, F-Mic = 0x1b
277 static hda_nid_t alc880_dac_nids
[4] = {
278 /* front, rear, clfe, rear_surr */
279 0x02, 0x05, 0x04, 0x03
282 static hda_nid_t alc880_adc_nids
[3] = {
287 /* The datasheet says the node 0x07 is connected from inputs,
288 * but it shows zero connection in the real implementation on some devices.
290 static hda_nid_t alc880_adc_nids_alt
[2] = {
295 #define ALC880_DIGOUT_NID 0x06
296 #define ALC880_DIGIN_NID 0x0a
298 static struct hda_input_mux alc880_capture_source
= {
302 { "Front Mic", 0x3 },
308 /* channel source setting (2/6 channel selection for 3-stack) */
310 static struct hda_verb alc880_threestack_ch2_init
[] = {
311 /* set line-in to input, mute it */
312 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
313 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
314 /* set mic-in to input vref 80%, mute it */
315 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
316 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
321 static struct hda_verb alc880_threestack_ch6_init
[] = {
322 /* set line-in to output, unmute it */
323 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
324 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
325 /* set mic-in to output, unmute it */
326 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
327 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
331 static struct alc_channel_mode alc880_threestack_modes
[2] = {
332 { 2, alc880_threestack_ch2_init
},
333 { 6, alc880_threestack_ch6_init
},
336 static snd_kcontrol_new_t alc880_three_stack_mixer
[] = {
337 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT
),
338 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT
),
339 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT
),
340 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT
),
341 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT
),
342 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT
),
343 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT
),
344 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT
),
345 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT
),
346 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT
),
347 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT
),
348 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT
),
349 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT
),
350 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT
),
351 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT
),
352 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT
),
353 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT
),
354 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT
),
355 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT
),
357 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
358 .name
= "Channel Mode",
359 .info
= alc880_ch_mode_info
,
360 .get
= alc880_ch_mode_get
,
361 .put
= alc880_ch_mode_put
,
366 /* capture mixer elements */
367 static snd_kcontrol_new_t alc880_capture_mixer
[] = {
368 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT
),
369 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT
),
370 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT
),
371 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT
),
372 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT
),
373 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT
),
375 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
376 /* The multiple "Capture Source" controls confuse alsamixer
377 * So call somewhat different..
378 * FIXME: the controls appear in the "playback" view!
380 /* .name = "Capture Source", */
381 .name
= "Input Source",
383 .info
= alc_mux_enum_info
,
384 .get
= alc_mux_enum_get
,
385 .put
= alc_mux_enum_put
,
390 /* capture mixer elements (in case NID 0x07 not available) */
391 static snd_kcontrol_new_t alc880_capture_alt_mixer
[] = {
392 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT
),
393 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT
),
394 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT
),
395 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT
),
397 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
398 /* The multiple "Capture Source" controls confuse alsamixer
399 * So call somewhat different..
400 * FIXME: the controls appear in the "playback" view!
402 /* .name = "Capture Source", */
403 .name
= "Input Source",
405 .info
= alc_mux_enum_info
,
406 .get
= alc_mux_enum_get
,
407 .put
= alc_mux_enum_put
,
415 * ALC880 5-stack model
417 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), Side = 0x02 (0xd)
418 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
419 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
422 /* additional mixers to alc880_three_stack_mixer */
423 static snd_kcontrol_new_t alc880_five_stack_mixer
[] = {
424 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT
),
425 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT
),
429 /* channel source setting (6/8 channel selection for 5-stack) */
431 static struct hda_verb alc880_fivestack_ch6_init
[] = {
432 /* set line-in to input, mute it */
433 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
434 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
439 static struct hda_verb alc880_fivestack_ch8_init
[] = {
440 /* set line-in to output, unmute it */
441 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
442 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
446 static struct alc_channel_mode alc880_fivestack_modes
[2] = {
447 { 6, alc880_fivestack_ch6_init
},
448 { 8, alc880_fivestack_ch8_init
},
453 * ALC880 6-stack model
455 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), Side = 0x05 (0x0f)
456 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
457 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
460 static hda_nid_t alc880_6st_dac_nids
[4] = {
461 /* front, rear, clfe, rear_surr */
462 0x02, 0x03, 0x04, 0x05
465 static struct hda_input_mux alc880_6stack_capture_source
= {
469 { "Front Mic", 0x1 },
475 /* fixed 8-channels */
476 static struct alc_channel_mode alc880_sixstack_modes
[1] = {
480 static snd_kcontrol_new_t alc880_six_stack_mixer
[] = {
481 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT
),
482 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT
),
483 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT
),
484 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT
),
485 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT
),
486 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT
),
487 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT
),
488 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT
),
489 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT
),
490 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT
),
491 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT
),
492 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT
),
493 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT
),
494 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT
),
495 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT
),
496 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT
),
497 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT
),
498 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT
),
499 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT
),
500 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT
),
502 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
503 .name
= "Channel Mode",
504 .info
= alc880_ch_mode_info
,
505 .get
= alc880_ch_mode_get
,
506 .put
= alc880_ch_mode_put
,
515 * W810 has rear IO for:
518 * Center/LFE (DAC 04)
521 * The system also has a pair of internal speakers, and a headphone jack.
522 * These are both connected to Line2 on the codec, hence to DAC 02.
524 * There is a variable resistor to control the speaker or headphone
525 * volume. This is a hardware-only device without a software API.
527 * Plugging headphones in will disable the internal speakers. This is
528 * implemented in hardware, not via the driver using jack sense. In
529 * a similar fashion, plugging into the rear socket marked "front" will
530 * disable both the speakers and headphones.
532 * For input, there's a microphone jack, and an "audio in" jack.
533 * These may not do anything useful with this driver yet, because I
534 * haven't setup any initialization verbs for these yet...
537 static hda_nid_t alc880_w810_dac_nids
[3] = {
538 /* front, rear/surround, clfe */
542 /* fixed 6 channels */
543 static struct alc_channel_mode alc880_w810_modes
[1] = {
547 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
548 static snd_kcontrol_new_t alc880_w810_base_mixer
[] = {
549 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT
),
550 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT
),
551 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT
),
552 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT
),
553 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT
),
554 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT
),
555 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT
),
556 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT
),
557 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT
),
565 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
566 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), Line = 0x1a
569 static hda_nid_t alc880_z71v_dac_nids
[1] = {
572 #define ALC880_Z71V_HP_DAC 0x03
574 /* fixed 2 channels */
575 static struct alc_channel_mode alc880_2_jack_modes
[1] = {
579 static snd_kcontrol_new_t alc880_z71v_mixer
[] = {
580 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT
),
581 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT
),
582 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT
),
583 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT
),
584 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT
),
585 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT
),
586 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT
),
587 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT
),
596 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
597 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
600 static hda_nid_t alc880_f1734_dac_nids
[1] = {
603 #define ALC880_F1734_HP_DAC 0x02
605 static snd_kcontrol_new_t alc880_f1734_mixer
[] = {
606 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT
),
607 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT
),
608 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT
),
609 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT
),
610 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT
),
611 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT
),
612 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT
),
613 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT
),
622 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
623 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
624 * Mic = 0x18, Line = 0x1a
627 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
628 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
630 static snd_kcontrol_new_t alc880_asus_mixer
[] = {
631 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT
),
632 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT
),
633 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT
),
634 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT
),
635 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT
),
636 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT
),
637 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT
),
638 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT
),
639 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT
),
640 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT
),
641 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT
),
642 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT
),
643 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT
),
644 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT
),
646 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
647 .name
= "Channel Mode",
648 .info
= alc880_ch_mode_info
,
649 .get
= alc880_ch_mode_get
,
650 .put
= alc880_ch_mode_put
,
657 * ALC880 ASUS W1V model
659 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
660 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
661 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
664 /* additional mixers to alc880_asus_mixer */
665 static snd_kcontrol_new_t alc880_asus_w1v_mixer
[] = {
666 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT
),
667 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT
),
671 /* additional mixers to alc880_asus_mixer */
672 static snd_kcontrol_new_t alc880_pcbeep_mixer
[] = {
673 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT
),
674 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT
),
679 * build control elements
681 static int alc_build_controls(struct hda_codec
*codec
)
683 struct alc_spec
*spec
= codec
->spec
;
687 for (i
= 0; i
< spec
->num_mixers
; i
++) {
688 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
693 if (spec
->multiout
.dig_out_nid
) {
694 err
= snd_hda_create_spdif_out_ctls(codec
, spec
->multiout
.dig_out_nid
);
698 if (spec
->dig_in_nid
) {
699 err
= snd_hda_create_spdif_in_ctls(codec
, spec
->dig_in_nid
);
708 * initialize the codec volumes, etc
712 * generic initialization of ADC, input mixers and output mixers
714 static struct hda_verb alc880_volume_init_verbs
[] = {
716 * Unmute ADC0-2 and set the default input to mic-in
718 {0x07, AC_VERB_SET_CONNECT_SEL
, 0x00},
719 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
720 {0x08, AC_VERB_SET_CONNECT_SEL
, 0x00},
721 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
722 {0x09, AC_VERB_SET_CONNECT_SEL
, 0x00},
723 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
725 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
727 * Note: PASD motherboards uses the Line In 2 as the input for front panel
730 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
731 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
732 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
733 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2)},
734 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(3)},
735 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(4)},
738 * Set up output mixers (0x0c - 0x0f)
740 /* set vol=0 to output mixers */
741 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
742 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
743 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
744 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
745 /* set up input amps for analog loopback */
746 /* Amp Indices: DAC = 0, mixer = 1 */
747 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
748 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
749 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
750 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
751 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
752 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
753 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
754 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
760 * 3-stack pin configuration:
761 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
763 static struct hda_verb alc880_pin_3stack_init_verbs
[] = {
765 * preset connection lists of input pins
766 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
768 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x02}, /* mic/clfe */
769 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* HP */
770 {0x12, AC_VERB_SET_CONNECT_SEL
, 0x03}, /* line/surround */
773 * Set pin mode and muting
775 /* set front pin widgets 0x14 for output */
776 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
777 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
778 /* Mic1 (rear panel) pin widget for input and vref at 80% */
779 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
780 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
781 /* Mic2 (as headphone out) for HP output */
782 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
783 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
784 /* Line In pin widget for input */
785 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
786 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
787 /* Line2 (as front mic) pin widget for input and vref at 80% */
788 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
789 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
790 /* CD pin widget for input */
791 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
797 * 5-stack pin configuration:
798 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
799 * line-in/side = 0x1a, f-mic = 0x1b
801 static struct hda_verb alc880_pin_5stack_init_verbs
[] = {
803 * preset connection lists of input pins
804 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
806 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* HP */
807 {0x12, AC_VERB_SET_CONNECT_SEL
, 0x01}, /* line/side */
810 * Set pin mode and muting
812 /* set pin widgets 0x14-0x17 for output */
813 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
814 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
815 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
816 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
817 /* unmute pins for output (no gain on this amp) */
818 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
819 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
820 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
821 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
823 /* Mic1 (rear panel) pin widget for input and vref at 80% */
824 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
825 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
826 /* Mic2 (as headphone out) for HP output */
827 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
828 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
829 /* Line In pin widget for input */
830 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
831 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
832 /* Line2 (as front mic) pin widget for input and vref at 80% */
833 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
834 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
835 /* CD pin widget for input */
836 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
842 * W810 pin configuration:
843 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
845 static struct hda_verb alc880_pin_w810_init_verbs
[] = {
846 /* hphone/speaker input selector: front DAC */
847 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0},
849 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
850 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
851 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
852 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
853 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
854 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
856 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
857 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
863 * Z71V pin configuration:
864 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
866 static struct hda_verb alc880_pin_z71v_init_verbs
[] = {
867 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
868 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
869 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
870 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
872 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
873 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
874 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
875 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
881 * 6-stack pin configuration:
882 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, f-mic = 0x19,
883 * line = 0x1a, HP = 0x1b
885 static struct hda_verb alc880_pin_6stack_init_verbs
[] = {
886 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* HP */
888 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
889 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
890 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
891 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
892 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
893 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
894 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
895 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
897 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
898 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
899 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
900 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
901 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
902 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
903 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
904 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
905 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
912 * F1734 pin configuration:
913 * HP = 0x14, speaker-out = 0x15, mic = 0x18
915 static struct hda_verb alc880_pin_f1734_init_verbs
[] = {
916 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x02},
917 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x00},
918 {0x12, AC_VERB_SET_CONNECT_SEL
, 0x01},
919 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x00},
921 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
922 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
923 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
924 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
926 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
927 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
928 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
929 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
930 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
931 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
932 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
933 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
934 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
941 * ASUS pin configuration:
942 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
944 static struct hda_verb alc880_pin_asus_init_verbs
[] = {
945 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x02},
946 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x00},
947 {0x12, AC_VERB_SET_CONNECT_SEL
, 0x01},
948 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x00},
950 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
951 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
952 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
953 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
954 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
955 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
956 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
957 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
959 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
960 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
961 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
962 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
963 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
964 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
965 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
966 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
967 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
972 /* Enable GPIO mask and set output */
973 static struct hda_verb alc880_gpio1_init_verbs
[] = {
974 {0x01, AC_VERB_SET_GPIO_MASK
, 0x01},
975 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x01},
976 {0x01, AC_VERB_SET_GPIO_DATA
, 0x01},
979 /* Enable GPIO mask and set output */
980 static struct hda_verb alc880_gpio2_init_verbs
[] = {
981 {0x01, AC_VERB_SET_GPIO_MASK
, 0x02},
982 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x02},
983 {0x01, AC_VERB_SET_GPIO_DATA
, 0x02},
990 static int alc_init(struct hda_codec
*codec
)
992 struct alc_spec
*spec
= codec
->spec
;
995 for (i
= 0; i
< spec
->num_init_verbs
; i
++)
996 snd_hda_sequence_write(codec
, spec
->init_verbs
[i
]);
1004 static int alc_resume(struct hda_codec
*codec
)
1006 struct alc_spec
*spec
= codec
->spec
;
1010 for (i
= 0; i
< spec
->num_mixers
; i
++)
1011 snd_hda_resume_ctls(codec
, spec
->mixers
[i
]);
1012 if (spec
->multiout
.dig_out_nid
)
1013 snd_hda_resume_spdif_out(codec
);
1014 if (spec
->dig_in_nid
)
1015 snd_hda_resume_spdif_in(codec
);
1022 * Analog playback callbacks
1024 static int alc880_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
1025 struct hda_codec
*codec
,
1026 snd_pcm_substream_t
*substream
)
1028 struct alc_spec
*spec
= codec
->spec
;
1029 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
);
1032 static int alc880_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
1033 struct hda_codec
*codec
,
1034 unsigned int stream_tag
,
1035 unsigned int format
,
1036 snd_pcm_substream_t
*substream
)
1038 struct alc_spec
*spec
= codec
->spec
;
1039 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
, stream_tag
,
1043 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
1044 struct hda_codec
*codec
,
1045 snd_pcm_substream_t
*substream
)
1047 struct alc_spec
*spec
= codec
->spec
;
1048 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
1054 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
1055 struct hda_codec
*codec
,
1056 snd_pcm_substream_t
*substream
)
1058 struct alc_spec
*spec
= codec
->spec
;
1059 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
1062 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
1063 struct hda_codec
*codec
,
1064 snd_pcm_substream_t
*substream
)
1066 struct alc_spec
*spec
= codec
->spec
;
1067 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
1073 static int alc880_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
1074 struct hda_codec
*codec
,
1075 unsigned int stream_tag
,
1076 unsigned int format
,
1077 snd_pcm_substream_t
*substream
)
1079 struct alc_spec
*spec
= codec
->spec
;
1081 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
],
1082 stream_tag
, 0, format
);
1086 static int alc880_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
1087 struct hda_codec
*codec
,
1088 snd_pcm_substream_t
*substream
)
1090 struct alc_spec
*spec
= codec
->spec
;
1092 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
], 0, 0, 0);
1099 static struct hda_pcm_stream alc880_pcm_analog_playback
= {
1103 /* NID is set in alc_build_pcms */
1105 .open
= alc880_playback_pcm_open
,
1106 .prepare
= alc880_playback_pcm_prepare
,
1107 .cleanup
= alc880_playback_pcm_cleanup
1111 static struct hda_pcm_stream alc880_pcm_analog_capture
= {
1115 /* NID is set in alc_build_pcms */
1117 .prepare
= alc880_capture_pcm_prepare
,
1118 .cleanup
= alc880_capture_pcm_cleanup
1122 static struct hda_pcm_stream alc880_pcm_digital_playback
= {
1126 /* NID is set in alc_build_pcms */
1128 .open
= alc880_dig_playback_pcm_open
,
1129 .close
= alc880_dig_playback_pcm_close
1133 static struct hda_pcm_stream alc880_pcm_digital_capture
= {
1137 /* NID is set in alc_build_pcms */
1140 static int alc_build_pcms(struct hda_codec
*codec
)
1142 struct alc_spec
*spec
= codec
->spec
;
1143 struct hda_pcm
*info
= spec
->pcm_rec
;
1146 codec
->num_pcms
= 1;
1147 codec
->pcm_info
= info
;
1149 info
->name
= spec
->stream_name_analog
;
1150 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = *(spec
->stream_analog_playback
);
1151 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dac_nids
[0];
1152 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *(spec
->stream_analog_capture
);
1153 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
1155 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
= 0;
1156 for (i
= 0; i
< spec
->num_channel_mode
; i
++) {
1157 if (spec
->channel_mode
[i
].channels
> info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
) {
1158 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
= spec
->channel_mode
[i
].channels
;
1162 if (spec
->multiout
.dig_out_nid
|| spec
->dig_in_nid
) {
1165 info
->name
= spec
->stream_name_digital
;
1166 if (spec
->multiout
.dig_out_nid
) {
1167 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = *(spec
->stream_digital_playback
);
1168 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dig_out_nid
;
1170 if (spec
->dig_in_nid
) {
1171 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *(spec
->stream_digital_capture
);
1172 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->dig_in_nid
;
1179 static void alc_free(struct hda_codec
*codec
)
1181 struct alc_spec
*spec
= codec
->spec
;
1187 if (spec
->kctl_alloc
) {
1188 for (i
= 0; i
< spec
->num_kctl_used
; i
++)
1189 kfree(spec
->kctl_alloc
[i
].name
);
1190 kfree(spec
->kctl_alloc
);
1197 static struct hda_codec_ops alc_patch_ops
= {
1198 .build_controls
= alc_build_controls
,
1199 .build_pcms
= alc_build_pcms
,
1203 .resume
= alc_resume
,
1209 * Test configuration for debugging
1211 * Almost all inputs/outputs are enabled. I/O pins can be configured via
1214 #ifdef CONFIG_SND_DEBUG
1215 static hda_nid_t alc880_test_dac_nids
[4] = {
1216 0x02, 0x03, 0x04, 0x05
1219 static struct hda_input_mux alc880_test_capture_source
= {
1230 static struct alc_channel_mode alc880_test_modes
[4] = {
1237 static int alc_test_pin_ctl_info(snd_kcontrol_t
*kcontrol
, snd_ctl_elem_info_t
*uinfo
)
1239 static char *texts
[] = {
1240 "N/A", "Line Out", "HP Out",
1241 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
1243 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
1245 uinfo
->value
.enumerated
.items
= 8;
1246 if (uinfo
->value
.enumerated
.item
>= 8)
1247 uinfo
->value
.enumerated
.item
= 7;
1248 strcpy(uinfo
->value
.enumerated
.name
, texts
[uinfo
->value
.enumerated
.item
]);
1252 static int alc_test_pin_ctl_get(snd_kcontrol_t
*kcontrol
, snd_ctl_elem_value_t
*ucontrol
)
1254 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1255 hda_nid_t nid
= (hda_nid_t
)kcontrol
->private_value
;
1256 unsigned int pin_ctl
, item
= 0;
1258 pin_ctl
= snd_hda_codec_read(codec
, nid
, 0,
1259 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
1260 if (pin_ctl
& AC_PINCTL_OUT_EN
) {
1261 if (pin_ctl
& AC_PINCTL_HP_EN
)
1265 } else if (pin_ctl
& AC_PINCTL_IN_EN
) {
1266 switch (pin_ctl
& AC_PINCTL_VREFEN
) {
1267 case AC_PINCTL_VREF_HIZ
: item
= 3; break;
1268 case AC_PINCTL_VREF_50
: item
= 4; break;
1269 case AC_PINCTL_VREF_GRD
: item
= 5; break;
1270 case AC_PINCTL_VREF_80
: item
= 6; break;
1271 case AC_PINCTL_VREF_100
: item
= 7; break;
1274 ucontrol
->value
.enumerated
.item
[0] = item
;
1278 static int alc_test_pin_ctl_put(snd_kcontrol_t
*kcontrol
, snd_ctl_elem_value_t
*ucontrol
)
1280 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1281 hda_nid_t nid
= (hda_nid_t
)kcontrol
->private_value
;
1282 static unsigned int ctls
[] = {
1283 0, AC_PINCTL_OUT_EN
, AC_PINCTL_OUT_EN
| AC_PINCTL_HP_EN
,
1284 AC_PINCTL_IN_EN
| AC_PINCTL_VREF_HIZ
,
1285 AC_PINCTL_IN_EN
| AC_PINCTL_VREF_50
,
1286 AC_PINCTL_IN_EN
| AC_PINCTL_VREF_GRD
,
1287 AC_PINCTL_IN_EN
| AC_PINCTL_VREF_80
,
1288 AC_PINCTL_IN_EN
| AC_PINCTL_VREF_100
,
1290 unsigned int old_ctl
, new_ctl
;
1292 old_ctl
= snd_hda_codec_read(codec
, nid
, 0,
1293 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
1294 new_ctl
= ctls
[ucontrol
->value
.enumerated
.item
[0]];
1295 if (old_ctl
!= new_ctl
) {
1296 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
, new_ctl
);
1297 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
1298 ucontrol
->value
.enumerated
.item
[0] >= 3 ? 0xb080 : 0xb000);
1304 static int alc_test_pin_src_info(snd_kcontrol_t
*kcontrol
, snd_ctl_elem_info_t
*uinfo
)
1306 static char *texts
[] = {
1307 "Front", "Surround", "CLFE", "Side"
1309 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
1311 uinfo
->value
.enumerated
.items
= 4;
1312 if (uinfo
->value
.enumerated
.item
>= 4)
1313 uinfo
->value
.enumerated
.item
= 3;
1314 strcpy(uinfo
->value
.enumerated
.name
, texts
[uinfo
->value
.enumerated
.item
]);
1318 static int alc_test_pin_src_get(snd_kcontrol_t
*kcontrol
, snd_ctl_elem_value_t
*ucontrol
)
1320 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1321 hda_nid_t nid
= (hda_nid_t
)kcontrol
->private_value
;
1324 sel
= snd_hda_codec_read(codec
, nid
, 0, AC_VERB_GET_CONNECT_SEL
, 0);
1325 ucontrol
->value
.enumerated
.item
[0] = sel
& 3;
1329 static int alc_test_pin_src_put(snd_kcontrol_t
*kcontrol
, snd_ctl_elem_value_t
*ucontrol
)
1331 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1332 hda_nid_t nid
= (hda_nid_t
)kcontrol
->private_value
;
1335 sel
= snd_hda_codec_read(codec
, nid
, 0, AC_VERB_GET_CONNECT_SEL
, 0) & 3;
1336 if (ucontrol
->value
.enumerated
.item
[0] != sel
) {
1337 sel
= ucontrol
->value
.enumerated
.item
[0] & 3;
1338 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_CONNECT_SEL
, sel
);
1344 #define PIN_CTL_TEST(xname,nid) { \
1345 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1347 .info = alc_test_pin_ctl_info, \
1348 .get = alc_test_pin_ctl_get, \
1349 .put = alc_test_pin_ctl_put, \
1350 .private_value = nid \
1353 #define PIN_SRC_TEST(xname,nid) { \
1354 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1356 .info = alc_test_pin_src_info, \
1357 .get = alc_test_pin_src_get, \
1358 .put = alc_test_pin_src_put, \
1359 .private_value = nid \
1362 static snd_kcontrol_new_t alc880_test_mixer
[] = {
1363 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT
),
1364 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT
),
1365 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT
),
1366 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT
),
1367 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT
),
1368 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT
),
1369 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT
),
1370 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT
),
1371 PIN_CTL_TEST("Front Pin Mode", 0x14),
1372 PIN_CTL_TEST("Surround Pin Mode", 0x15),
1373 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
1374 PIN_CTL_TEST("Side Pin Mode", 0x17),
1375 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
1376 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
1377 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
1378 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
1379 PIN_SRC_TEST("In-1 Pin Source", 0x18),
1380 PIN_SRC_TEST("In-2 Pin Source", 0x19),
1381 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
1382 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
1383 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT
),
1384 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT
),
1385 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT
),
1386 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT
),
1387 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT
),
1388 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT
),
1389 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT
),
1390 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT
),
1391 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT
),
1392 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT
),
1394 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1395 .name
= "Channel Mode",
1396 .info
= alc880_ch_mode_info
,
1397 .get
= alc880_ch_mode_get
,
1398 .put
= alc880_ch_mode_put
,
1403 static struct hda_verb alc880_test_init_verbs
[] = {
1404 /* Unmute inputs of 0x0c - 0x0f */
1405 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
1406 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
1407 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
1408 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
1409 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
1410 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
1411 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
1412 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
1413 /* Vol output for 0x0c-0x0f */
1414 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
1415 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
1416 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
1417 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
1418 /* Set output pins 0x14-0x17 */
1419 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1420 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1421 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1422 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1423 /* Unmute output pins 0x14-0x17 */
1424 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1425 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1426 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1427 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1428 /* Set input pins 0x18-0x1c */
1429 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1430 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1431 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1432 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1433 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1434 /* Mute input pins 0x18-0x1b */
1435 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1436 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1437 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1438 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1440 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1441 {0x07, AC_VERB_SET_CONNECT_SEL
, 0x00},
1442 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1443 {0x08, AC_VERB_SET_CONNECT_SEL
, 0x00},
1444 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1445 {0x09, AC_VERB_SET_CONNECT_SEL
, 0x00},
1446 /* Analog input/passthru */
1447 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1448 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1449 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
1450 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
1451 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
1459 static struct hda_board_config alc880_cfg_tbl
[] = {
1460 /* Back 3 jack, front 2 jack */
1461 { .modelname
= "3stack", .config
= ALC880_3ST
},
1462 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe200, .config
= ALC880_3ST
},
1463 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe201, .config
= ALC880_3ST
},
1464 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe202, .config
= ALC880_3ST
},
1465 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe203, .config
= ALC880_3ST
},
1466 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe204, .config
= ALC880_3ST
},
1467 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe205, .config
= ALC880_3ST
},
1468 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe206, .config
= ALC880_3ST
},
1469 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe207, .config
= ALC880_3ST
},
1470 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe208, .config
= ALC880_3ST
},
1471 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe209, .config
= ALC880_3ST
},
1472 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe20a, .config
= ALC880_3ST
},
1473 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe20b, .config
= ALC880_3ST
},
1474 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe20c, .config
= ALC880_3ST
},
1475 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe20d, .config
= ALC880_3ST
},
1476 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe20e, .config
= ALC880_3ST
},
1477 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe20f, .config
= ALC880_3ST
},
1478 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe210, .config
= ALC880_3ST
},
1479 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe211, .config
= ALC880_3ST
},
1480 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe214, .config
= ALC880_3ST
},
1481 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe302, .config
= ALC880_3ST
},
1482 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe303, .config
= ALC880_3ST
},
1483 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe304, .config
= ALC880_3ST
},
1484 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe306, .config
= ALC880_3ST
},
1485 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe307, .config
= ALC880_3ST
},
1486 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe404, .config
= ALC880_3ST
},
1487 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xa101, .config
= ALC880_3ST
},
1488 { .pci_subvendor
= 0x107b, .pci_subdevice
= 0x3031, .config
= ALC880_3ST
},
1489 { .pci_subvendor
= 0x107b, .pci_subdevice
= 0x4036, .config
= ALC880_3ST
},
1490 { .pci_subvendor
= 0x107b, .pci_subdevice
= 0x4037, .config
= ALC880_3ST
},
1491 { .pci_subvendor
= 0x107b, .pci_subdevice
= 0x4038, .config
= ALC880_3ST
},
1492 { .pci_subvendor
= 0x107b, .pci_subdevice
= 0x4040, .config
= ALC880_3ST
},
1493 { .pci_subvendor
= 0x107b, .pci_subdevice
= 0x4041, .config
= ALC880_3ST
},
1495 /* Back 3 jack, front 2 jack (Internal add Aux-In) */
1496 { .pci_subvendor
= 0x1025, .pci_subdevice
= 0xe310, .config
= ALC880_3ST
},
1497 { .pci_subvendor
= 0x104d, .pci_subdevice
= 0x81d6, .config
= ALC880_3ST
},
1498 { .pci_subvendor
= 0x104d, .pci_subdevice
= 0x81a0, .config
= ALC880_3ST
},
1500 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
1501 { .modelname
= "3stack-digout", .config
= ALC880_3ST_DIG
},
1502 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe308, .config
= ALC880_3ST_DIG
},
1503 { .pci_subvendor
= 0x1025, .pci_subdevice
= 0x0070, .config
= ALC880_3ST_DIG
},
1505 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
1506 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe305, .config
= ALC880_3ST_DIG
},
1507 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xd402, .config
= ALC880_3ST_DIG
},
1508 { .pci_subvendor
= 0x1025, .pci_subdevice
= 0xe309, .config
= ALC880_3ST_DIG
},
1510 /* Back 5 jack, front 2 jack */
1511 { .modelname
= "5stack", .config
= ALC880_5ST
},
1512 { .pci_subvendor
= 0x107b, .pci_subdevice
= 0x3033, .config
= ALC880_5ST
},
1513 { .pci_subvendor
= 0x107b, .pci_subdevice
= 0x4039, .config
= ALC880_5ST
},
1514 { .pci_subvendor
= 0x107b, .pci_subdevice
= 0x3032, .config
= ALC880_5ST
},
1515 { .pci_subvendor
= 0x103c, .pci_subdevice
= 0x2a09, .config
= ALC880_5ST
},
1516 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x814e, .config
= ALC880_5ST
},
1518 /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
1519 { .modelname
= "5stack-digout", .config
= ALC880_5ST_DIG
},
1520 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe224, .config
= ALC880_5ST_DIG
},
1521 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe400, .config
= ALC880_5ST_DIG
},
1522 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe401, .config
= ALC880_5ST_DIG
},
1523 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe402, .config
= ALC880_5ST_DIG
},
1524 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xd400, .config
= ALC880_5ST_DIG
},
1525 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xd401, .config
= ALC880_5ST_DIG
},
1526 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xa100, .config
= ALC880_5ST_DIG
},
1527 { .pci_subvendor
= 0x1565, .pci_subdevice
= 0x8202, .config
= ALC880_5ST_DIG
},
1528 { .pci_subvendor
= 0x1019, .pci_subdevice
= 0xa880, .config
= ALC880_5ST_DIG
},
1529 /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
1530 { .pci_subvendor
= 0x1695, .pci_subdevice
= 0x400d, .config
= ALC880_5ST_DIG
},
1531 /* note subvendor = 0 below */
1532 /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
1534 { .modelname
= "w810", .config
= ALC880_W810
},
1535 { .pci_subvendor
= 0x161f, .pci_subdevice
= 0x203d, .config
= ALC880_W810
},
1537 { .modelname
= "z71v", .config
= ALC880_Z71V
},
1538 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x1964, .config
= ALC880_Z71V
},
1540 { .modelname
= "6stack", .config
= ALC880_6ST
},
1541 { .pci_subvendor
= 0x1019, .pci_subdevice
= 0xa884, .config
= ALC880_6ST
}, /* Acer APFV */
1543 { .modelname
= "6stack-digout", .config
= ALC880_6ST_DIG
},
1544 { .pci_subvendor
= 0x2668, .pci_subdevice
= 0x8086, .config
= ALC880_6ST_DIG
},
1545 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0x2668, .config
= ALC880_6ST_DIG
},
1546 { .pci_subvendor
= 0x1462, .pci_subdevice
= 0x1150, .config
= ALC880_6ST_DIG
},
1547 { .pci_subvendor
= 0xe803, .pci_subdevice
= 0x1019, .config
= ALC880_6ST_DIG
},
1549 { .modelname
= "asus", .config
= ALC880_ASUS
},
1550 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x1964, .config
= ALC880_ASUS_DIG
},
1551 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x1973, .config
= ALC880_ASUS_DIG
},
1552 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x19b3, .config
= ALC880_ASUS_DIG
},
1553 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x1113, .config
= ALC880_ASUS_DIG
},
1554 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x1173, .config
= ALC880_ASUS_DIG
},
1555 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x1993, .config
= ALC880_ASUS
},
1556 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x10c3, .config
= ALC880_ASUS_DIG
},
1557 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x1133, .config
= ALC880_ASUS
},
1558 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x1123, .config
= ALC880_ASUS_DIG
},
1559 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x1143, .config
= ALC880_ASUS
},
1560 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x10b3, .config
= ALC880_ASUS_W1V
},
1562 { .modelname
= "uniwill", .config
= ALC880_UNIWILL_DIG
},
1563 { .pci_subvendor
= 0x1584, .pci_subdevice
= 0x9050, .config
= ALC880_UNIWILL_DIG
},
1565 { .modelname
= "F1734", .config
= ALC880_F1734
},
1566 { .pci_subvendor
= 0x1734, .pci_subdevice
= 0x107c, .config
= ALC880_F1734
},
1568 #ifdef CONFIG_SND_DEBUG
1569 { .modelname
= "test", .config
= ALC880_TEST
},
1576 * configuration template - to be copied to the spec instance
1578 struct alc_config_preset
{
1579 snd_kcontrol_new_t
*mixers
[4];
1580 const struct hda_verb
*init_verbs
[4];
1581 unsigned int num_dacs
;
1582 hda_nid_t
*dac_nids
;
1583 hda_nid_t dig_out_nid
; /* optional */
1584 hda_nid_t hp_nid
; /* optional */
1585 unsigned int num_adc_nids
;
1586 hda_nid_t
*adc_nids
;
1587 unsigned int num_channel_mode
;
1588 const struct alc_channel_mode
*channel_mode
;
1589 const struct hda_input_mux
*input_mux
;
1592 static struct alc_config_preset alc880_presets
[] = {
1594 .mixers
= { alc880_three_stack_mixer
},
1595 .init_verbs
= { alc880_volume_init_verbs
, alc880_pin_3stack_init_verbs
},
1596 .num_dacs
= ARRAY_SIZE(alc880_dac_nids
),
1597 .dac_nids
= alc880_dac_nids
,
1598 .num_channel_mode
= ARRAY_SIZE(alc880_threestack_modes
),
1599 .channel_mode
= alc880_threestack_modes
,
1600 .input_mux
= &alc880_capture_source
,
1602 [ALC880_3ST_DIG
] = {
1603 .mixers
= { alc880_three_stack_mixer
},
1604 .init_verbs
= { alc880_volume_init_verbs
, alc880_pin_3stack_init_verbs
},
1605 .num_dacs
= ARRAY_SIZE(alc880_dac_nids
),
1606 .dac_nids
= alc880_dac_nids
,
1607 .dig_out_nid
= ALC880_DIGOUT_NID
,
1608 .num_channel_mode
= ARRAY_SIZE(alc880_threestack_modes
),
1609 .channel_mode
= alc880_threestack_modes
,
1610 .input_mux
= &alc880_capture_source
,
1613 .mixers
= { alc880_three_stack_mixer
, alc880_five_stack_mixer
},
1614 .init_verbs
= { alc880_volume_init_verbs
, alc880_pin_5stack_init_verbs
},
1615 .num_dacs
= ARRAY_SIZE(alc880_dac_nids
),
1616 .dac_nids
= alc880_dac_nids
,
1617 .num_channel_mode
= ARRAY_SIZE(alc880_fivestack_modes
),
1618 .channel_mode
= alc880_fivestack_modes
,
1619 .input_mux
= &alc880_capture_source
,
1621 [ALC880_5ST_DIG
] = {
1622 .mixers
= { alc880_three_stack_mixer
, alc880_five_stack_mixer
},
1623 .init_verbs
= { alc880_volume_init_verbs
, alc880_pin_5stack_init_verbs
},
1624 .num_dacs
= ARRAY_SIZE(alc880_dac_nids
),
1625 .dac_nids
= alc880_dac_nids
,
1626 .dig_out_nid
= ALC880_DIGOUT_NID
,
1627 .num_channel_mode
= ARRAY_SIZE(alc880_fivestack_modes
),
1628 .channel_mode
= alc880_fivestack_modes
,
1629 .input_mux
= &alc880_capture_source
,
1632 .mixers
= { alc880_six_stack_mixer
},
1633 .init_verbs
= { alc880_volume_init_verbs
, alc880_pin_6stack_init_verbs
},
1634 .num_dacs
= ARRAY_SIZE(alc880_6st_dac_nids
),
1635 .dac_nids
= alc880_6st_dac_nids
,
1636 .num_channel_mode
= ARRAY_SIZE(alc880_sixstack_modes
),
1637 .channel_mode
= alc880_sixstack_modes
,
1638 .input_mux
= &alc880_6stack_capture_source
,
1640 [ALC880_6ST_DIG
] = {
1641 .mixers
= { alc880_six_stack_mixer
},
1642 .init_verbs
= { alc880_volume_init_verbs
, alc880_pin_6stack_init_verbs
},
1643 .num_dacs
= ARRAY_SIZE(alc880_6st_dac_nids
),
1644 .dac_nids
= alc880_6st_dac_nids
,
1645 .dig_out_nid
= ALC880_DIGOUT_NID
,
1646 .num_channel_mode
= ARRAY_SIZE(alc880_sixstack_modes
),
1647 .channel_mode
= alc880_sixstack_modes
,
1648 .input_mux
= &alc880_6stack_capture_source
,
1651 .mixers
= { alc880_w810_base_mixer
},
1652 .init_verbs
= { alc880_volume_init_verbs
, alc880_pin_w810_init_verbs
,
1653 alc880_gpio2_init_verbs
},
1654 .num_dacs
= ARRAY_SIZE(alc880_w810_dac_nids
),
1655 .dac_nids
= alc880_w810_dac_nids
,
1656 .dig_out_nid
= ALC880_DIGOUT_NID
,
1657 .num_channel_mode
= ARRAY_SIZE(alc880_w810_modes
),
1658 .channel_mode
= alc880_w810_modes
,
1659 .input_mux
= &alc880_capture_source
,
1662 .mixers
= { alc880_z71v_mixer
},
1663 .init_verbs
= { alc880_volume_init_verbs
, alc880_pin_z71v_init_verbs
},
1664 .num_dacs
= ARRAY_SIZE(alc880_z71v_dac_nids
),
1665 .dac_nids
= alc880_z71v_dac_nids
,
1666 .dig_out_nid
= ALC880_DIGOUT_NID
,
1668 .num_channel_mode
= ARRAY_SIZE(alc880_2_jack_modes
),
1669 .channel_mode
= alc880_2_jack_modes
,
1670 .input_mux
= &alc880_capture_source
,
1673 .mixers
= { alc880_f1734_mixer
},
1674 .init_verbs
= { alc880_volume_init_verbs
, alc880_pin_f1734_init_verbs
},
1675 .num_dacs
= ARRAY_SIZE(alc880_f1734_dac_nids
),
1676 .dac_nids
= alc880_f1734_dac_nids
,
1678 .num_channel_mode
= ARRAY_SIZE(alc880_2_jack_modes
),
1679 .channel_mode
= alc880_2_jack_modes
,
1680 .input_mux
= &alc880_capture_source
,
1683 .mixers
= { alc880_asus_mixer
},
1684 .init_verbs
= { alc880_volume_init_verbs
, alc880_pin_asus_init_verbs
,
1685 alc880_gpio1_init_verbs
},
1686 .num_dacs
= ARRAY_SIZE(alc880_asus_dac_nids
),
1687 .dac_nids
= alc880_asus_dac_nids
,
1688 .num_channel_mode
= ARRAY_SIZE(alc880_asus_modes
),
1689 .channel_mode
= alc880_asus_modes
,
1690 .input_mux
= &alc880_capture_source
,
1692 [ALC880_ASUS_DIG
] = {
1693 .mixers
= { alc880_asus_mixer
},
1694 .init_verbs
= { alc880_volume_init_verbs
, alc880_pin_asus_init_verbs
,
1695 alc880_gpio1_init_verbs
},
1696 .num_dacs
= ARRAY_SIZE(alc880_asus_dac_nids
),
1697 .dac_nids
= alc880_asus_dac_nids
,
1698 .dig_out_nid
= ALC880_DIGOUT_NID
,
1699 .num_channel_mode
= ARRAY_SIZE(alc880_asus_modes
),
1700 .channel_mode
= alc880_asus_modes
,
1701 .input_mux
= &alc880_capture_source
,
1703 [ALC880_ASUS_W1V
] = {
1704 .mixers
= { alc880_asus_mixer
, alc880_asus_w1v_mixer
},
1705 .init_verbs
= { alc880_volume_init_verbs
, alc880_pin_asus_init_verbs
,
1706 alc880_gpio1_init_verbs
},
1707 .num_dacs
= ARRAY_SIZE(alc880_asus_dac_nids
),
1708 .dac_nids
= alc880_asus_dac_nids
,
1709 .dig_out_nid
= ALC880_DIGOUT_NID
,
1710 .num_channel_mode
= ARRAY_SIZE(alc880_asus_modes
),
1711 .channel_mode
= alc880_asus_modes
,
1712 .input_mux
= &alc880_capture_source
,
1714 [ALC880_UNIWILL_DIG
] = {
1715 .mixers
= { alc880_asus_mixer
, alc880_pcbeep_mixer
},
1716 .init_verbs
= { alc880_volume_init_verbs
, alc880_pin_asus_init_verbs
},
1717 .num_dacs
= ARRAY_SIZE(alc880_asus_dac_nids
),
1718 .dac_nids
= alc880_asus_dac_nids
,
1719 .dig_out_nid
= ALC880_DIGOUT_NID
,
1720 .num_channel_mode
= ARRAY_SIZE(alc880_asus_modes
),
1721 .channel_mode
= alc880_asus_modes
,
1722 .input_mux
= &alc880_capture_source
,
1724 #ifdef CONFIG_SND_DEBUG
1726 .mixers
= { alc880_test_mixer
},
1727 .init_verbs
= { alc880_test_init_verbs
},
1728 .num_dacs
= ARRAY_SIZE(alc880_test_dac_nids
),
1729 .dac_nids
= alc880_test_dac_nids
,
1730 .dig_out_nid
= ALC880_DIGOUT_NID
,
1731 .num_channel_mode
= ARRAY_SIZE(alc880_test_modes
),
1732 .channel_mode
= alc880_test_modes
,
1733 .input_mux
= &alc880_test_capture_source
,
1739 * Automatic parse of I/O pins from the BIOS configuration
1742 #define NUM_CONTROL_ALLOC 32
1743 #define NUM_VERB_ALLOC 32
1747 ALC_CTL_WIDGET_MUTE
,
1750 static snd_kcontrol_new_t alc880_control_templates
[] = {
1751 HDA_CODEC_VOLUME(NULL
, 0, 0, 0),
1752 HDA_CODEC_MUTE(NULL
, 0, 0, 0),
1753 HDA_BIND_MUTE(NULL
, 0, 0, 0),
1756 /* add dynamic controls */
1757 static int add_control(struct alc_spec
*spec
, int type
, const char *name
, unsigned long val
)
1759 snd_kcontrol_new_t
*knew
;
1761 if (spec
->num_kctl_used
>= spec
->num_kctl_alloc
) {
1762 int num
= spec
->num_kctl_alloc
+ NUM_CONTROL_ALLOC
;
1764 knew
= kcalloc(num
+ 1, sizeof(*knew
), GFP_KERNEL
); /* array + terminator */
1767 if (spec
->kctl_alloc
) {
1768 memcpy(knew
, spec
->kctl_alloc
, sizeof(*knew
) * spec
->num_kctl_alloc
);
1769 kfree(spec
->kctl_alloc
);
1771 spec
->kctl_alloc
= knew
;
1772 spec
->num_kctl_alloc
= num
;
1775 knew
= &spec
->kctl_alloc
[spec
->num_kctl_used
];
1776 *knew
= alc880_control_templates
[type
];
1777 knew
->name
= kstrdup(name
, GFP_KERNEL
);
1780 knew
->private_value
= val
;
1781 spec
->num_kctl_used
++;
1785 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
1786 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
1787 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
1788 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
1789 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
1790 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
1791 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
1792 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
1793 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
1794 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
1795 #define ALC880_PIN_CD_NID 0x1c
1797 /* fill in the dac_nids table from the parsed pin configuration */
1798 static int alc880_auto_fill_dac_nids(struct alc_spec
*spec
, const struct auto_pin_cfg
*cfg
)
1804 memset(assigned
, 0, sizeof(assigned
));
1805 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
1807 /* check the pins hardwired to audio widget */
1808 for (i
= 0; i
< cfg
->line_outs
; i
++) {
1809 nid
= cfg
->line_out_pins
[i
];
1810 if (alc880_is_fixed_pin(nid
)) {
1811 int idx
= alc880_fixed_pin_idx(nid
);
1812 spec
->multiout
.dac_nids
[i
] = alc880_dac_to_idx(idx
);
1816 /* left pins can be connect to any audio widget */
1817 for (i
= 0; i
< cfg
->line_outs
; i
++) {
1818 nid
= cfg
->line_out_pins
[i
];
1819 if (alc880_is_fixed_pin(nid
))
1821 /* search for an empty channel */
1822 for (j
= 0; j
< cfg
->line_outs
; j
++) {
1823 if (! assigned
[j
]) {
1824 spec
->multiout
.dac_nids
[i
] = alc880_idx_to_dac(j
);
1830 spec
->multiout
.num_dacs
= cfg
->line_outs
;
1834 /* add playback controls from the parsed DAC table */
1835 static int alc880_auto_create_multi_out_ctls(struct alc_spec
*spec
, const struct auto_pin_cfg
*cfg
)
1838 static const char *chname
[4] = { "Front", "Surround", NULL
/*CLFE*/, "Side" };
1842 for (i
= 0; i
< cfg
->line_outs
; i
++) {
1843 if (! spec
->multiout
.dac_nids
[i
])
1845 nid
= alc880_idx_to_mixer(alc880_dac_to_idx(spec
->multiout
.dac_nids
[i
]));
1848 if ((err
= add_control(spec
, ALC_CTL_WIDGET_VOL
, "Center Playback Volume",
1849 HDA_COMPOSE_AMP_VAL(nid
, 1, 0, HDA_OUTPUT
))) < 0)
1851 if ((err
= add_control(spec
, ALC_CTL_WIDGET_VOL
, "LFE Playback Volume",
1852 HDA_COMPOSE_AMP_VAL(nid
, 2, 0, HDA_OUTPUT
))) < 0)
1854 if ((err
= add_control(spec
, ALC_CTL_BIND_MUTE
, "Center Playback Switch",
1855 HDA_COMPOSE_AMP_VAL(nid
, 1, 2, HDA_INPUT
))) < 0)
1857 if ((err
= add_control(spec
, ALC_CTL_BIND_MUTE
, "LFE Playback Switch",
1858 HDA_COMPOSE_AMP_VAL(nid
, 2, 2, HDA_INPUT
))) < 0)
1861 sprintf(name
, "%s Playback Volume", chname
[i
]);
1862 if ((err
= add_control(spec
, ALC_CTL_WIDGET_VOL
, name
,
1863 HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
))) < 0)
1865 sprintf(name
, "%s Playback Switch", chname
[i
]);
1866 if ((err
= add_control(spec
, ALC_CTL_BIND_MUTE
, name
,
1867 HDA_COMPOSE_AMP_VAL(nid
, 3, 2, HDA_INPUT
))) < 0)
1875 /* add playback controls for HP output */
1876 static int alc880_auto_create_hp_ctls(struct alc_spec
*spec
, hda_nid_t pin
)
1884 if (alc880_is_fixed_pin(pin
)) {
1885 nid
= alc880_idx_to_dac(alc880_fixed_pin_idx(pin
));
1886 if (! spec
->multiout
.dac_nids
[0]) {
1887 /* use this as the primary output */
1888 spec
->multiout
.dac_nids
[0] = nid
;
1889 if (! spec
->multiout
.num_dacs
)
1890 spec
->multiout
.num_dacs
= 1;
1892 /* specify the DAC as the extra HP output */
1893 spec
->multiout
.hp_nid
= nid
;
1894 /* control HP volume/switch on the output mixer amp */
1895 nid
= alc880_idx_to_mixer(alc880_fixed_pin_idx(pin
));
1896 if ((err
= add_control(spec
, ALC_CTL_WIDGET_VOL
, "Headphone Playback Volume",
1897 HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
))) < 0)
1899 if ((err
= add_control(spec
, ALC_CTL_BIND_MUTE
, "Headphone Playback Switch",
1900 HDA_COMPOSE_AMP_VAL(nid
, 3, 2, HDA_INPUT
))) < 0)
1902 } else if (alc880_is_multi_pin(pin
)) {
1903 /* set manual connection */
1904 if (! spec
->multiout
.dac_nids
[0]) {
1905 /* use this as the primary output */
1906 spec
->multiout
.dac_nids
[0] = alc880_idx_to_dac(alc880_multi_pin_idx(pin
));
1907 if (! spec
->multiout
.num_dacs
)
1908 spec
->multiout
.num_dacs
= 1;
1910 /* we have only a switch on HP-out PIN */
1911 if ((err
= add_control(spec
, ALC_CTL_WIDGET_MUTE
, "Headphone Playback Switch",
1912 HDA_COMPOSE_AMP_VAL(pin
, 3, 0, HDA_OUTPUT
))) < 0)
1918 /* create input playback/capture controls for the given pin */
1919 static int new_analog_input(struct alc_spec
*spec
, hda_nid_t pin
, const char *ctlname
)
1924 sprintf(name
, "%s Playback Volume", ctlname
);
1925 idx
= alc880_input_pin_idx(pin
);
1926 if ((err
= add_control(spec
, ALC_CTL_WIDGET_VOL
, name
,
1927 HDA_COMPOSE_AMP_VAL(0x0b, 3, idx
, HDA_INPUT
))) < 0)
1929 sprintf(name
, "%s Playback Switch", ctlname
);
1930 if ((err
= add_control(spec
, ALC_CTL_WIDGET_MUTE
, name
,
1931 HDA_COMPOSE_AMP_VAL(0x0b, 3, idx
, HDA_INPUT
))) < 0)
1936 /* create playback/capture controls for input pins */
1937 static int alc880_auto_create_analog_input_ctls(struct alc_spec
*spec
, const struct auto_pin_cfg
*cfg
)
1939 static char *labels
[AUTO_PIN_LAST
] = {
1940 "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux"
1942 struct hda_input_mux
*imux
= &spec
->private_imux
;
1945 for (i
= 0; i
< AUTO_PIN_LAST
; i
++) {
1946 if (alc880_is_input_pin(cfg
->input_pins
[i
])) {
1947 err
= new_analog_input(spec
, cfg
->input_pins
[i
], labels
[i
]);
1950 imux
->items
[imux
->num_items
].label
= labels
[i
];
1951 imux
->items
[imux
->num_items
].index
= alc880_input_pin_idx(cfg
->input_pins
[i
]);
1958 static void alc880_auto_set_output_and_unmute(struct hda_codec
*codec
, hda_nid_t nid
, int pin_type
,
1962 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
, pin_type
);
1963 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
);
1964 /* need the manual connection? */
1965 if (alc880_is_multi_pin(nid
)) {
1966 struct alc_spec
*spec
= codec
->spec
;
1967 int idx
= alc880_multi_pin_idx(nid
);
1968 snd_hda_codec_write(codec
, alc880_idx_to_selector(idx
), 0,
1969 AC_VERB_SET_CONNECT_SEL
,
1970 alc880_dac_to_idx(spec
->multiout
.dac_nids
[dac_idx
]));
1974 static void alc880_auto_init_multi_out(struct hda_codec
*codec
)
1976 struct alc_spec
*spec
= codec
->spec
;
1979 for (i
= 0; i
< spec
->autocfg
.line_outs
; i
++) {
1980 hda_nid_t nid
= spec
->autocfg
.line_out_pins
[i
];
1981 alc880_auto_set_output_and_unmute(codec
, nid
, PIN_OUT
, i
);
1985 static void alc880_auto_init_hp_out(struct hda_codec
*codec
)
1987 struct alc_spec
*spec
= codec
->spec
;
1990 pin
= spec
->autocfg
.hp_pin
;
1991 if (pin
) /* connect to front */
1992 alc880_auto_set_output_and_unmute(codec
, pin
, PIN_HP
, 0);
1995 static void alc880_auto_init_analog_input(struct hda_codec
*codec
)
1997 struct alc_spec
*spec
= codec
->spec
;
2000 for (i
= 0; i
< AUTO_PIN_LAST
; i
++) {
2001 hda_nid_t nid
= spec
->autocfg
.input_pins
[i
];
2002 if (alc880_is_input_pin(nid
)) {
2003 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2004 i
<= AUTO_PIN_FRONT_MIC
? PIN_VREF80
: PIN_IN
);
2005 if (nid
!= ALC880_PIN_CD_NID
)
2006 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
2012 /* parse the BIOS configuration and set up the alc_spec */
2013 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2014 static int alc880_parse_auto_config(struct hda_codec
*codec
)
2016 struct alc_spec
*spec
= codec
->spec
;
2019 if ((err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
)) < 0)
2021 if ((err
= alc880_auto_fill_dac_nids(spec
, &spec
->autocfg
)) < 0)
2023 if (! spec
->autocfg
.line_outs
&& ! spec
->autocfg
.hp_pin
)
2024 return 0; /* can't find valid BIOS pin config */
2025 if ((err
= alc880_auto_create_multi_out_ctls(spec
, &spec
->autocfg
)) < 0 ||
2026 (err
= alc880_auto_create_hp_ctls(spec
, spec
->autocfg
.hp_pin
)) < 0 ||
2027 (err
= alc880_auto_create_analog_input_ctls(spec
, &spec
->autocfg
)) < 0)
2030 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
2032 if (spec
->autocfg
.dig_out_pin
)
2033 spec
->multiout
.dig_out_nid
= ALC880_DIGOUT_NID
;
2034 if (spec
->autocfg
.dig_in_pin
)
2035 spec
->dig_in_nid
= ALC880_DIGIN_NID
;
2037 if (spec
->kctl_alloc
)
2038 spec
->mixers
[spec
->num_mixers
++] = spec
->kctl_alloc
;
2040 spec
->init_verbs
[spec
->num_init_verbs
++] = alc880_volume_init_verbs
;
2042 spec
->input_mux
= &spec
->private_imux
;
2047 /* init callback for auto-configuration model -- overriding the default init */
2048 static int alc880_auto_init(struct hda_codec
*codec
)
2051 alc880_auto_init_multi_out(codec
);
2052 alc880_auto_init_hp_out(codec
);
2053 alc880_auto_init_analog_input(codec
);
2058 * OK, here we have finally the patch for ALC880
2061 static int patch_alc880(struct hda_codec
*codec
)
2063 struct alc_spec
*spec
;
2067 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
2073 board_config
= snd_hda_check_board_config(codec
, alc880_cfg_tbl
);
2074 if (board_config
< 0 || board_config
>= ALC880_MODEL_LAST
) {
2075 printk(KERN_INFO
"hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n");
2076 board_config
= ALC880_AUTO
;
2079 if (board_config
== ALC880_AUTO
) {
2080 /* automatic parse from the BIOS config */
2081 err
= alc880_parse_auto_config(codec
);
2086 printk(KERN_INFO
"hda_codec: Cannot set up configuration from BIOS. Using 3-stack mode...\n");
2087 board_config
= ALC880_3ST
;
2091 if (board_config
!= ALC880_AUTO
) {
2092 /* set up from the preset table */
2093 const struct alc_config_preset
*preset
;
2095 preset
= &alc880_presets
[board_config
];
2097 for (i
= 0; preset
->mixers
[i
]; i
++) {
2098 snd_assert(spec
->num_mixers
< ARRAY_SIZE(spec
->mixers
), break);
2099 spec
->mixers
[spec
->num_mixers
++] = preset
->mixers
[i
];
2101 for (i
= 0; preset
->init_verbs
[i
]; i
++) {
2102 snd_assert(spec
->num_init_verbs
< ARRAY_SIZE(spec
->init_verbs
), break);
2103 spec
->init_verbs
[spec
->num_init_verbs
++] = preset
->init_verbs
[i
];
2106 spec
->channel_mode
= preset
->channel_mode
;
2107 spec
->num_channel_mode
= preset
->num_channel_mode
;
2109 spec
->multiout
.max_channels
= spec
->channel_mode
[0].channels
;
2111 spec
->multiout
.num_dacs
= preset
->num_dacs
;
2112 spec
->multiout
.dac_nids
= preset
->dac_nids
;
2113 spec
->multiout
.dig_out_nid
= preset
->dig_out_nid
;
2114 spec
->multiout
.hp_nid
= preset
->hp_nid
;
2116 spec
->input_mux
= preset
->input_mux
;
2118 spec
->num_adc_nids
= preset
->num_adc_nids
;
2119 spec
->adc_nids
= preset
->adc_nids
;
2122 spec
->stream_name_analog
= "ALC880 Analog";
2123 spec
->stream_analog_playback
= &alc880_pcm_analog_playback
;
2124 spec
->stream_analog_capture
= &alc880_pcm_analog_capture
;
2126 spec
->stream_name_digital
= "ALC880 Digital";
2127 spec
->stream_digital_playback
= &alc880_pcm_digital_playback
;
2128 spec
->stream_digital_capture
= &alc880_pcm_digital_capture
;
2130 if (! spec
->adc_nids
&& spec
->input_mux
) {
2131 /* check whether NID 0x07 is valid */
2132 unsigned int wcap
= snd_hda_param_read(codec
, alc880_adc_nids
[0],
2133 AC_PAR_AUDIO_WIDGET_CAP
);
2134 wcap
= (wcap
& AC_WCAP_TYPE
) >> AC_WCAP_TYPE_SHIFT
; /* get type */
2135 if (wcap
!= AC_WID_AUD_IN
) {
2136 spec
->adc_nids
= alc880_adc_nids_alt
;
2137 spec
->num_adc_nids
= ARRAY_SIZE(alc880_adc_nids_alt
);
2138 spec
->mixers
[spec
->num_mixers
] = alc880_capture_alt_mixer
;
2141 spec
->adc_nids
= alc880_adc_nids
;
2142 spec
->num_adc_nids
= ARRAY_SIZE(alc880_adc_nids
);
2143 spec
->mixers
[spec
->num_mixers
] = alc880_capture_mixer
;
2148 codec
->patch_ops
= alc_patch_ops
;
2149 if (board_config
== ALC880_AUTO
)
2150 codec
->patch_ops
.init
= alc880_auto_init
;
2160 static hda_nid_t alc260_dac_nids
[1] = {
2165 static hda_nid_t alc260_adc_nids
[1] = {
2170 static hda_nid_t alc260_hp_adc_nids
[1] = {
2175 #define ALC260_DIGOUT_NID 0x03
2176 #define ALC260_DIGIN_NID 0x06
2178 static struct hda_input_mux alc260_capture_source
= {
2182 { "Front Mic", 0x1 },
2188 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack
2189 * and the internal CD lines.
2191 static struct hda_input_mux alc260_fujitsu_capture_source
= {
2194 { "Mic/Line", 0x0 },
2200 * This is just place-holder, so there's something for alc_build_pcms to look
2201 * at when it calculates the maximum number of channels. ALC260 has no mixer
2202 * element which allows changing the channel mode, so the verb list is
2205 static struct alc_channel_mode alc260_modes
[1] = {
2209 static snd_kcontrol_new_t alc260_base_mixer
[] = {
2210 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT
),
2211 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT
),
2212 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT
),
2213 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT
),
2214 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT
),
2215 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT
),
2216 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT
),
2217 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT
),
2218 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT
),
2219 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT
),
2220 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT
),
2221 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT
),
2222 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT
),
2223 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT
),
2224 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT
),
2225 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT
),
2226 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT
),
2227 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT
),
2229 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2230 .name
= "Capture Source",
2231 .info
= alc_mux_enum_info
,
2232 .get
= alc_mux_enum_get
,
2233 .put
= alc_mux_enum_put
,
2238 static snd_kcontrol_new_t alc260_hp_mixer
[] = {
2239 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT
),
2240 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT
),
2241 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT
),
2242 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT
),
2243 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT
),
2244 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT
),
2245 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT
),
2246 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT
),
2247 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT
),
2248 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT
),
2249 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT
),
2250 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT
),
2251 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT
),
2252 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT
),
2253 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT
),
2254 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT
),
2256 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2257 .name
= "Capture Source",
2258 .info
= alc_mux_enum_info
,
2259 .get
= alc_mux_enum_get
,
2260 .put
= alc_mux_enum_put
,
2265 static snd_kcontrol_new_t alc260_fujitsu_mixer
[] = {
2266 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT
),
2267 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT
),
2268 ALC_PINCTL_SWITCH("Headphone Amp Switch", 0x14, PIN_HP_AMP
),
2269 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT
),
2270 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT
),
2271 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT
),
2272 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT
),
2273 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT
),
2274 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT
),
2275 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT
),
2276 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT
),
2277 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT
),
2278 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT
),
2280 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2281 .name
= "Capture Source",
2282 .info
= alc_mux_enum_info
,
2283 .get
= alc_mux_enum_get
,
2284 .put
= alc_mux_enum_put
,
2289 static struct hda_verb alc260_init_verbs
[] = {
2290 /* Line In pin widget for input */
2291 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2292 /* CD pin widget for input */
2293 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2294 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2295 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2296 /* Mic2 (front panel) pin widget for input and vref at 80% */
2297 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2298 /* LINE-2 is used for line-out in rear */
2299 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2300 /* select line-out */
2301 {0x15, AC_VERB_SET_CONNECT_SEL
, 0x00},
2303 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2305 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2307 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2308 /* mute capture amp left and right */
2309 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2310 /* set connection select to line in (default select for this ADC) */
2311 {0x04, AC_VERB_SET_CONNECT_SEL
, 0x02},
2312 /* mute capture amp left and right */
2313 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2314 /* set connection select to line in (default select for this ADC) */
2315 {0x05, AC_VERB_SET_CONNECT_SEL
, 0x02},
2316 /* set vol=0 Line-Out mixer amp left and right */
2317 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2318 /* unmute pin widget amp left and right (no gain on this amp) */
2319 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2320 /* set vol=0 HP mixer amp left and right */
2321 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2322 /* unmute pin widget amp left and right (no gain on this amp) */
2323 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2324 /* set vol=0 Mono mixer amp left and right */
2325 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2326 /* unmute pin widget amp left and right (no gain on this amp) */
2327 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2328 /* unmute LINE-2 out pin */
2329 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2330 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
2332 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(4)},
2334 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2)},
2336 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2337 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
2338 /* mute Front out path */
2339 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2340 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2341 /* mute Headphone out path */
2342 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2343 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2344 /* mute Mono out path */
2345 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2346 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2350 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
2353 static struct hda_verb alc260_fujitsu_init_verbs
[] = {
2354 /* Disable all GPIOs */
2355 {0x01, AC_VERB_SET_GPIO_MASK
, 0},
2356 /* Internal speaker is connected to headphone pin */
2357 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2358 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
2359 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2360 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
2361 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2362 /* Ensure all other unused pins are disabled and muted.
2363 * Note: trying to set widget 0x15 to anything blocks all audio
2364 * output for some reason, so just leave that at the default.
2366 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2367 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2368 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2369 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2370 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2371 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2372 /* Disable digital (SPDIF) pins */
2373 {0x03, AC_VERB_SET_DIGI_CONVERT_1
, 0},
2374 {0x06, AC_VERB_SET_DIGI_CONVERT_1
, 0},
2376 /* Start with mixer outputs muted */
2377 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2378 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2379 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2381 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
2382 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2383 /* Unmute Line1 pin widget amp left and right (no equiv mixer ctrl) */
2384 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2385 /* Unmute pin widget used for Line-in (no equiv mixer ctrl) */
2386 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2388 /* Mute capture amp left and right */
2389 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2390 /* Set ADC connection select to line in (on mic1 pin) */
2391 {0x04, AC_VERB_SET_CONNECT_SEL
, 0x00},
2393 /* Mute all inputs to mixer widget (even unconnected ones) */
2394 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* mic1 pin */
2395 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* mic2 pin */
2396 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* line1 pin */
2397 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* line2 pin */
2398 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
2399 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)}, /* Beep-gen pin */
2400 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)}, /* Line-out pin */
2401 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)}, /* HP-pin pin */
2404 static struct hda_pcm_stream alc260_pcm_analog_playback
= {
2410 static struct hda_pcm_stream alc260_pcm_analog_capture
= {
2416 static struct hda_board_config alc260_cfg_tbl
[] = {
2417 { .modelname
= "hp", .config
= ALC260_HP
},
2418 { .pci_subvendor
= 0x103c, .config
= ALC260_HP
},
2419 { .modelname
= "fujitsu", .config
= ALC260_FUJITSU_S702x
},
2420 { .pci_subvendor
= 0x10cf, .pci_subdevice
= 0x1326, .config
= ALC260_FUJITSU_S702x
},
2424 static int patch_alc260(struct hda_codec
*codec
)
2426 struct alc_spec
*spec
;
2429 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
2435 board_config
= snd_hda_check_board_config(codec
, alc260_cfg_tbl
);
2436 if (board_config
< 0 || board_config
>= ALC260_MODEL_LAST
) {
2437 snd_printd(KERN_INFO
"hda_codec: Unknown model for ALC260\n");
2438 board_config
= ALC260_BASIC
;
2441 switch (board_config
) {
2443 spec
->mixers
[spec
->num_mixers
] = alc260_hp_mixer
;
2446 case ALC260_FUJITSU_S702x
:
2447 spec
->mixers
[spec
->num_mixers
] = alc260_fujitsu_mixer
;
2451 spec
->mixers
[spec
->num_mixers
] = alc260_base_mixer
;
2456 if (board_config
!= ALC260_FUJITSU_S702x
) {
2457 spec
->init_verbs
[0] = alc260_init_verbs
;
2458 spec
->num_init_verbs
= 1;
2460 spec
->init_verbs
[0] = alc260_fujitsu_init_verbs
;
2461 spec
->num_init_verbs
= 1;
2464 spec
->channel_mode
= alc260_modes
;
2465 spec
->num_channel_mode
= ARRAY_SIZE(alc260_modes
);
2467 spec
->stream_name_analog
= "ALC260 Analog";
2468 spec
->stream_analog_playback
= &alc260_pcm_analog_playback
;
2469 spec
->stream_analog_capture
= &alc260_pcm_analog_capture
;
2471 spec
->multiout
.max_channels
= spec
->channel_mode
[0].channels
;
2472 spec
->multiout
.num_dacs
= ARRAY_SIZE(alc260_dac_nids
);
2473 spec
->multiout
.dac_nids
= alc260_dac_nids
;
2475 if (board_config
!= ALC260_FUJITSU_S702x
) {
2476 spec
->input_mux
= &alc260_capture_source
;
2478 spec
->input_mux
= &alc260_fujitsu_capture_source
;
2480 switch (board_config
) {
2482 spec
->num_adc_nids
= ARRAY_SIZE(alc260_hp_adc_nids
);
2483 spec
->adc_nids
= alc260_hp_adc_nids
;
2486 spec
->num_adc_nids
= ARRAY_SIZE(alc260_adc_nids
);
2487 spec
->adc_nids
= alc260_adc_nids
;
2491 codec
->patch_ops
= alc_patch_ops
;
2500 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
2501 * configuration. Each pin widget can choose any input DACs and a mixer.
2502 * Each ADC is connected from a mixer of all inputs. This makes possible
2503 * 6-channel independent captures.
2505 * In addition, an independent DAC for the multi-playback (not used in this
2509 static struct alc_channel_mode alc882_ch_modes
[1] = {
2513 static hda_nid_t alc882_dac_nids
[4] = {
2514 /* front, rear, clfe, rear_surr */
2515 0x02, 0x03, 0x04, 0x05
2518 static hda_nid_t alc882_adc_nids
[3] = {
2524 /* FIXME: should be a matrix-type input source selection */
2526 static struct hda_input_mux alc882_capture_source
= {
2530 { "Front Mic", 0x1 },
2536 #define alc882_mux_enum_info alc_mux_enum_info
2537 #define alc882_mux_enum_get alc_mux_enum_get
2539 static int alc882_mux_enum_put(snd_kcontrol_t
*kcontrol
, snd_ctl_elem_value_t
*ucontrol
)
2541 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2542 struct alc_spec
*spec
= codec
->spec
;
2543 const struct hda_input_mux
*imux
= spec
->input_mux
;
2544 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
2545 static hda_nid_t capture_mixers
[3] = { 0x24, 0x23, 0x22 };
2546 hda_nid_t nid
= capture_mixers
[adc_idx
];
2547 unsigned int *cur_val
= &spec
->cur_mux
[adc_idx
];
2548 unsigned int i
, idx
;
2550 idx
= ucontrol
->value
.enumerated
.item
[0];
2551 if (idx
>= imux
->num_items
)
2552 idx
= imux
->num_items
- 1;
2553 if (*cur_val
== idx
&& ! codec
->in_resume
)
2555 for (i
= 0; i
< imux
->num_items
; i
++) {
2556 unsigned int v
= (i
== idx
) ? 0x7000 : 0x7080;
2557 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
2558 v
| (imux
->items
[i
].index
<< 8));
2564 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
2565 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
2567 static snd_kcontrol_new_t alc882_base_mixer
[] = {
2568 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT
),
2569 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT
),
2570 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT
),
2571 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT
),
2572 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT
),
2573 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT
),
2574 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT
),
2575 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT
),
2576 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT
),
2577 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT
),
2578 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT
),
2579 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT
),
2580 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT
),
2581 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT
),
2582 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT
),
2583 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT
),
2584 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT
),
2585 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT
),
2586 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT
),
2587 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT
),
2588 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT
),
2589 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT
),
2590 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT
),
2591 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT
),
2592 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT
),
2593 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT
),
2594 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT
),
2596 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2597 /* .name = "Capture Source", */
2598 .name
= "Input Source",
2600 .info
= alc882_mux_enum_info
,
2601 .get
= alc882_mux_enum_get
,
2602 .put
= alc882_mux_enum_put
,
2607 static struct hda_verb alc882_init_verbs
[] = {
2608 /* Front mixer: unmute input/output amp left and right (volume = 0) */
2609 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2610 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2611 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2613 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2614 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2615 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2617 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2618 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2619 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2621 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2622 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2623 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2625 /* Front Pin: output 0 (0x0c) */
2626 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2627 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2628 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x00},
2629 /* Rear Pin: output 1 (0x0d) */
2630 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2631 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2632 {0x15, AC_VERB_SET_CONNECT_SEL
, 0x01},
2633 /* CLFE Pin: output 2 (0x0e) */
2634 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2635 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2636 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x02},
2637 /* Side Pin: output 3 (0x0f) */
2638 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2639 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2640 {0x17, AC_VERB_SET_CONNECT_SEL
, 0x03},
2641 /* Mic (rear) pin: input vref at 80% */
2642 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2643 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2644 /* Front Mic pin: input vref at 80% */
2645 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2646 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2647 /* Line In pin: input */
2648 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2649 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2650 /* Line-2 In: Headphone output (output 0 - 0x0c) */
2651 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2652 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2653 {0x1b, AC_VERB_SET_CONNECT_SEL
, 0x00},
2654 /* CD pin widget for input */
2655 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2657 /* FIXME: use matrix-type input source selection */
2658 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
2659 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
2660 {0x24, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2661 {0x24, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2662 {0x24, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2663 {0x24, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2665 {0x23, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2666 {0x23, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2667 {0x23, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2668 {0x23, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2670 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2671 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2672 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2673 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2674 /* ADC1: mute amp left and right */
2675 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2676 {0x07, AC_VERB_SET_CONNECT_SEL
, 0x00},
2677 /* ADC2: mute amp left and right */
2678 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2679 {0x08, AC_VERB_SET_CONNECT_SEL
, 0x00},
2680 /* ADC3: mute amp left and right */
2681 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2682 {0x09, AC_VERB_SET_CONNECT_SEL
, 0x00},
2687 static int patch_alc882(struct hda_codec
*codec
)
2689 struct alc_spec
*spec
;
2691 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
2697 spec
->mixers
[spec
->num_mixers
] = alc882_base_mixer
;
2700 spec
->multiout
.dig_out_nid
= ALC880_DIGOUT_NID
;
2701 spec
->dig_in_nid
= ALC880_DIGIN_NID
;
2702 spec
->init_verbs
[0] = alc882_init_verbs
;
2703 spec
->num_init_verbs
= 1;
2705 spec
->channel_mode
= alc882_ch_modes
;
2706 spec
->num_channel_mode
= ARRAY_SIZE(alc882_ch_modes
);
2708 spec
->stream_name_analog
= "ALC882 Analog";
2709 spec
->stream_analog_playback
= &alc880_pcm_analog_playback
;
2710 spec
->stream_analog_capture
= &alc880_pcm_analog_capture
;
2712 spec
->stream_name_digital
= "ALC882 Digital";
2713 spec
->stream_digital_playback
= &alc880_pcm_digital_playback
;
2714 spec
->stream_digital_capture
= &alc880_pcm_digital_capture
;
2716 spec
->multiout
.max_channels
= spec
->channel_mode
[0].channels
;
2717 spec
->multiout
.num_dacs
= ARRAY_SIZE(alc882_dac_nids
);
2718 spec
->multiout
.dac_nids
= alc882_dac_nids
;
2720 spec
->input_mux
= &alc882_capture_source
;
2721 spec
->num_adc_nids
= ARRAY_SIZE(alc882_adc_nids
);
2722 spec
->adc_nids
= alc882_adc_nids
;
2724 codec
->patch_ops
= alc_patch_ops
;
2732 struct hda_codec_preset snd_hda_preset_realtek
[] = {
2733 { .id
= 0x10ec0260, .name
= "ALC260", .patch
= patch_alc260
},
2734 { .id
= 0x10ec0880, .name
= "ALC880", .patch
= patch_alc880
},
2735 { .id
= 0x10ec0882, .name
= "ALC882", .patch
= patch_alc882
},