2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for ALC 260/880/882 codecs
6 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
8 * Takashi Iwai <tiwai@suse.de>
9 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <sound/driver.h>
27 #include <linux/init.h>
28 #include <linux/delay.h>
29 #include <linux/slab.h>
30 #include <linux/pci.h>
31 #include <sound/core.h>
32 #include "hda_codec.h"
33 #include "hda_local.h"
36 /* ALC880 board config type */
54 #ifdef CONFIG_SND_DEBUG
58 ALC880_MODEL_LAST
/* last tag */
68 #ifdef CONFIG_SND_DEBUG
72 ALC260_MODEL_LAST
/* last tag */
79 ALC262_MODEL_LAST
/* last tag */
100 #define GPIO_MASK 0x03
103 /* codec parameterization */
104 struct snd_kcontrol_new
*mixers
[5]; /* mixer arrays */
105 unsigned int num_mixers
;
107 const struct hda_verb
*init_verbs
[5]; /* initialization verbs
108 * don't forget NULL termination!
110 unsigned int num_init_verbs
;
112 char *stream_name_analog
; /* analog PCM stream */
113 struct hda_pcm_stream
*stream_analog_playback
;
114 struct hda_pcm_stream
*stream_analog_capture
;
116 char *stream_name_digital
; /* digital PCM stream */
117 struct hda_pcm_stream
*stream_digital_playback
;
118 struct hda_pcm_stream
*stream_digital_capture
;
121 struct hda_multi_out multiout
; /* playback set-up
122 * max_channels, dacs must be set
123 * dig_out_nid and hp_nid are optional
127 unsigned int num_adc_nids
;
129 hda_nid_t dig_in_nid
; /* digital-in NID; optional */
132 const struct hda_input_mux
*input_mux
;
133 unsigned int cur_mux
[3];
136 const struct hda_channel_mode
*channel_mode
;
137 int num_channel_mode
;
139 /* PCM information */
140 struct hda_pcm pcm_rec
[3]; /* used in alc_build_pcms() */
142 /* dynamic controls, init_verbs and input_mux */
143 struct auto_pin_cfg autocfg
;
144 unsigned int num_kctl_alloc
, num_kctl_used
;
145 struct snd_kcontrol_new
*kctl_alloc
;
146 struct hda_input_mux private_imux
;
147 hda_nid_t private_dac_nids
[5];
151 * configuration template - to be copied to the spec instance
153 struct alc_config_preset
{
154 struct snd_kcontrol_new
*mixers
[5]; /* should be identical size with spec */
155 const struct hda_verb
*init_verbs
[5];
156 unsigned int num_dacs
;
158 hda_nid_t dig_out_nid
; /* optional */
159 hda_nid_t hp_nid
; /* optional */
160 unsigned int num_adc_nids
;
162 hda_nid_t dig_in_nid
;
163 unsigned int num_channel_mode
;
164 const struct hda_channel_mode
*channel_mode
;
165 const struct hda_input_mux
*input_mux
;
172 static int alc_mux_enum_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
174 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
175 struct alc_spec
*spec
= codec
->spec
;
176 return snd_hda_input_mux_info(spec
->input_mux
, uinfo
);
179 static int alc_mux_enum_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
181 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
182 struct alc_spec
*spec
= codec
->spec
;
183 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
185 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
189 static int alc_mux_enum_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
191 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
192 struct alc_spec
*spec
= codec
->spec
;
193 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
194 return snd_hda_input_mux_put(codec
, spec
->input_mux
, ucontrol
,
195 spec
->adc_nids
[adc_idx
], &spec
->cur_mux
[adc_idx
]);
200 * channel mode setting
202 static int alc_ch_mode_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
204 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
205 struct alc_spec
*spec
= codec
->spec
;
206 return snd_hda_ch_mode_info(codec
, uinfo
, spec
->channel_mode
,
207 spec
->num_channel_mode
);
210 static int alc_ch_mode_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
212 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
213 struct alc_spec
*spec
= codec
->spec
;
214 return snd_hda_ch_mode_get(codec
, ucontrol
, spec
->channel_mode
,
215 spec
->num_channel_mode
, spec
->multiout
.max_channels
);
218 static int alc_ch_mode_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
220 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
221 struct alc_spec
*spec
= codec
->spec
;
222 return snd_hda_ch_mode_put(codec
, ucontrol
, spec
->channel_mode
,
223 spec
->num_channel_mode
, &spec
->multiout
.max_channels
);
227 * Control the mode of pin widget settings via the mixer. "pc" is used
228 * instead of "%" to avoid consequences of accidently treating the % as
229 * being part of a format specifier. Maximum allowed length of a value is
230 * 63 characters plus NULL terminator.
232 * Note: some retasking pin complexes seem to ignore requests for input
233 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
234 * are requested. Therefore order this list so that this behaviour will not
235 * cause problems when mixer clients move through the enum sequentially.
236 * NIDs 0x0f and 0x10 have been observed to have this behaviour.
238 static char *alc_pin_mode_names
[] = {
239 "Mic 50pc bias", "Mic 80pc bias",
240 "Line in", "Line out", "Headphone out",
242 static unsigned char alc_pin_mode_values
[] = {
243 PIN_VREF50
, PIN_VREF80
, PIN_IN
, PIN_OUT
, PIN_HP
,
245 /* The control can present all 5 options, or it can limit the options based
246 * in the pin being assumed to be exclusively an input or an output pin.
248 #define ALC_PIN_DIR_IN 0x00
249 #define ALC_PIN_DIR_OUT 0x01
250 #define ALC_PIN_DIR_INOUT 0x02
252 /* Info about the pin modes supported by the three different pin directions.
253 * For each direction the minimum and maximum values are given.
255 static signed char alc_pin_mode_dir_info
[3][2] = {
256 { 0, 2 }, /* ALC_PIN_DIR_IN */
257 { 3, 4 }, /* ALC_PIN_DIR_OUT */
258 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
260 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
261 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
262 #define alc_pin_mode_n_items(_dir) \
263 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
265 static int alc_pin_mode_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
267 unsigned int item_num
= uinfo
->value
.enumerated
.item
;
268 unsigned char dir
= (kcontrol
->private_value
>> 16) & 0xff;
270 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
272 uinfo
->value
.enumerated
.items
= alc_pin_mode_n_items(dir
);
274 if (item_num
<alc_pin_mode_min(dir
) || item_num
>alc_pin_mode_max(dir
))
275 item_num
= alc_pin_mode_min(dir
);
276 strcpy(uinfo
->value
.enumerated
.name
, alc_pin_mode_names
[item_num
]);
280 static int alc_pin_mode_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
283 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
284 hda_nid_t nid
= kcontrol
->private_value
& 0xffff;
285 unsigned char dir
= (kcontrol
->private_value
>> 16) & 0xff;
286 long *valp
= ucontrol
->value
.integer
.value
;
287 unsigned int pinctl
= snd_hda_codec_read(codec
,nid
,0,AC_VERB_GET_PIN_WIDGET_CONTROL
,0x00);
289 /* Find enumerated value for current pinctl setting */
290 i
= alc_pin_mode_min(dir
);
291 while (alc_pin_mode_values
[i
]!=pinctl
&& i
<=alc_pin_mode_max(dir
))
293 *valp
= i
<=alc_pin_mode_max(dir
)?i
:alc_pin_mode_min(dir
);
297 static int alc_pin_mode_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
300 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
301 hda_nid_t nid
= kcontrol
->private_value
& 0xffff;
302 unsigned char dir
= (kcontrol
->private_value
>> 16) & 0xff;
303 long val
= *ucontrol
->value
.integer
.value
;
304 unsigned int pinctl
= snd_hda_codec_read(codec
,nid
,0,AC_VERB_GET_PIN_WIDGET_CONTROL
,0x00);
306 if (val
<alc_pin_mode_min(dir
) || val
>alc_pin_mode_max(dir
))
307 val
= alc_pin_mode_min(dir
);
309 change
= pinctl
!= alc_pin_mode_values
[val
];
311 /* Set pin mode to that requested */
312 snd_hda_codec_write(codec
,nid
,0,AC_VERB_SET_PIN_WIDGET_CONTROL
,
313 alc_pin_mode_values
[val
]);
315 /* Also enable the retasking pin's input/output as required
316 * for the requested pin mode. Enum values of 2 or less are
319 * Dynamically switching the input/output buffers probably
320 * reduces noise slightly, particularly on input. However,
321 * havingboth input and output buffers enabled
322 * simultaneously doesn't seem to be problematic.
325 snd_hda_codec_write(codec
,nid
,0,AC_VERB_SET_AMP_GAIN_MUTE
,
327 snd_hda_codec_write(codec
,nid
,0,AC_VERB_SET_AMP_GAIN_MUTE
,
330 snd_hda_codec_write(codec
,nid
,0,AC_VERB_SET_AMP_GAIN_MUTE
,
332 snd_hda_codec_write(codec
,nid
,0,AC_VERB_SET_AMP_GAIN_MUTE
,
339 #define ALC_PIN_MODE(xname, nid, dir) \
340 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
341 .info = alc_pin_mode_info, \
342 .get = alc_pin_mode_get, \
343 .put = alc_pin_mode_put, \
344 .private_value = nid | (dir<<16) }
346 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
347 * together using a mask with more than one bit set. This control is
348 * currently used only by the ALC260 test model. At this stage they are not
349 * needed for any "production" models.
351 #ifdef CONFIG_SND_DEBUG
352 static int alc_gpio_data_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
354 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_BOOLEAN
;
356 uinfo
->value
.integer
.min
= 0;
357 uinfo
->value
.integer
.max
= 1;
360 static int alc_gpio_data_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
362 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
363 hda_nid_t nid
= kcontrol
->private_value
& 0xffff;
364 unsigned char mask
= (kcontrol
->private_value
>> 16) & 0xff;
365 long *valp
= ucontrol
->value
.integer
.value
;
366 unsigned int val
= snd_hda_codec_read(codec
,nid
,0,AC_VERB_GET_GPIO_DATA
,0x00);
368 *valp
= (val
& mask
) != 0;
371 static int alc_gpio_data_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
374 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
375 hda_nid_t nid
= kcontrol
->private_value
& 0xffff;
376 unsigned char mask
= (kcontrol
->private_value
>> 16) & 0xff;
377 long val
= *ucontrol
->value
.integer
.value
;
378 unsigned int gpio_data
= snd_hda_codec_read(codec
,nid
,0,AC_VERB_GET_GPIO_DATA
,0x00);
380 /* Set/unset the masked GPIO bit(s) as needed */
381 change
= (val
==0?0:mask
) != (gpio_data
& mask
);
386 snd_hda_codec_write(codec
,nid
,0,AC_VERB_SET_GPIO_DATA
,gpio_data
);
390 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
391 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
392 .info = alc_gpio_data_info, \
393 .get = alc_gpio_data_get, \
394 .put = alc_gpio_data_put, \
395 .private_value = nid | (mask<<16) }
396 #endif /* CONFIG_SND_DEBUG */
398 /* A switch control to allow the enabling of the digital IO pins on the
399 * ALC260. This is incredibly simplistic; the intention of this control is
400 * to provide something in the test model allowing digital outputs to be
401 * identified if present. If models are found which can utilise these
402 * outputs a more complete mixer control can be devised for those models if
405 #ifdef CONFIG_SND_DEBUG
406 static int alc_spdif_ctrl_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
408 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_BOOLEAN
;
410 uinfo
->value
.integer
.min
= 0;
411 uinfo
->value
.integer
.max
= 1;
414 static int alc_spdif_ctrl_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
416 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
417 hda_nid_t nid
= kcontrol
->private_value
& 0xffff;
418 unsigned char mask
= (kcontrol
->private_value
>> 16) & 0xff;
419 long *valp
= ucontrol
->value
.integer
.value
;
420 unsigned int val
= snd_hda_codec_read(codec
,nid
,0,AC_VERB_GET_DIGI_CONVERT
,0x00);
422 *valp
= (val
& mask
) != 0;
425 static int alc_spdif_ctrl_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
428 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
429 hda_nid_t nid
= kcontrol
->private_value
& 0xffff;
430 unsigned char mask
= (kcontrol
->private_value
>> 16) & 0xff;
431 long val
= *ucontrol
->value
.integer
.value
;
432 unsigned int ctrl_data
= snd_hda_codec_read(codec
,nid
,0,AC_VERB_GET_DIGI_CONVERT
,0x00);
434 /* Set/unset the masked control bit(s) as needed */
435 change
= (val
==0?0:mask
) != (ctrl_data
& mask
);
440 snd_hda_codec_write(codec
,nid
,0,AC_VERB_SET_DIGI_CONVERT_1
,ctrl_data
);
444 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
445 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
446 .info = alc_spdif_ctrl_info, \
447 .get = alc_spdif_ctrl_get, \
448 .put = alc_spdif_ctrl_put, \
449 .private_value = nid | (mask<<16) }
450 #endif /* CONFIG_SND_DEBUG */
453 * set up from the preset table
455 static void setup_preset(struct alc_spec
*spec
, const struct alc_config_preset
*preset
)
459 for (i
= 0; i
< ARRAY_SIZE(preset
->mixers
) && preset
->mixers
[i
]; i
++)
460 spec
->mixers
[spec
->num_mixers
++] = preset
->mixers
[i
];
461 for (i
= 0; i
< ARRAY_SIZE(preset
->init_verbs
) && preset
->init_verbs
[i
]; i
++)
462 spec
->init_verbs
[spec
->num_init_verbs
++] = preset
->init_verbs
[i
];
464 spec
->channel_mode
= preset
->channel_mode
;
465 spec
->num_channel_mode
= preset
->num_channel_mode
;
467 spec
->multiout
.max_channels
= spec
->channel_mode
[0].channels
;
469 spec
->multiout
.num_dacs
= preset
->num_dacs
;
470 spec
->multiout
.dac_nids
= preset
->dac_nids
;
471 spec
->multiout
.dig_out_nid
= preset
->dig_out_nid
;
472 spec
->multiout
.hp_nid
= preset
->hp_nid
;
474 spec
->input_mux
= preset
->input_mux
;
476 spec
->num_adc_nids
= preset
->num_adc_nids
;
477 spec
->adc_nids
= preset
->adc_nids
;
478 spec
->dig_in_nid
= preset
->dig_in_nid
;
482 * ALC880 3-stack model
484 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
485 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, F-Mic = 0x1b
489 static hda_nid_t alc880_dac_nids
[4] = {
490 /* front, rear, clfe, rear_surr */
491 0x02, 0x05, 0x04, 0x03
494 static hda_nid_t alc880_adc_nids
[3] = {
499 /* The datasheet says the node 0x07 is connected from inputs,
500 * but it shows zero connection in the real implementation on some devices.
501 * Note: this is a 915GAV bug, fixed on 915GLV
503 static hda_nid_t alc880_adc_nids_alt
[2] = {
508 #define ALC880_DIGOUT_NID 0x06
509 #define ALC880_DIGIN_NID 0x0a
511 static struct hda_input_mux alc880_capture_source
= {
515 { "Front Mic", 0x3 },
521 /* channel source setting (2/6 channel selection for 3-stack) */
523 static struct hda_verb alc880_threestack_ch2_init
[] = {
524 /* set line-in to input, mute it */
525 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
526 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
527 /* set mic-in to input vref 80%, mute it */
528 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
529 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
534 static struct hda_verb alc880_threestack_ch6_init
[] = {
535 /* set line-in to output, unmute it */
536 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
537 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
538 /* set mic-in to output, unmute it */
539 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
540 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
544 static struct hda_channel_mode alc880_threestack_modes
[2] = {
545 { 2, alc880_threestack_ch2_init
},
546 { 6, alc880_threestack_ch6_init
},
549 static struct snd_kcontrol_new alc880_three_stack_mixer
[] = {
550 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT
),
551 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT
),
552 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT
),
553 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT
),
554 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT
),
555 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT
),
556 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT
),
557 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT
),
558 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT
),
559 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT
),
560 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT
),
561 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT
),
562 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT
),
563 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT
),
564 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT
),
565 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT
),
566 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT
),
567 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT
),
568 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT
),
570 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
571 .name
= "Channel Mode",
572 .info
= alc_ch_mode_info
,
573 .get
= alc_ch_mode_get
,
574 .put
= alc_ch_mode_put
,
579 /* capture mixer elements */
580 static struct snd_kcontrol_new alc880_capture_mixer
[] = {
581 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT
),
582 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT
),
583 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT
),
584 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT
),
585 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT
),
586 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT
),
588 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
589 /* The multiple "Capture Source" controls confuse alsamixer
590 * So call somewhat different..
591 * FIXME: the controls appear in the "playback" view!
593 /* .name = "Capture Source", */
594 .name
= "Input Source",
596 .info
= alc_mux_enum_info
,
597 .get
= alc_mux_enum_get
,
598 .put
= alc_mux_enum_put
,
603 /* capture mixer elements (in case NID 0x07 not available) */
604 static struct snd_kcontrol_new alc880_capture_alt_mixer
[] = {
605 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT
),
606 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT
),
607 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT
),
608 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT
),
610 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
611 /* The multiple "Capture Source" controls confuse alsamixer
612 * So call somewhat different..
613 * FIXME: the controls appear in the "playback" view!
615 /* .name = "Capture Source", */
616 .name
= "Input Source",
618 .info
= alc_mux_enum_info
,
619 .get
= alc_mux_enum_get
,
620 .put
= alc_mux_enum_put
,
628 * ALC880 5-stack model
630 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), Side = 0x02 (0xd)
631 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
632 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
635 /* additional mixers to alc880_three_stack_mixer */
636 static struct snd_kcontrol_new alc880_five_stack_mixer
[] = {
637 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT
),
638 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT
),
642 /* channel source setting (6/8 channel selection for 5-stack) */
644 static struct hda_verb alc880_fivestack_ch6_init
[] = {
645 /* set line-in to input, mute it */
646 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
647 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
652 static struct hda_verb alc880_fivestack_ch8_init
[] = {
653 /* set line-in to output, unmute it */
654 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
655 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
659 static struct hda_channel_mode alc880_fivestack_modes
[2] = {
660 { 6, alc880_fivestack_ch6_init
},
661 { 8, alc880_fivestack_ch8_init
},
666 * ALC880 6-stack model
668 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), Side = 0x05 (0x0f)
669 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
670 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
673 static hda_nid_t alc880_6st_dac_nids
[4] = {
674 /* front, rear, clfe, rear_surr */
675 0x02, 0x03, 0x04, 0x05
678 static struct hda_input_mux alc880_6stack_capture_source
= {
682 { "Front Mic", 0x1 },
688 /* fixed 8-channels */
689 static struct hda_channel_mode alc880_sixstack_modes
[1] = {
693 static struct snd_kcontrol_new alc880_six_stack_mixer
[] = {
694 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT
),
695 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT
),
696 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT
),
697 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT
),
698 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT
),
699 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT
),
700 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT
),
701 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT
),
702 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT
),
703 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT
),
704 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT
),
705 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT
),
706 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT
),
707 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT
),
708 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT
),
709 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT
),
710 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT
),
711 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT
),
712 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT
),
713 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT
),
715 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
716 .name
= "Channel Mode",
717 .info
= alc_ch_mode_info
,
718 .get
= alc_ch_mode_get
,
719 .put
= alc_ch_mode_put
,
728 * W810 has rear IO for:
731 * Center/LFE (DAC 04)
734 * The system also has a pair of internal speakers, and a headphone jack.
735 * These are both connected to Line2 on the codec, hence to DAC 02.
737 * There is a variable resistor to control the speaker or headphone
738 * volume. This is a hardware-only device without a software API.
740 * Plugging headphones in will disable the internal speakers. This is
741 * implemented in hardware, not via the driver using jack sense. In
742 * a similar fashion, plugging into the rear socket marked "front" will
743 * disable both the speakers and headphones.
745 * For input, there's a microphone jack, and an "audio in" jack.
746 * These may not do anything useful with this driver yet, because I
747 * haven't setup any initialization verbs for these yet...
750 static hda_nid_t alc880_w810_dac_nids
[3] = {
751 /* front, rear/surround, clfe */
755 /* fixed 6 channels */
756 static struct hda_channel_mode alc880_w810_modes
[1] = {
760 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
761 static struct snd_kcontrol_new alc880_w810_base_mixer
[] = {
762 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT
),
763 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT
),
764 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT
),
765 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT
),
766 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT
),
767 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT
),
768 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT
),
769 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT
),
770 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT
),
778 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
779 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), Line = 0x1a
782 static hda_nid_t alc880_z71v_dac_nids
[1] = {
785 #define ALC880_Z71V_HP_DAC 0x03
787 /* fixed 2 channels */
788 static struct hda_channel_mode alc880_2_jack_modes
[1] = {
792 static struct snd_kcontrol_new alc880_z71v_mixer
[] = {
793 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT
),
794 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT
),
795 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT
),
796 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT
),
797 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT
),
798 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT
),
799 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT
),
800 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT
),
809 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
810 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
813 static hda_nid_t alc880_f1734_dac_nids
[1] = {
816 #define ALC880_F1734_HP_DAC 0x02
818 static struct snd_kcontrol_new alc880_f1734_mixer
[] = {
819 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT
),
820 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT
),
821 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT
),
822 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT
),
823 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT
),
824 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT
),
825 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT
),
826 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT
),
835 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
836 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
837 * Mic = 0x18, Line = 0x1a
840 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
841 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
843 static struct snd_kcontrol_new alc880_asus_mixer
[] = {
844 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT
),
845 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT
),
846 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT
),
847 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT
),
848 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT
),
849 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT
),
850 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT
),
851 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT
),
852 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT
),
853 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT
),
854 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT
),
855 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT
),
856 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT
),
857 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT
),
859 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
860 .name
= "Channel Mode",
861 .info
= alc_ch_mode_info
,
862 .get
= alc_ch_mode_get
,
863 .put
= alc_ch_mode_put
,
870 * ALC880 ASUS W1V model
872 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
873 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
874 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
877 /* additional mixers to alc880_asus_mixer */
878 static struct snd_kcontrol_new alc880_asus_w1v_mixer
[] = {
879 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT
),
880 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT
),
884 /* additional mixers to alc880_asus_mixer */
885 static struct snd_kcontrol_new alc880_pcbeep_mixer
[] = {
886 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT
),
887 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT
),
892 static struct snd_kcontrol_new alc880_tcl_s700_mixer
[] = {
893 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT
),
894 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT
),
895 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT
),
896 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT
),
897 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT
),
898 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT
),
899 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT
),
900 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT
),
901 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT
),
903 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
904 /* The multiple "Capture Source" controls confuse alsamixer
905 * So call somewhat different..
906 * FIXME: the controls appear in the "playback" view!
908 /* .name = "Capture Source", */
909 .name
= "Input Source",
911 .info
= alc_mux_enum_info
,
912 .get
= alc_mux_enum_get
,
913 .put
= alc_mux_enum_put
,
919 * build control elements
921 static int alc_build_controls(struct hda_codec
*codec
)
923 struct alc_spec
*spec
= codec
->spec
;
927 for (i
= 0; i
< spec
->num_mixers
; i
++) {
928 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
933 if (spec
->multiout
.dig_out_nid
) {
934 err
= snd_hda_create_spdif_out_ctls(codec
, spec
->multiout
.dig_out_nid
);
938 if (spec
->dig_in_nid
) {
939 err
= snd_hda_create_spdif_in_ctls(codec
, spec
->dig_in_nid
);
948 * initialize the codec volumes, etc
952 * generic initialization of ADC, input mixers and output mixers
954 static struct hda_verb alc880_volume_init_verbs
[] = {
956 * Unmute ADC0-2 and set the default input to mic-in
958 {0x07, AC_VERB_SET_CONNECT_SEL
, 0x00},
959 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
960 {0x08, AC_VERB_SET_CONNECT_SEL
, 0x00},
961 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
962 {0x09, AC_VERB_SET_CONNECT_SEL
, 0x00},
963 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
965 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
967 * Note: PASD motherboards uses the Line In 2 as the input for front panel
970 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
971 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
972 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
973 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2)},
974 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(3)},
975 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(4)},
978 * Set up output mixers (0x0c - 0x0f)
980 /* set vol=0 to output mixers */
981 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
982 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
983 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
984 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
985 /* set up input amps for analog loopback */
986 /* Amp Indices: DAC = 0, mixer = 1 */
987 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
988 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
989 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
990 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
991 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
992 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
993 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
994 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1000 * 3-stack pin configuration:
1001 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1003 static struct hda_verb alc880_pin_3stack_init_verbs
[] = {
1005 * preset connection lists of input pins
1006 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1008 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x02}, /* mic/clfe */
1009 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* HP */
1010 {0x12, AC_VERB_SET_CONNECT_SEL
, 0x03}, /* line/surround */
1013 * Set pin mode and muting
1015 /* set front pin widgets 0x14 for output */
1016 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1017 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1018 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1019 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1020 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1021 /* Mic2 (as headphone out) for HP output */
1022 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1023 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1024 /* Line In pin widget for input */
1025 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1026 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1027 /* Line2 (as front mic) pin widget for input and vref at 80% */
1028 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1029 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1030 /* CD pin widget for input */
1031 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1037 * 5-stack pin configuration:
1038 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1039 * line-in/side = 0x1a, f-mic = 0x1b
1041 static struct hda_verb alc880_pin_5stack_init_verbs
[] = {
1043 * preset connection lists of input pins
1044 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1046 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* HP */
1047 {0x12, AC_VERB_SET_CONNECT_SEL
, 0x01}, /* line/side */
1050 * Set pin mode and muting
1052 /* set pin widgets 0x14-0x17 for output */
1053 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1054 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1055 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1056 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1057 /* unmute pins for output (no gain on this amp) */
1058 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1059 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1060 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1061 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1063 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1064 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1065 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1066 /* Mic2 (as headphone out) for HP output */
1067 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1068 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1069 /* Line In pin widget for input */
1070 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1071 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1072 /* Line2 (as front mic) pin widget for input and vref at 80% */
1073 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1074 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1075 /* CD pin widget for input */
1076 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1082 * W810 pin configuration:
1083 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1085 static struct hda_verb alc880_pin_w810_init_verbs
[] = {
1086 /* hphone/speaker input selector: front DAC */
1087 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0},
1089 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1090 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1091 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1092 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1093 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1094 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1096 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1097 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1103 * Z71V pin configuration:
1104 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1106 static struct hda_verb alc880_pin_z71v_init_verbs
[] = {
1107 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1108 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1109 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1110 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1112 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1113 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1114 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1115 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1121 * 6-stack pin configuration:
1122 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, f-mic = 0x19,
1123 * line = 0x1a, HP = 0x1b
1125 static struct hda_verb alc880_pin_6stack_init_verbs
[] = {
1126 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* HP */
1128 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1129 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1130 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1131 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1132 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1133 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1134 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1135 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1137 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1138 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1139 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1140 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1141 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1142 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1143 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1144 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1145 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1152 * F1734 pin configuration:
1153 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1155 static struct hda_verb alc880_pin_f1734_init_verbs
[] = {
1156 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x02},
1157 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x00},
1158 {0x12, AC_VERB_SET_CONNECT_SEL
, 0x01},
1159 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x00},
1161 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1162 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1163 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1164 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1166 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1167 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1168 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1169 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1170 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1171 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1172 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1173 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1174 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1181 * ASUS pin configuration:
1182 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1184 static struct hda_verb alc880_pin_asus_init_verbs
[] = {
1185 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x02},
1186 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x00},
1187 {0x12, AC_VERB_SET_CONNECT_SEL
, 0x01},
1188 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x00},
1190 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1191 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1192 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1193 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1194 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1195 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1196 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1197 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1199 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1200 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1201 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1202 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1203 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1204 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1205 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1206 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1207 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1212 /* Enable GPIO mask and set output */
1213 static struct hda_verb alc880_gpio1_init_verbs
[] = {
1214 {0x01, AC_VERB_SET_GPIO_MASK
, 0x01},
1215 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x01},
1216 {0x01, AC_VERB_SET_GPIO_DATA
, 0x01},
1221 /* Enable GPIO mask and set output */
1222 static struct hda_verb alc880_gpio2_init_verbs
[] = {
1223 {0x01, AC_VERB_SET_GPIO_MASK
, 0x02},
1224 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x02},
1225 {0x01, AC_VERB_SET_GPIO_DATA
, 0x02},
1230 /* Clevo m520g init */
1231 static struct hda_verb alc880_pin_clevo_init_verbs
[] = {
1232 /* headphone output */
1233 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x01},
1235 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1236 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1238 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1239 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1241 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1242 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1243 /* Mic1 (rear panel) */
1244 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1245 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1246 /* Mic2 (front panel) */
1247 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1248 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1250 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1251 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1252 /* change to EAPD mode */
1253 {0x20, AC_VERB_SET_COEF_INDEX
, 0x07},
1254 {0x20, AC_VERB_SET_PROC_COEF
, 0x3060},
1259 static struct hda_verb alc880_pin_tcl_S700_init_verbs
[] = {
1260 /* Headphone output */
1261 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1263 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1264 {0x1b, AC_VERB_SET_CONNECT_SEL
, 0x00},
1266 /* Line In pin widget for input */
1267 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1268 /* CD pin widget for input */
1269 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1270 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1271 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1273 /* change to EAPD mode */
1274 {0x20, AC_VERB_SET_COEF_INDEX
, 0x07},
1275 {0x20, AC_VERB_SET_PROC_COEF
, 0x3070},
1283 static int alc_init(struct hda_codec
*codec
)
1285 struct alc_spec
*spec
= codec
->spec
;
1288 for (i
= 0; i
< spec
->num_init_verbs
; i
++)
1289 snd_hda_sequence_write(codec
, spec
->init_verbs
[i
]);
1297 static int alc_resume(struct hda_codec
*codec
)
1299 struct alc_spec
*spec
= codec
->spec
;
1303 for (i
= 0; i
< spec
->num_mixers
; i
++)
1304 snd_hda_resume_ctls(codec
, spec
->mixers
[i
]);
1305 if (spec
->multiout
.dig_out_nid
)
1306 snd_hda_resume_spdif_out(codec
);
1307 if (spec
->dig_in_nid
)
1308 snd_hda_resume_spdif_in(codec
);
1315 * Analog playback callbacks
1317 static int alc880_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
1318 struct hda_codec
*codec
,
1319 struct snd_pcm_substream
*substream
)
1321 struct alc_spec
*spec
= codec
->spec
;
1322 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
);
1325 static int alc880_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
1326 struct hda_codec
*codec
,
1327 unsigned int stream_tag
,
1328 unsigned int format
,
1329 struct snd_pcm_substream
*substream
)
1331 struct alc_spec
*spec
= codec
->spec
;
1332 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
, stream_tag
,
1336 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
1337 struct hda_codec
*codec
,
1338 struct snd_pcm_substream
*substream
)
1340 struct alc_spec
*spec
= codec
->spec
;
1341 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
1347 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
1348 struct hda_codec
*codec
,
1349 struct snd_pcm_substream
*substream
)
1351 struct alc_spec
*spec
= codec
->spec
;
1352 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
1355 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
1356 struct hda_codec
*codec
,
1357 struct snd_pcm_substream
*substream
)
1359 struct alc_spec
*spec
= codec
->spec
;
1360 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
1366 static int alc880_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
1367 struct hda_codec
*codec
,
1368 unsigned int stream_tag
,
1369 unsigned int format
,
1370 struct snd_pcm_substream
*substream
)
1372 struct alc_spec
*spec
= codec
->spec
;
1374 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
],
1375 stream_tag
, 0, format
);
1379 static int alc880_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
1380 struct hda_codec
*codec
,
1381 struct snd_pcm_substream
*substream
)
1383 struct alc_spec
*spec
= codec
->spec
;
1385 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
], 0, 0, 0);
1392 static struct hda_pcm_stream alc880_pcm_analog_playback
= {
1396 /* NID is set in alc_build_pcms */
1398 .open
= alc880_playback_pcm_open
,
1399 .prepare
= alc880_playback_pcm_prepare
,
1400 .cleanup
= alc880_playback_pcm_cleanup
1404 static struct hda_pcm_stream alc880_pcm_analog_capture
= {
1408 /* NID is set in alc_build_pcms */
1410 .prepare
= alc880_capture_pcm_prepare
,
1411 .cleanup
= alc880_capture_pcm_cleanup
1415 static struct hda_pcm_stream alc880_pcm_digital_playback
= {
1419 /* NID is set in alc_build_pcms */
1421 .open
= alc880_dig_playback_pcm_open
,
1422 .close
= alc880_dig_playback_pcm_close
1426 static struct hda_pcm_stream alc880_pcm_digital_capture
= {
1430 /* NID is set in alc_build_pcms */
1433 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
1434 static struct hda_pcm_stream alc_pcm_null_playback
= {
1440 static int alc_build_pcms(struct hda_codec
*codec
)
1442 struct alc_spec
*spec
= codec
->spec
;
1443 struct hda_pcm
*info
= spec
->pcm_rec
;
1446 codec
->num_pcms
= 1;
1447 codec
->pcm_info
= info
;
1449 info
->name
= spec
->stream_name_analog
;
1450 if (spec
->stream_analog_playback
) {
1451 snd_assert(spec
->multiout
.dac_nids
, return -EINVAL
);
1452 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = *(spec
->stream_analog_playback
);
1453 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dac_nids
[0];
1455 if (spec
->stream_analog_capture
) {
1456 snd_assert(spec
->adc_nids
, return -EINVAL
);
1457 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *(spec
->stream_analog_capture
);
1458 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
1461 if (spec
->channel_mode
) {
1462 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
= 0;
1463 for (i
= 0; i
< spec
->num_channel_mode
; i
++) {
1464 if (spec
->channel_mode
[i
].channels
> info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
) {
1465 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
= spec
->channel_mode
[i
].channels
;
1470 /* If the use of more than one ADC is requested for the current
1471 * model, configure a second analog capture-only PCM.
1473 if (spec
->num_adc_nids
> 1) {
1476 info
->name
= spec
->stream_name_analog
;
1477 /* No playback stream for second PCM */
1478 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = alc_pcm_null_playback
;
1479 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= 0;
1480 if (spec
->stream_analog_capture
) {
1481 snd_assert(spec
->adc_nids
, return -EINVAL
);
1482 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *(spec
->stream_analog_capture
);
1483 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[1];
1487 if (spec
->multiout
.dig_out_nid
|| spec
->dig_in_nid
) {
1490 info
->name
= spec
->stream_name_digital
;
1491 if (spec
->multiout
.dig_out_nid
&&
1492 spec
->stream_digital_playback
) {
1493 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = *(spec
->stream_digital_playback
);
1494 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dig_out_nid
;
1496 if (spec
->dig_in_nid
&&
1497 spec
->stream_digital_capture
) {
1498 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *(spec
->stream_digital_capture
);
1499 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->dig_in_nid
;
1506 static void alc_free(struct hda_codec
*codec
)
1508 struct alc_spec
*spec
= codec
->spec
;
1514 if (spec
->kctl_alloc
) {
1515 for (i
= 0; i
< spec
->num_kctl_used
; i
++)
1516 kfree(spec
->kctl_alloc
[i
].name
);
1517 kfree(spec
->kctl_alloc
);
1524 static struct hda_codec_ops alc_patch_ops
= {
1525 .build_controls
= alc_build_controls
,
1526 .build_pcms
= alc_build_pcms
,
1530 .resume
= alc_resume
,
1536 * Test configuration for debugging
1538 * Almost all inputs/outputs are enabled. I/O pins can be configured via
1541 #ifdef CONFIG_SND_DEBUG
1542 static hda_nid_t alc880_test_dac_nids
[4] = {
1543 0x02, 0x03, 0x04, 0x05
1546 static struct hda_input_mux alc880_test_capture_source
= {
1557 static struct hda_channel_mode alc880_test_modes
[4] = {
1564 static int alc_test_pin_ctl_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
1566 static char *texts
[] = {
1567 "N/A", "Line Out", "HP Out",
1568 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
1570 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
1572 uinfo
->value
.enumerated
.items
= 8;
1573 if (uinfo
->value
.enumerated
.item
>= 8)
1574 uinfo
->value
.enumerated
.item
= 7;
1575 strcpy(uinfo
->value
.enumerated
.name
, texts
[uinfo
->value
.enumerated
.item
]);
1579 static int alc_test_pin_ctl_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
1581 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1582 hda_nid_t nid
= (hda_nid_t
)kcontrol
->private_value
;
1583 unsigned int pin_ctl
, item
= 0;
1585 pin_ctl
= snd_hda_codec_read(codec
, nid
, 0,
1586 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
1587 if (pin_ctl
& AC_PINCTL_OUT_EN
) {
1588 if (pin_ctl
& AC_PINCTL_HP_EN
)
1592 } else if (pin_ctl
& AC_PINCTL_IN_EN
) {
1593 switch (pin_ctl
& AC_PINCTL_VREFEN
) {
1594 case AC_PINCTL_VREF_HIZ
: item
= 3; break;
1595 case AC_PINCTL_VREF_50
: item
= 4; break;
1596 case AC_PINCTL_VREF_GRD
: item
= 5; break;
1597 case AC_PINCTL_VREF_80
: item
= 6; break;
1598 case AC_PINCTL_VREF_100
: item
= 7; break;
1601 ucontrol
->value
.enumerated
.item
[0] = item
;
1605 static int alc_test_pin_ctl_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
1607 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1608 hda_nid_t nid
= (hda_nid_t
)kcontrol
->private_value
;
1609 static unsigned int ctls
[] = {
1610 0, AC_PINCTL_OUT_EN
, AC_PINCTL_OUT_EN
| AC_PINCTL_HP_EN
,
1611 AC_PINCTL_IN_EN
| AC_PINCTL_VREF_HIZ
,
1612 AC_PINCTL_IN_EN
| AC_PINCTL_VREF_50
,
1613 AC_PINCTL_IN_EN
| AC_PINCTL_VREF_GRD
,
1614 AC_PINCTL_IN_EN
| AC_PINCTL_VREF_80
,
1615 AC_PINCTL_IN_EN
| AC_PINCTL_VREF_100
,
1617 unsigned int old_ctl
, new_ctl
;
1619 old_ctl
= snd_hda_codec_read(codec
, nid
, 0,
1620 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
1621 new_ctl
= ctls
[ucontrol
->value
.enumerated
.item
[0]];
1622 if (old_ctl
!= new_ctl
) {
1623 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
, new_ctl
);
1624 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
1625 ucontrol
->value
.enumerated
.item
[0] >= 3 ? 0xb080 : 0xb000);
1631 static int alc_test_pin_src_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
1633 static char *texts
[] = {
1634 "Front", "Surround", "CLFE", "Side"
1636 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
1638 uinfo
->value
.enumerated
.items
= 4;
1639 if (uinfo
->value
.enumerated
.item
>= 4)
1640 uinfo
->value
.enumerated
.item
= 3;
1641 strcpy(uinfo
->value
.enumerated
.name
, texts
[uinfo
->value
.enumerated
.item
]);
1645 static int alc_test_pin_src_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
1647 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1648 hda_nid_t nid
= (hda_nid_t
)kcontrol
->private_value
;
1651 sel
= snd_hda_codec_read(codec
, nid
, 0, AC_VERB_GET_CONNECT_SEL
, 0);
1652 ucontrol
->value
.enumerated
.item
[0] = sel
& 3;
1656 static int alc_test_pin_src_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
1658 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1659 hda_nid_t nid
= (hda_nid_t
)kcontrol
->private_value
;
1662 sel
= snd_hda_codec_read(codec
, nid
, 0, AC_VERB_GET_CONNECT_SEL
, 0) & 3;
1663 if (ucontrol
->value
.enumerated
.item
[0] != sel
) {
1664 sel
= ucontrol
->value
.enumerated
.item
[0] & 3;
1665 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_CONNECT_SEL
, sel
);
1671 #define PIN_CTL_TEST(xname,nid) { \
1672 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1674 .info = alc_test_pin_ctl_info, \
1675 .get = alc_test_pin_ctl_get, \
1676 .put = alc_test_pin_ctl_put, \
1677 .private_value = nid \
1680 #define PIN_SRC_TEST(xname,nid) { \
1681 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1683 .info = alc_test_pin_src_info, \
1684 .get = alc_test_pin_src_get, \
1685 .put = alc_test_pin_src_put, \
1686 .private_value = nid \
1689 static struct snd_kcontrol_new alc880_test_mixer
[] = {
1690 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT
),
1691 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT
),
1692 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT
),
1693 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT
),
1694 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT
),
1695 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT
),
1696 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT
),
1697 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT
),
1698 PIN_CTL_TEST("Front Pin Mode", 0x14),
1699 PIN_CTL_TEST("Surround Pin Mode", 0x15),
1700 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
1701 PIN_CTL_TEST("Side Pin Mode", 0x17),
1702 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
1703 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
1704 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
1705 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
1706 PIN_SRC_TEST("In-1 Pin Source", 0x18),
1707 PIN_SRC_TEST("In-2 Pin Source", 0x19),
1708 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
1709 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
1710 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT
),
1711 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT
),
1712 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT
),
1713 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT
),
1714 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT
),
1715 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT
),
1716 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT
),
1717 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT
),
1718 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT
),
1719 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT
),
1721 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1722 .name
= "Channel Mode",
1723 .info
= alc_ch_mode_info
,
1724 .get
= alc_ch_mode_get
,
1725 .put
= alc_ch_mode_put
,
1730 static struct hda_verb alc880_test_init_verbs
[] = {
1731 /* Unmute inputs of 0x0c - 0x0f */
1732 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
1733 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
1734 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
1735 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
1736 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
1737 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
1738 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
1739 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
1740 /* Vol output for 0x0c-0x0f */
1741 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
1742 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
1743 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
1744 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
1745 /* Set output pins 0x14-0x17 */
1746 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1747 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1748 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1749 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1750 /* Unmute output pins 0x14-0x17 */
1751 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1752 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1753 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1754 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1755 /* Set input pins 0x18-0x1c */
1756 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1757 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1758 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1759 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1760 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1761 /* Mute input pins 0x18-0x1b */
1762 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1763 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1764 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1765 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1767 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1768 {0x07, AC_VERB_SET_CONNECT_SEL
, 0x00},
1769 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1770 {0x08, AC_VERB_SET_CONNECT_SEL
, 0x00},
1771 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1772 {0x09, AC_VERB_SET_CONNECT_SEL
, 0x00},
1773 /* Analog input/passthru */
1774 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1775 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1776 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
1777 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
1778 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
1786 static struct hda_board_config alc880_cfg_tbl
[] = {
1787 /* Back 3 jack, front 2 jack */
1788 { .modelname
= "3stack", .config
= ALC880_3ST
},
1789 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe200, .config
= ALC880_3ST
},
1790 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe201, .config
= ALC880_3ST
},
1791 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe202, .config
= ALC880_3ST
},
1792 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe203, .config
= ALC880_3ST
},
1793 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe204, .config
= ALC880_3ST
},
1794 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe205, .config
= ALC880_3ST
},
1795 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe206, .config
= ALC880_3ST
},
1796 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe207, .config
= ALC880_3ST
},
1797 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe208, .config
= ALC880_3ST
},
1798 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe209, .config
= ALC880_3ST
},
1799 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe20a, .config
= ALC880_3ST
},
1800 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe20b, .config
= ALC880_3ST
},
1801 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe20c, .config
= ALC880_3ST
},
1802 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe20d, .config
= ALC880_3ST
},
1803 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe20e, .config
= ALC880_3ST
},
1804 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe20f, .config
= ALC880_3ST
},
1805 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe210, .config
= ALC880_3ST
},
1806 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe211, .config
= ALC880_3ST
},
1807 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe214, .config
= ALC880_3ST
},
1808 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe302, .config
= ALC880_3ST
},
1809 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe303, .config
= ALC880_3ST
},
1810 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe304, .config
= ALC880_3ST
},
1811 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe306, .config
= ALC880_3ST
},
1812 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe307, .config
= ALC880_3ST
},
1813 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe404, .config
= ALC880_3ST
},
1814 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xa101, .config
= ALC880_3ST
},
1815 { .pci_subvendor
= 0x107b, .pci_subdevice
= 0x3031, .config
= ALC880_3ST
},
1816 { .pci_subvendor
= 0x107b, .pci_subdevice
= 0x4036, .config
= ALC880_3ST
},
1817 { .pci_subvendor
= 0x107b, .pci_subdevice
= 0x4037, .config
= ALC880_3ST
},
1818 { .pci_subvendor
= 0x107b, .pci_subdevice
= 0x4038, .config
= ALC880_3ST
},
1819 { .pci_subvendor
= 0x107b, .pci_subdevice
= 0x4040, .config
= ALC880_3ST
},
1820 { .pci_subvendor
= 0x107b, .pci_subdevice
= 0x4041, .config
= ALC880_3ST
},
1822 { .pci_subvendor
= 0x19db, .pci_subdevice
= 0x4188, .config
= ALC880_TCL_S700
},
1824 /* Back 3 jack, front 2 jack (Internal add Aux-In) */
1825 { .pci_subvendor
= 0x1025, .pci_subdevice
= 0xe310, .config
= ALC880_3ST
},
1826 { .pci_subvendor
= 0x104d, .pci_subdevice
= 0x81d6, .config
= ALC880_3ST
},
1827 { .pci_subvendor
= 0x104d, .pci_subdevice
= 0x81a0, .config
= ALC880_3ST
},
1829 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
1830 { .modelname
= "3stack-digout", .config
= ALC880_3ST_DIG
},
1831 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe308, .config
= ALC880_3ST_DIG
},
1832 { .pci_subvendor
= 0x1025, .pci_subdevice
= 0x0070, .config
= ALC880_3ST_DIG
},
1833 /* Clevo m520G NB */
1834 { .pci_subvendor
= 0x1558, .pci_subdevice
= 0x0520, .config
= ALC880_CLEVO
},
1836 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
1837 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe305, .config
= ALC880_3ST_DIG
},
1838 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xd402, .config
= ALC880_3ST_DIG
},
1839 { .pci_subvendor
= 0x1025, .pci_subdevice
= 0xe309, .config
= ALC880_3ST_DIG
},
1841 /* Back 5 jack, front 2 jack */
1842 { .modelname
= "5stack", .config
= ALC880_5ST
},
1843 { .pci_subvendor
= 0x107b, .pci_subdevice
= 0x3033, .config
= ALC880_5ST
},
1844 { .pci_subvendor
= 0x107b, .pci_subdevice
= 0x4039, .config
= ALC880_5ST
},
1845 { .pci_subvendor
= 0x107b, .pci_subdevice
= 0x3032, .config
= ALC880_5ST
},
1846 { .pci_subvendor
= 0x103c, .pci_subdevice
= 0x2a09, .config
= ALC880_5ST
},
1847 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x814e, .config
= ALC880_5ST
},
1849 /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
1850 { .modelname
= "5stack-digout", .config
= ALC880_5ST_DIG
},
1851 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe224, .config
= ALC880_5ST_DIG
},
1852 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe400, .config
= ALC880_5ST_DIG
},
1853 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe401, .config
= ALC880_5ST_DIG
},
1854 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xe402, .config
= ALC880_5ST_DIG
},
1855 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xd400, .config
= ALC880_5ST_DIG
},
1856 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xd401, .config
= ALC880_5ST_DIG
},
1857 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xa100, .config
= ALC880_5ST_DIG
},
1858 { .pci_subvendor
= 0x1565, .pci_subdevice
= 0x8202, .config
= ALC880_5ST_DIG
},
1859 { .pci_subvendor
= 0x1019, .pci_subdevice
= 0xa880, .config
= ALC880_5ST_DIG
},
1860 /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
1861 { .pci_subvendor
= 0x1695, .pci_subdevice
= 0x400d, .config
= ALC880_5ST_DIG
},
1862 /* note subvendor = 0 below */
1863 /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
1865 { .modelname
= "w810", .config
= ALC880_W810
},
1866 { .pci_subvendor
= 0x161f, .pci_subdevice
= 0x203d, .config
= ALC880_W810
},
1868 { .modelname
= "z71v", .config
= ALC880_Z71V
},
1869 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x1964, .config
= ALC880_Z71V
},
1871 { .modelname
= "6stack", .config
= ALC880_6ST
},
1872 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x8196, .config
= ALC880_6ST
}, /* ASUS P5GD1-HVM */
1873 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x81b4, .config
= ALC880_6ST
},
1874 { .pci_subvendor
= 0x1019, .pci_subdevice
= 0xa884, .config
= ALC880_6ST
}, /* Acer APFV */
1875 { .pci_subvendor
= 0x1458, .pci_subdevice
= 0xa102, .config
= ALC880_6ST
}, /* Gigabyte K8N51 */
1877 { .modelname
= "6stack-digout", .config
= ALC880_6ST_DIG
},
1878 { .pci_subvendor
= 0x2668, .pci_subdevice
= 0x8086, .config
= ALC880_6ST_DIG
},
1879 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0x2668, .config
= ALC880_6ST_DIG
},
1880 { .pci_subvendor
= 0x1462, .pci_subdevice
= 0x1150, .config
= ALC880_6ST_DIG
},
1881 { .pci_subvendor
= 0xe803, .pci_subdevice
= 0x1019, .config
= ALC880_6ST_DIG
},
1882 { .pci_subvendor
= 0x1039, .pci_subdevice
= 0x1234, .config
= ALC880_6ST_DIG
},
1883 { .pci_subvendor
= 0x1025, .pci_subdevice
= 0x0077, .config
= ALC880_6ST_DIG
},
1884 { .pci_subvendor
= 0x1025, .pci_subdevice
= 0x0078, .config
= ALC880_6ST_DIG
},
1885 { .pci_subvendor
= 0x1025, .pci_subdevice
= 0x0087, .config
= ALC880_6ST_DIG
},
1886 { .pci_subvendor
= 0x1297, .pci_subdevice
= 0xc790, .config
= ALC880_6ST_DIG
}, /* Shuttle ST20G5 */
1888 { .modelname
= "asus", .config
= ALC880_ASUS
},
1889 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x1964, .config
= ALC880_ASUS_DIG
},
1890 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x1973, .config
= ALC880_ASUS_DIG
},
1891 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x19b3, .config
= ALC880_ASUS_DIG
},
1892 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x1113, .config
= ALC880_ASUS_DIG
},
1893 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x1173, .config
= ALC880_ASUS_DIG
},
1894 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x1993, .config
= ALC880_ASUS
},
1895 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x10c3, .config
= ALC880_ASUS_DIG
},
1896 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x1133, .config
= ALC880_ASUS
},
1897 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x1123, .config
= ALC880_ASUS_DIG
},
1898 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x1143, .config
= ALC880_ASUS
},
1899 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x10b3, .config
= ALC880_ASUS_W1V
},
1900 { .pci_subvendor
= 0x1558, .pci_subdevice
= 0x5401, .config
= ALC880_ASUS_DIG2
},
1902 { .modelname
= "uniwill", .config
= ALC880_UNIWILL_DIG
},
1903 { .pci_subvendor
= 0x1584, .pci_subdevice
= 0x9050, .config
= ALC880_UNIWILL_DIG
},
1905 { .modelname
= "F1734", .config
= ALC880_F1734
},
1906 { .pci_subvendor
= 0x1734, .pci_subdevice
= 0x107c, .config
= ALC880_F1734
},
1907 { .pci_subvendor
= 0x1584, .pci_subdevice
= 0x9054, .config
= ALC880_F1734
},
1909 #ifdef CONFIG_SND_DEBUG
1910 { .modelname
= "test", .config
= ALC880_TEST
},
1912 { .modelname
= "auto", .config
= ALC880_AUTO
},
1918 * ALC880 codec presets
1920 static struct alc_config_preset alc880_presets
[] = {
1922 .mixers
= { alc880_three_stack_mixer
},
1923 .init_verbs
= { alc880_volume_init_verbs
, alc880_pin_3stack_init_verbs
},
1924 .num_dacs
= ARRAY_SIZE(alc880_dac_nids
),
1925 .dac_nids
= alc880_dac_nids
,
1926 .num_channel_mode
= ARRAY_SIZE(alc880_threestack_modes
),
1927 .channel_mode
= alc880_threestack_modes
,
1928 .input_mux
= &alc880_capture_source
,
1930 [ALC880_3ST_DIG
] = {
1931 .mixers
= { alc880_three_stack_mixer
},
1932 .init_verbs
= { alc880_volume_init_verbs
, alc880_pin_3stack_init_verbs
},
1933 .num_dacs
= ARRAY_SIZE(alc880_dac_nids
),
1934 .dac_nids
= alc880_dac_nids
,
1935 .dig_out_nid
= ALC880_DIGOUT_NID
,
1936 .num_channel_mode
= ARRAY_SIZE(alc880_threestack_modes
),
1937 .channel_mode
= alc880_threestack_modes
,
1938 .input_mux
= &alc880_capture_source
,
1940 [ALC880_TCL_S700
] = {
1941 .mixers
= { alc880_tcl_s700_mixer
},
1942 .init_verbs
= { alc880_volume_init_verbs
,
1943 alc880_pin_tcl_S700_init_verbs
,
1944 alc880_gpio2_init_verbs
},
1945 .num_dacs
= ARRAY_SIZE(alc880_dac_nids
),
1946 .dac_nids
= alc880_dac_nids
,
1948 .num_channel_mode
= ARRAY_SIZE(alc880_2_jack_modes
),
1949 .channel_mode
= alc880_2_jack_modes
,
1950 .input_mux
= &alc880_capture_source
,
1953 .mixers
= { alc880_three_stack_mixer
, alc880_five_stack_mixer
},
1954 .init_verbs
= { alc880_volume_init_verbs
, alc880_pin_5stack_init_verbs
},
1955 .num_dacs
= ARRAY_SIZE(alc880_dac_nids
),
1956 .dac_nids
= alc880_dac_nids
,
1957 .num_channel_mode
= ARRAY_SIZE(alc880_fivestack_modes
),
1958 .channel_mode
= alc880_fivestack_modes
,
1959 .input_mux
= &alc880_capture_source
,
1961 [ALC880_5ST_DIG
] = {
1962 .mixers
= { alc880_three_stack_mixer
, alc880_five_stack_mixer
},
1963 .init_verbs
= { alc880_volume_init_verbs
, alc880_pin_5stack_init_verbs
},
1964 .num_dacs
= ARRAY_SIZE(alc880_dac_nids
),
1965 .dac_nids
= alc880_dac_nids
,
1966 .dig_out_nid
= ALC880_DIGOUT_NID
,
1967 .num_channel_mode
= ARRAY_SIZE(alc880_fivestack_modes
),
1968 .channel_mode
= alc880_fivestack_modes
,
1969 .input_mux
= &alc880_capture_source
,
1972 .mixers
= { alc880_six_stack_mixer
},
1973 .init_verbs
= { alc880_volume_init_verbs
, alc880_pin_6stack_init_verbs
},
1974 .num_dacs
= ARRAY_SIZE(alc880_6st_dac_nids
),
1975 .dac_nids
= alc880_6st_dac_nids
,
1976 .num_channel_mode
= ARRAY_SIZE(alc880_sixstack_modes
),
1977 .channel_mode
= alc880_sixstack_modes
,
1978 .input_mux
= &alc880_6stack_capture_source
,
1980 [ALC880_6ST_DIG
] = {
1981 .mixers
= { alc880_six_stack_mixer
},
1982 .init_verbs
= { alc880_volume_init_verbs
, alc880_pin_6stack_init_verbs
},
1983 .num_dacs
= ARRAY_SIZE(alc880_6st_dac_nids
),
1984 .dac_nids
= alc880_6st_dac_nids
,
1985 .dig_out_nid
= ALC880_DIGOUT_NID
,
1986 .num_channel_mode
= ARRAY_SIZE(alc880_sixstack_modes
),
1987 .channel_mode
= alc880_sixstack_modes
,
1988 .input_mux
= &alc880_6stack_capture_source
,
1991 .mixers
= { alc880_w810_base_mixer
},
1992 .init_verbs
= { alc880_volume_init_verbs
, alc880_pin_w810_init_verbs
,
1993 alc880_gpio2_init_verbs
},
1994 .num_dacs
= ARRAY_SIZE(alc880_w810_dac_nids
),
1995 .dac_nids
= alc880_w810_dac_nids
,
1996 .dig_out_nid
= ALC880_DIGOUT_NID
,
1997 .num_channel_mode
= ARRAY_SIZE(alc880_w810_modes
),
1998 .channel_mode
= alc880_w810_modes
,
1999 .input_mux
= &alc880_capture_source
,
2002 .mixers
= { alc880_z71v_mixer
},
2003 .init_verbs
= { alc880_volume_init_verbs
, alc880_pin_z71v_init_verbs
},
2004 .num_dacs
= ARRAY_SIZE(alc880_z71v_dac_nids
),
2005 .dac_nids
= alc880_z71v_dac_nids
,
2006 .dig_out_nid
= ALC880_DIGOUT_NID
,
2008 .num_channel_mode
= ARRAY_SIZE(alc880_2_jack_modes
),
2009 .channel_mode
= alc880_2_jack_modes
,
2010 .input_mux
= &alc880_capture_source
,
2013 .mixers
= { alc880_f1734_mixer
},
2014 .init_verbs
= { alc880_volume_init_verbs
, alc880_pin_f1734_init_verbs
},
2015 .num_dacs
= ARRAY_SIZE(alc880_f1734_dac_nids
),
2016 .dac_nids
= alc880_f1734_dac_nids
,
2018 .num_channel_mode
= ARRAY_SIZE(alc880_2_jack_modes
),
2019 .channel_mode
= alc880_2_jack_modes
,
2020 .input_mux
= &alc880_capture_source
,
2023 .mixers
= { alc880_asus_mixer
},
2024 .init_verbs
= { alc880_volume_init_verbs
, alc880_pin_asus_init_verbs
,
2025 alc880_gpio1_init_verbs
},
2026 .num_dacs
= ARRAY_SIZE(alc880_asus_dac_nids
),
2027 .dac_nids
= alc880_asus_dac_nids
,
2028 .num_channel_mode
= ARRAY_SIZE(alc880_asus_modes
),
2029 .channel_mode
= alc880_asus_modes
,
2030 .input_mux
= &alc880_capture_source
,
2032 [ALC880_ASUS_DIG
] = {
2033 .mixers
= { alc880_asus_mixer
},
2034 .init_verbs
= { alc880_volume_init_verbs
, alc880_pin_asus_init_verbs
,
2035 alc880_gpio1_init_verbs
},
2036 .num_dacs
= ARRAY_SIZE(alc880_asus_dac_nids
),
2037 .dac_nids
= alc880_asus_dac_nids
,
2038 .dig_out_nid
= ALC880_DIGOUT_NID
,
2039 .num_channel_mode
= ARRAY_SIZE(alc880_asus_modes
),
2040 .channel_mode
= alc880_asus_modes
,
2041 .input_mux
= &alc880_capture_source
,
2043 [ALC880_ASUS_DIG2
] = {
2044 .mixers
= { alc880_asus_mixer
},
2045 .init_verbs
= { alc880_volume_init_verbs
, alc880_pin_asus_init_verbs
,
2046 alc880_gpio2_init_verbs
}, /* use GPIO2 */
2047 .num_dacs
= ARRAY_SIZE(alc880_asus_dac_nids
),
2048 .dac_nids
= alc880_asus_dac_nids
,
2049 .dig_out_nid
= ALC880_DIGOUT_NID
,
2050 .num_channel_mode
= ARRAY_SIZE(alc880_asus_modes
),
2051 .channel_mode
= alc880_asus_modes
,
2052 .input_mux
= &alc880_capture_source
,
2054 [ALC880_ASUS_W1V
] = {
2055 .mixers
= { alc880_asus_mixer
, alc880_asus_w1v_mixer
},
2056 .init_verbs
= { alc880_volume_init_verbs
, alc880_pin_asus_init_verbs
,
2057 alc880_gpio1_init_verbs
},
2058 .num_dacs
= ARRAY_SIZE(alc880_asus_dac_nids
),
2059 .dac_nids
= alc880_asus_dac_nids
,
2060 .dig_out_nid
= ALC880_DIGOUT_NID
,
2061 .num_channel_mode
= ARRAY_SIZE(alc880_asus_modes
),
2062 .channel_mode
= alc880_asus_modes
,
2063 .input_mux
= &alc880_capture_source
,
2065 [ALC880_UNIWILL_DIG
] = {
2066 .mixers
= { alc880_asus_mixer
, alc880_pcbeep_mixer
},
2067 .init_verbs
= { alc880_volume_init_verbs
, alc880_pin_asus_init_verbs
},
2068 .num_dacs
= ARRAY_SIZE(alc880_asus_dac_nids
),
2069 .dac_nids
= alc880_asus_dac_nids
,
2070 .dig_out_nid
= ALC880_DIGOUT_NID
,
2071 .num_channel_mode
= ARRAY_SIZE(alc880_asus_modes
),
2072 .channel_mode
= alc880_asus_modes
,
2073 .input_mux
= &alc880_capture_source
,
2076 .mixers
= { alc880_three_stack_mixer
},
2077 .init_verbs
= { alc880_volume_init_verbs
,
2078 alc880_pin_clevo_init_verbs
},
2079 .num_dacs
= ARRAY_SIZE(alc880_dac_nids
),
2080 .dac_nids
= alc880_dac_nids
,
2082 .num_channel_mode
= ARRAY_SIZE(alc880_threestack_modes
),
2083 .channel_mode
= alc880_threestack_modes
,
2084 .input_mux
= &alc880_capture_source
,
2086 #ifdef CONFIG_SND_DEBUG
2088 .mixers
= { alc880_test_mixer
},
2089 .init_verbs
= { alc880_test_init_verbs
},
2090 .num_dacs
= ARRAY_SIZE(alc880_test_dac_nids
),
2091 .dac_nids
= alc880_test_dac_nids
,
2092 .dig_out_nid
= ALC880_DIGOUT_NID
,
2093 .num_channel_mode
= ARRAY_SIZE(alc880_test_modes
),
2094 .channel_mode
= alc880_test_modes
,
2095 .input_mux
= &alc880_test_capture_source
,
2101 * Automatic parse of I/O pins from the BIOS configuration
2104 #define NUM_CONTROL_ALLOC 32
2105 #define NUM_VERB_ALLOC 32
2109 ALC_CTL_WIDGET_MUTE
,
2112 static struct snd_kcontrol_new alc880_control_templates
[] = {
2113 HDA_CODEC_VOLUME(NULL
, 0, 0, 0),
2114 HDA_CODEC_MUTE(NULL
, 0, 0, 0),
2115 HDA_BIND_MUTE(NULL
, 0, 0, 0),
2118 /* add dynamic controls */
2119 static int add_control(struct alc_spec
*spec
, int type
, const char *name
, unsigned long val
)
2121 struct snd_kcontrol_new
*knew
;
2123 if (spec
->num_kctl_used
>= spec
->num_kctl_alloc
) {
2124 int num
= spec
->num_kctl_alloc
+ NUM_CONTROL_ALLOC
;
2126 knew
= kcalloc(num
+ 1, sizeof(*knew
), GFP_KERNEL
); /* array + terminator */
2129 if (spec
->kctl_alloc
) {
2130 memcpy(knew
, spec
->kctl_alloc
, sizeof(*knew
) * spec
->num_kctl_alloc
);
2131 kfree(spec
->kctl_alloc
);
2133 spec
->kctl_alloc
= knew
;
2134 spec
->num_kctl_alloc
= num
;
2137 knew
= &spec
->kctl_alloc
[spec
->num_kctl_used
];
2138 *knew
= alc880_control_templates
[type
];
2139 knew
->name
= kstrdup(name
, GFP_KERNEL
);
2142 knew
->private_value
= val
;
2143 spec
->num_kctl_used
++;
2147 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2148 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2149 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2150 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2151 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
2152 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
2153 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
2154 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
2155 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2156 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
2157 #define ALC880_PIN_CD_NID 0x1c
2159 /* fill in the dac_nids table from the parsed pin configuration */
2160 static int alc880_auto_fill_dac_nids(struct alc_spec
*spec
, const struct auto_pin_cfg
*cfg
)
2166 memset(assigned
, 0, sizeof(assigned
));
2167 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
2169 /* check the pins hardwired to audio widget */
2170 for (i
= 0; i
< cfg
->line_outs
; i
++) {
2171 nid
= cfg
->line_out_pins
[i
];
2172 if (alc880_is_fixed_pin(nid
)) {
2173 int idx
= alc880_fixed_pin_idx(nid
);
2174 spec
->multiout
.dac_nids
[i
] = alc880_idx_to_dac(idx
);
2178 /* left pins can be connect to any audio widget */
2179 for (i
= 0; i
< cfg
->line_outs
; i
++) {
2180 nid
= cfg
->line_out_pins
[i
];
2181 if (alc880_is_fixed_pin(nid
))
2183 /* search for an empty channel */
2184 for (j
= 0; j
< cfg
->line_outs
; j
++) {
2185 if (! assigned
[j
]) {
2186 spec
->multiout
.dac_nids
[i
] = alc880_idx_to_dac(j
);
2192 spec
->multiout
.num_dacs
= cfg
->line_outs
;
2196 /* add playback controls from the parsed DAC table */
2197 static int alc880_auto_create_multi_out_ctls(struct alc_spec
*spec
,
2198 const struct auto_pin_cfg
*cfg
)
2201 static const char *chname
[4] = { "Front", "Surround", NULL
/*CLFE*/, "Side" };
2205 for (i
= 0; i
< cfg
->line_outs
; i
++) {
2206 if (! spec
->multiout
.dac_nids
[i
])
2208 nid
= alc880_idx_to_mixer(alc880_dac_to_idx(spec
->multiout
.dac_nids
[i
]));
2211 if ((err
= add_control(spec
, ALC_CTL_WIDGET_VOL
, "Center Playback Volume",
2212 HDA_COMPOSE_AMP_VAL(nid
, 1, 0, HDA_OUTPUT
))) < 0)
2214 if ((err
= add_control(spec
, ALC_CTL_WIDGET_VOL
, "LFE Playback Volume",
2215 HDA_COMPOSE_AMP_VAL(nid
, 2, 0, HDA_OUTPUT
))) < 0)
2217 if ((err
= add_control(spec
, ALC_CTL_BIND_MUTE
, "Center Playback Switch",
2218 HDA_COMPOSE_AMP_VAL(nid
, 1, 2, HDA_INPUT
))) < 0)
2220 if ((err
= add_control(spec
, ALC_CTL_BIND_MUTE
, "LFE Playback Switch",
2221 HDA_COMPOSE_AMP_VAL(nid
, 2, 2, HDA_INPUT
))) < 0)
2224 sprintf(name
, "%s Playback Volume", chname
[i
]);
2225 if ((err
= add_control(spec
, ALC_CTL_WIDGET_VOL
, name
,
2226 HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
))) < 0)
2228 sprintf(name
, "%s Playback Switch", chname
[i
]);
2229 if ((err
= add_control(spec
, ALC_CTL_BIND_MUTE
, name
,
2230 HDA_COMPOSE_AMP_VAL(nid
, 3, 2, HDA_INPUT
))) < 0)
2237 /* add playback controls for speaker and HP outputs */
2238 static int alc880_auto_create_extra_out(struct alc_spec
*spec
, hda_nid_t pin
,
2248 if (alc880_is_fixed_pin(pin
)) {
2249 nid
= alc880_idx_to_dac(alc880_fixed_pin_idx(pin
));
2250 if (! spec
->multiout
.dac_nids
[0]) {
2251 /* use this as the primary output */
2252 spec
->multiout
.dac_nids
[0] = nid
;
2253 if (! spec
->multiout
.num_dacs
)
2254 spec
->multiout
.num_dacs
= 1;
2256 /* specify the DAC as the extra output */
2257 spec
->multiout
.hp_nid
= nid
;
2258 /* control HP volume/switch on the output mixer amp */
2259 nid
= alc880_idx_to_mixer(alc880_fixed_pin_idx(pin
));
2260 sprintf(name
, "%s Playback Volume", pfx
);
2261 if ((err
= add_control(spec
, ALC_CTL_WIDGET_VOL
, name
,
2262 HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
))) < 0)
2264 sprintf(name
, "%s Playback Switch", pfx
);
2265 if ((err
= add_control(spec
, ALC_CTL_BIND_MUTE
, name
,
2266 HDA_COMPOSE_AMP_VAL(nid
, 3, 2, HDA_INPUT
))) < 0)
2268 } else if (alc880_is_multi_pin(pin
)) {
2269 /* set manual connection */
2270 if (! spec
->multiout
.dac_nids
[0]) {
2271 /* use this as the primary output */
2272 spec
->multiout
.dac_nids
[0] = alc880_idx_to_dac(alc880_multi_pin_idx(pin
));
2273 if (! spec
->multiout
.num_dacs
)
2274 spec
->multiout
.num_dacs
= 1;
2276 /* we have only a switch on HP-out PIN */
2277 sprintf(name
, "%s Playback Switch", pfx
);
2278 if ((err
= add_control(spec
, ALC_CTL_WIDGET_MUTE
, name
,
2279 HDA_COMPOSE_AMP_VAL(pin
, 3, 0, HDA_OUTPUT
))) < 0)
2285 /* create input playback/capture controls for the given pin */
2286 static int new_analog_input(struct alc_spec
*spec
, hda_nid_t pin
, const char *ctlname
,
2287 int idx
, hda_nid_t mix_nid
)
2292 sprintf(name
, "%s Playback Volume", ctlname
);
2293 if ((err
= add_control(spec
, ALC_CTL_WIDGET_VOL
, name
,
2294 HDA_COMPOSE_AMP_VAL(mix_nid
, 3, idx
, HDA_INPUT
))) < 0)
2296 sprintf(name
, "%s Playback Switch", ctlname
);
2297 if ((err
= add_control(spec
, ALC_CTL_WIDGET_MUTE
, name
,
2298 HDA_COMPOSE_AMP_VAL(mix_nid
, 3, idx
, HDA_INPUT
))) < 0)
2303 /* create playback/capture controls for input pins */
2304 static int alc880_auto_create_analog_input_ctls(struct alc_spec
*spec
,
2305 const struct auto_pin_cfg
*cfg
)
2307 struct hda_input_mux
*imux
= &spec
->private_imux
;
2310 for (i
= 0; i
< AUTO_PIN_LAST
; i
++) {
2311 if (alc880_is_input_pin(cfg
->input_pins
[i
])) {
2312 idx
= alc880_input_pin_idx(cfg
->input_pins
[i
]);
2313 err
= new_analog_input(spec
, cfg
->input_pins
[i
],
2314 auto_pin_cfg_labels
[i
],
2318 imux
->items
[imux
->num_items
].label
= auto_pin_cfg_labels
[i
];
2319 imux
->items
[imux
->num_items
].index
= alc880_input_pin_idx(cfg
->input_pins
[i
]);
2326 static void alc880_auto_set_output_and_unmute(struct hda_codec
*codec
,
2327 hda_nid_t nid
, int pin_type
,
2331 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
, pin_type
);
2332 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
);
2333 /* need the manual connection? */
2334 if (alc880_is_multi_pin(nid
)) {
2335 struct alc_spec
*spec
= codec
->spec
;
2336 int idx
= alc880_multi_pin_idx(nid
);
2337 snd_hda_codec_write(codec
, alc880_idx_to_selector(idx
), 0,
2338 AC_VERB_SET_CONNECT_SEL
,
2339 alc880_dac_to_idx(spec
->multiout
.dac_nids
[dac_idx
]));
2343 static void alc880_auto_init_multi_out(struct hda_codec
*codec
)
2345 struct alc_spec
*spec
= codec
->spec
;
2348 for (i
= 0; i
< spec
->autocfg
.line_outs
; i
++) {
2349 hda_nid_t nid
= spec
->autocfg
.line_out_pins
[i
];
2350 alc880_auto_set_output_and_unmute(codec
, nid
, PIN_OUT
, i
);
2354 static void alc880_auto_init_extra_out(struct hda_codec
*codec
)
2356 struct alc_spec
*spec
= codec
->spec
;
2359 pin
= spec
->autocfg
.speaker_pin
;
2360 if (pin
) /* connect to front */
2361 alc880_auto_set_output_and_unmute(codec
, pin
, PIN_OUT
, 0);
2362 pin
= spec
->autocfg
.hp_pin
;
2363 if (pin
) /* connect to front */
2364 alc880_auto_set_output_and_unmute(codec
, pin
, PIN_HP
, 0);
2367 static void alc880_auto_init_analog_input(struct hda_codec
*codec
)
2369 struct alc_spec
*spec
= codec
->spec
;
2372 for (i
= 0; i
< AUTO_PIN_LAST
; i
++) {
2373 hda_nid_t nid
= spec
->autocfg
.input_pins
[i
];
2374 if (alc880_is_input_pin(nid
)) {
2375 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2376 i
<= AUTO_PIN_FRONT_MIC
? PIN_VREF80
: PIN_IN
);
2377 if (nid
!= ALC880_PIN_CD_NID
)
2378 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
2384 /* parse the BIOS configuration and set up the alc_spec */
2385 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2386 static int alc880_parse_auto_config(struct hda_codec
*codec
)
2388 struct alc_spec
*spec
= codec
->spec
;
2390 static hda_nid_t alc880_ignore
[] = { 0x1d, 0 };
2392 if ((err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
,
2393 alc880_ignore
)) < 0)
2395 if (! spec
->autocfg
.line_outs
&& ! spec
->autocfg
.speaker_pin
&&
2396 ! spec
->autocfg
.hp_pin
)
2397 return 0; /* can't find valid BIOS pin config */
2399 if ((err
= alc880_auto_fill_dac_nids(spec
, &spec
->autocfg
)) < 0 ||
2400 (err
= alc880_auto_create_multi_out_ctls(spec
, &spec
->autocfg
)) < 0 ||
2401 (err
= alc880_auto_create_extra_out(spec
, spec
->autocfg
.speaker_pin
,
2403 (err
= alc880_auto_create_extra_out(spec
, spec
->autocfg
.speaker_pin
,
2404 "Headphone")) < 0 ||
2405 (err
= alc880_auto_create_analog_input_ctls(spec
, &spec
->autocfg
)) < 0)
2408 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
2410 if (spec
->autocfg
.dig_out_pin
)
2411 spec
->multiout
.dig_out_nid
= ALC880_DIGOUT_NID
;
2412 if (spec
->autocfg
.dig_in_pin
)
2413 spec
->dig_in_nid
= ALC880_DIGIN_NID
;
2415 if (spec
->kctl_alloc
)
2416 spec
->mixers
[spec
->num_mixers
++] = spec
->kctl_alloc
;
2418 spec
->init_verbs
[spec
->num_init_verbs
++] = alc880_volume_init_verbs
;
2420 spec
->input_mux
= &spec
->private_imux
;
2425 /* init callback for auto-configuration model -- overriding the default init */
2426 static int alc880_auto_init(struct hda_codec
*codec
)
2429 alc880_auto_init_multi_out(codec
);
2430 alc880_auto_init_extra_out(codec
);
2431 alc880_auto_init_analog_input(codec
);
2436 * OK, here we have finally the patch for ALC880
2439 static int patch_alc880(struct hda_codec
*codec
)
2441 struct alc_spec
*spec
;
2445 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
2451 board_config
= snd_hda_check_board_config(codec
, alc880_cfg_tbl
);
2452 if (board_config
< 0 || board_config
>= ALC880_MODEL_LAST
) {
2453 printk(KERN_INFO
"hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n");
2454 board_config
= ALC880_AUTO
;
2457 if (board_config
== ALC880_AUTO
) {
2458 /* automatic parse from the BIOS config */
2459 err
= alc880_parse_auto_config(codec
);
2464 printk(KERN_INFO
"hda_codec: Cannot set up configuration from BIOS. Using 3-stack mode...\n");
2465 board_config
= ALC880_3ST
;
2469 if (board_config
!= ALC880_AUTO
)
2470 setup_preset(spec
, &alc880_presets
[board_config
]);
2472 spec
->stream_name_analog
= "ALC880 Analog";
2473 spec
->stream_analog_playback
= &alc880_pcm_analog_playback
;
2474 spec
->stream_analog_capture
= &alc880_pcm_analog_capture
;
2476 spec
->stream_name_digital
= "ALC880 Digital";
2477 spec
->stream_digital_playback
= &alc880_pcm_digital_playback
;
2478 spec
->stream_digital_capture
= &alc880_pcm_digital_capture
;
2480 if (! spec
->adc_nids
&& spec
->input_mux
) {
2481 /* check whether NID 0x07 is valid */
2482 unsigned int wcap
= get_wcaps(codec
, alc880_adc_nids
[0]);
2483 wcap
= (wcap
& AC_WCAP_TYPE
) >> AC_WCAP_TYPE_SHIFT
; /* get type */
2484 if (wcap
!= AC_WID_AUD_IN
) {
2485 spec
->adc_nids
= alc880_adc_nids_alt
;
2486 spec
->num_adc_nids
= ARRAY_SIZE(alc880_adc_nids_alt
);
2487 spec
->mixers
[spec
->num_mixers
] = alc880_capture_alt_mixer
;
2490 spec
->adc_nids
= alc880_adc_nids
;
2491 spec
->num_adc_nids
= ARRAY_SIZE(alc880_adc_nids
);
2492 spec
->mixers
[spec
->num_mixers
] = alc880_capture_mixer
;
2497 codec
->patch_ops
= alc_patch_ops
;
2498 if (board_config
== ALC880_AUTO
)
2499 codec
->patch_ops
.init
= alc880_auto_init
;
2509 static hda_nid_t alc260_dac_nids
[1] = {
2514 static hda_nid_t alc260_adc_nids
[1] = {
2519 static hda_nid_t alc260_adc_nids_alt
[1] = {
2524 static hda_nid_t alc260_hp_adc_nids
[2] = {
2529 /* NIDs used when simultaneous access to both ADCs makes sense. Note that
2530 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
2532 static hda_nid_t alc260_dual_adc_nids
[2] = {
2537 #define ALC260_DIGOUT_NID 0x03
2538 #define ALC260_DIGIN_NID 0x06
2540 static struct hda_input_mux alc260_capture_source
= {
2544 { "Front Mic", 0x1 },
2550 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
2551 * headphone jack and the internal CD lines.
2553 static struct hda_input_mux alc260_fujitsu_capture_source
= {
2556 { "Mic/Line", 0x0 },
2558 { "Headphone", 0x2 },
2562 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configutation to
2563 * the Fujitsu S702x, but jacks are marked differently. We won't allow
2564 * retasking the Headphone jack, so it won't be available here.
2566 static struct hda_input_mux alc260_acer_capture_source
= {
2576 * This is just place-holder, so there's something for alc_build_pcms to look
2577 * at when it calculates the maximum number of channels. ALC260 has no mixer
2578 * element which allows changing the channel mode, so the verb list is
2581 static struct hda_channel_mode alc260_modes
[1] = {
2586 /* Mixer combinations
2588 * basic: base_output + input + pc_beep + capture
2589 * HP: base_output + input + capture_alt
2590 * HP_3013: hp_3013 + input + capture
2591 * fujitsu: fujitsu + capture
2592 * acer: acer + capture
2595 static struct snd_kcontrol_new alc260_base_output_mixer
[] = {
2596 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT
),
2597 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT
),
2598 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT
),
2599 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT
),
2600 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT
),
2601 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT
),
2605 static struct snd_kcontrol_new alc260_input_mixer
[] = {
2606 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT
),
2607 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT
),
2608 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT
),
2609 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT
),
2610 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT
),
2611 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT
),
2612 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT
),
2613 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT
),
2617 static struct snd_kcontrol_new alc260_pc_beep_mixer
[] = {
2618 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT
),
2619 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT
),
2623 static struct snd_kcontrol_new alc260_hp_3013_mixer
[] = {
2624 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT
),
2625 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT
),
2626 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT
),
2627 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT
),
2628 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT
),
2629 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT
),
2630 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT
),
2631 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT
),
2635 static struct snd_kcontrol_new alc260_fujitsu_mixer
[] = {
2636 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT
),
2637 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT
),
2638 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT
),
2639 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT
),
2640 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT
),
2641 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT
),
2642 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT
),
2643 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN
),
2644 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT
),
2645 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT
),
2646 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT
),
2647 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT
),
2651 static struct snd_kcontrol_new alc260_acer_mixer
[] = {
2652 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT
),
2653 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT
),
2654 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT
),
2655 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT
),
2656 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT
),
2657 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT
),
2658 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN
),
2659 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT
),
2660 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT
),
2661 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT
),
2662 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT
),
2663 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT
),
2667 /* capture mixer elements */
2668 static struct snd_kcontrol_new alc260_capture_mixer
[] = {
2669 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT
),
2670 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT
),
2671 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT
),
2672 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT
),
2674 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2675 /* The multiple "Capture Source" controls confuse alsamixer
2676 * So call somewhat different..
2677 * FIXME: the controls appear in the "playback" view!
2679 /* .name = "Capture Source", */
2680 .name
= "Input Source",
2682 .info
= alc_mux_enum_info
,
2683 .get
= alc_mux_enum_get
,
2684 .put
= alc_mux_enum_put
,
2689 static struct snd_kcontrol_new alc260_capture_alt_mixer
[] = {
2690 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT
),
2691 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT
),
2693 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2694 /* The multiple "Capture Source" controls confuse alsamixer
2695 * So call somewhat different..
2696 * FIXME: the controls appear in the "playback" view!
2698 /* .name = "Capture Source", */
2699 .name
= "Input Source",
2701 .info
= alc_mux_enum_info
,
2702 .get
= alc_mux_enum_get
,
2703 .put
= alc_mux_enum_put
,
2709 * initialization verbs
2711 static struct hda_verb alc260_init_verbs
[] = {
2712 /* Line In pin widget for input */
2713 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2714 /* CD pin widget for input */
2715 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2716 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2717 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2718 /* Mic2 (front panel) pin widget for input and vref at 80% */
2719 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2720 /* LINE-2 is used for line-out in rear */
2721 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2722 /* select line-out */
2723 {0x0e, AC_VERB_SET_CONNECT_SEL
, 0x00},
2725 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2727 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2729 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2730 /* mute capture amp left and right */
2731 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2732 /* set connection select to line in (default select for this ADC) */
2733 {0x04, AC_VERB_SET_CONNECT_SEL
, 0x02},
2734 /* mute capture amp left and right */
2735 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2736 /* set connection select to line in (default select for this ADC) */
2737 {0x05, AC_VERB_SET_CONNECT_SEL
, 0x02},
2738 /* set vol=0 Line-Out mixer amp left and right */
2739 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2740 /* unmute pin widget amp left and right (no gain on this amp) */
2741 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2742 /* set vol=0 HP mixer amp left and right */
2743 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2744 /* unmute pin widget amp left and right (no gain on this amp) */
2745 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2746 /* set vol=0 Mono mixer amp left and right */
2747 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2748 /* unmute pin widget amp left and right (no gain on this amp) */
2749 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2750 /* unmute LINE-2 out pin */
2751 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2752 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
2754 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(4)},
2756 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2)},
2758 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2759 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
2760 /* mute Front out path */
2761 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2762 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2763 /* mute Headphone out path */
2764 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2765 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2766 /* mute Mono out path */
2767 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2768 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2772 static struct hda_verb alc260_hp_init_verbs
[] = {
2773 /* Headphone and output */
2774 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0xc0},
2776 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40},
2777 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2778 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24},
2779 /* Mic2 (front panel) pin widget for input and vref at 80% */
2780 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24},
2781 /* Line In pin widget for input */
2782 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20},
2783 /* Line-2 pin widget for output */
2784 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40},
2785 /* CD pin widget for input */
2786 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20},
2787 /* unmute amp left and right */
2788 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, 0x7000},
2789 /* set connection select to line in (default select for this ADC) */
2790 {0x04, AC_VERB_SET_CONNECT_SEL
, 0x02},
2791 /* unmute Line-Out mixer amp left and right (volume = 0) */
2792 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
2793 /* mute pin widget amp left and right (no gain on this amp) */
2794 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, 0x0000},
2795 /* unmute HP mixer amp left and right (volume = 0) */
2796 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
2797 /* mute pin widget amp left and right (no gain on this amp) */
2798 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, 0x0000},
2799 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
2801 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7000 | (0x04 << 8))},
2802 /* unmute Line In */
2803 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7000 | (0x02 << 8))},
2805 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7000 | (0x00 << 8))},
2806 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
2807 /* Unmute Front out path */
2808 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7000 | (0x00 << 8))},
2809 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7000 | (0x01 << 8))},
2810 /* Unmute Headphone out path */
2811 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7000 | (0x00 << 8))},
2812 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7000 | (0x01 << 8))},
2813 /* Unmute Mono out path */
2814 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7000 | (0x00 << 8))},
2815 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7000 | (0x01 << 8))},
2819 static struct hda_verb alc260_hp_3013_init_verbs
[] = {
2820 /* Line out and output */
2821 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40},
2823 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40},
2824 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2825 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24},
2826 /* Mic2 (front panel) pin widget for input and vref at 80% */
2827 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24},
2828 /* Line In pin widget for input */
2829 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20},
2830 /* Headphone pin widget for output */
2831 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0xc0},
2832 /* CD pin widget for input */
2833 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20},
2834 /* unmute amp left and right */
2835 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, 0x7000},
2836 /* set connection select to line in (default select for this ADC) */
2837 {0x04, AC_VERB_SET_CONNECT_SEL
, 0x02},
2838 /* unmute Line-Out mixer amp left and right (volume = 0) */
2839 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
2840 /* mute pin widget amp left and right (no gain on this amp) */
2841 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, 0x0000},
2842 /* unmute HP mixer amp left and right (volume = 0) */
2843 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
2844 /* mute pin widget amp left and right (no gain on this amp) */
2845 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, 0x0000},
2846 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
2848 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7000 | (0x04 << 8))},
2849 /* unmute Line In */
2850 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7000 | (0x02 << 8))},
2852 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7000 | (0x00 << 8))},
2853 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
2854 /* Unmute Front out path */
2855 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7000 | (0x00 << 8))},
2856 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7000 | (0x01 << 8))},
2857 /* Unmute Headphone out path */
2858 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7000 | (0x00 << 8))},
2859 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7000 | (0x01 << 8))},
2860 /* Unmute Mono out path */
2861 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7000 | (0x00 << 8))},
2862 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7000 | (0x01 << 8))},
2866 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
2869 static struct hda_verb alc260_fujitsu_init_verbs
[] = {
2870 /* Disable all GPIOs */
2871 {0x01, AC_VERB_SET_GPIO_MASK
, 0},
2872 /* Internal speaker is connected to headphone pin */
2873 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2874 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
2875 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2876 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
2877 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2878 /* Ensure all other unused pins are disabled and muted. */
2879 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2880 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2881 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2882 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2883 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2884 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2885 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2886 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2888 /* Disable digital (SPDIF) pins */
2889 {0x03, AC_VERB_SET_DIGI_CONVERT_1
, 0},
2890 {0x06, AC_VERB_SET_DIGI_CONVERT_1
, 0},
2892 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
2893 * when acting as an output.
2895 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0},
2897 /* Start with output sum widgets muted and their output gains at min */
2898 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2899 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2900 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2901 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2902 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2903 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2904 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2905 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2906 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2908 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
2909 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2910 /* Unmute Line1 pin widget output buffer since it starts as an output.
2911 * If the pin mode is changed by the user the pin mode control will
2912 * take care of enabling the pin's input/output buffers as needed.
2913 * Therefore there's no need to enable the input buffer at this
2916 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2917 /* Unmute input buffer of pin widget used for Line-in (no equiv
2920 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2922 /* Mute capture amp left and right */
2923 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2924 /* Set ADC connection select to match default mixer setting - line
2927 {0x04, AC_VERB_SET_CONNECT_SEL
, 0x00},
2929 /* Do the same for the second ADC: mute capture input amp and
2930 * set ADC connection to line in (on mic1 pin)
2932 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2933 {0x05, AC_VERB_SET_CONNECT_SEL
, 0x00},
2935 /* Mute all inputs to mixer widget (even unconnected ones) */
2936 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* mic1 pin */
2937 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* mic2 pin */
2938 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* line1 pin */
2939 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* line2 pin */
2940 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
2941 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)}, /* Beep-gen pin */
2942 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)}, /* Line-out pin */
2943 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)}, /* HP-pin pin */
2948 /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
2949 * similar laptops (adapted from Fujitsu init verbs).
2951 static struct hda_verb alc260_acer_init_verbs
[] = {
2952 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
2953 * the headphone jack. Turn this on and rely on the standard mute
2954 * methods whenever the user wants to turn these outputs off.
2956 {0x01, AC_VERB_SET_GPIO_MASK
, 0x01},
2957 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x01},
2958 {0x01, AC_VERB_SET_GPIO_DATA
, 0x01},
2959 /* Internal speaker/Headphone jack is connected to Line-out pin */
2960 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2961 /* Internal microphone/Mic jack is connected to Mic1 pin */
2962 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF50
},
2963 /* Line In jack is connected to Line1 pin */
2964 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2965 /* Ensure all other unused pins are disabled and muted. */
2966 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2967 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2968 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2969 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2970 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2971 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2972 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2973 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2974 /* Disable digital (SPDIF) pins */
2975 {0x03, AC_VERB_SET_DIGI_CONVERT_1
, 0},
2976 {0x06, AC_VERB_SET_DIGI_CONVERT_1
, 0},
2978 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
2979 * bus when acting as outputs.
2981 {0x0b, AC_VERB_SET_CONNECT_SEL
, 0},
2982 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0},
2984 /* Start with output sum widgets muted and their output gains at min */
2985 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2986 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2987 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2988 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2989 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2990 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2991 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2992 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2993 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2995 /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
2996 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2997 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
2998 * inputs. If the pin mode is changed by the user the pin mode control
2999 * will take care of enabling the pin's input/output buffers as needed.
3000 * Therefore there's no need to enable the input buffer at this
3003 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3004 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3006 /* Mute capture amp left and right */
3007 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3008 /* Set ADC connection select to match default mixer setting - mic
3011 {0x04, AC_VERB_SET_CONNECT_SEL
, 0x00},
3013 /* Do similar with the second ADC: mute capture input amp and
3014 * set ADC connection to line (on line1 pin)
3016 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3017 {0x05, AC_VERB_SET_CONNECT_SEL
, 0x02},
3019 /* Mute all inputs to mixer widget (even unconnected ones) */
3020 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* mic1 pin */
3021 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* mic2 pin */
3022 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* line1 pin */
3023 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* line2 pin */
3024 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
3025 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3026 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)}, /* Line-out pin */
3027 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)}, /* HP-pin pin */
3032 /* Test configuration for debugging, modelled after the ALC880 test
3035 #ifdef CONFIG_SND_DEBUG
3036 static hda_nid_t alc260_test_dac_nids
[1] = {
3039 static hda_nid_t alc260_test_adc_nids
[2] = {
3042 /* This is a bit messy since the two input muxes in the ALC260 have slight
3043 * variations in their signal assignments. The ideal way to deal with this
3044 * is to extend alc_spec.input_mux to allow a different input MUX for each
3045 * ADC. For the purposes of the test model it's sufficient to just list
3046 * both options for affected signal indices. The separate input mux
3047 * functionality only needs to be considered if a model comes along which
3048 * actually uses signals 0x5, 0x6 and 0x7 for something which makes sense to
3051 static struct hda_input_mux alc260_test_capture_source
= {
3054 { "MIC1 pin", 0x0 },
3055 { "MIC2 pin", 0x1 },
3056 { "LINE1 pin", 0x2 },
3057 { "LINE2 pin", 0x3 },
3059 { "LINE-OUT pin (cap1), Mixer (cap2)", 0x5 },
3060 { "HP-OUT pin (cap1), LINE-OUT pin (cap2)", 0x6 },
3061 { "HP-OUT pin (cap2 only)", 0x7 },
3064 static struct snd_kcontrol_new alc260_test_mixer
[] = {
3065 /* Output driver widgets */
3066 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT
),
3067 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT
),
3068 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT
),
3069 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT
),
3070 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT
),
3071 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT
),
3073 /* Modes for retasking pin widgets */
3074 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT
),
3075 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT
),
3076 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT
),
3077 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT
),
3078 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT
),
3079 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT
),
3081 /* Loopback mixer controls */
3082 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT
),
3083 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT
),
3084 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT
),
3085 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT
),
3086 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT
),
3087 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT
),
3088 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT
),
3089 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT
),
3090 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT
),
3091 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT
),
3092 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT
),
3093 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT
),
3094 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT
),
3095 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT
),
3096 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT
),
3097 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT
),
3099 /* Controls for GPIO pins, assuming they are configured as outputs */
3100 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
3101 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
3102 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
3103 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
3105 /* Switches to allow the digital IO pins to be enabled. The datasheet
3106 * is ambigious as to which NID is which; testing on laptops which
3107 * make this output available should provide clarification.
3109 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
3110 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
3114 static struct hda_verb alc260_test_init_verbs
[] = {
3115 /* Enable all GPIOs as outputs with an initial value of 0 */
3116 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x0f},
3117 {0x01, AC_VERB_SET_GPIO_DATA
, 0x00},
3118 {0x01, AC_VERB_SET_GPIO_MASK
, 0x0f},
3120 /* Enable retasking pins as output, initially without power amp */
3121 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
3122 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
3123 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
3124 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
3125 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
3126 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
3128 /* Disable digital (SPDIF) pins initially, but users can enable
3129 * them via a mixer switch. In the case of SPDIF-out, this initverb
3130 * payload also sets the generation to 0, output to be in "consumer"
3131 * PCM format, copyright asserted, no pre-emphasis and no validity
3134 {0x03, AC_VERB_SET_DIGI_CONVERT_1
, 0},
3135 {0x06, AC_VERB_SET_DIGI_CONVERT_1
, 0},
3137 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
3138 * OUT1 sum bus when acting as an output.
3140 {0x0b, AC_VERB_SET_CONNECT_SEL
, 0},
3141 {0x0c, AC_VERB_SET_CONNECT_SEL
, 0},
3142 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0},
3143 {0x0e, AC_VERB_SET_CONNECT_SEL
, 0},
3145 /* Start with output sum widgets muted and their output gains at min */
3146 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3147 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
3148 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
3149 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3150 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
3151 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
3152 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3153 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
3154 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
3156 /* Unmute retasking pin widget output buffers since the default
3157 * state appears to be output. As the pin mode is changed by the
3158 * user the pin mode control will take care of enabling the pin's
3159 * input/output buffers as needed.
3161 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
3162 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
3163 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
3164 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
3165 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
3166 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
3167 /* Also unmute the mono-out pin widget */
3168 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
3170 /* Mute capture amp left and right */
3171 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3172 /* Set ADC connection select to match default mixer setting (mic1
3175 {0x04, AC_VERB_SET_CONNECT_SEL
, 0x00},
3177 /* Do the same for the second ADC: mute capture input amp and
3178 * set ADC connection to mic1 pin
3180 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3181 {0x05, AC_VERB_SET_CONNECT_SEL
, 0x00},
3183 /* Mute all inputs to mixer widget (even unconnected ones) */
3184 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* mic1 pin */
3185 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* mic2 pin */
3186 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* line1 pin */
3187 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* line2 pin */
3188 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
3189 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3190 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)}, /* Line-out pin */
3191 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)}, /* HP-pin pin */
3197 static struct hda_pcm_stream alc260_pcm_analog_playback
= {
3203 static struct hda_pcm_stream alc260_pcm_analog_capture
= {
3209 #define alc260_pcm_digital_playback alc880_pcm_digital_playback
3210 #define alc260_pcm_digital_capture alc880_pcm_digital_capture
3213 * for BIOS auto-configuration
3216 static int alc260_add_playback_controls(struct alc_spec
*spec
, hda_nid_t nid
,
3220 unsigned long vol_val
, sw_val
;
3224 if (nid
>= 0x0f && nid
< 0x11) {
3225 nid_vol
= nid
- 0x7;
3226 vol_val
= HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0, HDA_OUTPUT
);
3227 sw_val
= HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
);
3228 } else if (nid
== 0x11) {
3229 nid_vol
= nid
- 0x7;
3230 vol_val
= HDA_COMPOSE_AMP_VAL(nid_vol
, 2, 0, HDA_OUTPUT
);
3231 sw_val
= HDA_COMPOSE_AMP_VAL(nid
, 2, 0, HDA_OUTPUT
);
3232 } else if (nid
>= 0x12 && nid
<= 0x15) {
3234 vol_val
= HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0, HDA_OUTPUT
);
3235 sw_val
= HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
);
3239 snprintf(name
, sizeof(name
), "%s Playback Volume", pfx
);
3240 if ((err
= add_control(spec
, ALC_CTL_WIDGET_VOL
, name
, vol_val
)) < 0)
3242 snprintf(name
, sizeof(name
), "%s Playback Switch", pfx
);
3243 if ((err
= add_control(spec
, ALC_CTL_WIDGET_MUTE
, name
, sw_val
)) < 0)
3248 /* add playback controls from the parsed DAC table */
3249 static int alc260_auto_create_multi_out_ctls(struct alc_spec
*spec
,
3250 const struct auto_pin_cfg
*cfg
)
3255 spec
->multiout
.num_dacs
= 1;
3256 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
3257 spec
->multiout
.dac_nids
[0] = 0x02;
3259 nid
= cfg
->line_out_pins
[0];
3261 err
= alc260_add_playback_controls(spec
, nid
, "Front");
3266 nid
= cfg
->speaker_pin
;
3268 err
= alc260_add_playback_controls(spec
, nid
, "Speaker");
3275 err
= alc260_add_playback_controls(spec
, nid
, "Headphone");
3282 /* create playback/capture controls for input pins */
3283 static int alc260_auto_create_analog_input_ctls(struct alc_spec
*spec
,
3284 const struct auto_pin_cfg
*cfg
)
3286 struct hda_input_mux
*imux
= &spec
->private_imux
;
3289 for (i
= 0; i
< AUTO_PIN_LAST
; i
++) {
3290 if (cfg
->input_pins
[i
] >= 0x12) {
3291 idx
= cfg
->input_pins
[i
] - 0x12;
3292 err
= new_analog_input(spec
, cfg
->input_pins
[i
],
3293 auto_pin_cfg_labels
[i
], idx
, 0x07);
3296 imux
->items
[imux
->num_items
].label
= auto_pin_cfg_labels
[i
];
3297 imux
->items
[imux
->num_items
].index
= idx
;
3300 if ((cfg
->input_pins
[i
] >= 0x0f) && (cfg
->input_pins
[i
] <= 0x10)){
3301 idx
= cfg
->input_pins
[i
] - 0x09;
3302 err
= new_analog_input(spec
, cfg
->input_pins
[i
],
3303 auto_pin_cfg_labels
[i
], idx
, 0x07);
3306 imux
->items
[imux
->num_items
].label
= auto_pin_cfg_labels
[i
];
3307 imux
->items
[imux
->num_items
].index
= idx
;
3314 static void alc260_auto_set_output_and_unmute(struct hda_codec
*codec
,
3315 hda_nid_t nid
, int pin_type
,
3319 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
, pin_type
);
3320 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
);
3321 /* need the manual connection? */
3323 int idx
= nid
- 0x12;
3324 snd_hda_codec_write(codec
, idx
+ 0x0b, 0,
3325 AC_VERB_SET_CONNECT_SEL
, sel_idx
);
3330 static void alc260_auto_init_multi_out(struct hda_codec
*codec
)
3332 struct alc_spec
*spec
= codec
->spec
;
3335 nid
= spec
->autocfg
.line_out_pins
[0];
3337 alc260_auto_set_output_and_unmute(codec
, nid
, PIN_OUT
, 0);
3339 nid
= spec
->autocfg
.speaker_pin
;
3341 alc260_auto_set_output_and_unmute(codec
, nid
, PIN_OUT
, 0);
3343 nid
= spec
->autocfg
.hp_pin
;
3345 alc260_auto_set_output_and_unmute(codec
, nid
, PIN_OUT
, 0);
3348 #define ALC260_PIN_CD_NID 0x16
3349 static void alc260_auto_init_analog_input(struct hda_codec
*codec
)
3351 struct alc_spec
*spec
= codec
->spec
;
3354 for (i
= 0; i
< AUTO_PIN_LAST
; i
++) {
3355 hda_nid_t nid
= spec
->autocfg
.input_pins
[i
];
3357 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
3358 i
<= AUTO_PIN_FRONT_MIC
? PIN_VREF80
: PIN_IN
);
3359 if (nid
!= ALC260_PIN_CD_NID
)
3360 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3367 * generic initialization of ADC, input mixers and output mixers
3369 static struct hda_verb alc260_volume_init_verbs
[] = {
3371 * Unmute ADC0-1 and set the default input to mic-in
3373 {0x04, AC_VERB_SET_CONNECT_SEL
, 0x00},
3374 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3375 {0x05, AC_VERB_SET_CONNECT_SEL
, 0x00},
3376 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3378 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3380 * Note: PASD motherboards uses the Line In 2 as the input for front panel
3383 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
3384 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3385 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3386 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2)},
3387 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(3)},
3388 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(4)},
3391 * Set up output mixers (0x08 - 0x0a)
3393 /* set vol=0 to output mixers */
3394 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
3395 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
3396 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
3397 /* set up input amps for analog loopback */
3398 /* Amp Indices: DAC = 0, mixer = 1 */
3399 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3400 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3401 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3402 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3403 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3404 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3409 static int alc260_parse_auto_config(struct hda_codec
*codec
)
3411 struct alc_spec
*spec
= codec
->spec
;
3414 static hda_nid_t alc260_ignore
[] = { 0x17, 0 };
3416 if ((err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
,
3417 alc260_ignore
)) < 0)
3419 if ((err
= alc260_auto_create_multi_out_ctls(spec
, &spec
->autocfg
)) < 0)
3421 if (! spec
->kctl_alloc
)
3422 return 0; /* can't find valid BIOS pin config */
3423 if ((err
= alc260_auto_create_analog_input_ctls(spec
, &spec
->autocfg
)) < 0)
3426 spec
->multiout
.max_channels
= 2;
3428 if (spec
->autocfg
.dig_out_pin
)
3429 spec
->multiout
.dig_out_nid
= ALC260_DIGOUT_NID
;
3430 if (spec
->kctl_alloc
)
3431 spec
->mixers
[spec
->num_mixers
++] = spec
->kctl_alloc
;
3433 spec
->init_verbs
[spec
->num_init_verbs
++] = alc260_volume_init_verbs
;
3435 spec
->input_mux
= &spec
->private_imux
;
3437 /* check whether NID 0x04 is valid */
3438 wcap
= get_wcaps(codec
, 0x04);
3439 wcap
= (wcap
& AC_WCAP_TYPE
) >> AC_WCAP_TYPE_SHIFT
; /* get type */
3440 if (wcap
!= AC_WID_AUD_IN
) {
3441 spec
->adc_nids
= alc260_adc_nids_alt
;
3442 spec
->num_adc_nids
= ARRAY_SIZE(alc260_adc_nids_alt
);
3443 spec
->mixers
[spec
->num_mixers
] = alc260_capture_alt_mixer
;
3445 spec
->adc_nids
= alc260_adc_nids
;
3446 spec
->num_adc_nids
= ARRAY_SIZE(alc260_adc_nids
);
3447 spec
->mixers
[spec
->num_mixers
] = alc260_capture_mixer
;
3454 /* init callback for auto-configuration model -- overriding the default init */
3455 static int alc260_auto_init(struct hda_codec
*codec
)
3458 alc260_auto_init_multi_out(codec
);
3459 alc260_auto_init_analog_input(codec
);
3464 * ALC260 configurations
3466 static struct hda_board_config alc260_cfg_tbl
[] = {
3467 { .modelname
= "basic", .config
= ALC260_BASIC
},
3468 { .pci_subvendor
= 0x104d, .pci_subdevice
= 0x81bb,
3469 .config
= ALC260_BASIC
}, /* Sony VAIO */
3470 { .modelname
= "hp", .config
= ALC260_HP
},
3471 { .pci_subvendor
= 0x103c, .pci_subdevice
= 0x3010, .config
= ALC260_HP
},
3472 { .pci_subvendor
= 0x103c, .pci_subdevice
= 0x3011, .config
= ALC260_HP
},
3473 { .pci_subvendor
= 0x103c, .pci_subdevice
= 0x3012, .config
= ALC260_HP
},
3474 { .pci_subvendor
= 0x103c, .pci_subdevice
= 0x3013, .config
= ALC260_HP_3013
},
3475 { .pci_subvendor
= 0x103c, .pci_subdevice
= 0x3014, .config
= ALC260_HP
},
3476 { .pci_subvendor
= 0x103c, .pci_subdevice
= 0x3015, .config
= ALC260_HP
},
3477 { .pci_subvendor
= 0x103c, .pci_subdevice
= 0x3016, .config
= ALC260_HP
},
3478 { .modelname
= "fujitsu", .config
= ALC260_FUJITSU_S702X
},
3479 { .pci_subvendor
= 0x10cf, .pci_subdevice
= 0x1326, .config
= ALC260_FUJITSU_S702X
},
3480 { .modelname
= "acer", .config
= ALC260_ACER
},
3481 { .pci_subvendor
= 0x1025, .pci_subdevice
= 0x008f, .config
= ALC260_ACER
},
3482 #ifdef CONFIG_SND_DEBUG
3483 { .modelname
= "test", .config
= ALC260_TEST
},
3485 { .modelname
= "auto", .config
= ALC260_AUTO
},
3489 static struct alc_config_preset alc260_presets
[] = {
3491 .mixers
= { alc260_base_output_mixer
,
3493 alc260_pc_beep_mixer
,
3494 alc260_capture_mixer
},
3495 .init_verbs
= { alc260_init_verbs
},
3496 .num_dacs
= ARRAY_SIZE(alc260_dac_nids
),
3497 .dac_nids
= alc260_dac_nids
,
3498 .num_adc_nids
= ARRAY_SIZE(alc260_adc_nids
),
3499 .adc_nids
= alc260_adc_nids
,
3500 .num_channel_mode
= ARRAY_SIZE(alc260_modes
),
3501 .channel_mode
= alc260_modes
,
3502 .input_mux
= &alc260_capture_source
,
3505 .mixers
= { alc260_base_output_mixer
,
3507 alc260_capture_alt_mixer
},
3508 .init_verbs
= { alc260_hp_init_verbs
},
3509 .num_dacs
= ARRAY_SIZE(alc260_dac_nids
),
3510 .dac_nids
= alc260_dac_nids
,
3511 .num_adc_nids
= ARRAY_SIZE(alc260_hp_adc_nids
),
3512 .adc_nids
= alc260_hp_adc_nids
,
3513 .num_channel_mode
= ARRAY_SIZE(alc260_modes
),
3514 .channel_mode
= alc260_modes
,
3515 .input_mux
= &alc260_capture_source
,
3517 [ALC260_HP_3013
] = {
3518 .mixers
= { alc260_hp_3013_mixer
,
3520 alc260_capture_alt_mixer
},
3521 .init_verbs
= { alc260_hp_3013_init_verbs
},
3522 .num_dacs
= ARRAY_SIZE(alc260_dac_nids
),
3523 .dac_nids
= alc260_dac_nids
,
3524 .num_adc_nids
= ARRAY_SIZE(alc260_hp_adc_nids
),
3525 .adc_nids
= alc260_hp_adc_nids
,
3526 .num_channel_mode
= ARRAY_SIZE(alc260_modes
),
3527 .channel_mode
= alc260_modes
,
3528 .input_mux
= &alc260_capture_source
,
3530 [ALC260_FUJITSU_S702X
] = {
3531 .mixers
= { alc260_fujitsu_mixer
,
3532 alc260_capture_mixer
},
3533 .init_verbs
= { alc260_fujitsu_init_verbs
},
3534 .num_dacs
= ARRAY_SIZE(alc260_dac_nids
),
3535 .dac_nids
= alc260_dac_nids
,
3536 .num_adc_nids
= ARRAY_SIZE(alc260_dual_adc_nids
),
3537 .adc_nids
= alc260_dual_adc_nids
,
3538 .num_channel_mode
= ARRAY_SIZE(alc260_modes
),
3539 .channel_mode
= alc260_modes
,
3540 .input_mux
= &alc260_fujitsu_capture_source
,
3543 .mixers
= { alc260_acer_mixer
,
3544 alc260_capture_mixer
},
3545 .init_verbs
= { alc260_acer_init_verbs
},
3546 .num_dacs
= ARRAY_SIZE(alc260_dac_nids
),
3547 .dac_nids
= alc260_dac_nids
,
3548 .num_adc_nids
= ARRAY_SIZE(alc260_dual_adc_nids
),
3549 .adc_nids
= alc260_dual_adc_nids
,
3550 .num_channel_mode
= ARRAY_SIZE(alc260_modes
),
3551 .channel_mode
= alc260_modes
,
3552 .input_mux
= &alc260_acer_capture_source
,
3554 #ifdef CONFIG_SND_DEBUG
3556 .mixers
= { alc260_test_mixer
,
3557 alc260_capture_mixer
},
3558 .init_verbs
= { alc260_test_init_verbs
},
3559 .num_dacs
= ARRAY_SIZE(alc260_test_dac_nids
),
3560 .dac_nids
= alc260_test_dac_nids
,
3561 .num_adc_nids
= ARRAY_SIZE(alc260_test_adc_nids
),
3562 .adc_nids
= alc260_test_adc_nids
,
3563 .num_channel_mode
= ARRAY_SIZE(alc260_modes
),
3564 .channel_mode
= alc260_modes
,
3565 .input_mux
= &alc260_test_capture_source
,
3570 static int patch_alc260(struct hda_codec
*codec
)
3572 struct alc_spec
*spec
;
3573 int err
, board_config
;
3575 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
3581 board_config
= snd_hda_check_board_config(codec
, alc260_cfg_tbl
);
3582 if (board_config
< 0 || board_config
>= ALC260_MODEL_LAST
) {
3583 snd_printd(KERN_INFO
"hda_codec: Unknown model for ALC260\n");
3584 board_config
= ALC260_AUTO
;
3587 if (board_config
== ALC260_AUTO
) {
3588 /* automatic parse from the BIOS config */
3589 err
= alc260_parse_auto_config(codec
);
3594 printk(KERN_INFO
"hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
3595 board_config
= ALC260_BASIC
;
3599 if (board_config
!= ALC260_AUTO
)
3600 setup_preset(spec
, &alc260_presets
[board_config
]);
3602 spec
->stream_name_analog
= "ALC260 Analog";
3603 spec
->stream_analog_playback
= &alc260_pcm_analog_playback
;
3604 spec
->stream_analog_capture
= &alc260_pcm_analog_capture
;
3606 spec
->stream_name_digital
= "ALC260 Digital";
3607 spec
->stream_digital_playback
= &alc260_pcm_digital_playback
;
3608 spec
->stream_digital_capture
= &alc260_pcm_digital_capture
;
3610 codec
->patch_ops
= alc_patch_ops
;
3611 if (board_config
== ALC260_AUTO
)
3612 codec
->patch_ops
.init
= alc260_auto_init
;
3621 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
3622 * configuration. Each pin widget can choose any input DACs and a mixer.
3623 * Each ADC is connected from a mixer of all inputs. This makes possible
3624 * 6-channel independent captures.
3626 * In addition, an independent DAC for the multi-playback (not used in this
3629 #define ALC882_DIGOUT_NID 0x06
3630 #define ALC882_DIGIN_NID 0x0a
3632 static struct hda_channel_mode alc882_ch_modes
[1] = {
3636 static hda_nid_t alc882_dac_nids
[4] = {
3637 /* front, rear, clfe, rear_surr */
3638 0x02, 0x03, 0x04, 0x05
3641 /* identical with ALC880 */
3642 #define alc882_adc_nids alc880_adc_nids
3643 #define alc882_adc_nids_alt alc880_adc_nids_alt
3646 /* FIXME: should be a matrix-type input source selection */
3648 static struct hda_input_mux alc882_capture_source
= {
3652 { "Front Mic", 0x1 },
3658 #define alc882_mux_enum_info alc_mux_enum_info
3659 #define alc882_mux_enum_get alc_mux_enum_get
3661 static int alc882_mux_enum_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
3663 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3664 struct alc_spec
*spec
= codec
->spec
;
3665 const struct hda_input_mux
*imux
= spec
->input_mux
;
3666 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
3667 static hda_nid_t capture_mixers
[3] = { 0x24, 0x23, 0x22 };
3668 hda_nid_t nid
= capture_mixers
[adc_idx
];
3669 unsigned int *cur_val
= &spec
->cur_mux
[adc_idx
];
3670 unsigned int i
, idx
;
3672 idx
= ucontrol
->value
.enumerated
.item
[0];
3673 if (idx
>= imux
->num_items
)
3674 idx
= imux
->num_items
- 1;
3675 if (*cur_val
== idx
&& ! codec
->in_resume
)
3677 for (i
= 0; i
< imux
->num_items
; i
++) {
3678 unsigned int v
= (i
== idx
) ? 0x7000 : 0x7080;
3679 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3680 v
| (imux
->items
[i
].index
<< 8));
3689 static struct hda_verb alc882_sixstack_ch6_init
[] = {
3690 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x00 },
3691 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
3692 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
3693 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
3700 static struct hda_verb alc882_sixstack_ch8_init
[] = {
3701 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
3702 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
3703 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
3704 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
3708 static struct hda_channel_mode alc882_sixstack_modes
[2] = {
3709 { 6, alc882_sixstack_ch6_init
},
3710 { 8, alc882_sixstack_ch8_init
},
3713 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
3714 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
3716 static struct snd_kcontrol_new alc882_base_mixer
[] = {
3717 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT
),
3718 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT
),
3719 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT
),
3720 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT
),
3721 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT
),
3722 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT
),
3723 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT
),
3724 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT
),
3725 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT
),
3726 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT
),
3727 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT
),
3728 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT
),
3729 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT
),
3730 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT
),
3731 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT
),
3732 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT
),
3733 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT
),
3734 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT
),
3735 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT
),
3736 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT
),
3737 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT
),
3738 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT
),
3739 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT
),
3740 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT
),
3741 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT
),
3742 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT
),
3743 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT
),
3745 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3746 /* .name = "Capture Source", */
3747 .name
= "Input Source",
3749 .info
= alc882_mux_enum_info
,
3750 .get
= alc882_mux_enum_get
,
3751 .put
= alc882_mux_enum_put
,
3756 static struct snd_kcontrol_new alc882_chmode_mixer
[] = {
3758 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3759 .name
= "Channel Mode",
3760 .info
= alc_ch_mode_info
,
3761 .get
= alc_ch_mode_get
,
3762 .put
= alc_ch_mode_put
,
3767 static struct hda_verb alc882_init_verbs
[] = {
3768 /* Front mixer: unmute input/output amp left and right (volume = 0) */
3769 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
3770 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3771 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
3773 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
3774 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3775 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
3777 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
3778 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3779 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
3781 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
3782 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3783 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
3785 /* Front Pin: output 0 (0x0c) */
3786 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
3787 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
3788 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x00},
3789 /* Rear Pin: output 1 (0x0d) */
3790 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
3791 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
3792 {0x15, AC_VERB_SET_CONNECT_SEL
, 0x01},
3793 /* CLFE Pin: output 2 (0x0e) */
3794 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
3795 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
3796 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x02},
3797 /* Side Pin: output 3 (0x0f) */
3798 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
3799 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
3800 {0x17, AC_VERB_SET_CONNECT_SEL
, 0x03},
3801 /* Mic (rear) pin: input vref at 80% */
3802 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
3803 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3804 /* Front Mic pin: input vref at 80% */
3805 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
3806 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3807 /* Line In pin: input */
3808 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
3809 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3810 /* Line-2 In: Headphone output (output 0 - 0x0c) */
3811 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
3812 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
3813 {0x1b, AC_VERB_SET_CONNECT_SEL
, 0x00},
3814 /* CD pin widget for input */
3815 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
3817 /* FIXME: use matrix-type input source selection */
3818 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
3819 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
3820 {0x24, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3821 {0x24, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
3822 {0x24, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
3823 {0x24, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
3825 {0x23, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3826 {0x23, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
3827 {0x23, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
3828 {0x23, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
3830 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3831 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
3832 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
3833 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
3834 /* ADC1: mute amp left and right */
3835 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3836 {0x07, AC_VERB_SET_CONNECT_SEL
, 0x00},
3837 /* ADC2: mute amp left and right */
3838 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3839 {0x08, AC_VERB_SET_CONNECT_SEL
, 0x00},
3840 /* ADC3: mute amp left and right */
3841 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3842 {0x09, AC_VERB_SET_CONNECT_SEL
, 0x00},
3848 * generic initialization of ADC, input mixers and output mixers
3850 static struct hda_verb alc882_auto_init_verbs
[] = {
3852 * Unmute ADC0-2 and set the default input to mic-in
3854 {0x07, AC_VERB_SET_CONNECT_SEL
, 0x00},
3855 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3856 {0x08, AC_VERB_SET_CONNECT_SEL
, 0x00},
3857 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3858 {0x09, AC_VERB_SET_CONNECT_SEL
, 0x00},
3859 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3861 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3863 * Note: PASD motherboards uses the Line In 2 as the input for front panel
3866 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
3867 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3868 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3869 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2)},
3870 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(3)},
3871 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(4)},
3874 * Set up output mixers (0x0c - 0x0f)
3876 /* set vol=0 to output mixers */
3877 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
3878 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
3879 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
3880 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
3881 /* set up input amps for analog loopback */
3882 /* Amp Indices: DAC = 0, mixer = 1 */
3883 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3884 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3885 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3886 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3887 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3888 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3889 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3890 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3891 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3892 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3894 /* FIXME: use matrix-type input source selection */
3895 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
3896 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
3897 {0x24, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7000 | (0x00 << 8))},
3898 {0x24, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7080 | (0x03 << 8))},
3899 {0x24, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7080 | (0x02 << 8))},
3900 {0x24, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7080 | (0x04 << 8))},
3902 {0x23, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7000 | (0x00 << 8))},
3903 {0x23, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7080 | (0x03 << 8))},
3904 {0x23, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7080 | (0x02 << 8))},
3905 {0x23, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7080 | (0x04 << 8))},
3907 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7000 | (0x00 << 8))},
3908 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7080 | (0x03 << 8))},
3909 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7080 | (0x02 << 8))},
3910 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7080 | (0x04 << 8))},
3915 /* capture mixer elements */
3916 static struct snd_kcontrol_new alc882_capture_alt_mixer
[] = {
3917 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT
),
3918 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT
),
3919 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT
),
3920 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT
),
3922 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3923 /* The multiple "Capture Source" controls confuse alsamixer
3924 * So call somewhat different..
3925 * FIXME: the controls appear in the "playback" view!
3927 /* .name = "Capture Source", */
3928 .name
= "Input Source",
3930 .info
= alc882_mux_enum_info
,
3931 .get
= alc882_mux_enum_get
,
3932 .put
= alc882_mux_enum_put
,
3937 static struct snd_kcontrol_new alc882_capture_mixer
[] = {
3938 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT
),
3939 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT
),
3940 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT
),
3941 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT
),
3942 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT
),
3943 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT
),
3945 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3946 /* The multiple "Capture Source" controls confuse alsamixer
3947 * So call somewhat different..
3948 * FIXME: the controls appear in the "playback" view!
3950 /* .name = "Capture Source", */
3951 .name
= "Input Source",
3953 .info
= alc882_mux_enum_info
,
3954 .get
= alc882_mux_enum_get
,
3955 .put
= alc882_mux_enum_put
,
3960 /* pcm configuration: identiacal with ALC880 */
3961 #define alc882_pcm_analog_playback alc880_pcm_analog_playback
3962 #define alc882_pcm_analog_capture alc880_pcm_analog_capture
3963 #define alc882_pcm_digital_playback alc880_pcm_digital_playback
3964 #define alc882_pcm_digital_capture alc880_pcm_digital_capture
3967 * configuration and preset
3969 static struct hda_board_config alc882_cfg_tbl
[] = {
3970 { .modelname
= "3stack-dig", .config
= ALC882_3ST_DIG
},
3971 { .modelname
= "6stack-dig", .config
= ALC882_6ST_DIG
},
3972 { .pci_subvendor
= 0x1462, .pci_subdevice
= 0x6668, .config
= ALC882_6ST_DIG
}, /* MSI */
3973 { .pci_subvendor
= 0x105b, .pci_subdevice
= 0x6668, .config
= ALC882_6ST_DIG
}, /* Foxconn */
3974 { .pci_subvendor
= 0x1019, .pci_subdevice
= 0x6668, .config
= ALC882_6ST_DIG
}, /* ECS */
3975 { .modelname
= "auto", .config
= ALC882_AUTO
},
3979 static struct alc_config_preset alc882_presets
[] = {
3980 [ALC882_3ST_DIG
] = {
3981 .mixers
= { alc882_base_mixer
},
3982 .init_verbs
= { alc882_init_verbs
},
3983 .num_dacs
= ARRAY_SIZE(alc882_dac_nids
),
3984 .dac_nids
= alc882_dac_nids
,
3985 .dig_out_nid
= ALC882_DIGOUT_NID
,
3986 .num_adc_nids
= ARRAY_SIZE(alc882_adc_nids
),
3987 .adc_nids
= alc882_adc_nids
,
3988 .dig_in_nid
= ALC882_DIGIN_NID
,
3989 .num_channel_mode
= ARRAY_SIZE(alc882_ch_modes
),
3990 .channel_mode
= alc882_ch_modes
,
3991 .input_mux
= &alc882_capture_source
,
3993 [ALC882_6ST_DIG
] = {
3994 .mixers
= { alc882_base_mixer
, alc882_chmode_mixer
},
3995 .init_verbs
= { alc882_init_verbs
},
3996 .num_dacs
= ARRAY_SIZE(alc882_dac_nids
),
3997 .dac_nids
= alc882_dac_nids
,
3998 .dig_out_nid
= ALC882_DIGOUT_NID
,
3999 .num_adc_nids
= ARRAY_SIZE(alc882_adc_nids
),
4000 .adc_nids
= alc882_adc_nids
,
4001 .dig_in_nid
= ALC882_DIGIN_NID
,
4002 .num_channel_mode
= ARRAY_SIZE(alc882_sixstack_modes
),
4003 .channel_mode
= alc882_sixstack_modes
,
4004 .input_mux
= &alc882_capture_source
,
4010 * BIOS auto configuration
4012 static void alc882_auto_set_output_and_unmute(struct hda_codec
*codec
,
4013 hda_nid_t nid
, int pin_type
,
4017 struct alc_spec
*spec
= codec
->spec
;
4020 if (spec
->multiout
.dac_nids
[dac_idx
] == 0x25)
4023 idx
= spec
->multiout
.dac_nids
[dac_idx
] - 2;
4025 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
, pin_type
);
4026 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
);
4027 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_CONNECT_SEL
, idx
);
4031 static void alc882_auto_init_multi_out(struct hda_codec
*codec
)
4033 struct alc_spec
*spec
= codec
->spec
;
4036 for (i
= 0; i
<= HDA_SIDE
; i
++) {
4037 hda_nid_t nid
= spec
->autocfg
.line_out_pins
[i
];
4039 alc882_auto_set_output_and_unmute(codec
, nid
, PIN_OUT
, i
);
4043 static void alc882_auto_init_hp_out(struct hda_codec
*codec
)
4045 struct alc_spec
*spec
= codec
->spec
;
4048 pin
= spec
->autocfg
.hp_pin
;
4049 if (pin
) /* connect to front */
4050 alc882_auto_set_output_and_unmute(codec
, pin
, PIN_HP
, 0); /* use dac 0 */
4053 #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
4054 #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
4056 static void alc882_auto_init_analog_input(struct hda_codec
*codec
)
4058 struct alc_spec
*spec
= codec
->spec
;
4061 for (i
= 0; i
< AUTO_PIN_LAST
; i
++) {
4062 hda_nid_t nid
= spec
->autocfg
.input_pins
[i
];
4063 if (alc882_is_input_pin(nid
)) {
4064 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
4065 i
<= AUTO_PIN_FRONT_MIC
? PIN_VREF80
: PIN_IN
);
4066 if (nid
!= ALC882_PIN_CD_NID
)
4067 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
4073 /* almost identical with ALC880 parser... */
4074 static int alc882_parse_auto_config(struct hda_codec
*codec
)
4076 struct alc_spec
*spec
= codec
->spec
;
4077 int err
= alc880_parse_auto_config(codec
);
4082 /* hack - override the init verbs */
4083 spec
->init_verbs
[0] = alc882_auto_init_verbs
;
4087 /* init callback for auto-configuration model -- overriding the default init */
4088 static int alc882_auto_init(struct hda_codec
*codec
)
4091 alc882_auto_init_multi_out(codec
);
4092 alc882_auto_init_hp_out(codec
);
4093 alc882_auto_init_analog_input(codec
);
4098 * ALC882 Headphone poll in 3.5.1a or 3.5.2
4101 static int patch_alc882(struct hda_codec
*codec
)
4103 struct alc_spec
*spec
;
4104 int err
, board_config
;
4106 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4112 board_config
= snd_hda_check_board_config(codec
, alc882_cfg_tbl
);
4114 if (board_config
< 0 || board_config
>= ALC882_MODEL_LAST
) {
4115 printk(KERN_INFO
"hda_codec: Unknown model for ALC882, trying auto-probe from BIOS...\n");
4116 board_config
= ALC882_AUTO
;
4119 if (board_config
== ALC882_AUTO
) {
4120 /* automatic parse from the BIOS config */
4121 err
= alc882_parse_auto_config(codec
);
4126 printk(KERN_INFO
"hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
4127 board_config
= ALC882_3ST_DIG
;
4131 if (board_config
!= ALC882_AUTO
)
4132 setup_preset(spec
, &alc882_presets
[board_config
]);
4134 spec
->stream_name_analog
= "ALC882 Analog";
4135 spec
->stream_analog_playback
= &alc882_pcm_analog_playback
;
4136 spec
->stream_analog_capture
= &alc882_pcm_analog_capture
;
4138 spec
->stream_name_digital
= "ALC882 Digital";
4139 spec
->stream_digital_playback
= &alc882_pcm_digital_playback
;
4140 spec
->stream_digital_capture
= &alc882_pcm_digital_capture
;
4142 if (! spec
->adc_nids
&& spec
->input_mux
) {
4143 /* check whether NID 0x07 is valid */
4144 unsigned int wcap
= get_wcaps(codec
, 0x07);
4145 wcap
= (wcap
& AC_WCAP_TYPE
) >> AC_WCAP_TYPE_SHIFT
; /* get type */
4146 if (wcap
!= AC_WID_AUD_IN
) {
4147 spec
->adc_nids
= alc882_adc_nids_alt
;
4148 spec
->num_adc_nids
= ARRAY_SIZE(alc882_adc_nids_alt
);
4149 spec
->mixers
[spec
->num_mixers
] = alc882_capture_alt_mixer
;
4152 spec
->adc_nids
= alc882_adc_nids
;
4153 spec
->num_adc_nids
= ARRAY_SIZE(alc882_adc_nids
);
4154 spec
->mixers
[spec
->num_mixers
] = alc882_capture_mixer
;
4159 codec
->patch_ops
= alc_patch_ops
;
4160 if (board_config
== ALC882_AUTO
)
4161 codec
->patch_ops
.init
= alc882_auto_init
;
4170 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
4171 #define ALC262_DIGIN_NID ALC880_DIGIN_NID
4173 #define alc262_dac_nids alc260_dac_nids
4174 #define alc262_adc_nids alc882_adc_nids
4175 #define alc262_adc_nids_alt alc882_adc_nids_alt
4177 #define alc262_modes alc260_modes
4178 #define alc262_capture_source alc882_capture_source
4180 static struct snd_kcontrol_new alc262_base_mixer
[] = {
4181 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT
),
4182 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT
),
4183 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT
),
4184 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT
),
4185 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT
),
4186 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT
),
4187 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT
),
4188 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT
),
4189 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT
),
4190 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT
),
4191 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
4192 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
4193 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT
),
4194 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT
),
4195 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT
),
4196 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT
),
4197 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT
),
4198 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT
),
4200 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4201 .name
= "Capture Source",
4203 .info
= alc882_mux_enum_info
,
4204 .get
= alc882_mux_enum_get
,
4205 .put
= alc882_mux_enum_put
,
4210 #define alc262_capture_mixer alc882_capture_mixer
4211 #define alc262_capture_alt_mixer alc882_capture_alt_mixer
4214 * generic initialization of ADC, input mixers and output mixers
4216 static struct hda_verb alc262_init_verbs
[] = {
4218 * Unmute ADC0-2 and set the default input to mic-in
4220 {0x07, AC_VERB_SET_CONNECT_SEL
, 0x00},
4221 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4222 {0x08, AC_VERB_SET_CONNECT_SEL
, 0x00},
4223 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4224 {0x09, AC_VERB_SET_CONNECT_SEL
, 0x00},
4225 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4227 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4229 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4232 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4233 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4234 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4235 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2)},
4236 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(3)},
4237 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(4)},
4240 * Set up output mixers (0x0c - 0x0e)
4242 /* set vol=0 to output mixers */
4243 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
4244 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
4245 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
4246 /* set up input amps for analog loopback */
4247 /* Amp Indices: DAC = 0, mixer = 1 */
4248 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4249 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4250 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4251 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4252 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4253 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4255 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40},
4256 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0xc0},
4257 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40},
4258 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24},
4259 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20},
4260 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20},
4262 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0x0000},
4263 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, 0x0000},
4264 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, 0x0000},
4265 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, 0x0000},
4266 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, 0x0000},
4268 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x00},
4269 {0x15, AC_VERB_SET_CONNECT_SEL
, 0x01},
4271 /* FIXME: use matrix-type input source selection */
4272 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4273 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4274 {0x24, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7000 | (0x00 << 8))},
4275 {0x24, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7080 | (0x03 << 8))},
4276 {0x24, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7080 | (0x02 << 8))},
4277 {0x24, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7080 | (0x04 << 8))},
4279 {0x23, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7000 | (0x00 << 8))},
4280 {0x23, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7080 | (0x03 << 8))},
4281 {0x23, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7080 | (0x02 << 8))},
4282 {0x23, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7080 | (0x04 << 8))},
4284 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7000 | (0x00 << 8))},
4285 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7080 | (0x03 << 8))},
4286 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7080 | (0x02 << 8))},
4287 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7080 | (0x04 << 8))},
4292 /* add playback controls from the parsed DAC table */
4293 static int alc262_auto_create_multi_out_ctls(struct alc_spec
*spec
, const struct auto_pin_cfg
*cfg
)
4298 spec
->multiout
.num_dacs
= 1; /* only use one dac */
4299 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
4300 spec
->multiout
.dac_nids
[0] = 2;
4302 nid
= cfg
->line_out_pins
[0];
4304 if ((err
= add_control(spec
, ALC_CTL_WIDGET_VOL
, "Front Playback Volume",
4305 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT
))) < 0)
4307 if ((err
= add_control(spec
, ALC_CTL_WIDGET_MUTE
, "Front Playback Switch",
4308 HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
))) < 0)
4312 nid
= cfg
->speaker_pin
;
4315 if ((err
= add_control(spec
, ALC_CTL_WIDGET_VOL
, "Speaker Playback Volume",
4316 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT
))) < 0)
4318 if ((err
= add_control(spec
, ALC_CTL_WIDGET_MUTE
, "Speaker Playback Switch",
4319 HDA_COMPOSE_AMP_VAL(nid
, 2, 0, HDA_OUTPUT
))) < 0)
4322 if (! cfg
->line_out_pins
[0])
4323 if ((err
= add_control(spec
, ALC_CTL_WIDGET_VOL
, "Speaker Playback Volume",
4324 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT
))) < 0)
4326 if ((err
= add_control(spec
, ALC_CTL_WIDGET_MUTE
, "Speaker Playback Switch",
4327 HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
))) < 0)
4333 /* spec->multiout.hp_nid = 2; */
4335 if ((err
= add_control(spec
, ALC_CTL_WIDGET_VOL
, "Headphone Playback Volume",
4336 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT
))) < 0)
4338 if ((err
= add_control(spec
, ALC_CTL_WIDGET_MUTE
, "Headphone Playback Switch",
4339 HDA_COMPOSE_AMP_VAL(nid
, 2, 0, HDA_OUTPUT
))) < 0)
4342 if (! cfg
->line_out_pins
[0])
4343 if ((err
= add_control(spec
, ALC_CTL_WIDGET_VOL
, "Headphone Playback Volume",
4344 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT
))) < 0)
4346 if ((err
= add_control(spec
, ALC_CTL_WIDGET_MUTE
, "Headphone Playback Switch",
4347 HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
))) < 0)
4354 /* identical with ALC880 */
4355 #define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
4358 * generic initialization of ADC, input mixers and output mixers
4360 static struct hda_verb alc262_volume_init_verbs
[] = {
4362 * Unmute ADC0-2 and set the default input to mic-in
4364 {0x07, AC_VERB_SET_CONNECT_SEL
, 0x00},
4365 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4366 {0x08, AC_VERB_SET_CONNECT_SEL
, 0x00},
4367 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4368 {0x09, AC_VERB_SET_CONNECT_SEL
, 0x00},
4369 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4371 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4373 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4376 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4377 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4378 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4379 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2)},
4380 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(3)},
4381 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(4)},
4384 * Set up output mixers (0x0c - 0x0f)
4386 /* set vol=0 to output mixers */
4387 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
4388 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
4389 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
4391 /* set up input amps for analog loopback */
4392 /* Amp Indices: DAC = 0, mixer = 1 */
4393 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4394 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4395 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4396 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4397 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4398 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4400 /* FIXME: use matrix-type input source selection */
4401 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4402 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4403 {0x24, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7000 | (0x00 << 8))},
4404 {0x24, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7080 | (0x03 << 8))},
4405 {0x24, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7080 | (0x02 << 8))},
4406 {0x24, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7080 | (0x04 << 8))},
4408 {0x23, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7000 | (0x00 << 8))},
4409 {0x23, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7080 | (0x03 << 8))},
4410 {0x23, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7080 | (0x02 << 8))},
4411 {0x23, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7080 | (0x04 << 8))},
4413 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7000 | (0x00 << 8))},
4414 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7080 | (0x03 << 8))},
4415 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7080 | (0x02 << 8))},
4416 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7080 | (0x04 << 8))},
4421 /* pcm configuration: identiacal with ALC880 */
4422 #define alc262_pcm_analog_playback alc880_pcm_analog_playback
4423 #define alc262_pcm_analog_capture alc880_pcm_analog_capture
4424 #define alc262_pcm_digital_playback alc880_pcm_digital_playback
4425 #define alc262_pcm_digital_capture alc880_pcm_digital_capture
4428 * BIOS auto configuration
4430 static int alc262_parse_auto_config(struct hda_codec
*codec
)
4432 struct alc_spec
*spec
= codec
->spec
;
4434 static hda_nid_t alc262_ignore
[] = { 0x1d, 0 };
4436 if ((err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
,
4437 alc262_ignore
)) < 0)
4439 if (! spec
->autocfg
.line_outs
&& ! spec
->autocfg
.speaker_pin
&&
4440 ! spec
->autocfg
.hp_pin
)
4441 return 0; /* can't find valid BIOS pin config */
4442 if ((err
= alc262_auto_create_multi_out_ctls(spec
, &spec
->autocfg
)) < 0 ||
4443 (err
= alc262_auto_create_analog_input_ctls(spec
, &spec
->autocfg
)) < 0)
4446 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
4448 if (spec
->autocfg
.dig_out_pin
)
4449 spec
->multiout
.dig_out_nid
= ALC262_DIGOUT_NID
;
4450 if (spec
->autocfg
.dig_in_pin
)
4451 spec
->dig_in_nid
= ALC262_DIGIN_NID
;
4453 if (spec
->kctl_alloc
)
4454 spec
->mixers
[spec
->num_mixers
++] = spec
->kctl_alloc
;
4456 spec
->init_verbs
[spec
->num_init_verbs
++] = alc262_volume_init_verbs
;
4457 spec
->input_mux
= &spec
->private_imux
;
4462 #define alc262_auto_init_multi_out alc882_auto_init_multi_out
4463 #define alc262_auto_init_hp_out alc882_auto_init_hp_out
4464 #define alc262_auto_init_analog_input alc882_auto_init_analog_input
4467 /* init callback for auto-configuration model -- overriding the default init */
4468 static int alc262_auto_init(struct hda_codec
*codec
)
4471 alc262_auto_init_multi_out(codec
);
4472 alc262_auto_init_hp_out(codec
);
4473 alc262_auto_init_analog_input(codec
);
4478 * configuration and preset
4480 static struct hda_board_config alc262_cfg_tbl
[] = {
4481 { .modelname
= "basic", .config
= ALC262_BASIC
},
4482 { .modelname
= "auto", .config
= ALC262_AUTO
},
4486 static struct alc_config_preset alc262_presets
[] = {
4488 .mixers
= { alc262_base_mixer
},
4489 .init_verbs
= { alc262_init_verbs
},
4490 .num_dacs
= ARRAY_SIZE(alc262_dac_nids
),
4491 .dac_nids
= alc262_dac_nids
,
4493 .num_channel_mode
= ARRAY_SIZE(alc262_modes
),
4494 .channel_mode
= alc262_modes
,
4495 .input_mux
= &alc262_capture_source
,
4499 static int patch_alc262(struct hda_codec
*codec
)
4501 struct alc_spec
*spec
;
4505 spec
= kcalloc(1, sizeof(*spec
), GFP_KERNEL
);
4511 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
4514 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_COEF_INDEX
, 7);
4515 tmp
= snd_hda_codec_read(codec
, 0x20, 0, AC_VERB_GET_PROC_COEF
, 0);
4516 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_COEF_INDEX
, 7);
4517 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PROC_COEF
, tmp
| 0x80);
4521 board_config
= snd_hda_check_board_config(codec
, alc262_cfg_tbl
);
4522 if (board_config
< 0 || board_config
>= ALC262_MODEL_LAST
) {
4523 printk(KERN_INFO
"hda_codec: Unknown model for ALC262, trying auto-probe from BIOS...\n");
4524 board_config
= ALC262_AUTO
;
4527 if (board_config
== ALC262_AUTO
) {
4528 /* automatic parse from the BIOS config */
4529 err
= alc262_parse_auto_config(codec
);
4534 printk(KERN_INFO
"hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
4535 board_config
= ALC262_BASIC
;
4539 if (board_config
!= ALC262_AUTO
)
4540 setup_preset(spec
, &alc262_presets
[board_config
]);
4542 spec
->stream_name_analog
= "ALC262 Analog";
4543 spec
->stream_analog_playback
= &alc262_pcm_analog_playback
;
4544 spec
->stream_analog_capture
= &alc262_pcm_analog_capture
;
4546 spec
->stream_name_digital
= "ALC262 Digital";
4547 spec
->stream_digital_playback
= &alc262_pcm_digital_playback
;
4548 spec
->stream_digital_capture
= &alc262_pcm_digital_capture
;
4550 if (! spec
->adc_nids
&& spec
->input_mux
) {
4551 /* check whether NID 0x07 is valid */
4552 unsigned int wcap
= get_wcaps(codec
, 0x07);
4554 wcap
= (wcap
& AC_WCAP_TYPE
) >> AC_WCAP_TYPE_SHIFT
; /* get type */
4555 if (wcap
!= AC_WID_AUD_IN
) {
4556 spec
->adc_nids
= alc262_adc_nids_alt
;
4557 spec
->num_adc_nids
= ARRAY_SIZE(alc262_adc_nids_alt
);
4558 spec
->mixers
[spec
->num_mixers
] = alc262_capture_alt_mixer
;
4561 spec
->adc_nids
= alc262_adc_nids
;
4562 spec
->num_adc_nids
= ARRAY_SIZE(alc262_adc_nids
);
4563 spec
->mixers
[spec
->num_mixers
] = alc262_capture_mixer
;
4568 codec
->patch_ops
= alc_patch_ops
;
4569 if (board_config
== ALC262_AUTO
)
4570 codec
->patch_ops
.init
= alc262_auto_init
;
4577 * ALC861 channel source setting (2/6 channel selection for 3-stack)
4581 * set the path ways for 2 channel output
4582 * need to set the codec line out and mic 1 pin widgets to inputs
4584 static struct hda_verb alc861_threestack_ch2_init
[] = {
4585 /* set pin widget 1Ah (line in) for input */
4586 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
4587 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
4588 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24 },
4590 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb00c },
4591 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7000 | (0x01 << 8)) }, //mic
4592 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7000 | (0x02 << 8)) }, //line in
4597 * need to set the codec line out and mic 1 pin widgets to outputs
4599 static struct hda_verb alc861_threestack_ch6_init
[] = {
4600 /* set pin widget 1Ah (line in) for output (Back Surround)*/
4601 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
4602 /* set pin widget 18h (mic1) for output (CLFE)*/
4603 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
4605 { 0x0c, AC_VERB_SET_CONNECT_SEL
, 0x00 },
4606 { 0x0d, AC_VERB_SET_CONNECT_SEL
, 0x00 },
4608 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080 },
4609 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7080 | (0x01 << 8)) }, //mic
4610 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE
, (0x7080 | (0x02 << 8)) }, //line in
4614 static struct hda_channel_mode alc861_threestack_modes
[2] = {
4615 { 2, alc861_threestack_ch2_init
},
4616 { 6, alc861_threestack_ch6_init
},
4621 static struct snd_kcontrol_new alc861_base_mixer
[] = {
4622 /* output mixer control */
4623 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT
),
4624 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT
),
4625 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT
),
4626 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT
),
4627 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT
),
4629 /*Input mixer control */
4630 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
4631 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
4632 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT
),
4633 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT
),
4634 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT
),
4635 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT
),
4636 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT
),
4637 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT
),
4638 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT
),
4639 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT
),
4641 /* Capture mixer control */
4642 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT
),
4643 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT
),
4645 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4646 .name
= "Capture Source",
4648 .info
= alc_mux_enum_info
,
4649 .get
= alc_mux_enum_get
,
4650 .put
= alc_mux_enum_put
,
4655 static struct snd_kcontrol_new alc861_3ST_mixer
[] = {
4656 /* output mixer control */
4657 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT
),
4658 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT
),
4659 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT
),
4660 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT
),
4661 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
4663 /* Input mixer control */
4664 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
4665 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
4666 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT
),
4667 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT
),
4668 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT
),
4669 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT
),
4670 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT
),
4671 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT
),
4672 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT
),
4673 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT
),
4675 /* Capture mixer control */
4676 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT
),
4677 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT
),
4679 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4680 .name
= "Capture Source",
4682 .info
= alc_mux_enum_info
,
4683 .get
= alc_mux_enum_get
,
4684 .put
= alc_mux_enum_put
,
4687 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4688 .name
= "Channel Mode",
4689 .info
= alc_ch_mode_info
,
4690 .get
= alc_ch_mode_get
,
4691 .put
= alc_ch_mode_put
,
4692 .private_value
= ARRAY_SIZE(alc861_threestack_modes
),
4698 * generic initialization of ADC, input mixers and output mixers
4700 static struct hda_verb alc861_base_init_verbs
[] = {
4702 * Unmute ADC0 and set the default input to mic-in
4704 /* port-A for surround (rear panel) */
4705 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
4706 { 0x0e, AC_VERB_SET_CONNECT_SEL
, 0x00 },
4707 /* port-B for mic-in (rear panel) with vref */
4708 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24 },
4709 /* port-C for line-in (rear panel) */
4710 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
4711 /* port-D for Front */
4712 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
4713 { 0x0b, AC_VERB_SET_CONNECT_SEL
, 0x00 },
4714 /* port-E for HP out (front panel) */
4715 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0xc0 },
4716 /* route front PCM to HP */
4717 { 0x0f, AC_VERB_SET_CONNECT_SEL
, 0x01 },
4718 /* port-F for mic-in (front panel) with vref */
4719 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24 },
4720 /* port-G for CLFE (rear panel) */
4721 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
4722 { 0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00 },
4723 /* port-H for side (rear panel) */
4724 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
4725 { 0x20, AC_VERB_SET_CONNECT_SEL
, 0x00 },
4727 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
4728 /* route front mic to ADC1*/
4729 {0x08, AC_VERB_SET_CONNECT_SEL
, 0x00},
4730 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4732 /* Unmute DAC0~3 & spdif out*/
4733 {0x03, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
4734 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
4735 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
4736 {0x06, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
4737 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
4739 /* Unmute Mixer 14 (mic) 1c (Line in)*/
4740 {0x014, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4741 {0x014, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4742 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4743 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4745 /* Unmute Stereo Mixer 15 */
4746 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4747 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4748 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2)},
4749 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb00c }, //Output 0~12 step
4751 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4752 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4753 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4754 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4755 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4756 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4757 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4758 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4759 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
4760 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2)},
4765 static struct hda_verb alc861_threestack_init_verbs
[] = {
4767 * Unmute ADC0 and set the default input to mic-in
4769 /* port-A for surround (rear panel) */
4770 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x00 },
4771 /* port-B for mic-in (rear panel) with vref */
4772 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24 },
4773 /* port-C for line-in (rear panel) */
4774 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
4775 /* port-D for Front */
4776 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
4777 { 0x0b, AC_VERB_SET_CONNECT_SEL
, 0x00 },
4778 /* port-E for HP out (front panel) */
4779 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0xc0 },
4780 /* route front PCM to HP */
4781 { 0x0f, AC_VERB_SET_CONNECT_SEL
, 0x01 },
4782 /* port-F for mic-in (front panel) with vref */
4783 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24 },
4784 /* port-G for CLFE (rear panel) */
4785 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x00 },
4786 /* port-H for side (rear panel) */
4787 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x00 },
4789 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
4790 /* route front mic to ADC1*/
4791 {0x08, AC_VERB_SET_CONNECT_SEL
, 0x00},
4792 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4793 /* Unmute DAC0~3 & spdif out*/
4794 {0x03, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
4795 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
4796 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
4797 {0x06, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
4798 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
4800 /* Unmute Mixer 14 (mic) 1c (Line in)*/
4801 {0x014, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4802 {0x014, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4803 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4804 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4806 /* Unmute Stereo Mixer 15 */
4807 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4808 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4809 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2)},
4810 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb00c }, //Output 0~12 step
4812 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4813 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4814 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4815 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4816 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4817 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4818 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4819 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4820 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
4821 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2)},
4825 * generic initialization of ADC, input mixers and output mixers
4827 static struct hda_verb alc861_auto_init_verbs
[] = {
4829 * Unmute ADC0 and set the default input to mic-in
4831 // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4832 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4834 /* Unmute DAC0~3 & spdif out*/
4835 {0x03, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4836 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4837 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4838 {0x06, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4839 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
4841 /* Unmute Mixer 14 (mic) 1c (Line in)*/
4842 {0x014, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4843 {0x014, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4844 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4845 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4847 /* Unmute Stereo Mixer 15 */
4848 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4849 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4850 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2)},
4851 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb00c},
4853 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4854 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4855 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4856 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4857 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4858 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4859 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4860 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4862 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4863 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4864 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2)},
4865 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(3)},
4866 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4867 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4868 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2)},
4869 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(3)},
4871 {0x08, AC_VERB_SET_CONNECT_SEL
, 0x00}, // set Mic 1
4876 /* pcm configuration: identiacal with ALC880 */
4877 #define alc861_pcm_analog_playback alc880_pcm_analog_playback
4878 #define alc861_pcm_analog_capture alc880_pcm_analog_capture
4879 #define alc861_pcm_digital_playback alc880_pcm_digital_playback
4880 #define alc861_pcm_digital_capture alc880_pcm_digital_capture
4883 #define ALC861_DIGOUT_NID 0x07
4885 static struct hda_channel_mode alc861_8ch_modes
[1] = {
4889 static hda_nid_t alc861_dac_nids
[4] = {
4890 /* front, surround, clfe, side */
4891 0x03, 0x06, 0x05, 0x04
4894 static hda_nid_t alc861_adc_nids
[1] = {
4899 static struct hda_input_mux alc861_capture_source
= {
4903 { "Front Mic", 0x3 },
4910 /* fill in the dac_nids table from the parsed pin configuration */
4911 static int alc861_auto_fill_dac_nids(struct alc_spec
*spec
, const struct auto_pin_cfg
*cfg
)
4916 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
4917 for (i
= 0; i
< cfg
->line_outs
; i
++) {
4918 nid
= cfg
->line_out_pins
[i
];
4920 if (i
>= ARRAY_SIZE(alc861_dac_nids
))
4922 spec
->multiout
.dac_nids
[i
] = alc861_dac_nids
[i
];
4925 spec
->multiout
.num_dacs
= cfg
->line_outs
;
4929 /* add playback controls from the parsed DAC table */
4930 static int alc861_auto_create_multi_out_ctls(struct alc_spec
*spec
,
4931 const struct auto_pin_cfg
*cfg
)
4934 static const char *chname
[4] = { "Front", "Surround", NULL
/*CLFE*/, "Side" };
4938 for (i
= 0; i
< cfg
->line_outs
; i
++) {
4939 nid
= spec
->multiout
.dac_nids
[i
];
4944 if ((err
= add_control(spec
, ALC_CTL_BIND_MUTE
, "Center Playback Switch",
4945 HDA_COMPOSE_AMP_VAL(nid
, 1, 0, HDA_OUTPUT
))) < 0)
4947 if ((err
= add_control(spec
, ALC_CTL_BIND_MUTE
, "LFE Playback Switch",
4948 HDA_COMPOSE_AMP_VAL(nid
, 2, 0, HDA_OUTPUT
))) < 0)
4951 for (idx
= 0; idx
< ARRAY_SIZE(alc861_dac_nids
) - 1; idx
++)
4952 if (nid
== alc861_dac_nids
[idx
])
4954 sprintf(name
, "%s Playback Switch", chname
[idx
]);
4955 if ((err
= add_control(spec
, ALC_CTL_BIND_MUTE
, name
,
4956 HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
))) < 0)
4963 static int alc861_auto_create_hp_ctls(struct alc_spec
*spec
, hda_nid_t pin
)
4971 if ((pin
>= 0x0b && pin
<= 0x10) || pin
== 0x1f || pin
== 0x20) {
4973 if ((err
= add_control(spec
, ALC_CTL_WIDGET_MUTE
, "Headphone Playback Switch",
4974 HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
))) < 0)
4976 spec
->multiout
.hp_nid
= nid
;
4981 /* create playback/capture controls for input pins */
4982 static int alc861_auto_create_analog_input_ctls(struct alc_spec
*spec
, const struct auto_pin_cfg
*cfg
)
4984 struct hda_input_mux
*imux
= &spec
->private_imux
;
4985 int i
, err
, idx
, idx1
;
4987 for (i
= 0; i
< AUTO_PIN_LAST
; i
++) {
4988 switch(cfg
->input_pins
[i
]) {
5013 err
= new_analog_input(spec
, cfg
->input_pins
[i
],
5014 auto_pin_cfg_labels
[i
], idx
, 0x15);
5018 imux
->items
[imux
->num_items
].label
= auto_pin_cfg_labels
[i
];
5019 imux
->items
[imux
->num_items
].index
= idx1
;
5025 static struct snd_kcontrol_new alc861_capture_mixer
[] = {
5026 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT
),
5027 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT
),
5030 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
5031 /* The multiple "Capture Source" controls confuse alsamixer
5032 * So call somewhat different..
5033 *FIXME: the controls appear in the "playback" view!
5035 /* .name = "Capture Source", */
5036 .name
= "Input Source",
5038 .info
= alc_mux_enum_info
,
5039 .get
= alc_mux_enum_get
,
5040 .put
= alc_mux_enum_put
,
5045 static void alc861_auto_set_output_and_unmute(struct hda_codec
*codec
, hda_nid_t nid
,
5046 int pin_type
, int dac_idx
)
5050 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
, pin_type
);
5051 snd_hda_codec_write(codec
, dac_idx
, 0, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
);
5055 static void alc861_auto_init_multi_out(struct hda_codec
*codec
)
5057 struct alc_spec
*spec
= codec
->spec
;
5060 for (i
= 0; i
< spec
->autocfg
.line_outs
; i
++) {
5061 hda_nid_t nid
= spec
->autocfg
.line_out_pins
[i
];
5063 alc861_auto_set_output_and_unmute(codec
, nid
, PIN_OUT
, spec
->multiout
.dac_nids
[i
]);
5067 static void alc861_auto_init_hp_out(struct hda_codec
*codec
)
5069 struct alc_spec
*spec
= codec
->spec
;
5072 pin
= spec
->autocfg
.hp_pin
;
5073 if (pin
) /* connect to front */
5074 alc861_auto_set_output_and_unmute(codec
, pin
, PIN_HP
, spec
->multiout
.dac_nids
[0]);
5077 static void alc861_auto_init_analog_input(struct hda_codec
*codec
)
5079 struct alc_spec
*spec
= codec
->spec
;
5082 for (i
= 0; i
< AUTO_PIN_LAST
; i
++) {
5083 hda_nid_t nid
= spec
->autocfg
.input_pins
[i
];
5084 if ((nid
>=0x0c) && (nid
<=0x11)) {
5085 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
5086 i
<= AUTO_PIN_FRONT_MIC
? PIN_VREF80
: PIN_IN
);
5091 /* parse the BIOS configuration and set up the alc_spec */
5092 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
5093 static int alc861_parse_auto_config(struct hda_codec
*codec
)
5095 struct alc_spec
*spec
= codec
->spec
;
5097 static hda_nid_t alc861_ignore
[] = { 0x1d, 0 };
5099 if ((err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
,
5100 alc861_ignore
)) < 0)
5102 if (! spec
->autocfg
.line_outs
&& ! spec
->autocfg
.speaker_pin
&&
5103 ! spec
->autocfg
.hp_pin
)
5104 return 0; /* can't find valid BIOS pin config */
5106 if ((err
= alc861_auto_fill_dac_nids(spec
, &spec
->autocfg
)) < 0 ||
5107 (err
= alc861_auto_create_multi_out_ctls(spec
, &spec
->autocfg
)) < 0 ||
5108 (err
= alc861_auto_create_hp_ctls(spec
, spec
->autocfg
.hp_pin
)) < 0 ||
5109 (err
= alc861_auto_create_analog_input_ctls(spec
, &spec
->autocfg
)) < 0)
5112 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
5114 if (spec
->autocfg
.dig_out_pin
)
5115 spec
->multiout
.dig_out_nid
= ALC861_DIGOUT_NID
;
5117 if (spec
->kctl_alloc
)
5118 spec
->mixers
[spec
->num_mixers
++] = spec
->kctl_alloc
;
5120 spec
->init_verbs
[spec
->num_init_verbs
++] = alc861_auto_init_verbs
;
5122 spec
->input_mux
= &spec
->private_imux
;
5124 spec
->adc_nids
= alc861_adc_nids
;
5125 spec
->num_adc_nids
= ARRAY_SIZE(alc861_adc_nids
);
5126 spec
->mixers
[spec
->num_mixers
] = alc861_capture_mixer
;
5132 /* init callback for auto-configuration model -- overriding the default init */
5133 static int alc861_auto_init(struct hda_codec
*codec
)
5136 alc861_auto_init_multi_out(codec
);
5137 alc861_auto_init_hp_out(codec
);
5138 alc861_auto_init_analog_input(codec
);
5145 * configuration and preset
5147 static struct hda_board_config alc861_cfg_tbl
[] = {
5148 { .modelname
= "3stack", .config
= ALC861_3ST
},
5149 { .pci_subvendor
= 0x8086, .pci_subdevice
= 0xd600, .config
= ALC861_3ST
},
5150 { .modelname
= "3stack-dig", .config
= ALC861_3ST_DIG
},
5151 { .modelname
= "6stack-dig", .config
= ALC861_6ST_DIG
},
5152 { .modelname
= "auto", .config
= ALC861_AUTO
},
5156 static struct alc_config_preset alc861_presets
[] = {
5158 .mixers
= { alc861_3ST_mixer
},
5159 .init_verbs
= { alc861_threestack_init_verbs
},
5160 .num_dacs
= ARRAY_SIZE(alc861_dac_nids
),
5161 .dac_nids
= alc861_dac_nids
,
5162 .num_channel_mode
= ARRAY_SIZE(alc861_threestack_modes
),
5163 .channel_mode
= alc861_threestack_modes
,
5164 .num_adc_nids
= ARRAY_SIZE(alc861_adc_nids
),
5165 .adc_nids
= alc861_adc_nids
,
5166 .input_mux
= &alc861_capture_source
,
5168 [ALC861_3ST_DIG
] = {
5169 .mixers
= { alc861_base_mixer
},
5170 .init_verbs
= { alc861_threestack_init_verbs
},
5171 .num_dacs
= ARRAY_SIZE(alc861_dac_nids
),
5172 .dac_nids
= alc861_dac_nids
,
5173 .dig_out_nid
= ALC861_DIGOUT_NID
,
5174 .num_channel_mode
= ARRAY_SIZE(alc861_threestack_modes
),
5175 .channel_mode
= alc861_threestack_modes
,
5176 .num_adc_nids
= ARRAY_SIZE(alc861_adc_nids
),
5177 .adc_nids
= alc861_adc_nids
,
5178 .input_mux
= &alc861_capture_source
,
5180 [ALC861_6ST_DIG
] = {
5181 .mixers
= { alc861_base_mixer
},
5182 .init_verbs
= { alc861_base_init_verbs
},
5183 .num_dacs
= ARRAY_SIZE(alc861_dac_nids
),
5184 .dac_nids
= alc861_dac_nids
,
5185 .dig_out_nid
= ALC861_DIGOUT_NID
,
5186 .num_channel_mode
= ARRAY_SIZE(alc861_8ch_modes
),
5187 .channel_mode
= alc861_8ch_modes
,
5188 .num_adc_nids
= ARRAY_SIZE(alc861_adc_nids
),
5189 .adc_nids
= alc861_adc_nids
,
5190 .input_mux
= &alc861_capture_source
,
5195 static int patch_alc861(struct hda_codec
*codec
)
5197 struct alc_spec
*spec
;
5201 spec
= kcalloc(1, sizeof(*spec
), GFP_KERNEL
);
5207 board_config
= snd_hda_check_board_config(codec
, alc861_cfg_tbl
);
5208 if (board_config
< 0 || board_config
>= ALC861_MODEL_LAST
) {
5209 printk(KERN_INFO
"hda_codec: Unknown model for ALC861, trying auto-probe from BIOS...\n");
5210 board_config
= ALC861_AUTO
;
5213 if (board_config
== ALC861_AUTO
) {
5214 /* automatic parse from the BIOS config */
5215 err
= alc861_parse_auto_config(codec
);
5220 printk(KERN_INFO
"hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
5221 board_config
= ALC861_3ST_DIG
;
5225 if (board_config
!= ALC861_AUTO
)
5226 setup_preset(spec
, &alc861_presets
[board_config
]);
5228 spec
->stream_name_analog
= "ALC861 Analog";
5229 spec
->stream_analog_playback
= &alc861_pcm_analog_playback
;
5230 spec
->stream_analog_capture
= &alc861_pcm_analog_capture
;
5232 spec
->stream_name_digital
= "ALC861 Digital";
5233 spec
->stream_digital_playback
= &alc861_pcm_digital_playback
;
5234 spec
->stream_digital_capture
= &alc861_pcm_digital_capture
;
5236 codec
->patch_ops
= alc_patch_ops
;
5237 if (board_config
== ALC861_AUTO
)
5238 codec
->patch_ops
.init
= alc861_auto_init
;
5246 struct hda_codec_preset snd_hda_preset_realtek
[] = {
5247 { .id
= 0x10ec0260, .name
= "ALC260", .patch
= patch_alc260
},
5248 { .id
= 0x10ec0262, .name
= "ALC262", .patch
= patch_alc262
},
5249 { .id
= 0x10ec0880, .name
= "ALC880", .patch
= patch_alc880
},
5250 { .id
= 0x10ec0882, .name
= "ALC882", .patch
= patch_alc882
},
5251 { .id
= 0x10ec0883, .name
= "ALC883", .patch
= patch_alc882
},
5252 { .id
= 0x10ec0885, .name
= "ALC885", .patch
= patch_alc882
},
5253 { .id
= 0x10ec0861, .name
= "ALC861", .patch
= patch_alc861
},