2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for VIA VT17xx/VT18xx/VT20xx codec
6 * (C) 2006-2009 VIA Technology, Inc.
7 * (C) 2006-2008 Takashi Iwai <tiwai@suse.de>
9 * This driver is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This driver is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 /* * * * * * * * * * * * * * Release History * * * * * * * * * * * * * * * * */
26 /* 2006-03-03 Lydia Wang Create the basic patch to support VT1708 codec */
27 /* 2006-03-14 Lydia Wang Modify hard code for some pin widget nid */
28 /* 2006-08-02 Lydia Wang Add support to VT1709 codec */
29 /* 2006-09-08 Lydia Wang Fix internal loopback recording source select bug */
30 /* 2007-09-12 Lydia Wang Add EAPD enable during driver initialization */
31 /* 2007-09-17 Lydia Wang Add VT1708B codec support */
32 /* 2007-11-14 Lydia Wang Add VT1708A codec HP and CD pin connect config */
33 /* 2008-02-03 Lydia Wang Fix Rear channels and Back channels inverse issue */
34 /* 2008-03-06 Lydia Wang Add VT1702 codec and VT1708S codec support */
35 /* 2008-04-09 Lydia Wang Add mute front speaker when HP plugin */
36 /* 2008-04-09 Lydia Wang Add Independent HP feature */
37 /* 2008-05-28 Lydia Wang Add second S/PDIF Out support for VT1702 */
38 /* 2008-09-15 Logan Li Add VT1708S Mic Boost workaround/backdoor */
39 /* 2009-02-16 Logan Li Add support for VT1718S */
40 /* 2009-03-13 Logan Li Add support for VT1716S */
41 /* 2009-04-14 Lydai Wang Add support for VT1828S and VT2020 */
42 /* 2009-07-08 Lydia Wang Add support for VT2002P */
43 /* 2009-07-21 Lydia Wang Add support for VT1812 */
44 /* 2009-09-19 Lydia Wang Add support for VT1818S */
46 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
49 #include <linux/init.h>
50 #include <linux/delay.h>
51 #include <linux/slab.h>
52 #include <sound/core.h>
53 #include <sound/asoundef.h>
54 #include "hda_codec.h"
55 #include "hda_local.h"
57 #define NID_MAPPING (-1)
60 #define AMP_VAL_IDX_SHIFT 19
61 #define AMP_VAL_IDX_MASK (0x0f<<19)
64 #define VT1708_HP_NID 0x13
65 #define VT1708_DIGOUT_NID 0x14
66 #define VT1708_DIGIN_NID 0x16
67 #define VT1708_DIGIN_PIN 0x26
68 #define VT1708_HP_PIN_NID 0x20
69 #define VT1708_CD_PIN_NID 0x24
71 #define VT1709_HP_DAC_NID 0x28
72 #define VT1709_DIGOUT_NID 0x13
73 #define VT1709_DIGIN_NID 0x17
74 #define VT1709_DIGIN_PIN 0x25
76 #define VT1708B_HP_NID 0x25
77 #define VT1708B_DIGOUT_NID 0x12
78 #define VT1708B_DIGIN_NID 0x15
79 #define VT1708B_DIGIN_PIN 0x21
81 #define VT1708S_HP_NID 0x25
82 #define VT1708S_DIGOUT_NID 0x12
84 #define VT1702_HP_NID 0x17
85 #define VT1702_DIGOUT_NID 0x11
105 #define VT2002P_COMPATIBLE(spec) \
106 ((spec)->codec_type == VT2002P ||\
107 (spec)->codec_type == VT1812 ||\
108 (spec)->codec_type == VT1802)
111 /* codec parameterization */
112 const struct snd_kcontrol_new
*mixers
[6];
113 unsigned int num_mixers
;
115 const struct hda_verb
*init_verbs
[5];
116 unsigned int num_iverbs
;
118 char *stream_name_analog
;
119 const struct hda_pcm_stream
*stream_analog_playback
;
120 const struct hda_pcm_stream
*stream_analog_capture
;
122 char *stream_name_digital
;
123 const struct hda_pcm_stream
*stream_digital_playback
;
124 const struct hda_pcm_stream
*stream_digital_capture
;
127 struct hda_multi_out multiout
;
128 hda_nid_t slave_dig_outs
[2];
131 unsigned int num_adc_nids
;
132 const hda_nid_t
*adc_nids
;
133 hda_nid_t mux_nids
[3];
134 hda_nid_t dig_in_nid
;
135 hda_nid_t dig_in_pin
;
138 const struct hda_input_mux
*input_mux
;
139 unsigned int cur_mux
[3];
141 /* PCM information */
142 struct hda_pcm pcm_rec
[3];
144 /* dynamic controls, init_verbs and input_mux */
145 struct auto_pin_cfg autocfg
;
146 struct snd_array kctls
;
147 struct hda_input_mux private_imux
[2];
148 hda_nid_t private_dac_nids
[AUTO_CFG_MAX_OUTS
];
151 const struct hda_input_mux
*hp_mux
;
152 unsigned int hp_independent_mode
;
153 unsigned int hp_independent_mode_index
;
154 unsigned int smart51_enabled
;
155 unsigned int dmic_enabled
;
156 enum VIA_HDA_CODEC codec_type
;
158 /* work to check hp jack state */
159 struct hda_codec
*codec
;
160 struct delayed_work vt1708_hp_work
;
161 int vt1708_jack_detectect
;
162 int vt1708_hp_present
;
164 void (*set_widgets_power_state
)(struct hda_codec
*codec
);
166 #ifdef CONFIG_SND_HDA_POWER_SAVE
167 struct hda_loopback_check loopback
;
171 static enum VIA_HDA_CODEC
get_codec_type(struct hda_codec
*codec
);
172 static struct via_spec
* via_new_spec(struct hda_codec
*codec
)
174 struct via_spec
*spec
;
176 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
182 spec
->codec_type
= get_codec_type(codec
);
183 /* VT1708BCE & VT1708S are almost same */
184 if (spec
->codec_type
== VT1708BCE
)
185 spec
->codec_type
= VT1708S
;
189 static enum VIA_HDA_CODEC
get_codec_type(struct hda_codec
*codec
)
191 u32 vendor_id
= codec
->vendor_id
;
192 u16 ven_id
= vendor_id
>> 16;
193 u16 dev_id
= vendor_id
& 0xffff;
194 enum VIA_HDA_CODEC codec_type
;
197 if (ven_id
!= 0x1106)
198 codec_type
= UNKNOWN
;
199 else if (dev_id
>= 0x1708 && dev_id
<= 0x170b)
201 else if (dev_id
>= 0xe710 && dev_id
<= 0xe713)
202 codec_type
= VT1709_10CH
;
203 else if (dev_id
>= 0xe714 && dev_id
<= 0xe717)
204 codec_type
= VT1709_6CH
;
205 else if (dev_id
>= 0xe720 && dev_id
<= 0xe723) {
206 codec_type
= VT1708B_8CH
;
207 if (snd_hda_param_read(codec
, 0x16, AC_PAR_CONNLIST_LEN
) == 0x7)
208 codec_type
= VT1708BCE
;
209 } else if (dev_id
>= 0xe724 && dev_id
<= 0xe727)
210 codec_type
= VT1708B_4CH
;
211 else if ((dev_id
& 0xfff) == 0x397
212 && (dev_id
>> 12) < 8)
213 codec_type
= VT1708S
;
214 else if ((dev_id
& 0xfff) == 0x398
215 && (dev_id
>> 12) < 8)
217 else if ((dev_id
& 0xfff) == 0x428
218 && (dev_id
>> 12) < 8)
219 codec_type
= VT1718S
;
220 else if (dev_id
== 0x0433 || dev_id
== 0xa721)
221 codec_type
= VT1716S
;
222 else if (dev_id
== 0x0441 || dev_id
== 0x4441)
223 codec_type
= VT1718S
;
224 else if (dev_id
== 0x0438 || dev_id
== 0x4438)
225 codec_type
= VT2002P
;
226 else if (dev_id
== 0x0448)
228 else if (dev_id
== 0x0440)
229 codec_type
= VT1708S
;
230 else if ((dev_id
& 0xfff) == 0x446)
233 codec_type
= UNKNOWN
;
237 #define VIA_JACK_EVENT 0x20
238 #define VIA_HP_EVENT 0x01
239 #define VIA_GPIO_EVENT 0x02
240 #define VIA_MONO_EVENT 0x03
241 #define VIA_SPEAKER_EVENT 0x04
242 #define VIA_BIND_HP_EVENT 0x05
247 VIA_CTL_WIDGET_ANALOG_MUTE
,
248 VIA_CTL_WIDGET_BIND_PIN_MUTE
,
258 static void analog_low_current_mode(struct hda_codec
*codec
, int stream_idle
);
259 static int is_aa_path_mute(struct hda_codec
*codec
);
261 static void vt1708_start_hp_work(struct via_spec
*spec
)
263 if (spec
->codec_type
!= VT1708
|| spec
->autocfg
.hp_pins
[0] == 0)
265 snd_hda_codec_write(spec
->codec
, 0x1, 0, 0xf81,
266 !spec
->vt1708_jack_detectect
);
267 if (!delayed_work_pending(&spec
->vt1708_hp_work
))
268 schedule_delayed_work(&spec
->vt1708_hp_work
,
269 msecs_to_jiffies(100));
272 static void vt1708_stop_hp_work(struct via_spec
*spec
)
274 if (spec
->codec_type
!= VT1708
|| spec
->autocfg
.hp_pins
[0] == 0)
276 if (snd_hda_get_bool_hint(spec
->codec
, "analog_loopback_hp_detect") == 1
277 && !is_aa_path_mute(spec
->codec
))
279 snd_hda_codec_write(spec
->codec
, 0x1, 0, 0xf81,
280 !spec
->vt1708_jack_detectect
);
281 cancel_delayed_work_sync(&spec
->vt1708_hp_work
);
284 static void set_widgets_power_state(struct hda_codec
*codec
)
286 struct via_spec
*spec
= codec
->spec
;
287 if (spec
->set_widgets_power_state
)
288 spec
->set_widgets_power_state(codec
);
291 static int analog_input_switch_put(struct snd_kcontrol
*kcontrol
,
292 struct snd_ctl_elem_value
*ucontrol
)
294 int change
= snd_hda_mixer_amp_switch_put(kcontrol
, ucontrol
);
295 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
297 set_widgets_power_state(codec
);
298 analog_low_current_mode(snd_kcontrol_chip(kcontrol
), -1);
299 if (snd_hda_get_bool_hint(codec
, "analog_loopback_hp_detect") == 1) {
300 if (is_aa_path_mute(codec
))
301 vt1708_start_hp_work(codec
->spec
);
303 vt1708_stop_hp_work(codec
->spec
);
308 /* modify .put = snd_hda_mixer_amp_switch_put */
309 #define ANALOG_INPUT_MUTE \
310 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
313 .info = snd_hda_mixer_amp_switch_info, \
314 .get = snd_hda_mixer_amp_switch_get, \
315 .put = analog_input_switch_put, \
316 .private_value = HDA_COMPOSE_AMP_VAL(0, 3, 0, 0) }
318 static void via_hp_bind_automute(struct hda_codec
*codec
);
320 static int bind_pin_switch_put(struct snd_kcontrol
*kcontrol
,
321 struct snd_ctl_elem_value
*ucontrol
)
323 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
324 struct via_spec
*spec
= codec
->spec
;
328 long *valp
= ucontrol
->value
.integer
.value
;
330 if (strstr(kcontrol
->id
.name
, "Switch") == NULL
) {
331 snd_printd("Invalid control!\n");
334 change
= snd_hda_mixer_amp_switch_put(kcontrol
,
337 lmute
= *valp
? 0 : HDA_AMP_MUTE
;
339 rmute
= *valp
? 0 : HDA_AMP_MUTE
;
342 if (!spec
->hp_independent_mode
) {
343 for (i
= 0; i
< spec
->autocfg
.hp_outs
; i
++) {
344 snd_hda_codec_amp_update(
345 codec
, spec
->autocfg
.hp_pins
[i
],
346 0, HDA_OUTPUT
, 0, HDA_AMP_MUTE
,
348 snd_hda_codec_amp_update(
349 codec
, spec
->autocfg
.hp_pins
[i
],
350 1, HDA_OUTPUT
, 0, HDA_AMP_MUTE
,
355 if (!lmute
&& !rmute
) {
357 for (i
= 0; i
< spec
->autocfg
.line_outs
; i
++)
358 snd_hda_codec_amp_stereo(
359 codec
, spec
->autocfg
.line_out_pins
[i
],
360 HDA_OUTPUT
, 0, HDA_AMP_MUTE
, 0);
362 for (i
= 0; i
< spec
->autocfg
.speaker_outs
; i
++)
363 snd_hda_codec_amp_stereo(
364 codec
, spec
->autocfg
.speaker_pins
[i
],
365 HDA_OUTPUT
, 0, HDA_AMP_MUTE
, 0);
367 via_hp_bind_automute(codec
);
371 /* Mute all left channels */
372 for (i
= 1; i
< spec
->autocfg
.line_outs
; i
++)
373 snd_hda_codec_amp_update(
375 spec
->autocfg
.line_out_pins
[i
],
376 0, HDA_OUTPUT
, 0, HDA_AMP_MUTE
,
378 for (i
= 0; i
< spec
->autocfg
.speaker_outs
; i
++)
379 snd_hda_codec_amp_update(
381 spec
->autocfg
.speaker_pins
[i
],
382 0, HDA_OUTPUT
, 0, HDA_AMP_MUTE
,
386 /* mute all right channels */
387 for (i
= 1; i
< spec
->autocfg
.line_outs
; i
++)
388 snd_hda_codec_amp_update(
390 spec
->autocfg
.line_out_pins
[i
],
391 1, HDA_OUTPUT
, 0, HDA_AMP_MUTE
,
393 for (i
= 0; i
< spec
->autocfg
.speaker_outs
; i
++)
394 snd_hda_codec_amp_update(
396 spec
->autocfg
.speaker_pins
[i
],
397 1, HDA_OUTPUT
, 0, HDA_AMP_MUTE
,
404 #define BIND_PIN_MUTE \
405 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
408 .info = snd_hda_mixer_amp_switch_info, \
409 .get = snd_hda_mixer_amp_switch_get, \
410 .put = bind_pin_switch_put, \
411 .private_value = HDA_COMPOSE_AMP_VAL(0, 3, 0, 0) }
413 static const struct snd_kcontrol_new via_control_templates
[] = {
414 HDA_CODEC_VOLUME(NULL
, 0, 0, 0),
415 HDA_CODEC_MUTE(NULL
, 0, 0, 0),
420 static const hda_nid_t vt1708_adc_nids
[2] = {
425 static const hda_nid_t vt1709_adc_nids
[3] = {
430 static const hda_nid_t vt1708B_adc_nids
[2] = {
435 static const hda_nid_t vt1708S_adc_nids
[2] = {
440 static const hda_nid_t vt1702_adc_nids
[3] = {
445 static const hda_nid_t vt1718S_adc_nids
[2] = {
450 static const hda_nid_t vt1716S_adc_nids
[2] = {
455 static const hda_nid_t vt2002P_adc_nids
[2] = {
460 static const hda_nid_t vt1812_adc_nids
[2] = {
466 /* add dynamic controls */
467 static int __via_add_control(struct via_spec
*spec
, int type
, const char *name
,
468 int idx
, unsigned long val
)
470 struct snd_kcontrol_new
*knew
;
472 snd_array_init(&spec
->kctls
, sizeof(*knew
), 32);
473 knew
= snd_array_new(&spec
->kctls
);
476 *knew
= via_control_templates
[type
];
477 knew
->name
= kstrdup(name
, GFP_KERNEL
);
480 if (get_amp_nid_(val
))
481 knew
->subdevice
= HDA_SUBDEV_AMP_FLAG
;
482 knew
->private_value
= val
;
486 #define via_add_control(spec, type, name, val) \
487 __via_add_control(spec, type, name, 0, val)
489 static struct snd_kcontrol_new
*via_clone_control(struct via_spec
*spec
,
490 const struct snd_kcontrol_new
*tmpl
)
492 struct snd_kcontrol_new
*knew
;
494 snd_array_init(&spec
->kctls
, sizeof(*knew
), 32);
495 knew
= snd_array_new(&spec
->kctls
);
499 knew
->name
= kstrdup(tmpl
->name
, GFP_KERNEL
);
505 static void via_free_kctls(struct hda_codec
*codec
)
507 struct via_spec
*spec
= codec
->spec
;
509 if (spec
->kctls
.list
) {
510 struct snd_kcontrol_new
*kctl
= spec
->kctls
.list
;
512 for (i
= 0; i
< spec
->kctls
.used
; i
++)
515 snd_array_free(&spec
->kctls
);
518 /* create input playback/capture controls for the given pin */
519 static int via_new_analog_input(struct via_spec
*spec
, const char *ctlname
,
520 int type_idx
, int idx
, int mix_nid
)
525 sprintf(name
, "%s Playback Volume", ctlname
);
526 err
= __via_add_control(spec
, VIA_CTL_WIDGET_VOL
, name
, type_idx
,
527 HDA_COMPOSE_AMP_VAL(mix_nid
, 3, idx
, HDA_INPUT
));
530 sprintf(name
, "%s Playback Switch", ctlname
);
531 err
= __via_add_control(spec
, VIA_CTL_WIDGET_ANALOG_MUTE
, name
, type_idx
,
532 HDA_COMPOSE_AMP_VAL(mix_nid
, 3, idx
, HDA_INPUT
));
538 static void via_auto_set_output_and_unmute(struct hda_codec
*codec
,
539 hda_nid_t nid
, int pin_type
,
543 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
545 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
547 if (snd_hda_query_pin_caps(codec
, nid
) & AC_PINCAP_EAPD
)
548 snd_hda_codec_write(codec
, nid
, 0,
549 AC_VERB_SET_EAPD_BTLENABLE
, 0x02);
553 static void via_auto_init_multi_out(struct hda_codec
*codec
)
555 struct via_spec
*spec
= codec
->spec
;
558 for (i
= 0; i
<= AUTO_SEQ_SIDE
; i
++) {
559 hda_nid_t nid
= spec
->autocfg
.line_out_pins
[i
];
561 via_auto_set_output_and_unmute(codec
, nid
, PIN_OUT
, i
);
565 static void via_auto_init_hp_out(struct hda_codec
*codec
)
567 struct via_spec
*spec
= codec
->spec
;
571 for (i
= 0; i
< spec
->autocfg
.hp_outs
; i
++) {
572 pin
= spec
->autocfg
.hp_pins
[i
];
573 if (pin
) /* connect to front */
574 via_auto_set_output_and_unmute(codec
, pin
, PIN_HP
, 0);
578 static int is_smart51_pins(struct via_spec
*spec
, hda_nid_t pin
);
580 static void via_auto_init_analog_input(struct hda_codec
*codec
)
582 struct via_spec
*spec
= codec
->spec
;
583 const struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
587 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
588 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
589 if (spec
->smart51_enabled
&& is_smart51_pins(spec
, nid
))
591 else if (cfg
->inputs
[i
].type
== AUTO_PIN_MIC
)
595 snd_hda_codec_write(codec
, nid
, 0,
596 AC_VERB_SET_PIN_WIDGET_CONTROL
, ctl
);
600 static void set_pin_power_state(struct hda_codec
*codec
, hda_nid_t nid
,
601 unsigned int *affected_parm
)
604 unsigned def_conf
= snd_hda_codec_get_pincfg(codec
, nid
);
605 unsigned no_presence
= (def_conf
& AC_DEFCFG_MISC
)
606 >> AC_DEFCFG_MISC_SHIFT
607 & AC_DEFCFG_MISC_NO_PRESENCE
; /* do not support pin sense */
608 unsigned present
= snd_hda_jack_detect(codec
, nid
);
609 struct via_spec
*spec
= codec
->spec
;
610 if ((spec
->smart51_enabled
&& is_smart51_pins(spec
, nid
))
611 || ((no_presence
|| present
)
612 && get_defcfg_connect(def_conf
) != AC_JACK_PORT_NONE
)) {
613 *affected_parm
= AC_PWRST_D0
; /* if it's connected */
618 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_POWER_STATE
, parm
);
624 static int via_mux_enum_info(struct snd_kcontrol
*kcontrol
,
625 struct snd_ctl_elem_info
*uinfo
)
627 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
628 struct via_spec
*spec
= codec
->spec
;
629 return snd_hda_input_mux_info(spec
->input_mux
, uinfo
);
632 static int via_mux_enum_get(struct snd_kcontrol
*kcontrol
,
633 struct snd_ctl_elem_value
*ucontrol
)
635 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
636 struct via_spec
*spec
= codec
->spec
;
637 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
639 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
643 static int via_mux_enum_put(struct snd_kcontrol
*kcontrol
,
644 struct snd_ctl_elem_value
*ucontrol
)
646 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
647 struct via_spec
*spec
= codec
->spec
;
648 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
651 if (!spec
->mux_nids
[adc_idx
])
653 /* switch to D0 beofre change index */
654 if (snd_hda_codec_read(codec
, spec
->mux_nids
[adc_idx
], 0,
655 AC_VERB_GET_POWER_STATE
, 0x00) != AC_PWRST_D0
)
656 snd_hda_codec_write(codec
, spec
->mux_nids
[adc_idx
], 0,
657 AC_VERB_SET_POWER_STATE
, AC_PWRST_D0
);
659 ret
= snd_hda_input_mux_put(codec
, spec
->input_mux
, ucontrol
,
660 spec
->mux_nids
[adc_idx
],
661 &spec
->cur_mux
[adc_idx
]);
662 /* update jack power state */
663 set_widgets_power_state(codec
);
668 static int via_independent_hp_info(struct snd_kcontrol
*kcontrol
,
669 struct snd_ctl_elem_info
*uinfo
)
671 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
672 struct via_spec
*spec
= codec
->spec
;
673 return snd_hda_input_mux_info(spec
->hp_mux
, uinfo
);
676 static int via_independent_hp_get(struct snd_kcontrol
*kcontrol
,
677 struct snd_ctl_elem_value
*ucontrol
)
679 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
680 hda_nid_t nid
= kcontrol
->private_value
;
683 /* use !! to translate conn sel 2 for VT1718S */
684 pinsel
= !!snd_hda_codec_read(codec
, nid
, 0,
685 AC_VERB_GET_CONNECT_SEL
,
687 ucontrol
->value
.enumerated
.item
[0] = pinsel
;
692 static void activate_ctl(struct hda_codec
*codec
, const char *name
, int active
)
694 struct snd_kcontrol
*ctl
= snd_hda_find_mixer_ctl(codec
, name
);
696 ctl
->vd
[0].access
&= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE
;
697 ctl
->vd
[0].access
|= active
698 ? 0 : SNDRV_CTL_ELEM_ACCESS_INACTIVE
;
699 snd_ctl_notify(codec
->bus
->card
,
700 SNDRV_CTL_EVENT_MASK_VALUE
, &ctl
->id
);
704 static hda_nid_t
side_mute_channel(struct via_spec
*spec
)
706 switch (spec
->codec_type
) {
707 case VT1708
: return 0x1b;
708 case VT1709_10CH
: return 0x29;
709 case VT1708B_8CH
: /* fall thru */
710 case VT1708S
: return 0x27;
711 case VT2002P
: return 0x19;
712 case VT1802
: return 0x15;
713 case VT1812
: return 0x15;
718 static int update_side_mute_status(struct hda_codec
*codec
)
720 /* mute side channel */
721 struct via_spec
*spec
= codec
->spec
;
723 hda_nid_t sw3
= side_mute_channel(spec
);
726 if (VT2002P_COMPATIBLE(spec
))
727 parm
= spec
->hp_independent_mode
?
728 AMP_IN_MUTE(1) : AMP_IN_UNMUTE(1);
730 parm
= spec
->hp_independent_mode
?
731 AMP_OUT_MUTE
: AMP_OUT_UNMUTE
;
732 snd_hda_codec_write(codec
, sw3
, 0,
733 AC_VERB_SET_AMP_GAIN_MUTE
, parm
);
734 if (spec
->codec_type
== VT1812
)
735 snd_hda_codec_write(codec
, 0x1d, 0,
736 AC_VERB_SET_AMP_GAIN_MUTE
, parm
);
741 static int via_independent_hp_put(struct snd_kcontrol
*kcontrol
,
742 struct snd_ctl_elem_value
*ucontrol
)
744 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
745 struct via_spec
*spec
= codec
->spec
;
746 hda_nid_t nid
= kcontrol
->private_value
;
747 unsigned int pinsel
= ucontrol
->value
.enumerated
.item
[0];
748 /* Get Independent Mode index of headphone pin widget */
749 spec
->hp_independent_mode
= spec
->hp_independent_mode_index
== pinsel
751 if (spec
->codec_type
== VT1718S
)
752 snd_hda_codec_write(codec
, nid
, 0,
753 AC_VERB_SET_CONNECT_SEL
, pinsel
? 2 : 0);
755 snd_hda_codec_write(codec
, nid
, 0,
756 AC_VERB_SET_CONNECT_SEL
, pinsel
);
758 if (spec
->codec_type
== VT1812
)
759 snd_hda_codec_write(codec
, 0x35, 0,
760 AC_VERB_SET_CONNECT_SEL
, pinsel
);
761 if (spec
->multiout
.hp_nid
&& spec
->multiout
.hp_nid
762 != spec
->multiout
.dac_nids
[HDA_FRONT
])
763 snd_hda_codec_setup_stream(codec
, spec
->multiout
.hp_nid
,
766 update_side_mute_status(codec
);
767 /* update HP volume/swtich active state */
768 if (spec
->codec_type
== VT1708S
769 || spec
->codec_type
== VT1702
770 || spec
->codec_type
== VT1718S
771 || spec
->codec_type
== VT1716S
772 || VT2002P_COMPATIBLE(spec
)) {
773 activate_ctl(codec
, "Headphone Playback Volume",
774 spec
->hp_independent_mode
);
775 activate_ctl(codec
, "Headphone Playback Switch",
776 spec
->hp_independent_mode
);
778 /* update jack power state */
779 set_widgets_power_state(codec
);
783 static const struct snd_kcontrol_new via_hp_mixer
[2] = {
785 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
786 .name
= "Independent HP",
787 .info
= via_independent_hp_info
,
788 .get
= via_independent_hp_get
,
789 .put
= via_independent_hp_put
,
792 .iface
= NID_MAPPING
,
793 .name
= "Independent HP",
797 static int via_hp_build(struct hda_codec
*codec
)
799 struct via_spec
*spec
= codec
->spec
;
800 struct snd_kcontrol_new
*knew
;
803 hda_nid_t conn
[HDA_MAX_CONNECTIONS
];
805 switch (spec
->codec_type
) {
817 nid
= spec
->autocfg
.hp_pins
[0];
821 if (spec
->codec_type
!= VT1708
) {
822 nums
= snd_hda_get_connections(codec
, nid
,
823 conn
, HDA_MAX_CONNECTIONS
);
828 knew
= via_clone_control(spec
, &via_hp_mixer
[0]);
832 knew
->subdevice
= HDA_SUBDEV_NID_FLAG
| nid
;
833 knew
->private_value
= nid
;
835 nid
= side_mute_channel(spec
);
837 knew
= via_clone_control(spec
, &via_hp_mixer
[1]);
840 knew
->subdevice
= nid
;
846 static void notify_aa_path_ctls(struct hda_codec
*codec
)
849 struct snd_ctl_elem_id id
;
850 const char *labels
[] = {"Mic", "Front Mic", "Line", "Rear Mic"};
851 struct snd_kcontrol
*ctl
;
853 memset(&id
, 0, sizeof(id
));
854 id
.iface
= SNDRV_CTL_ELEM_IFACE_MIXER
;
855 for (i
= 0; i
< ARRAY_SIZE(labels
); i
++) {
856 sprintf(id
.name
, "%s Playback Volume", labels
[i
]);
857 ctl
= snd_hda_find_mixer_ctl(codec
, id
.name
);
859 snd_ctl_notify(codec
->bus
->card
,
860 SNDRV_CTL_EVENT_MASK_VALUE
,
865 static void mute_aa_path(struct hda_codec
*codec
, int mute
)
867 struct via_spec
*spec
= codec
->spec
;
872 /* get nid of MW0 and start & end index */
873 switch (spec
->codec_type
) {
901 /* check AA path's mute status */
902 for (i
= start_idx
; i
<= end_idx
; i
++) {
903 int val
= mute
? HDA_AMP_MUTE
: HDA_AMP_UNMUTE
;
904 snd_hda_codec_amp_stereo(codec
, nid_mixer
, HDA_INPUT
, i
,
908 static int is_smart51_pins(struct via_spec
*spec
, hda_nid_t pin
)
910 const struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
913 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
914 if (pin
== cfg
->inputs
[i
].pin
)
915 return cfg
->inputs
[i
].type
<= AUTO_PIN_LINE_IN
;
920 static int via_smart51_info(struct snd_kcontrol
*kcontrol
,
921 struct snd_ctl_elem_info
*uinfo
)
923 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_BOOLEAN
;
925 uinfo
->value
.integer
.min
= 0;
926 uinfo
->value
.integer
.max
= 1;
930 static int via_smart51_get(struct snd_kcontrol
*kcontrol
,
931 struct snd_ctl_elem_value
*ucontrol
)
933 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
934 struct via_spec
*spec
= codec
->spec
;
935 const struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
939 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
940 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
941 int ctl
= snd_hda_codec_read(codec
, nid
, 0,
942 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
943 if (cfg
->inputs
[i
].type
> AUTO_PIN_LINE_IN
)
945 if (cfg
->inputs
[i
].type
== AUTO_PIN_MIC
&&
946 spec
->hp_independent_mode
&& spec
->codec_type
!= VT1718S
)
947 continue; /* ignore FMic for independent HP */
948 if ((ctl
& AC_PINCTL_IN_EN
) && !(ctl
& AC_PINCTL_OUT_EN
))
951 *ucontrol
->value
.integer
.value
= on
;
955 static int via_smart51_put(struct snd_kcontrol
*kcontrol
,
956 struct snd_ctl_elem_value
*ucontrol
)
958 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
959 struct via_spec
*spec
= codec
->spec
;
960 const struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
961 int out_in
= *ucontrol
->value
.integer
.value
962 ? AC_PINCTL_OUT_EN
: AC_PINCTL_IN_EN
;
965 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
966 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
969 if (cfg
->inputs
[i
].type
> AUTO_PIN_LINE_IN
)
971 if (cfg
->inputs
[i
].type
== AUTO_PIN_MIC
&&
972 spec
->hp_independent_mode
&& spec
->codec_type
!= VT1718S
)
973 continue; /* don't retask FMic for independent HP */
975 parm
= snd_hda_codec_read(codec
, nid
, 0,
976 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
977 parm
&= ~(AC_PINCTL_IN_EN
| AC_PINCTL_OUT_EN
);
979 snd_hda_codec_write(codec
, nid
, 0,
980 AC_VERB_SET_PIN_WIDGET_CONTROL
,
982 if (out_in
== AC_PINCTL_OUT_EN
) {
983 mute_aa_path(codec
, 1);
984 notify_aa_path_ctls(codec
);
986 if (spec
->codec_type
== VT1718S
) {
987 snd_hda_codec_amp_stereo(
988 codec
, nid
, HDA_OUTPUT
, 0, HDA_AMP_MUTE
,
991 if (cfg
->inputs
[i
].type
== AUTO_PIN_MIC
) {
992 if (spec
->codec_type
== VT1708S
993 || spec
->codec_type
== VT1716S
) {
994 /* input = index 1 (AOW3) */
997 AC_VERB_SET_CONNECT_SEL
, 1);
998 snd_hda_codec_amp_stereo(
999 codec
, nid
, HDA_OUTPUT
,
1000 0, HDA_AMP_MUTE
, HDA_AMP_UNMUTE
);
1004 spec
->smart51_enabled
= *ucontrol
->value
.integer
.value
;
1005 set_widgets_power_state(codec
);
1009 static const struct snd_kcontrol_new via_smart51_mixer
[2] = {
1011 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1012 .name
= "Smart 5.1",
1014 .info
= via_smart51_info
,
1015 .get
= via_smart51_get
,
1016 .put
= via_smart51_put
,
1019 .iface
= NID_MAPPING
,
1020 .name
= "Smart 5.1",
1024 static int via_smart51_build(struct via_spec
*spec
)
1026 struct snd_kcontrol_new
*knew
;
1027 const struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
1033 if (cfg
->line_outs
> 2)
1036 knew
= via_clone_control(spec
, &via_smart51_mixer
[0]);
1040 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
1041 nid
= cfg
->inputs
[i
].pin
;
1042 if (cfg
->inputs
[i
].type
<= AUTO_PIN_LINE_IN
) {
1043 knew
= via_clone_control(spec
, &via_smart51_mixer
[1]);
1046 knew
->subdevice
= nid
;
1054 /* capture mixer elements */
1055 static const struct snd_kcontrol_new vt1708_capture_mixer
[] = {
1056 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_INPUT
),
1057 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_INPUT
),
1058 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x27, 0x0, HDA_INPUT
),
1059 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x27, 0x0, HDA_INPUT
),
1061 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1062 /* The multiple "Capture Source" controls confuse alsamixer
1063 * So call somewhat different..
1065 /* .name = "Capture Source", */
1066 .name
= "Input Source",
1068 .info
= via_mux_enum_info
,
1069 .get
= via_mux_enum_get
,
1070 .put
= via_mux_enum_put
,
1075 /* check AA path's mute statue */
1076 static int is_aa_path_mute(struct hda_codec
*codec
)
1079 hda_nid_t nid_mixer
;
1083 struct via_spec
*spec
= codec
->spec
;
1084 /* get nid of MW0 and start & end index */
1085 switch (spec
->codec_type
) {
1114 /* check AA path's mute status */
1115 for (i
= start_idx
; i
<= end_idx
; i
++) {
1116 unsigned int con_list
= snd_hda_codec_read(
1117 codec
, nid_mixer
, 0, AC_VERB_GET_CONNECT_LIST
, i
/4*4);
1118 int shift
= 8 * (i
% 4);
1119 hda_nid_t nid_pin
= (con_list
& (0xff << shift
)) >> shift
;
1120 unsigned int defconf
= snd_hda_codec_get_pincfg(codec
, nid_pin
);
1121 if (get_defcfg_connect(defconf
) == AC_JACK_PORT_COMPLEX
) {
1122 /* check mute status while the pin is connected */
1123 int mute_l
= snd_hda_codec_amp_read(codec
, nid_mixer
, 0,
1125 int mute_r
= snd_hda_codec_amp_read(codec
, nid_mixer
, 1,
1127 if (!mute_l
|| !mute_r
) {
1136 /* enter/exit analog low-current mode */
1137 static void analog_low_current_mode(struct hda_codec
*codec
, int stream_idle
)
1139 struct via_spec
*spec
= codec
->spec
;
1140 static int saved_stream_idle
= 1; /* saved stream idle status */
1141 int enable
= is_aa_path_mute(codec
);
1142 unsigned int verb
= 0;
1143 unsigned int parm
= 0;
1145 if (stream_idle
== -1) /* stream status did not change */
1146 enable
= enable
&& saved_stream_idle
;
1148 enable
= enable
&& stream_idle
;
1149 saved_stream_idle
= stream_idle
;
1152 /* decide low current mode's verb & parameter */
1153 switch (spec
->codec_type
) {
1157 parm
= enable
? 0x02 : 0x00; /* 0x02: 2/3x, 0x00: 1x */
1163 parm
= enable
? 0x51 : 0xe1; /* 0x51: 4/28x, 0xe1: 1x */
1167 parm
= enable
? 0x01 : 0x1d; /* 0x01: 4/40x, 0x1d: 1x */
1173 parm
= enable
? 0x00 : 0xe0; /* 0x00: 4/40x, 0xe0: 1x */
1176 return; /* other codecs are not supported */
1179 snd_hda_codec_write(codec
, codec
->afg
, 0, verb
, parm
);
1183 * generic initialization of ADC, input mixers and output mixers
1185 static const struct hda_verb vt1708_volume_init_verbs
[] = {
1187 * Unmute ADC0-1 and set the default input to mic-in
1189 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
1190 {0x27, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
1193 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1196 /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */
1197 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
1198 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
1199 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2)},
1200 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(3)},
1201 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(4)},
1204 * Set up output mixers (0x19 - 0x1b)
1206 /* set vol=0 to output mixers */
1207 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
1208 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
1209 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
1211 /* Setup default input MW0 to PW4 */
1212 {0x20, AC_VERB_SET_CONNECT_SEL
, 0},
1213 /* PW9 Output enable */
1214 {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40},
1215 /* power down jack detect function */
1220 static int via_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
1221 struct hda_codec
*codec
,
1222 struct snd_pcm_substream
*substream
)
1224 struct via_spec
*spec
= codec
->spec
;
1225 int idle
= substream
->pstr
->substream_opened
== 1
1226 && substream
->ref_count
== 0;
1227 analog_low_current_mode(codec
, idle
);
1228 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
1232 static void playback_multi_pcm_prep_0(struct hda_codec
*codec
,
1233 unsigned int stream_tag
,
1234 unsigned int format
,
1235 struct snd_pcm_substream
*substream
)
1237 struct via_spec
*spec
= codec
->spec
;
1238 struct hda_multi_out
*mout
= &spec
->multiout
;
1239 const hda_nid_t
*nids
= mout
->dac_nids
;
1240 int chs
= substream
->runtime
->channels
;
1243 mutex_lock(&codec
->spdif_mutex
);
1244 if (mout
->dig_out_nid
&& mout
->dig_out_used
!= HDA_DIG_EXCLUSIVE
) {
1246 snd_hda_is_supported_format(codec
, mout
->dig_out_nid
,
1248 !(codec
->spdif_status
& IEC958_AES0_NONAUDIO
)) {
1249 mout
->dig_out_used
= HDA_DIG_ANALOG_DUP
;
1250 /* turn off SPDIF once; otherwise the IEC958 bits won't
1252 if (codec
->spdif_ctls
& AC_DIG1_ENABLE
)
1253 snd_hda_codec_write(codec
, mout
->dig_out_nid
, 0,
1254 AC_VERB_SET_DIGI_CONVERT_1
,
1256 ~AC_DIG1_ENABLE
& 0xff);
1257 snd_hda_codec_setup_stream(codec
, mout
->dig_out_nid
,
1258 stream_tag
, 0, format
);
1259 /* turn on again (if needed) */
1260 if (codec
->spdif_ctls
& AC_DIG1_ENABLE
)
1261 snd_hda_codec_write(codec
, mout
->dig_out_nid
, 0,
1262 AC_VERB_SET_DIGI_CONVERT_1
,
1263 codec
->spdif_ctls
& 0xff);
1265 mout
->dig_out_used
= 0;
1266 snd_hda_codec_setup_stream(codec
, mout
->dig_out_nid
,
1270 mutex_unlock(&codec
->spdif_mutex
);
1273 snd_hda_codec_setup_stream(codec
, nids
[HDA_FRONT
], stream_tag
,
1276 if (mout
->hp_nid
&& mout
->hp_nid
!= nids
[HDA_FRONT
]
1277 && !spec
->hp_independent_mode
)
1278 /* headphone out will just decode front left/right (stereo) */
1279 snd_hda_codec_setup_stream(codec
, mout
->hp_nid
, stream_tag
,
1282 /* extra outputs copied from front */
1283 for (i
= 0; i
< ARRAY_SIZE(mout
->extra_out_nid
); i
++)
1284 if (mout
->extra_out_nid
[i
])
1285 snd_hda_codec_setup_stream(codec
,
1286 mout
->extra_out_nid
[i
],
1287 stream_tag
, 0, format
);
1290 for (i
= 1; i
< mout
->num_dacs
; i
++) {
1291 if (chs
>= (i
+ 1) * 2) /* independent out */
1292 snd_hda_codec_setup_stream(codec
, nids
[i
], stream_tag
,
1294 else /* copy front */
1295 snd_hda_codec_setup_stream(codec
, nids
[i
], stream_tag
,
1300 static int via_playback_multi_pcm_prepare(struct hda_pcm_stream
*hinfo
,
1301 struct hda_codec
*codec
,
1302 unsigned int stream_tag
,
1303 unsigned int format
,
1304 struct snd_pcm_substream
*substream
)
1306 struct via_spec
*spec
= codec
->spec
;
1307 struct hda_multi_out
*mout
= &spec
->multiout
;
1308 const hda_nid_t
*nids
= mout
->dac_nids
;
1310 if (substream
->number
== 0)
1311 playback_multi_pcm_prep_0(codec
, stream_tag
, format
,
1314 if (mout
->hp_nid
&& mout
->hp_nid
!= nids
[HDA_FRONT
] &&
1315 spec
->hp_independent_mode
)
1316 snd_hda_codec_setup_stream(codec
, mout
->hp_nid
,
1317 stream_tag
, 0, format
);
1319 vt1708_start_hp_work(spec
);
1323 static int via_playback_multi_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
1324 struct hda_codec
*codec
,
1325 struct snd_pcm_substream
*substream
)
1327 struct via_spec
*spec
= codec
->spec
;
1328 struct hda_multi_out
*mout
= &spec
->multiout
;
1329 const hda_nid_t
*nids
= mout
->dac_nids
;
1332 if (substream
->number
== 0) {
1333 for (i
= 0; i
< mout
->num_dacs
; i
++)
1334 snd_hda_codec_setup_stream(codec
, nids
[i
], 0, 0, 0);
1336 if (mout
->hp_nid
&& !spec
->hp_independent_mode
)
1337 snd_hda_codec_setup_stream(codec
, mout
->hp_nid
,
1340 for (i
= 0; i
< ARRAY_SIZE(mout
->extra_out_nid
); i
++)
1341 if (mout
->extra_out_nid
[i
])
1342 snd_hda_codec_setup_stream(codec
,
1343 mout
->extra_out_nid
[i
],
1345 mutex_lock(&codec
->spdif_mutex
);
1346 if (mout
->dig_out_nid
&&
1347 mout
->dig_out_used
== HDA_DIG_ANALOG_DUP
) {
1348 snd_hda_codec_setup_stream(codec
, mout
->dig_out_nid
,
1350 mout
->dig_out_used
= 0;
1352 mutex_unlock(&codec
->spdif_mutex
);
1354 if (mout
->hp_nid
&& mout
->hp_nid
!= nids
[HDA_FRONT
] &&
1355 spec
->hp_independent_mode
)
1356 snd_hda_codec_setup_stream(codec
, mout
->hp_nid
,
1359 vt1708_stop_hp_work(spec
);
1366 static int via_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
1367 struct hda_codec
*codec
,
1368 struct snd_pcm_substream
*substream
)
1370 struct via_spec
*spec
= codec
->spec
;
1371 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
1374 static int via_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
1375 struct hda_codec
*codec
,
1376 struct snd_pcm_substream
*substream
)
1378 struct via_spec
*spec
= codec
->spec
;
1379 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
1382 static int via_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
1383 struct hda_codec
*codec
,
1384 unsigned int stream_tag
,
1385 unsigned int format
,
1386 struct snd_pcm_substream
*substream
)
1388 struct via_spec
*spec
= codec
->spec
;
1389 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
1390 stream_tag
, format
, substream
);
1393 static int via_dig_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
1394 struct hda_codec
*codec
,
1395 struct snd_pcm_substream
*substream
)
1397 struct via_spec
*spec
= codec
->spec
;
1398 snd_hda_multi_out_dig_cleanup(codec
, &spec
->multiout
);
1405 static int via_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
1406 struct hda_codec
*codec
,
1407 unsigned int stream_tag
,
1408 unsigned int format
,
1409 struct snd_pcm_substream
*substream
)
1411 struct via_spec
*spec
= codec
->spec
;
1413 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
],
1414 stream_tag
, 0, format
);
1418 static int via_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
1419 struct hda_codec
*codec
,
1420 struct snd_pcm_substream
*substream
)
1422 struct via_spec
*spec
= codec
->spec
;
1423 snd_hda_codec_cleanup_stream(codec
, spec
->adc_nids
[substream
->number
]);
1427 static const struct hda_pcm_stream vt1708_pcm_analog_playback
= {
1431 .nid
= 0x10, /* NID to query formats and rates */
1433 .open
= via_playback_pcm_open
,
1434 .prepare
= via_playback_multi_pcm_prepare
,
1435 .cleanup
= via_playback_multi_pcm_cleanup
1439 static const struct hda_pcm_stream vt1708_pcm_analog_s16_playback
= {
1443 .nid
= 0x10, /* NID to query formats and rates */
1444 /* We got noisy outputs on the right channel on VT1708 when
1445 * 24bit samples are used. Until any workaround is found,
1446 * disable the 24bit format, so far.
1448 .formats
= SNDRV_PCM_FMTBIT_S16_LE
,
1450 .open
= via_playback_pcm_open
,
1451 .prepare
= via_playback_multi_pcm_prepare
,
1452 .cleanup
= via_playback_multi_pcm_cleanup
1456 static const struct hda_pcm_stream vt1708_pcm_analog_capture
= {
1460 .nid
= 0x15, /* NID to query formats and rates */
1462 .prepare
= via_capture_pcm_prepare
,
1463 .cleanup
= via_capture_pcm_cleanup
1467 static const struct hda_pcm_stream vt1708_pcm_digital_playback
= {
1471 /* NID is set in via_build_pcms */
1473 .open
= via_dig_playback_pcm_open
,
1474 .close
= via_dig_playback_pcm_close
,
1475 .prepare
= via_dig_playback_pcm_prepare
,
1476 .cleanup
= via_dig_playback_pcm_cleanup
1480 static const struct hda_pcm_stream vt1708_pcm_digital_capture
= {
1486 static int via_build_controls(struct hda_codec
*codec
)
1488 struct via_spec
*spec
= codec
->spec
;
1489 struct snd_kcontrol
*kctl
;
1490 const struct snd_kcontrol_new
*knew
;
1493 for (i
= 0; i
< spec
->num_mixers
; i
++) {
1494 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
1499 if (spec
->multiout
.dig_out_nid
) {
1500 err
= snd_hda_create_spdif_out_ctls(codec
,
1501 spec
->multiout
.dig_out_nid
);
1504 err
= snd_hda_create_spdif_share_sw(codec
,
1508 spec
->multiout
.share_spdif
= 1;
1510 if (spec
->dig_in_nid
) {
1511 err
= snd_hda_create_spdif_in_ctls(codec
, spec
->dig_in_nid
);
1516 /* assign Capture Source enums to NID */
1517 kctl
= snd_hda_find_mixer_ctl(codec
, "Input Source");
1518 for (i
= 0; kctl
&& i
< kctl
->count
; i
++) {
1519 err
= snd_hda_add_nid(codec
, kctl
, i
, spec
->mux_nids
[i
]);
1524 /* other nid->control mapping */
1525 for (i
= 0; i
< spec
->num_mixers
; i
++) {
1526 for (knew
= spec
->mixers
[i
]; knew
->name
; knew
++) {
1527 if (knew
->iface
!= NID_MAPPING
)
1529 kctl
= snd_hda_find_mixer_ctl(codec
, knew
->name
);
1532 err
= snd_hda_add_nid(codec
, kctl
, 0,
1537 /* init power states */
1538 set_widgets_power_state(codec
);
1539 analog_low_current_mode(codec
, 1);
1541 via_free_kctls(codec
); /* no longer needed */
1545 static int via_build_pcms(struct hda_codec
*codec
)
1547 struct via_spec
*spec
= codec
->spec
;
1548 struct hda_pcm
*info
= spec
->pcm_rec
;
1550 codec
->num_pcms
= 1;
1551 codec
->pcm_info
= info
;
1553 info
->name
= spec
->stream_name_analog
;
1554 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] =
1555 *(spec
->stream_analog_playback
);
1556 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
1557 spec
->multiout
.dac_nids
[0];
1558 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *(spec
->stream_analog_capture
);
1559 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
1561 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
=
1562 spec
->multiout
.max_channels
;
1564 if (spec
->multiout
.dig_out_nid
|| spec
->dig_in_nid
) {
1567 info
->name
= spec
->stream_name_digital
;
1568 info
->pcm_type
= HDA_PCM_TYPE_SPDIF
;
1569 if (spec
->multiout
.dig_out_nid
) {
1570 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] =
1571 *(spec
->stream_digital_playback
);
1572 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
1573 spec
->multiout
.dig_out_nid
;
1575 if (spec
->dig_in_nid
) {
1576 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
1577 *(spec
->stream_digital_capture
);
1578 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
=
1586 static void via_free(struct hda_codec
*codec
)
1588 struct via_spec
*spec
= codec
->spec
;
1593 via_free_kctls(codec
);
1594 vt1708_stop_hp_work(spec
);
1598 /* mute internal speaker if HP is plugged */
1599 static void via_hp_automute(struct hda_codec
*codec
)
1601 unsigned int present
= 0;
1602 struct via_spec
*spec
= codec
->spec
;
1604 present
= snd_hda_jack_detect(codec
, spec
->autocfg
.hp_pins
[0]);
1606 if (!spec
->hp_independent_mode
) {
1607 struct snd_ctl_elem_id id
;
1609 snd_hda_codec_amp_stereo(
1610 codec
, spec
->autocfg
.line_out_pins
[0], HDA_OUTPUT
, 0,
1611 HDA_AMP_MUTE
, present
? HDA_AMP_MUTE
: 0);
1613 memset(&id
, 0, sizeof(id
));
1614 id
.iface
= SNDRV_CTL_ELEM_IFACE_MIXER
;
1615 strcpy(id
.name
, "Front Playback Switch");
1616 snd_ctl_notify(codec
->bus
->card
, SNDRV_CTL_EVENT_MASK_VALUE
,
1621 /* mute mono out if HP or Line out is plugged */
1622 static void via_mono_automute(struct hda_codec
*codec
)
1624 unsigned int hp_present
, lineout_present
;
1625 struct via_spec
*spec
= codec
->spec
;
1627 if (spec
->codec_type
!= VT1716S
)
1630 lineout_present
= snd_hda_jack_detect(codec
,
1631 spec
->autocfg
.line_out_pins
[0]);
1633 /* Mute Mono Out if Line Out is plugged */
1634 if (lineout_present
) {
1635 snd_hda_codec_amp_stereo(
1636 codec
, 0x2A, HDA_OUTPUT
, 0, HDA_AMP_MUTE
, HDA_AMP_MUTE
);
1640 hp_present
= snd_hda_jack_detect(codec
, spec
->autocfg
.hp_pins
[0]);
1642 if (!spec
->hp_independent_mode
)
1643 snd_hda_codec_amp_stereo(
1644 codec
, 0x2A, HDA_OUTPUT
, 0, HDA_AMP_MUTE
,
1645 hp_present
? HDA_AMP_MUTE
: 0);
1648 static void via_gpio_control(struct hda_codec
*codec
)
1650 unsigned int gpio_data
;
1651 unsigned int vol_counter
;
1653 unsigned int master_vol
;
1655 struct via_spec
*spec
= codec
->spec
;
1657 gpio_data
= snd_hda_codec_read(codec
, codec
->afg
, 0,
1658 AC_VERB_GET_GPIO_DATA
, 0) & 0x03;
1660 vol_counter
= (snd_hda_codec_read(codec
, codec
->afg
, 0,
1661 0xF84, 0) & 0x3F0000) >> 16;
1663 vol
= vol_counter
& 0x1F;
1664 master_vol
= snd_hda_codec_read(codec
, 0x1A, 0,
1665 AC_VERB_GET_AMP_GAIN_MUTE
,
1668 if (gpio_data
== 0x02) {
1669 /* unmute line out */
1670 snd_hda_codec_amp_stereo(codec
, spec
->autocfg
.line_out_pins
[0],
1671 HDA_OUTPUT
, 0, HDA_AMP_MUTE
, 0);
1673 if (vol_counter
& 0x20) {
1674 /* decrease volume */
1675 if (vol
> master_vol
)
1677 snd_hda_codec_amp_stereo(codec
, 0x1A, HDA_INPUT
,
1681 /* increase volume */
1682 snd_hda_codec_amp_stereo(codec
, 0x1A, HDA_INPUT
, 0,
1684 ((master_vol
+vol
) > 0x2A) ? 0x2A :
1687 } else if (!(gpio_data
& 0x02)) {
1689 snd_hda_codec_amp_stereo(codec
,
1690 spec
->autocfg
.line_out_pins
[0],
1691 HDA_OUTPUT
, 0, HDA_AMP_MUTE
,
1696 /* mute Internal-Speaker if HP is plugged */
1697 static void via_speaker_automute(struct hda_codec
*codec
)
1699 unsigned int hp_present
;
1700 struct via_spec
*spec
= codec
->spec
;
1702 if (!VT2002P_COMPATIBLE(spec
))
1705 hp_present
= snd_hda_jack_detect(codec
, spec
->autocfg
.hp_pins
[0]);
1707 if (!spec
->hp_independent_mode
) {
1708 struct snd_ctl_elem_id id
;
1709 snd_hda_codec_amp_stereo(
1710 codec
, spec
->autocfg
.speaker_pins
[0], HDA_OUTPUT
, 0,
1711 HDA_AMP_MUTE
, hp_present
? HDA_AMP_MUTE
: 0);
1713 memset(&id
, 0, sizeof(id
));
1714 id
.iface
= SNDRV_CTL_ELEM_IFACE_MIXER
;
1715 strcpy(id
.name
, "Speaker Playback Switch");
1716 snd_ctl_notify(codec
->bus
->card
, SNDRV_CTL_EVENT_MASK_VALUE
,
1721 /* mute line-out and internal speaker if HP is plugged */
1722 static void via_hp_bind_automute(struct hda_codec
*codec
)
1724 /* use long instead of int below just to avoid an internal compiler
1725 * error with gcc 4.0.x
1727 unsigned long hp_present
, present
= 0;
1728 struct via_spec
*spec
= codec
->spec
;
1731 if (!spec
->autocfg
.hp_pins
[0] || !spec
->autocfg
.line_out_pins
[0])
1734 hp_present
= snd_hda_jack_detect(codec
, spec
->autocfg
.hp_pins
[0]);
1736 present
= snd_hda_jack_detect(codec
, spec
->autocfg
.line_out_pins
[0]);
1738 if (!spec
->hp_independent_mode
) {
1739 /* Mute Line-Outs */
1740 for (i
= 0; i
< spec
->autocfg
.line_outs
; i
++)
1741 snd_hda_codec_amp_stereo(
1742 codec
, spec
->autocfg
.line_out_pins
[i
],
1744 HDA_AMP_MUTE
, hp_present
? HDA_AMP_MUTE
: 0);
1746 present
= hp_present
;
1749 for (i
= 0; i
< spec
->autocfg
.speaker_outs
; i
++)
1750 snd_hda_codec_amp_stereo(
1751 codec
, spec
->autocfg
.speaker_pins
[i
], HDA_OUTPUT
, 0,
1752 HDA_AMP_MUTE
, present
? HDA_AMP_MUTE
: 0);
1756 /* unsolicited event for jack sensing */
1757 static void via_unsol_event(struct hda_codec
*codec
,
1762 if (res
& VIA_JACK_EVENT
)
1763 set_widgets_power_state(codec
);
1765 res
&= ~VIA_JACK_EVENT
;
1767 if (res
== VIA_HP_EVENT
)
1768 via_hp_automute(codec
);
1769 else if (res
== VIA_GPIO_EVENT
)
1770 via_gpio_control(codec
);
1771 else if (res
== VIA_MONO_EVENT
)
1772 via_mono_automute(codec
);
1773 else if (res
== VIA_SPEAKER_EVENT
)
1774 via_speaker_automute(codec
);
1775 else if (res
== VIA_BIND_HP_EVENT
)
1776 via_hp_bind_automute(codec
);
1779 static int via_init(struct hda_codec
*codec
)
1781 struct via_spec
*spec
= codec
->spec
;
1783 for (i
= 0; i
< spec
->num_iverbs
; i
++)
1784 snd_hda_sequence_write(codec
, spec
->init_verbs
[i
]);
1786 /* Lydia Add for EAPD enable */
1787 if (!spec
->dig_in_nid
) { /* No Digital In connection */
1788 if (spec
->dig_in_pin
) {
1789 snd_hda_codec_write(codec
, spec
->dig_in_pin
, 0,
1790 AC_VERB_SET_PIN_WIDGET_CONTROL
,
1792 snd_hda_codec_write(codec
, spec
->dig_in_pin
, 0,
1793 AC_VERB_SET_EAPD_BTLENABLE
, 0x02);
1795 } else /* enable SPDIF-input pin */
1796 snd_hda_codec_write(codec
, spec
->autocfg
.dig_in_pin
, 0,
1797 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
);
1799 /* assign slave outs */
1800 if (spec
->slave_dig_outs
[0])
1801 codec
->slave_dig_outs
= spec
->slave_dig_outs
;
1806 #ifdef SND_HDA_NEEDS_RESUME
1807 static int via_suspend(struct hda_codec
*codec
, pm_message_t state
)
1809 struct via_spec
*spec
= codec
->spec
;
1810 vt1708_stop_hp_work(spec
);
1815 #ifdef CONFIG_SND_HDA_POWER_SAVE
1816 static int via_check_power_status(struct hda_codec
*codec
, hda_nid_t nid
)
1818 struct via_spec
*spec
= codec
->spec
;
1819 return snd_hda_check_amp_list_power(codec
, &spec
->loopback
, nid
);
1825 static const struct hda_codec_ops via_patch_ops
= {
1826 .build_controls
= via_build_controls
,
1827 .build_pcms
= via_build_pcms
,
1830 #ifdef SND_HDA_NEEDS_RESUME
1831 .suspend
= via_suspend
,
1833 #ifdef CONFIG_SND_HDA_POWER_SAVE
1834 .check_power_status
= via_check_power_status
,
1838 /* fill in the dac_nids table from the parsed pin configuration */
1839 static int vt1708_auto_fill_dac_nids(struct via_spec
*spec
,
1840 const struct auto_pin_cfg
*cfg
)
1845 spec
->multiout
.num_dacs
= cfg
->line_outs
;
1847 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
1849 for (i
= 0; i
< 4; i
++) {
1850 nid
= cfg
->line_out_pins
[i
];
1852 /* config dac list */
1854 case AUTO_SEQ_FRONT
:
1855 spec
->private_dac_nids
[i
] = 0x10;
1857 case AUTO_SEQ_CENLFE
:
1858 spec
->private_dac_nids
[i
] = 0x12;
1860 case AUTO_SEQ_SURROUND
:
1861 spec
->private_dac_nids
[i
] = 0x11;
1864 spec
->private_dac_nids
[i
] = 0x13;
1873 /* add playback controls from the parsed DAC table */
1874 static int vt1708_auto_create_multi_out_ctls(struct via_spec
*spec
,
1875 const struct auto_pin_cfg
*cfg
)
1878 static const char * const chname
[4] = {
1879 "Front", "Surround", "C/LFE", "Side"
1881 hda_nid_t nid
, nid_vol
, nid_vols
[] = {0x17, 0x19, 0x1a, 0x1b};
1884 for (i
= 0; i
<= AUTO_SEQ_SIDE
; i
++) {
1885 nid
= cfg
->line_out_pins
[i
];
1890 nid_vol
= nid_vols
[i
];
1892 if (i
== AUTO_SEQ_CENLFE
) {
1894 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
1895 "Center Playback Volume",
1896 HDA_COMPOSE_AMP_VAL(nid_vol
, 1, 0,
1900 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
1901 "LFE Playback Volume",
1902 HDA_COMPOSE_AMP_VAL(nid_vol
, 2, 0,
1906 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
1907 "Center Playback Switch",
1908 HDA_COMPOSE_AMP_VAL(nid_vol
, 1, 0,
1912 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
1913 "LFE Playback Switch",
1914 HDA_COMPOSE_AMP_VAL(nid_vol
, 2, 0,
1918 } else if (i
== AUTO_SEQ_FRONT
) {
1919 /* add control to mixer index 0 */
1920 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
1921 "Master Front Playback Volume",
1922 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0,
1926 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
1927 "Master Front Playback Switch",
1928 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0,
1933 /* add control to PW3 */
1934 sprintf(name
, "%s Playback Volume", chname
[i
]);
1935 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
, name
,
1936 HDA_COMPOSE_AMP_VAL(nid
, 3, 0,
1940 sprintf(name
, "%s Playback Switch", chname
[i
]);
1941 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
, name
,
1942 HDA_COMPOSE_AMP_VAL(nid
, 3, 0,
1947 sprintf(name
, "%s Playback Volume", chname
[i
]);
1948 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
, name
,
1949 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0,
1953 sprintf(name
, "%s Playback Switch", chname
[i
]);
1954 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
, name
,
1955 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0,
1965 static void create_hp_imux(struct via_spec
*spec
)
1968 struct hda_input_mux
*imux
= &spec
->private_imux
[1];
1969 static const char * const texts
[] = { "OFF", "ON", NULL
};
1971 /* for hp mode select */
1972 for (i
= 0; texts
[i
]; i
++)
1973 snd_hda_add_imux_item(imux
, texts
[i
], i
, NULL
);
1975 spec
->hp_mux
= &spec
->private_imux
[1];
1978 static int vt1708_auto_create_hp_ctls(struct via_spec
*spec
, hda_nid_t pin
)
1985 spec
->multiout
.hp_nid
= VT1708_HP_NID
; /* AOW3 */
1986 spec
->hp_independent_mode_index
= 1;
1988 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
1989 "Headphone Playback Volume",
1990 HDA_COMPOSE_AMP_VAL(pin
, 3, 0, HDA_OUTPUT
));
1993 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
1994 "Headphone Playback Switch",
1995 HDA_COMPOSE_AMP_VAL(pin
, 3, 0, HDA_OUTPUT
));
1999 create_hp_imux(spec
);
2004 /* create playback/capture controls for input pins */
2005 static int vt_auto_create_analog_input_ctls(struct hda_codec
*codec
,
2006 const struct auto_pin_cfg
*cfg
,
2008 const hda_nid_t pin_idxs
[],
2011 struct via_spec
*spec
= codec
->spec
;
2012 struct hda_input_mux
*imux
= &spec
->private_imux
[0];
2013 int i
, err
, idx
, type
, type_idx
= 0;
2015 /* for internal loopback recording select */
2016 for (idx
= 0; idx
< num_idxs
; idx
++) {
2017 if (pin_idxs
[idx
] == 0xff) {
2018 snd_hda_add_imux_item(imux
, "Stereo Mixer", idx
, NULL
);
2023 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
2025 type
= cfg
->inputs
[i
].type
;
2026 for (idx
= 0; idx
< num_idxs
; idx
++)
2027 if (pin_idxs
[idx
] == cfg
->inputs
[i
].pin
)
2029 if (idx
>= num_idxs
)
2031 if (i
> 0 && type
== cfg
->inputs
[i
- 1].type
)
2035 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
2036 if (spec
->codec_type
== VT1708S
||
2037 spec
->codec_type
== VT1702
||
2038 spec
->codec_type
== VT1716S
)
2039 err
= via_new_analog_input(spec
, label
, type_idx
,
2042 err
= via_new_analog_input(spec
, label
, type_idx
,
2046 snd_hda_add_imux_item(imux
, label
, idx
, NULL
);
2051 /* create playback/capture controls for input pins */
2052 static int vt1708_auto_create_analog_input_ctls(struct hda_codec
*codec
,
2053 const struct auto_pin_cfg
*cfg
)
2055 static const hda_nid_t pin_idxs
[] = { 0xff, 0x24, 0x1d, 0x1e, 0x21 };
2056 return vt_auto_create_analog_input_ctls(codec
, cfg
, 0x17, pin_idxs
,
2057 ARRAY_SIZE(pin_idxs
));
2060 #ifdef CONFIG_SND_HDA_POWER_SAVE
2061 static const struct hda_amp_list vt1708_loopbacks
[] = {
2062 { 0x17, HDA_INPUT
, 1 },
2063 { 0x17, HDA_INPUT
, 2 },
2064 { 0x17, HDA_INPUT
, 3 },
2065 { 0x17, HDA_INPUT
, 4 },
2070 static void vt1708_set_pinconfig_connect(struct hda_codec
*codec
, hda_nid_t nid
)
2072 unsigned int def_conf
;
2073 unsigned char seqassoc
;
2075 def_conf
= snd_hda_codec_get_pincfg(codec
, nid
);
2076 seqassoc
= (unsigned char) get_defcfg_association(def_conf
);
2077 seqassoc
= (seqassoc
<< 4) | get_defcfg_sequence(def_conf
);
2078 if (get_defcfg_connect(def_conf
) == AC_JACK_PORT_NONE
2079 && (seqassoc
== 0xf0 || seqassoc
== 0xff)) {
2080 def_conf
= def_conf
& (~(AC_JACK_PORT_BOTH
<< 30));
2081 snd_hda_codec_set_pincfg(codec
, nid
, def_conf
);
2087 static int vt1708_jack_detectect_get(struct snd_kcontrol
*kcontrol
,
2088 struct snd_ctl_elem_value
*ucontrol
)
2090 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2091 struct via_spec
*spec
= codec
->spec
;
2093 if (spec
->codec_type
!= VT1708
)
2095 spec
->vt1708_jack_detectect
=
2096 !((snd_hda_codec_read(codec
, 0x1, 0, 0xf84, 0) >> 8) & 0x1);
2097 ucontrol
->value
.integer
.value
[0] = spec
->vt1708_jack_detectect
;
2101 static int vt1708_jack_detectect_put(struct snd_kcontrol
*kcontrol
,
2102 struct snd_ctl_elem_value
*ucontrol
)
2104 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2105 struct via_spec
*spec
= codec
->spec
;
2108 if (spec
->codec_type
!= VT1708
)
2110 spec
->vt1708_jack_detectect
= ucontrol
->value
.integer
.value
[0];
2111 change
= (0x1 & (snd_hda_codec_read(codec
, 0x1, 0, 0xf84, 0) >> 8))
2112 == !spec
->vt1708_jack_detectect
;
2113 if (spec
->vt1708_jack_detectect
) {
2114 mute_aa_path(codec
, 1);
2115 notify_aa_path_ctls(codec
);
2120 static const struct snd_kcontrol_new vt1708_jack_detectect
[] = {
2122 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2123 .name
= "Jack Detect",
2125 .info
= snd_ctl_boolean_mono_info
,
2126 .get
= vt1708_jack_detectect_get
,
2127 .put
= vt1708_jack_detectect_put
,
2132 static int vt1708_parse_auto_config(struct hda_codec
*codec
)
2134 struct via_spec
*spec
= codec
->spec
;
2137 /* Add HP and CD pin config connect bit re-config action */
2138 vt1708_set_pinconfig_connect(codec
, VT1708_HP_PIN_NID
);
2139 vt1708_set_pinconfig_connect(codec
, VT1708_CD_PIN_NID
);
2141 err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
);
2144 err
= vt1708_auto_fill_dac_nids(spec
, &spec
->autocfg
);
2147 if (!spec
->autocfg
.line_outs
&& !spec
->autocfg
.hp_pins
[0])
2148 return 0; /* can't find valid BIOS pin config */
2150 err
= vt1708_auto_create_multi_out_ctls(spec
, &spec
->autocfg
);
2153 err
= vt1708_auto_create_hp_ctls(spec
, spec
->autocfg
.hp_pins
[0]);
2156 err
= vt1708_auto_create_analog_input_ctls(codec
, &spec
->autocfg
);
2159 /* add jack detect on/off control */
2160 err
= snd_hda_add_new_ctls(codec
, vt1708_jack_detectect
);
2164 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
2166 if (spec
->autocfg
.dig_outs
)
2167 spec
->multiout
.dig_out_nid
= VT1708_DIGOUT_NID
;
2168 spec
->dig_in_pin
= VT1708_DIGIN_PIN
;
2169 if (spec
->autocfg
.dig_in_pin
)
2170 spec
->dig_in_nid
= VT1708_DIGIN_NID
;
2172 if (spec
->kctls
.list
)
2173 spec
->mixers
[spec
->num_mixers
++] = spec
->kctls
.list
;
2175 spec
->init_verbs
[spec
->num_iverbs
++] = vt1708_volume_init_verbs
;
2177 spec
->input_mux
= &spec
->private_imux
[0];
2180 via_hp_build(codec
);
2182 via_smart51_build(spec
);
2186 /* init callback for auto-configuration model -- overriding the default init */
2187 static int via_auto_init(struct hda_codec
*codec
)
2189 struct via_spec
*spec
= codec
->spec
;
2192 via_auto_init_multi_out(codec
);
2193 via_auto_init_hp_out(codec
);
2194 via_auto_init_analog_input(codec
);
2196 if (VT2002P_COMPATIBLE(spec
)) {
2197 via_hp_bind_automute(codec
);
2199 via_hp_automute(codec
);
2200 via_speaker_automute(codec
);
2206 static void vt1708_update_hp_jack_state(struct work_struct
*work
)
2208 struct via_spec
*spec
= container_of(work
, struct via_spec
,
2209 vt1708_hp_work
.work
);
2210 if (spec
->codec_type
!= VT1708
)
2212 /* if jack state toggled */
2213 if (spec
->vt1708_hp_present
2214 != snd_hda_jack_detect(spec
->codec
, spec
->autocfg
.hp_pins
[0])) {
2215 spec
->vt1708_hp_present
^= 1;
2216 via_hp_automute(spec
->codec
);
2218 vt1708_start_hp_work(spec
);
2221 static int get_mux_nids(struct hda_codec
*codec
)
2223 struct via_spec
*spec
= codec
->spec
;
2224 hda_nid_t nid
, conn
[8];
2228 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
2229 nid
= spec
->adc_nids
[i
];
2231 type
= get_wcaps_type(get_wcaps(codec
, nid
));
2232 if (type
== AC_WID_PIN
)
2234 n
= snd_hda_get_connections(codec
, nid
, conn
,
2239 spec
->mux_nids
[i
] = nid
;
2248 static int patch_vt1708(struct hda_codec
*codec
)
2250 struct via_spec
*spec
;
2253 /* create a codec specific record */
2254 spec
= via_new_spec(codec
);
2258 /* automatic parse from the BIOS config */
2259 err
= vt1708_parse_auto_config(codec
);
2264 printk(KERN_INFO
"hda_codec: Cannot set up configuration "
2265 "from BIOS. Using genenic mode...\n");
2269 spec
->stream_name_analog
= "VT1708 Analog";
2270 spec
->stream_analog_playback
= &vt1708_pcm_analog_playback
;
2271 /* disable 32bit format on VT1708 */
2272 if (codec
->vendor_id
== 0x11061708)
2273 spec
->stream_analog_playback
= &vt1708_pcm_analog_s16_playback
;
2274 spec
->stream_analog_capture
= &vt1708_pcm_analog_capture
;
2276 spec
->stream_name_digital
= "VT1708 Digital";
2277 spec
->stream_digital_playback
= &vt1708_pcm_digital_playback
;
2278 spec
->stream_digital_capture
= &vt1708_pcm_digital_capture
;
2281 if (!spec
->adc_nids
&& spec
->input_mux
) {
2282 spec
->adc_nids
= vt1708_adc_nids
;
2283 spec
->num_adc_nids
= ARRAY_SIZE(vt1708_adc_nids
);
2284 get_mux_nids(codec
);
2285 spec
->mixers
[spec
->num_mixers
] = vt1708_capture_mixer
;
2289 codec
->patch_ops
= via_patch_ops
;
2291 codec
->patch_ops
.init
= via_auto_init
;
2292 #ifdef CONFIG_SND_HDA_POWER_SAVE
2293 spec
->loopback
.amplist
= vt1708_loopbacks
;
2295 INIT_DELAYED_WORK(&spec
->vt1708_hp_work
, vt1708_update_hp_jack_state
);
2299 /* capture mixer elements */
2300 static const struct snd_kcontrol_new vt1709_capture_mixer
[] = {
2301 HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x0, HDA_INPUT
),
2302 HDA_CODEC_MUTE("Capture Switch", 0x14, 0x0, HDA_INPUT
),
2303 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x15, 0x0, HDA_INPUT
),
2304 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x15, 0x0, HDA_INPUT
),
2305 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x16, 0x0, HDA_INPUT
),
2306 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x16, 0x0, HDA_INPUT
),
2308 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2309 /* The multiple "Capture Source" controls confuse alsamixer
2310 * So call somewhat different..
2312 /* .name = "Capture Source", */
2313 .name
= "Input Source",
2315 .info
= via_mux_enum_info
,
2316 .get
= via_mux_enum_get
,
2317 .put
= via_mux_enum_put
,
2322 static const struct hda_verb vt1709_uniwill_init_verbs
[] = {
2323 {0x20, AC_VERB_SET_UNSOLICITED_ENABLE
,
2324 AC_USRSP_EN
| VIA_HP_EVENT
| VIA_JACK_EVENT
},
2329 * generic initialization of ADC, input mixers and output mixers
2331 static const struct hda_verb vt1709_10ch_volume_init_verbs
[] = {
2333 * Unmute ADC0-2 and set the default input to mic-in
2335 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2336 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2337 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2340 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2343 /* Amp Indices: AOW0=0, CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */
2344 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2345 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
2346 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2)},
2347 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(3)},
2348 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(4)},
2351 * Set up output selector (0x1a, 0x1b, 0x29)
2353 /* set vol=0 to output mixers */
2354 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2355 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2356 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2359 * Unmute PW3 and PW4
2361 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2362 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2364 /* Set input of PW4 as MW0 */
2365 {0x20, AC_VERB_SET_CONNECT_SEL
, 0},
2366 /* PW9 Output enable */
2367 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40},
2371 static const struct hda_pcm_stream vt1709_10ch_pcm_analog_playback
= {
2375 .nid
= 0x10, /* NID to query formats and rates */
2377 .open
= via_playback_pcm_open
,
2378 .prepare
= via_playback_multi_pcm_prepare
,
2379 .cleanup
= via_playback_multi_pcm_cleanup
,
2383 static const struct hda_pcm_stream vt1709_6ch_pcm_analog_playback
= {
2387 .nid
= 0x10, /* NID to query formats and rates */
2389 .open
= via_playback_pcm_open
,
2390 .prepare
= via_playback_multi_pcm_prepare
,
2391 .cleanup
= via_playback_multi_pcm_cleanup
,
2395 static const struct hda_pcm_stream vt1709_pcm_analog_capture
= {
2399 .nid
= 0x14, /* NID to query formats and rates */
2401 .prepare
= via_capture_pcm_prepare
,
2402 .cleanup
= via_capture_pcm_cleanup
2406 static const struct hda_pcm_stream vt1709_pcm_digital_playback
= {
2410 /* NID is set in via_build_pcms */
2412 .open
= via_dig_playback_pcm_open
,
2413 .close
= via_dig_playback_pcm_close
2417 static const struct hda_pcm_stream vt1709_pcm_digital_capture
= {
2423 static int vt1709_auto_fill_dac_nids(struct via_spec
*spec
,
2424 const struct auto_pin_cfg
*cfg
)
2429 if (cfg
->line_outs
== 4) /* 10 channels */
2430 spec
->multiout
.num_dacs
= cfg
->line_outs
+1; /* AOW0~AOW4 */
2431 else if (cfg
->line_outs
== 3) /* 6 channels */
2432 spec
->multiout
.num_dacs
= cfg
->line_outs
; /* AOW0~AOW2 */
2434 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
2436 if (cfg
->line_outs
== 4) { /* 10 channels */
2437 for (i
= 0; i
< cfg
->line_outs
; i
++) {
2438 nid
= cfg
->line_out_pins
[i
];
2440 /* config dac list */
2442 case AUTO_SEQ_FRONT
:
2444 spec
->private_dac_nids
[i
] = 0x10;
2446 case AUTO_SEQ_CENLFE
:
2448 spec
->private_dac_nids
[i
] = 0x12;
2450 case AUTO_SEQ_SURROUND
:
2452 spec
->private_dac_nids
[i
] = 0x11;
2456 spec
->private_dac_nids
[i
] = 0x27;
2463 spec
->private_dac_nids
[cfg
->line_outs
] = 0x28; /* AOW4 */
2465 } else if (cfg
->line_outs
== 3) { /* 6 channels */
2466 for (i
= 0; i
< cfg
->line_outs
; i
++) {
2467 nid
= cfg
->line_out_pins
[i
];
2469 /* config dac list */
2471 case AUTO_SEQ_FRONT
:
2473 spec
->private_dac_nids
[i
] = 0x10;
2475 case AUTO_SEQ_CENLFE
:
2477 spec
->private_dac_nids
[i
] = 0x12;
2479 case AUTO_SEQ_SURROUND
:
2481 spec
->private_dac_nids
[i
] = 0x11;
2493 /* add playback controls from the parsed DAC table */
2494 static int vt1709_auto_create_multi_out_ctls(struct via_spec
*spec
,
2495 const struct auto_pin_cfg
*cfg
)
2498 static const char * const chname
[4] = {
2499 "Front", "Surround", "C/LFE", "Side"
2501 hda_nid_t nid
, nid_vol
, nid_vols
[] = {0x18, 0x1a, 0x1b, 0x29};
2504 for (i
= 0; i
<= AUTO_SEQ_SIDE
; i
++) {
2505 nid
= cfg
->line_out_pins
[i
];
2510 nid_vol
= nid_vols
[i
];
2512 if (i
== AUTO_SEQ_CENLFE
) {
2514 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
2515 "Center Playback Volume",
2516 HDA_COMPOSE_AMP_VAL(nid_vol
, 1, 0,
2520 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
2521 "LFE Playback Volume",
2522 HDA_COMPOSE_AMP_VAL(nid_vol
, 2, 0,
2526 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
2527 "Center Playback Switch",
2528 HDA_COMPOSE_AMP_VAL(nid_vol
, 1, 0,
2532 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
2533 "LFE Playback Switch",
2534 HDA_COMPOSE_AMP_VAL(nid_vol
, 2, 0,
2538 } else if (i
== AUTO_SEQ_FRONT
) {
2539 /* ADD control to mixer index 0 */
2540 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
2541 "Master Front Playback Volume",
2542 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0,
2546 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
2547 "Master Front Playback Switch",
2548 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0,
2553 /* add control to PW3 */
2554 sprintf(name
, "%s Playback Volume", chname
[i
]);
2555 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
, name
,
2556 HDA_COMPOSE_AMP_VAL(nid
, 3, 0,
2560 sprintf(name
, "%s Playback Switch", chname
[i
]);
2561 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
, name
,
2562 HDA_COMPOSE_AMP_VAL(nid
, 3, 0,
2566 } else if (i
== AUTO_SEQ_SURROUND
) {
2567 sprintf(name
, "%s Playback Volume", chname
[i
]);
2568 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
, name
,
2569 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0,
2573 sprintf(name
, "%s Playback Switch", chname
[i
]);
2574 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
, name
,
2575 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0,
2579 } else if (i
== AUTO_SEQ_SIDE
) {
2580 sprintf(name
, "%s Playback Volume", chname
[i
]);
2581 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
, name
,
2582 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0,
2586 sprintf(name
, "%s Playback Switch", chname
[i
]);
2587 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
, name
,
2588 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0,
2598 static int vt1709_auto_create_hp_ctls(struct via_spec
*spec
, hda_nid_t pin
)
2605 if (spec
->multiout
.num_dacs
== 5) /* 10 channels */
2606 spec
->multiout
.hp_nid
= VT1709_HP_DAC_NID
;
2607 else if (spec
->multiout
.num_dacs
== 3) /* 6 channels */
2608 spec
->multiout
.hp_nid
= 0;
2609 spec
->hp_independent_mode_index
= 1;
2611 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
2612 "Headphone Playback Volume",
2613 HDA_COMPOSE_AMP_VAL(pin
, 3, 0, HDA_OUTPUT
));
2616 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
2617 "Headphone Playback Switch",
2618 HDA_COMPOSE_AMP_VAL(pin
, 3, 0, HDA_OUTPUT
));
2625 /* create playback/capture controls for input pins */
2626 static int vt1709_auto_create_analog_input_ctls(struct hda_codec
*codec
,
2627 const struct auto_pin_cfg
*cfg
)
2629 static const hda_nid_t pin_idxs
[] = { 0xff, 0x23, 0x1d, 0x1e, 0x21 };
2630 return vt_auto_create_analog_input_ctls(codec
, cfg
, 0x18, pin_idxs
,
2631 ARRAY_SIZE(pin_idxs
));
2634 static int vt1709_parse_auto_config(struct hda_codec
*codec
)
2636 struct via_spec
*spec
= codec
->spec
;
2639 err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
);
2642 err
= vt1709_auto_fill_dac_nids(spec
, &spec
->autocfg
);
2645 if (!spec
->autocfg
.line_outs
&& !spec
->autocfg
.hp_pins
[0])
2646 return 0; /* can't find valid BIOS pin config */
2648 err
= vt1709_auto_create_multi_out_ctls(spec
, &spec
->autocfg
);
2651 err
= vt1709_auto_create_hp_ctls(spec
, spec
->autocfg
.hp_pins
[0]);
2654 err
= vt1709_auto_create_analog_input_ctls(codec
, &spec
->autocfg
);
2658 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
2660 if (spec
->autocfg
.dig_outs
)
2661 spec
->multiout
.dig_out_nid
= VT1709_DIGOUT_NID
;
2662 spec
->dig_in_pin
= VT1709_DIGIN_PIN
;
2663 if (spec
->autocfg
.dig_in_pin
)
2664 spec
->dig_in_nid
= VT1709_DIGIN_NID
;
2666 if (spec
->kctls
.list
)
2667 spec
->mixers
[spec
->num_mixers
++] = spec
->kctls
.list
;
2669 spec
->input_mux
= &spec
->private_imux
[0];
2672 via_hp_build(codec
);
2674 via_smart51_build(spec
);
2678 #ifdef CONFIG_SND_HDA_POWER_SAVE
2679 static const struct hda_amp_list vt1709_loopbacks
[] = {
2680 { 0x18, HDA_INPUT
, 1 },
2681 { 0x18, HDA_INPUT
, 2 },
2682 { 0x18, HDA_INPUT
, 3 },
2683 { 0x18, HDA_INPUT
, 4 },
2688 static int patch_vt1709_10ch(struct hda_codec
*codec
)
2690 struct via_spec
*spec
;
2693 /* create a codec specific record */
2694 spec
= via_new_spec(codec
);
2698 err
= vt1709_parse_auto_config(codec
);
2703 printk(KERN_INFO
"hda_codec: Cannot set up configuration. "
2704 "Using genenic mode...\n");
2707 spec
->init_verbs
[spec
->num_iverbs
++] = vt1709_10ch_volume_init_verbs
;
2708 spec
->init_verbs
[spec
->num_iverbs
++] = vt1709_uniwill_init_verbs
;
2710 spec
->stream_name_analog
= "VT1709 Analog";
2711 spec
->stream_analog_playback
= &vt1709_10ch_pcm_analog_playback
;
2712 spec
->stream_analog_capture
= &vt1709_pcm_analog_capture
;
2714 spec
->stream_name_digital
= "VT1709 Digital";
2715 spec
->stream_digital_playback
= &vt1709_pcm_digital_playback
;
2716 spec
->stream_digital_capture
= &vt1709_pcm_digital_capture
;
2719 if (!spec
->adc_nids
&& spec
->input_mux
) {
2720 spec
->adc_nids
= vt1709_adc_nids
;
2721 spec
->num_adc_nids
= ARRAY_SIZE(vt1709_adc_nids
);
2722 get_mux_nids(codec
);
2723 spec
->mixers
[spec
->num_mixers
] = vt1709_capture_mixer
;
2727 codec
->patch_ops
= via_patch_ops
;
2729 codec
->patch_ops
.init
= via_auto_init
;
2730 codec
->patch_ops
.unsol_event
= via_unsol_event
;
2731 #ifdef CONFIG_SND_HDA_POWER_SAVE
2732 spec
->loopback
.amplist
= vt1709_loopbacks
;
2738 * generic initialization of ADC, input mixers and output mixers
2740 static const struct hda_verb vt1709_6ch_volume_init_verbs
[] = {
2742 * Unmute ADC0-2 and set the default input to mic-in
2744 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2745 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2746 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2749 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2752 /* Amp Indices: AOW0=0, CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */
2753 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2754 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
2755 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2)},
2756 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(3)},
2757 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(4)},
2760 * Set up output selector (0x1a, 0x1b, 0x29)
2762 /* set vol=0 to output mixers */
2763 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2764 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2765 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2768 * Unmute PW3 and PW4
2770 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2771 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2773 /* Set input of PW4 as MW0 */
2774 {0x20, AC_VERB_SET_CONNECT_SEL
, 0},
2775 /* PW9 Output enable */
2776 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40},
2780 static int patch_vt1709_6ch(struct hda_codec
*codec
)
2782 struct via_spec
*spec
;
2785 /* create a codec specific record */
2786 spec
= via_new_spec(codec
);
2790 err
= vt1709_parse_auto_config(codec
);
2795 printk(KERN_INFO
"hda_codec: Cannot set up configuration. "
2796 "Using genenic mode...\n");
2799 spec
->init_verbs
[spec
->num_iverbs
++] = vt1709_6ch_volume_init_verbs
;
2800 spec
->init_verbs
[spec
->num_iverbs
++] = vt1709_uniwill_init_verbs
;
2802 spec
->stream_name_analog
= "VT1709 Analog";
2803 spec
->stream_analog_playback
= &vt1709_6ch_pcm_analog_playback
;
2804 spec
->stream_analog_capture
= &vt1709_pcm_analog_capture
;
2806 spec
->stream_name_digital
= "VT1709 Digital";
2807 spec
->stream_digital_playback
= &vt1709_pcm_digital_playback
;
2808 spec
->stream_digital_capture
= &vt1709_pcm_digital_capture
;
2811 if (!spec
->adc_nids
&& spec
->input_mux
) {
2812 spec
->adc_nids
= vt1709_adc_nids
;
2813 spec
->num_adc_nids
= ARRAY_SIZE(vt1709_adc_nids
);
2814 get_mux_nids(codec
);
2815 spec
->mixers
[spec
->num_mixers
] = vt1709_capture_mixer
;
2819 codec
->patch_ops
= via_patch_ops
;
2821 codec
->patch_ops
.init
= via_auto_init
;
2822 codec
->patch_ops
.unsol_event
= via_unsol_event
;
2823 #ifdef CONFIG_SND_HDA_POWER_SAVE
2824 spec
->loopback
.amplist
= vt1709_loopbacks
;
2829 /* capture mixer elements */
2830 static const struct snd_kcontrol_new vt1708B_capture_mixer
[] = {
2831 HDA_CODEC_VOLUME("Capture Volume", 0x13, 0x0, HDA_INPUT
),
2832 HDA_CODEC_MUTE("Capture Switch", 0x13, 0x0, HDA_INPUT
),
2833 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x14, 0x0, HDA_INPUT
),
2834 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x14, 0x0, HDA_INPUT
),
2836 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2837 /* The multiple "Capture Source" controls confuse alsamixer
2838 * So call somewhat different..
2840 /* .name = "Capture Source", */
2841 .name
= "Input Source",
2843 .info
= via_mux_enum_info
,
2844 .get
= via_mux_enum_get
,
2845 .put
= via_mux_enum_put
,
2850 * generic initialization of ADC, input mixers and output mixers
2852 static const struct hda_verb vt1708B_8ch_volume_init_verbs
[] = {
2854 * Unmute ADC0-1 and set the default input to mic-in
2856 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2857 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2860 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2863 /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */
2864 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2865 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
2866 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2)},
2867 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(3)},
2868 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(4)},
2871 * Set up output mixers
2873 /* set vol=0 to output mixers */
2874 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2875 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2876 {0x27, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2878 /* Setup default input to PW4 */
2879 {0x1d, AC_VERB_SET_CONNECT_SEL
, 0},
2880 /* PW9 Output enable */
2881 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40},
2882 /* PW10 Input enable */
2883 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20},
2887 static const struct hda_verb vt1708B_4ch_volume_init_verbs
[] = {
2889 * Unmute ADC0-1 and set the default input to mic-in
2891 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2892 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2895 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2898 /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */
2899 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2900 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
2901 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2)},
2902 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(3)},
2903 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(4)},
2906 * Set up output mixers
2908 /* set vol=0 to output mixers */
2909 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2910 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2911 {0x27, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2913 /* Setup default input of PW4 to MW0 */
2914 {0x1d, AC_VERB_SET_CONNECT_SEL
, 0x0},
2915 /* PW9 Output enable */
2916 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40},
2917 /* PW10 Input enable */
2918 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20},
2922 static const struct hda_verb vt1708B_uniwill_init_verbs
[] = {
2923 {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE
,
2924 AC_USRSP_EN
| VIA_HP_EVENT
| VIA_JACK_EVENT
},
2925 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
2926 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
2927 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
2928 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
2929 {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
2930 {0x22, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
2931 {0x23, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
2935 static int via_pcm_open_close(struct hda_pcm_stream
*hinfo
,
2936 struct hda_codec
*codec
,
2937 struct snd_pcm_substream
*substream
)
2939 int idle
= substream
->pstr
->substream_opened
== 1
2940 && substream
->ref_count
== 0;
2942 analog_low_current_mode(codec
, idle
);
2946 static const struct hda_pcm_stream vt1708B_8ch_pcm_analog_playback
= {
2950 .nid
= 0x10, /* NID to query formats and rates */
2952 .open
= via_playback_pcm_open
,
2953 .prepare
= via_playback_multi_pcm_prepare
,
2954 .cleanup
= via_playback_multi_pcm_cleanup
,
2955 .close
= via_pcm_open_close
2959 static const struct hda_pcm_stream vt1708B_4ch_pcm_analog_playback
= {
2963 .nid
= 0x10, /* NID to query formats and rates */
2965 .open
= via_playback_pcm_open
,
2966 .prepare
= via_playback_multi_pcm_prepare
,
2967 .cleanup
= via_playback_multi_pcm_cleanup
2971 static const struct hda_pcm_stream vt1708B_pcm_analog_capture
= {
2975 .nid
= 0x13, /* NID to query formats and rates */
2977 .open
= via_pcm_open_close
,
2978 .prepare
= via_capture_pcm_prepare
,
2979 .cleanup
= via_capture_pcm_cleanup
,
2980 .close
= via_pcm_open_close
2984 static const struct hda_pcm_stream vt1708B_pcm_digital_playback
= {
2988 /* NID is set in via_build_pcms */
2990 .open
= via_dig_playback_pcm_open
,
2991 .close
= via_dig_playback_pcm_close
,
2992 .prepare
= via_dig_playback_pcm_prepare
,
2993 .cleanup
= via_dig_playback_pcm_cleanup
2997 static const struct hda_pcm_stream vt1708B_pcm_digital_capture
= {
3003 /* fill in the dac_nids table from the parsed pin configuration */
3004 static int vt1708B_auto_fill_dac_nids(struct via_spec
*spec
,
3005 const struct auto_pin_cfg
*cfg
)
3010 spec
->multiout
.num_dacs
= cfg
->line_outs
;
3012 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
3014 for (i
= 0; i
< 4; i
++) {
3015 nid
= cfg
->line_out_pins
[i
];
3017 /* config dac list */
3019 case AUTO_SEQ_FRONT
:
3020 spec
->private_dac_nids
[i
] = 0x10;
3022 case AUTO_SEQ_CENLFE
:
3023 spec
->private_dac_nids
[i
] = 0x24;
3025 case AUTO_SEQ_SURROUND
:
3026 spec
->private_dac_nids
[i
] = 0x11;
3029 spec
->private_dac_nids
[i
] = 0x25;
3038 /* add playback controls from the parsed DAC table */
3039 static int vt1708B_auto_create_multi_out_ctls(struct via_spec
*spec
,
3040 const struct auto_pin_cfg
*cfg
)
3043 static const char * const chname
[4] = {
3044 "Front", "Surround", "C/LFE", "Side"
3046 hda_nid_t nid_vols
[] = {0x16, 0x18, 0x26, 0x27};
3047 hda_nid_t nid
, nid_vol
= 0;
3050 for (i
= 0; i
<= AUTO_SEQ_SIDE
; i
++) {
3051 nid
= cfg
->line_out_pins
[i
];
3056 nid_vol
= nid_vols
[i
];
3058 if (i
== AUTO_SEQ_CENLFE
) {
3060 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
3061 "Center Playback Volume",
3062 HDA_COMPOSE_AMP_VAL(nid_vol
, 1, 0,
3066 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
3067 "LFE Playback Volume",
3068 HDA_COMPOSE_AMP_VAL(nid_vol
, 2, 0,
3072 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
3073 "Center Playback Switch",
3074 HDA_COMPOSE_AMP_VAL(nid_vol
, 1, 0,
3078 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
3079 "LFE Playback Switch",
3080 HDA_COMPOSE_AMP_VAL(nid_vol
, 2, 0,
3084 } else if (i
== AUTO_SEQ_FRONT
) {
3085 /* add control to mixer index 0 */
3086 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
3087 "Master Front Playback Volume",
3088 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0,
3092 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
3093 "Master Front Playback Switch",
3094 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0,
3099 /* add control to PW3 */
3100 sprintf(name
, "%s Playback Volume", chname
[i
]);
3101 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
, name
,
3102 HDA_COMPOSE_AMP_VAL(nid
, 3, 0,
3106 sprintf(name
, "%s Playback Switch", chname
[i
]);
3107 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
, name
,
3108 HDA_COMPOSE_AMP_VAL(nid
, 3, 0,
3113 sprintf(name
, "%s Playback Volume", chname
[i
]);
3114 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
, name
,
3115 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0,
3119 sprintf(name
, "%s Playback Switch", chname
[i
]);
3120 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
, name
,
3121 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0,
3131 static int vt1708B_auto_create_hp_ctls(struct via_spec
*spec
, hda_nid_t pin
)
3138 spec
->multiout
.hp_nid
= VT1708B_HP_NID
; /* AOW3 */
3139 spec
->hp_independent_mode_index
= 1;
3141 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
3142 "Headphone Playback Volume",
3143 HDA_COMPOSE_AMP_VAL(pin
, 3, 0, HDA_OUTPUT
));
3146 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
3147 "Headphone Playback Switch",
3148 HDA_COMPOSE_AMP_VAL(pin
, 3, 0, HDA_OUTPUT
));
3152 create_hp_imux(spec
);
3157 /* create playback/capture controls for input pins */
3158 static int vt1708B_auto_create_analog_input_ctls(struct hda_codec
*codec
,
3159 const struct auto_pin_cfg
*cfg
)
3161 static const hda_nid_t pin_idxs
[] = { 0xff, 0x1f, 0x1a, 0x1b, 0x1e };
3162 return vt_auto_create_analog_input_ctls(codec
, cfg
, 0x16, pin_idxs
,
3163 ARRAY_SIZE(pin_idxs
));
3166 static int vt1708B_parse_auto_config(struct hda_codec
*codec
)
3168 struct via_spec
*spec
= codec
->spec
;
3171 err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
);
3174 err
= vt1708B_auto_fill_dac_nids(spec
, &spec
->autocfg
);
3177 if (!spec
->autocfg
.line_outs
&& !spec
->autocfg
.hp_pins
[0])
3178 return 0; /* can't find valid BIOS pin config */
3180 err
= vt1708B_auto_create_multi_out_ctls(spec
, &spec
->autocfg
);
3183 err
= vt1708B_auto_create_hp_ctls(spec
, spec
->autocfg
.hp_pins
[0]);
3186 err
= vt1708B_auto_create_analog_input_ctls(codec
, &spec
->autocfg
);
3190 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
3192 if (spec
->autocfg
.dig_outs
)
3193 spec
->multiout
.dig_out_nid
= VT1708B_DIGOUT_NID
;
3194 spec
->dig_in_pin
= VT1708B_DIGIN_PIN
;
3195 if (spec
->autocfg
.dig_in_pin
)
3196 spec
->dig_in_nid
= VT1708B_DIGIN_NID
;
3198 if (spec
->kctls
.list
)
3199 spec
->mixers
[spec
->num_mixers
++] = spec
->kctls
.list
;
3201 spec
->input_mux
= &spec
->private_imux
[0];
3204 via_hp_build(codec
);
3206 via_smart51_build(spec
);
3210 #ifdef CONFIG_SND_HDA_POWER_SAVE
3211 static const struct hda_amp_list vt1708B_loopbacks
[] = {
3212 { 0x16, HDA_INPUT
, 1 },
3213 { 0x16, HDA_INPUT
, 2 },
3214 { 0x16, HDA_INPUT
, 3 },
3215 { 0x16, HDA_INPUT
, 4 },
3220 static void set_widgets_power_state_vt1708B(struct hda_codec
*codec
)
3222 struct via_spec
*spec
= codec
->spec
;
3226 if ((spec
->codec_type
!= VT1708B_4CH
) &&
3227 (codec
->vendor_id
!= 0x11064397))
3230 /* SW0 (17h) = stereo mixer */
3232 (snd_hda_codec_read(codec
, 0x17, 0, AC_VERB_GET_CONNECT_SEL
, 0x00)
3233 == ((spec
->codec_type
== VT1708S
) ? 5 : 0));
3235 /* PW 1/2/5 (1ah/1bh/1eh) */
3237 set_pin_power_state(codec
, 0x1a, &parm
);
3238 set_pin_power_state(codec
, 0x1b, &parm
);
3239 set_pin_power_state(codec
, 0x1e, &parm
);
3242 /* SW0 (17h), AIW 0/1 (13h/14h) */
3243 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_POWER_STATE
, parm
);
3244 snd_hda_codec_write(codec
, 0x13, 0, AC_VERB_SET_POWER_STATE
, parm
);
3245 snd_hda_codec_write(codec
, 0x14, 0, AC_VERB_SET_POWER_STATE
, parm
);
3248 /* PW0 (19h), SW1 (18h), AOW1 (11h) */
3250 set_pin_power_state(codec
, 0x19, &parm
);
3251 if (spec
->smart51_enabled
)
3252 set_pin_power_state(codec
, 0x1b, &parm
);
3253 snd_hda_codec_write(codec
, 0x18, 0, AC_VERB_SET_POWER_STATE
, parm
);
3254 snd_hda_codec_write(codec
, 0x11, 0, AC_VERB_SET_POWER_STATE
, parm
);
3256 /* PW6 (22h), SW2 (26h), AOW2 (24h) */
3259 set_pin_power_state(codec
, 0x22, &parm
);
3260 if (spec
->smart51_enabled
)
3261 set_pin_power_state(codec
, 0x1a, &parm
);
3262 snd_hda_codec_write(codec
, 0x26, 0,
3263 AC_VERB_SET_POWER_STATE
, parm
);
3264 snd_hda_codec_write(codec
, 0x24, 0,
3265 AC_VERB_SET_POWER_STATE
, parm
);
3266 } else if (codec
->vendor_id
== 0x11064397) {
3267 /* PW7(23h), SW2(27h), AOW2(25h) */
3269 set_pin_power_state(codec
, 0x23, &parm
);
3270 if (spec
->smart51_enabled
)
3271 set_pin_power_state(codec
, 0x1a, &parm
);
3272 snd_hda_codec_write(codec
, 0x27, 0,
3273 AC_VERB_SET_POWER_STATE
, parm
);
3274 snd_hda_codec_write(codec
, 0x25, 0,
3275 AC_VERB_SET_POWER_STATE
, parm
);
3278 /* PW 3/4/7 (1ch/1dh/23h) */
3280 /* force to D0 for internal Speaker */
3281 set_pin_power_state(codec
, 0x1c, &parm
);
3282 set_pin_power_state(codec
, 0x1d, &parm
);
3284 set_pin_power_state(codec
, 0x23, &parm
);
3286 /* MW0 (16h), Sw3 (27h), AOW 0/3 (10h/25h) */
3287 snd_hda_codec_write(codec
, 0x16, 0, AC_VERB_SET_POWER_STATE
,
3288 imux_is_smixer
? AC_PWRST_D0
: parm
);
3289 snd_hda_codec_write(codec
, 0x10, 0, AC_VERB_SET_POWER_STATE
, parm
);
3291 snd_hda_codec_write(codec
, 0x25, 0,
3292 AC_VERB_SET_POWER_STATE
, parm
);
3293 snd_hda_codec_write(codec
, 0x27, 0,
3294 AC_VERB_SET_POWER_STATE
, parm
);
3295 } else if (codec
->vendor_id
== 0x11064397 && spec
->hp_independent_mode
)
3296 snd_hda_codec_write(codec
, 0x25, 0,
3297 AC_VERB_SET_POWER_STATE
, parm
);
3300 static int patch_vt1708S(struct hda_codec
*codec
);
3301 static int patch_vt1708B_8ch(struct hda_codec
*codec
)
3303 struct via_spec
*spec
;
3306 if (get_codec_type(codec
) == VT1708BCE
)
3307 return patch_vt1708S(codec
);
3308 /* create a codec specific record */
3309 spec
= via_new_spec(codec
);
3313 /* automatic parse from the BIOS config */
3314 err
= vt1708B_parse_auto_config(codec
);
3319 printk(KERN_INFO
"hda_codec: Cannot set up configuration "
3320 "from BIOS. Using genenic mode...\n");
3323 spec
->init_verbs
[spec
->num_iverbs
++] = vt1708B_8ch_volume_init_verbs
;
3324 spec
->init_verbs
[spec
->num_iverbs
++] = vt1708B_uniwill_init_verbs
;
3326 spec
->stream_name_analog
= "VT1708B Analog";
3327 spec
->stream_analog_playback
= &vt1708B_8ch_pcm_analog_playback
;
3328 spec
->stream_analog_capture
= &vt1708B_pcm_analog_capture
;
3330 spec
->stream_name_digital
= "VT1708B Digital";
3331 spec
->stream_digital_playback
= &vt1708B_pcm_digital_playback
;
3332 spec
->stream_digital_capture
= &vt1708B_pcm_digital_capture
;
3334 if (!spec
->adc_nids
&& spec
->input_mux
) {
3335 spec
->adc_nids
= vt1708B_adc_nids
;
3336 spec
->num_adc_nids
= ARRAY_SIZE(vt1708B_adc_nids
);
3337 get_mux_nids(codec
);
3338 spec
->mixers
[spec
->num_mixers
] = vt1708B_capture_mixer
;
3342 codec
->patch_ops
= via_patch_ops
;
3344 codec
->patch_ops
.init
= via_auto_init
;
3345 codec
->patch_ops
.unsol_event
= via_unsol_event
;
3346 #ifdef CONFIG_SND_HDA_POWER_SAVE
3347 spec
->loopback
.amplist
= vt1708B_loopbacks
;
3350 spec
->set_widgets_power_state
= set_widgets_power_state_vt1708B
;
3355 static int patch_vt1708B_4ch(struct hda_codec
*codec
)
3357 struct via_spec
*spec
;
3360 /* create a codec specific record */
3361 spec
= via_new_spec(codec
);
3365 /* automatic parse from the BIOS config */
3366 err
= vt1708B_parse_auto_config(codec
);
3371 printk(KERN_INFO
"hda_codec: Cannot set up configuration "
3372 "from BIOS. Using genenic mode...\n");
3375 spec
->init_verbs
[spec
->num_iverbs
++] = vt1708B_4ch_volume_init_verbs
;
3376 spec
->init_verbs
[spec
->num_iverbs
++] = vt1708B_uniwill_init_verbs
;
3378 spec
->stream_name_analog
= "VT1708B Analog";
3379 spec
->stream_analog_playback
= &vt1708B_4ch_pcm_analog_playback
;
3380 spec
->stream_analog_capture
= &vt1708B_pcm_analog_capture
;
3382 spec
->stream_name_digital
= "VT1708B Digital";
3383 spec
->stream_digital_playback
= &vt1708B_pcm_digital_playback
;
3384 spec
->stream_digital_capture
= &vt1708B_pcm_digital_capture
;
3386 if (!spec
->adc_nids
&& spec
->input_mux
) {
3387 spec
->adc_nids
= vt1708B_adc_nids
;
3388 spec
->num_adc_nids
= ARRAY_SIZE(vt1708B_adc_nids
);
3389 get_mux_nids(codec
);
3390 spec
->mixers
[spec
->num_mixers
] = vt1708B_capture_mixer
;
3394 codec
->patch_ops
= via_patch_ops
;
3396 codec
->patch_ops
.init
= via_auto_init
;
3397 codec
->patch_ops
.unsol_event
= via_unsol_event
;
3398 #ifdef CONFIG_SND_HDA_POWER_SAVE
3399 spec
->loopback
.amplist
= vt1708B_loopbacks
;
3402 spec
->set_widgets_power_state
= set_widgets_power_state_vt1708B
;
3407 /* Patch for VT1708S */
3409 /* capture mixer elements */
3410 static const struct snd_kcontrol_new vt1708S_capture_mixer
[] = {
3411 HDA_CODEC_VOLUME("Capture Volume", 0x13, 0x0, HDA_INPUT
),
3412 HDA_CODEC_MUTE("Capture Switch", 0x13, 0x0, HDA_INPUT
),
3413 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x14, 0x0, HDA_INPUT
),
3414 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x14, 0x0, HDA_INPUT
),
3415 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x1A, 0x0, HDA_INPUT
),
3416 HDA_CODEC_VOLUME("Front Mic Boost Capture Volume", 0x1E, 0x0,
3419 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3420 /* The multiple "Capture Source" controls confuse alsamixer
3421 * So call somewhat different..
3423 /* .name = "Capture Source", */
3424 .name
= "Input Source",
3426 .info
= via_mux_enum_info
,
3427 .get
= via_mux_enum_get
,
3428 .put
= via_mux_enum_put
,
3433 static const struct hda_verb vt1708S_volume_init_verbs
[] = {
3434 /* Unmute ADC0-1 and set the default input to mic-in */
3435 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3436 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3438 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the
3439 * analog-loopback mixer widget */
3440 /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */
3441 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3442 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3443 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2)},
3444 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(3)},
3445 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(4)},
3447 /* Setup default input of PW4 to MW0 */
3448 {0x1d, AC_VERB_SET_CONNECT_SEL
, 0x0},
3449 /* PW9, PW10 Output enable */
3450 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40},
3451 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40},
3452 /* Enable Mic Boost Volume backdoor */
3454 /* don't bybass mixer */
3459 static const struct hda_verb vt1708S_uniwill_init_verbs
[] = {
3460 {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE
,
3461 AC_USRSP_EN
| VIA_HP_EVENT
| VIA_JACK_EVENT
},
3462 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
3463 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
3464 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
3465 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
3466 {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
3467 {0x22, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
3468 {0x23, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
3472 static const struct hda_verb vt1705_uniwill_init_verbs
[] = {
3473 {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE
,
3474 AC_USRSP_EN
| VIA_HP_EVENT
| VIA_JACK_EVENT
},
3475 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
3476 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
3477 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
3478 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
3479 {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
3480 {0x23, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
3484 static const struct hda_pcm_stream vt1708S_pcm_analog_playback
= {
3488 .nid
= 0x10, /* NID to query formats and rates */
3490 .open
= via_playback_pcm_open
,
3491 .prepare
= via_playback_multi_pcm_prepare
,
3492 .cleanup
= via_playback_multi_pcm_cleanup
,
3493 .close
= via_pcm_open_close
3497 static const struct hda_pcm_stream vt1705_pcm_analog_playback
= {
3501 .nid
= 0x10, /* NID to query formats and rates */
3503 .open
= via_playback_pcm_open
,
3504 .prepare
= via_playback_multi_pcm_prepare
,
3505 .cleanup
= via_playback_multi_pcm_cleanup
,
3506 .close
= via_pcm_open_close
3510 static const struct hda_pcm_stream vt1708S_pcm_analog_capture
= {
3514 .nid
= 0x13, /* NID to query formats and rates */
3516 .open
= via_pcm_open_close
,
3517 .prepare
= via_capture_pcm_prepare
,
3518 .cleanup
= via_capture_pcm_cleanup
,
3519 .close
= via_pcm_open_close
3523 static const struct hda_pcm_stream vt1708S_pcm_digital_playback
= {
3527 /* NID is set in via_build_pcms */
3529 .open
= via_dig_playback_pcm_open
,
3530 .close
= via_dig_playback_pcm_close
,
3531 .prepare
= via_dig_playback_pcm_prepare
,
3532 .cleanup
= via_dig_playback_pcm_cleanup
3536 /* fill in the dac_nids table from the parsed pin configuration */
3537 static int vt1708S_auto_fill_dac_nids(struct via_spec
*spec
,
3538 const struct auto_pin_cfg
*cfg
)
3543 spec
->multiout
.num_dacs
= cfg
->line_outs
;
3545 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
3547 for (i
= 0; i
< 4; i
++) {
3548 nid
= cfg
->line_out_pins
[i
];
3550 /* config dac list */
3552 case AUTO_SEQ_FRONT
:
3553 spec
->private_dac_nids
[i
] = 0x10;
3555 case AUTO_SEQ_CENLFE
:
3556 if (spec
->codec
->vendor_id
== 0x11064397)
3557 spec
->private_dac_nids
[i
] = 0x25;
3559 spec
->private_dac_nids
[i
] = 0x24;
3561 case AUTO_SEQ_SURROUND
:
3562 spec
->private_dac_nids
[i
] = 0x11;
3565 spec
->private_dac_nids
[i
] = 0x25;
3571 /* for Smart 5.1, line/mic inputs double as output pins */
3572 if (cfg
->line_outs
== 1) {
3573 spec
->multiout
.num_dacs
= 3;
3574 spec
->private_dac_nids
[AUTO_SEQ_SURROUND
] = 0x11;
3575 if (spec
->codec
->vendor_id
== 0x11064397)
3576 spec
->private_dac_nids
[AUTO_SEQ_CENLFE
] = 0x25;
3578 spec
->private_dac_nids
[AUTO_SEQ_CENLFE
] = 0x24;
3584 /* add playback controls from the parsed DAC table */
3585 static int vt1708S_auto_create_multi_out_ctls(struct hda_codec
*codec
,
3586 const struct auto_pin_cfg
*cfg
)
3588 struct via_spec
*spec
= codec
->spec
;
3590 static const char * const chname
[4] = {
3591 "Front", "Surround", "C/LFE", "Side"
3593 hda_nid_t nid_vols
[2][4] = { {0x10, 0x11, 0x24, 0x25},
3594 {0x10, 0x11, 0x25, 0} };
3595 hda_nid_t nid_mutes
[2][4] = { {0x1C, 0x18, 0x26, 0x27},
3596 {0x1C, 0x18, 0x27, 0} };
3597 hda_nid_t nid
, nid_vol
, nid_mute
;
3600 for (i
= 0; i
<= AUTO_SEQ_SIDE
; i
++) {
3601 nid
= cfg
->line_out_pins
[i
];
3603 /* for Smart 5.1, there are always at least six channels */
3604 if (!nid
&& i
> AUTO_SEQ_CENLFE
)
3607 if (codec
->vendor_id
== 0x11064397) {
3608 nid_vol
= nid_vols
[1][i
];
3609 nid_mute
= nid_mutes
[1][i
];
3611 nid_vol
= nid_vols
[0][i
];
3612 nid_mute
= nid_mutes
[0][i
];
3614 if (!nid_vol
&& !nid_mute
)
3617 if (i
== AUTO_SEQ_CENLFE
) {
3619 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
3620 "Center Playback Volume",
3621 HDA_COMPOSE_AMP_VAL(nid_vol
, 1, 0,
3625 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
3626 "LFE Playback Volume",
3627 HDA_COMPOSE_AMP_VAL(nid_vol
, 2, 0,
3631 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
3632 "Center Playback Switch",
3633 HDA_COMPOSE_AMP_VAL(nid_mute
,
3638 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
3639 "LFE Playback Switch",
3640 HDA_COMPOSE_AMP_VAL(nid_mute
,
3645 } else if (i
== AUTO_SEQ_FRONT
) {
3646 /* add control to mixer index 0 */
3647 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
3648 "Master Front Playback Volume",
3649 HDA_COMPOSE_AMP_VAL(0x16, 3, 0,
3653 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
3654 "Master Front Playback Switch",
3655 HDA_COMPOSE_AMP_VAL(0x16, 3, 0,
3661 sprintf(name
, "%s Playback Volume", chname
[i
]);
3662 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
, name
,
3663 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0,
3667 sprintf(name
, "%s Playback Switch", chname
[i
]);
3668 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
, name
,
3669 HDA_COMPOSE_AMP_VAL(nid_mute
,
3675 sprintf(name
, "%s Playback Volume", chname
[i
]);
3676 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
, name
,
3677 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0,
3681 sprintf(name
, "%s Playback Switch", chname
[i
]);
3682 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
, name
,
3683 HDA_COMPOSE_AMP_VAL(nid_mute
,
3694 static int vt1708S_auto_create_hp_ctls(struct via_spec
*spec
, hda_nid_t pin
)
3701 spec
->multiout
.hp_nid
= VT1708S_HP_NID
; /* AOW3 */
3702 spec
->hp_independent_mode_index
= 1;
3704 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
3705 "Headphone Playback Volume",
3706 HDA_COMPOSE_AMP_VAL(0x25, 3, 0, HDA_OUTPUT
));
3710 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
3711 "Headphone Playback Switch",
3712 HDA_COMPOSE_AMP_VAL(pin
, 3, 0, HDA_OUTPUT
));
3716 create_hp_imux(spec
);
3721 /* create playback/capture controls for input pins */
3722 static int vt1708S_auto_create_analog_input_ctls(struct hda_codec
*codec
,
3723 const struct auto_pin_cfg
*cfg
)
3725 static const hda_nid_t pin_idxs
[] = { 0x1f, 0x1a, 0x1b, 0x1e, 0, 0xff };
3726 return vt_auto_create_analog_input_ctls(codec
, cfg
, 0x16, pin_idxs
,
3727 ARRAY_SIZE(pin_idxs
));
3730 /* fill out digital output widgets; one for master and one for slave outputs */
3731 static void fill_dig_outs(struct hda_codec
*codec
)
3733 struct via_spec
*spec
= codec
->spec
;
3736 for (i
= 0; i
< spec
->autocfg
.dig_outs
; i
++) {
3740 nid
= spec
->autocfg
.dig_out_pins
[i
];
3743 conn
= snd_hda_get_connections(codec
, nid
, &nid
, 1);
3746 if (!spec
->multiout
.dig_out_nid
)
3747 spec
->multiout
.dig_out_nid
= nid
;
3749 spec
->slave_dig_outs
[0] = nid
;
3750 break; /* at most two dig outs */
3755 static int vt1708S_parse_auto_config(struct hda_codec
*codec
)
3757 struct via_spec
*spec
= codec
->spec
;
3760 err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
);
3763 err
= vt1708S_auto_fill_dac_nids(spec
, &spec
->autocfg
);
3766 if (!spec
->autocfg
.line_outs
&& !spec
->autocfg
.hp_pins
[0])
3767 return 0; /* can't find valid BIOS pin config */
3769 err
= vt1708S_auto_create_multi_out_ctls(codec
, &spec
->autocfg
);
3772 err
= vt1708S_auto_create_hp_ctls(spec
, spec
->autocfg
.hp_pins
[0]);
3775 err
= vt1708S_auto_create_analog_input_ctls(codec
, &spec
->autocfg
);
3779 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
3781 fill_dig_outs(codec
);
3783 if (spec
->kctls
.list
)
3784 spec
->mixers
[spec
->num_mixers
++] = spec
->kctls
.list
;
3786 spec
->input_mux
= &spec
->private_imux
[0];
3789 via_hp_build(codec
);
3791 via_smart51_build(spec
);
3795 #ifdef CONFIG_SND_HDA_POWER_SAVE
3796 static const struct hda_amp_list vt1708S_loopbacks
[] = {
3797 { 0x16, HDA_INPUT
, 1 },
3798 { 0x16, HDA_INPUT
, 2 },
3799 { 0x16, HDA_INPUT
, 3 },
3800 { 0x16, HDA_INPUT
, 4 },
3805 static void override_mic_boost(struct hda_codec
*codec
, hda_nid_t pin
,
3806 int offset
, int num_steps
, int step_size
)
3808 snd_hda_override_amp_caps(codec
, pin
, HDA_INPUT
,
3809 (offset
<< AC_AMPCAP_OFFSET_SHIFT
) |
3810 (num_steps
<< AC_AMPCAP_NUM_STEPS_SHIFT
) |
3811 (step_size
<< AC_AMPCAP_STEP_SIZE_SHIFT
) |
3812 (0 << AC_AMPCAP_MUTE_SHIFT
));
3815 static int patch_vt1708S(struct hda_codec
*codec
)
3817 struct via_spec
*spec
;
3820 /* create a codec specific record */
3821 spec
= via_new_spec(codec
);
3825 /* automatic parse from the BIOS config */
3826 err
= vt1708S_parse_auto_config(codec
);
3831 printk(KERN_INFO
"hda_codec: Cannot set up configuration "
3832 "from BIOS. Using genenic mode...\n");
3835 spec
->init_verbs
[spec
->num_iverbs
++] = vt1708S_volume_init_verbs
;
3836 if (codec
->vendor_id
== 0x11064397)
3837 spec
->init_verbs
[spec
->num_iverbs
++] =
3838 vt1705_uniwill_init_verbs
;
3840 spec
->init_verbs
[spec
->num_iverbs
++] =
3841 vt1708S_uniwill_init_verbs
;
3843 if (codec
->vendor_id
== 0x11060440)
3844 spec
->stream_name_analog
= "VT1818S Analog";
3845 else if (codec
->vendor_id
== 0x11064397)
3846 spec
->stream_name_analog
= "VT1705 Analog";
3848 spec
->stream_name_analog
= "VT1708S Analog";
3849 if (codec
->vendor_id
== 0x11064397)
3850 spec
->stream_analog_playback
= &vt1705_pcm_analog_playback
;
3852 spec
->stream_analog_playback
= &vt1708S_pcm_analog_playback
;
3853 spec
->stream_analog_capture
= &vt1708S_pcm_analog_capture
;
3855 if (codec
->vendor_id
== 0x11060440)
3856 spec
->stream_name_digital
= "VT1818S Digital";
3857 else if (codec
->vendor_id
== 0x11064397)
3858 spec
->stream_name_digital
= "VT1705 Digital";
3860 spec
->stream_name_digital
= "VT1708S Digital";
3861 spec
->stream_digital_playback
= &vt1708S_pcm_digital_playback
;
3863 if (!spec
->adc_nids
&& spec
->input_mux
) {
3864 spec
->adc_nids
= vt1708S_adc_nids
;
3865 spec
->num_adc_nids
= ARRAY_SIZE(vt1708S_adc_nids
);
3866 get_mux_nids(codec
);
3867 override_mic_boost(codec
, 0x1a, 0, 3, 40);
3868 override_mic_boost(codec
, 0x1e, 0, 3, 40);
3869 spec
->mixers
[spec
->num_mixers
] = vt1708S_capture_mixer
;
3873 codec
->patch_ops
= via_patch_ops
;
3875 codec
->patch_ops
.init
= via_auto_init
;
3876 codec
->patch_ops
.unsol_event
= via_unsol_event
;
3877 #ifdef CONFIG_SND_HDA_POWER_SAVE
3878 spec
->loopback
.amplist
= vt1708S_loopbacks
;
3881 /* correct names for VT1708BCE */
3882 if (get_codec_type(codec
) == VT1708BCE
) {
3883 kfree(codec
->chip_name
);
3884 codec
->chip_name
= kstrdup("VT1708BCE", GFP_KERNEL
);
3885 snprintf(codec
->bus
->card
->mixername
,
3886 sizeof(codec
->bus
->card
->mixername
),
3887 "%s %s", codec
->vendor_name
, codec
->chip_name
);
3888 spec
->stream_name_analog
= "VT1708BCE Analog";
3889 spec
->stream_name_digital
= "VT1708BCE Digital";
3891 /* correct names for VT1818S */
3892 if (codec
->vendor_id
== 0x11060440) {
3893 spec
->stream_name_analog
= "VT1818S Analog";
3894 spec
->stream_name_digital
= "VT1818S Digital";
3896 /* correct names for VT1705 */
3897 if (codec
->vendor_id
== 0x11064397) {
3898 kfree(codec
->chip_name
);
3899 codec
->chip_name
= kstrdup("VT1705", GFP_KERNEL
);
3900 snprintf(codec
->bus
->card
->mixername
,
3901 sizeof(codec
->bus
->card
->mixername
),
3902 "%s %s", codec
->vendor_name
, codec
->chip_name
);
3904 spec
->set_widgets_power_state
= set_widgets_power_state_vt1708B
;
3908 /* Patch for VT1702 */
3910 /* capture mixer elements */
3911 static const struct snd_kcontrol_new vt1702_capture_mixer
[] = {
3912 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_INPUT
),
3913 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_INPUT
),
3914 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x20, 0x0, HDA_INPUT
),
3915 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x20, 0x0, HDA_INPUT
),
3916 HDA_CODEC_VOLUME("Digital Mic Capture Volume", 0x1F, 0x0, HDA_INPUT
),
3917 HDA_CODEC_MUTE("Digital Mic Capture Switch", 0x1F, 0x0, HDA_INPUT
),
3918 HDA_CODEC_VOLUME("Digital Mic Boost Capture Volume", 0x1E, 0x0,
3921 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3922 /* The multiple "Capture Source" controls confuse alsamixer
3923 * So call somewhat different..
3925 /* .name = "Capture Source", */
3926 .name
= "Input Source",
3928 .info
= via_mux_enum_info
,
3929 .get
= via_mux_enum_get
,
3930 .put
= via_mux_enum_put
,
3935 static const struct hda_verb vt1702_volume_init_verbs
[] = {
3937 * Unmute ADC0-1 and set the default input to mic-in
3939 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3940 {0x1F, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3941 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3944 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3947 /* Amp Indices: Mic1 = 1, Line = 1, Mic2 = 3 */
3948 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3949 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3950 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2)},
3951 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(3)},
3952 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
3954 /* Setup default input of PW4 to MW0 */
3955 {0x17, AC_VERB_SET_CONNECT_SEL
, 0x1},
3956 /* PW6 PW7 Output enable */
3957 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40},
3958 {0x1C, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40},
3966 static const struct hda_verb vt1702_uniwill_init_verbs
[] = {
3967 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE
,
3968 AC_USRSP_EN
| VIA_HP_EVENT
| VIA_JACK_EVENT
},
3969 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
3970 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
3971 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
3972 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
3976 static const struct hda_pcm_stream vt1702_pcm_analog_playback
= {
3980 .nid
= 0x10, /* NID to query formats and rates */
3982 .open
= via_playback_pcm_open
,
3983 .prepare
= via_playback_multi_pcm_prepare
,
3984 .cleanup
= via_playback_multi_pcm_cleanup
,
3985 .close
= via_pcm_open_close
3989 static const struct hda_pcm_stream vt1702_pcm_analog_capture
= {
3993 .nid
= 0x12, /* NID to query formats and rates */
3995 .open
= via_pcm_open_close
,
3996 .prepare
= via_capture_pcm_prepare
,
3997 .cleanup
= via_capture_pcm_cleanup
,
3998 .close
= via_pcm_open_close
4002 static const struct hda_pcm_stream vt1702_pcm_digital_playback
= {
4006 /* NID is set in via_build_pcms */
4008 .open
= via_dig_playback_pcm_open
,
4009 .close
= via_dig_playback_pcm_close
,
4010 .prepare
= via_dig_playback_pcm_prepare
,
4011 .cleanup
= via_dig_playback_pcm_cleanup
4015 /* fill in the dac_nids table from the parsed pin configuration */
4016 static int vt1702_auto_fill_dac_nids(struct via_spec
*spec
,
4017 const struct auto_pin_cfg
*cfg
)
4019 spec
->multiout
.num_dacs
= 1;
4020 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
4022 if (cfg
->line_out_pins
[0]) {
4023 /* config dac list */
4024 spec
->private_dac_nids
[0] = 0x10;
4030 /* add playback controls from the parsed DAC table */
4031 static int vt1702_auto_create_line_out_ctls(struct via_spec
*spec
,
4032 const struct auto_pin_cfg
*cfg
)
4036 if (!cfg
->line_out_pins
[0])
4039 /* add control to mixer index 0 */
4040 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
4041 "Master Front Playback Volume",
4042 HDA_COMPOSE_AMP_VAL(0x1A, 3, 0, HDA_INPUT
));
4045 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
4046 "Master Front Playback Switch",
4047 HDA_COMPOSE_AMP_VAL(0x1A, 3, 0, HDA_INPUT
));
4052 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
4053 "Front Playback Volume",
4054 HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT
));
4057 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
4058 "Front Playback Switch",
4059 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT
));
4066 static int vt1702_auto_create_hp_ctls(struct via_spec
*spec
, hda_nid_t pin
)
4069 struct hda_input_mux
*imux
;
4070 static const char * const texts
[] = { "ON", "OFF", NULL
};
4073 spec
->multiout
.hp_nid
= 0x1D;
4074 spec
->hp_independent_mode_index
= 0;
4076 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
4077 "Headphone Playback Volume",
4078 HDA_COMPOSE_AMP_VAL(0x1D, 3, 0, HDA_OUTPUT
));
4082 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
4083 "Headphone Playback Switch",
4084 HDA_COMPOSE_AMP_VAL(pin
, 3, 0, HDA_OUTPUT
));
4088 imux
= &spec
->private_imux
[1];
4090 /* for hp mode select */
4091 for (i
= 0; texts
[i
]; i
++)
4092 snd_hda_add_imux_item(imux
, texts
[i
], i
, NULL
);
4094 spec
->hp_mux
= &spec
->private_imux
[1];
4098 /* create playback/capture controls for input pins */
4099 static int vt1702_auto_create_analog_input_ctls(struct hda_codec
*codec
,
4100 const struct auto_pin_cfg
*cfg
)
4102 static const hda_nid_t pin_idxs
[] = { 0x14, 0x15, 0x18, 0xff };
4103 return vt_auto_create_analog_input_ctls(codec
, cfg
, 0x1a, pin_idxs
,
4104 ARRAY_SIZE(pin_idxs
));
4107 static int vt1702_parse_auto_config(struct hda_codec
*codec
)
4109 struct via_spec
*spec
= codec
->spec
;
4112 err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
);
4115 err
= vt1702_auto_fill_dac_nids(spec
, &spec
->autocfg
);
4118 if (!spec
->autocfg
.line_outs
&& !spec
->autocfg
.hp_pins
[0])
4119 return 0; /* can't find valid BIOS pin config */
4121 err
= vt1702_auto_create_line_out_ctls(spec
, &spec
->autocfg
);
4124 err
= vt1702_auto_create_hp_ctls(spec
, spec
->autocfg
.hp_pins
[0]);
4127 /* limit AA path volume to 0 dB */
4128 snd_hda_override_amp_caps(codec
, 0x1A, HDA_INPUT
,
4129 (0x17 << AC_AMPCAP_OFFSET_SHIFT
) |
4130 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
4131 (0x5 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
4132 (1 << AC_AMPCAP_MUTE_SHIFT
));
4133 err
= vt1702_auto_create_analog_input_ctls(codec
, &spec
->autocfg
);
4137 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
4139 fill_dig_outs(codec
);
4141 if (spec
->kctls
.list
)
4142 spec
->mixers
[spec
->num_mixers
++] = spec
->kctls
.list
;
4144 spec
->input_mux
= &spec
->private_imux
[0];
4147 via_hp_build(codec
);
4152 #ifdef CONFIG_SND_HDA_POWER_SAVE
4153 static const struct hda_amp_list vt1702_loopbacks
[] = {
4154 { 0x1A, HDA_INPUT
, 1 },
4155 { 0x1A, HDA_INPUT
, 2 },
4156 { 0x1A, HDA_INPUT
, 3 },
4157 { 0x1A, HDA_INPUT
, 4 },
4162 static void set_widgets_power_state_vt1702(struct hda_codec
*codec
)
4164 int imux_is_smixer
=
4165 snd_hda_codec_read(codec
, 0x13, 0, AC_VERB_GET_CONNECT_SEL
, 0x00) == 3;
4168 /* PW 1/2/5 (14h/15h/18h) */
4170 set_pin_power_state(codec
, 0x14, &parm
);
4171 set_pin_power_state(codec
, 0x15, &parm
);
4172 set_pin_power_state(codec
, 0x18, &parm
);
4174 parm
= AC_PWRST_D0
; /* SW0 (13h) = stereo mixer (idx 3) */
4175 /* SW0 (13h), AIW 0/1/2 (12h/1fh/20h) */
4176 snd_hda_codec_write(codec
, 0x13, 0, AC_VERB_SET_POWER_STATE
, parm
);
4177 snd_hda_codec_write(codec
, 0x12, 0, AC_VERB_SET_POWER_STATE
, parm
);
4178 snd_hda_codec_write(codec
, 0x1f, 0, AC_VERB_SET_POWER_STATE
, parm
);
4179 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_POWER_STATE
, parm
);
4182 /* PW 3/4 (16h/17h) */
4184 set_pin_power_state(codec
, 0x17, &parm
);
4185 set_pin_power_state(codec
, 0x16, &parm
);
4186 /* MW0 (1ah), AOW 0/1 (10h/1dh) */
4187 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_POWER_STATE
,
4188 imux_is_smixer
? AC_PWRST_D0
: parm
);
4189 snd_hda_codec_write(codec
, 0x10, 0, AC_VERB_SET_POWER_STATE
, parm
);
4190 snd_hda_codec_write(codec
, 0x1d, 0, AC_VERB_SET_POWER_STATE
, parm
);
4193 static int patch_vt1702(struct hda_codec
*codec
)
4195 struct via_spec
*spec
;
4198 /* create a codec specific record */
4199 spec
= via_new_spec(codec
);
4203 /* automatic parse from the BIOS config */
4204 err
= vt1702_parse_auto_config(codec
);
4209 printk(KERN_INFO
"hda_codec: Cannot set up configuration "
4210 "from BIOS. Using genenic mode...\n");
4213 spec
->init_verbs
[spec
->num_iverbs
++] = vt1702_volume_init_verbs
;
4214 spec
->init_verbs
[spec
->num_iverbs
++] = vt1702_uniwill_init_verbs
;
4216 spec
->stream_name_analog
= "VT1702 Analog";
4217 spec
->stream_analog_playback
= &vt1702_pcm_analog_playback
;
4218 spec
->stream_analog_capture
= &vt1702_pcm_analog_capture
;
4220 spec
->stream_name_digital
= "VT1702 Digital";
4221 spec
->stream_digital_playback
= &vt1702_pcm_digital_playback
;
4223 if (!spec
->adc_nids
&& spec
->input_mux
) {
4224 spec
->adc_nids
= vt1702_adc_nids
;
4225 spec
->num_adc_nids
= ARRAY_SIZE(vt1702_adc_nids
);
4226 get_mux_nids(codec
);
4227 spec
->mixers
[spec
->num_mixers
] = vt1702_capture_mixer
;
4231 codec
->patch_ops
= via_patch_ops
;
4233 codec
->patch_ops
.init
= via_auto_init
;
4234 codec
->patch_ops
.unsol_event
= via_unsol_event
;
4235 #ifdef CONFIG_SND_HDA_POWER_SAVE
4236 spec
->loopback
.amplist
= vt1702_loopbacks
;
4239 spec
->set_widgets_power_state
= set_widgets_power_state_vt1702
;
4243 /* Patch for VT1718S */
4245 /* capture mixer elements */
4246 static const struct snd_kcontrol_new vt1718S_capture_mixer
[] = {
4247 HDA_CODEC_VOLUME("Capture Volume", 0x10, 0x0, HDA_INPUT
),
4248 HDA_CODEC_MUTE("Capture Switch", 0x10, 0x0, HDA_INPUT
),
4249 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x11, 0x0, HDA_INPUT
),
4250 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x11, 0x0, HDA_INPUT
),
4251 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x2b, 0x0, HDA_INPUT
),
4252 HDA_CODEC_VOLUME("Front Mic Boost Capture Volume", 0x29, 0x0,
4255 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4256 /* The multiple "Capture Source" controls confuse alsamixer
4257 * So call somewhat different..
4259 .name
= "Input Source",
4261 .info
= via_mux_enum_info
,
4262 .get
= via_mux_enum_get
,
4263 .put
= via_mux_enum_put
,
4268 static const struct hda_verb vt1718S_volume_init_verbs
[] = {
4270 * Unmute ADC0-1 and set the default input to mic-in
4272 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4273 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4275 /* Enable MW0 adjust Gain 5 */
4277 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4280 /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */
4281 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4282 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4283 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
4284 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
4285 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(5)},
4287 /* Setup default input of Front HP to MW9 */
4288 {0x28, AC_VERB_SET_CONNECT_SEL
, 0x1},
4289 /* PW9 PW10 Output enable */
4290 {0x2d, AC_VERB_SET_PIN_WIDGET_CONTROL
, AC_PINCTL_OUT_EN
},
4291 {0x2e, AC_VERB_SET_PIN_WIDGET_CONTROL
, AC_PINCTL_OUT_EN
},
4292 /* PW11 Input enable */
4293 {0x2f, AC_VERB_SET_PIN_WIDGET_CONTROL
, AC_PINCTL_IN_EN
},
4294 /* Enable Boost Volume backdoor */
4296 /* MW0/1/2/3/4: un-mute index 0 (AOWx), mute index 1 (MW9) */
4297 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4298 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4299 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4300 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4301 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4302 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4303 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4304 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4305 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4306 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4307 /* set MUX1 = 2 (AOW4), MUX2 = 1 (AOW3) */
4308 {0x34, AC_VERB_SET_CONNECT_SEL
, 0x2},
4309 {0x35, AC_VERB_SET_CONNECT_SEL
, 0x1},
4310 /* Unmute MW4's index 0 */
4311 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4316 static const struct hda_verb vt1718S_uniwill_init_verbs
[] = {
4317 {0x28, AC_VERB_SET_UNSOLICITED_ENABLE
,
4318 AC_USRSP_EN
| VIA_HP_EVENT
| VIA_JACK_EVENT
},
4319 {0x24, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
4320 {0x25, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
4321 {0x26, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
4322 {0x27, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
4323 {0x29, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
4324 {0x2a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
4325 {0x2b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
4329 static const struct hda_pcm_stream vt1718S_pcm_analog_playback
= {
4333 .nid
= 0x8, /* NID to query formats and rates */
4335 .open
= via_playback_pcm_open
,
4336 .prepare
= via_playback_multi_pcm_prepare
,
4337 .cleanup
= via_playback_multi_pcm_cleanup
,
4338 .close
= via_pcm_open_close
,
4342 static const struct hda_pcm_stream vt1718S_pcm_analog_capture
= {
4346 .nid
= 0x10, /* NID to query formats and rates */
4348 .open
= via_pcm_open_close
,
4349 .prepare
= via_capture_pcm_prepare
,
4350 .cleanup
= via_capture_pcm_cleanup
,
4351 .close
= via_pcm_open_close
,
4355 static const struct hda_pcm_stream vt1718S_pcm_digital_playback
= {
4359 /* NID is set in via_build_pcms */
4361 .open
= via_dig_playback_pcm_open
,
4362 .close
= via_dig_playback_pcm_close
,
4363 .prepare
= via_dig_playback_pcm_prepare
,
4364 .cleanup
= via_dig_playback_pcm_cleanup
4368 static const struct hda_pcm_stream vt1718S_pcm_digital_capture
= {
4374 /* fill in the dac_nids table from the parsed pin configuration */
4375 static int vt1718S_auto_fill_dac_nids(struct via_spec
*spec
,
4376 const struct auto_pin_cfg
*cfg
)
4381 spec
->multiout
.num_dacs
= cfg
->line_outs
;
4383 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
4385 for (i
= 0; i
< 4; i
++) {
4386 nid
= cfg
->line_out_pins
[i
];
4388 /* config dac list */
4390 case AUTO_SEQ_FRONT
:
4391 spec
->private_dac_nids
[i
] = 0x8;
4393 case AUTO_SEQ_CENLFE
:
4394 spec
->private_dac_nids
[i
] = 0xa;
4396 case AUTO_SEQ_SURROUND
:
4397 spec
->private_dac_nids
[i
] = 0x9;
4400 spec
->private_dac_nids
[i
] = 0xb;
4409 /* add playback controls from the parsed DAC table */
4410 static int vt1718S_auto_create_multi_out_ctls(struct via_spec
*spec
,
4411 const struct auto_pin_cfg
*cfg
)
4414 static const char * const chname
[4] = {
4415 "Front", "Surround", "C/LFE", "Side"
4417 hda_nid_t nid_vols
[] = {0x8, 0x9, 0xa, 0xb};
4418 hda_nid_t nid_mutes
[] = {0x24, 0x25, 0x26, 0x27};
4419 hda_nid_t nid
, nid_vol
, nid_mute
= 0;
4422 for (i
= 0; i
<= AUTO_SEQ_SIDE
; i
++) {
4423 nid
= cfg
->line_out_pins
[i
];
4427 nid_vol
= nid_vols
[i
];
4428 nid_mute
= nid_mutes
[i
];
4430 if (i
== AUTO_SEQ_CENLFE
) {
4432 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
4433 "Center Playback Volume",
4434 HDA_COMPOSE_AMP_VAL(nid_vol
, 1, 0,
4438 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
4439 "LFE Playback Volume",
4440 HDA_COMPOSE_AMP_VAL(nid_vol
, 2, 0,
4444 err
= via_add_control(
4445 spec
, VIA_CTL_WIDGET_MUTE
,
4446 "Center Playback Switch",
4447 HDA_COMPOSE_AMP_VAL(nid_mute
, 1, 0,
4451 err
= via_add_control(
4452 spec
, VIA_CTL_WIDGET_MUTE
,
4453 "LFE Playback Switch",
4454 HDA_COMPOSE_AMP_VAL(nid_mute
, 2, 0,
4458 } else if (i
== AUTO_SEQ_FRONT
) {
4460 sprintf(name
, "%s Playback Volume", chname
[i
]);
4461 err
= via_add_control(
4462 spec
, VIA_CTL_WIDGET_VOL
, name
,
4463 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0, HDA_OUTPUT
));
4466 sprintf(name
, "%s Playback Switch", chname
[i
]);
4467 err
= via_add_control(
4468 spec
, VIA_CTL_WIDGET_MUTE
, name
,
4469 HDA_COMPOSE_AMP_VAL(nid_mute
, 3, 0,
4474 sprintf(name
, "%s Playback Volume", chname
[i
]);
4475 err
= via_add_control(
4476 spec
, VIA_CTL_WIDGET_VOL
, name
,
4477 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0, HDA_OUTPUT
));
4480 sprintf(name
, "%s Playback Switch", chname
[i
]);
4481 err
= via_add_control(
4482 spec
, VIA_CTL_WIDGET_MUTE
, name
,
4483 HDA_COMPOSE_AMP_VAL(nid_mute
, 3, 0,
4492 static int vt1718S_auto_create_hp_ctls(struct via_spec
*spec
, hda_nid_t pin
)
4499 spec
->multiout
.hp_nid
= 0xc; /* AOW4 */
4500 spec
->hp_independent_mode_index
= 1;
4502 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
4503 "Headphone Playback Volume",
4504 HDA_COMPOSE_AMP_VAL(0xc, 3, 0, HDA_OUTPUT
));
4508 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
4509 "Headphone Playback Switch",
4510 HDA_COMPOSE_AMP_VAL(pin
, 3, 0, HDA_OUTPUT
));
4514 create_hp_imux(spec
);
4518 /* create playback/capture controls for input pins */
4519 static int vt1718S_auto_create_analog_input_ctls(struct hda_codec
*codec
,
4520 const struct auto_pin_cfg
*cfg
)
4522 static const hda_nid_t pin_idxs
[] = { 0x2c, 0x2b, 0x2a, 0x29, 0, 0xff };
4523 return vt_auto_create_analog_input_ctls(codec
, cfg
, 0x21, pin_idxs
,
4524 ARRAY_SIZE(pin_idxs
));
4527 static int vt1718S_parse_auto_config(struct hda_codec
*codec
)
4529 struct via_spec
*spec
= codec
->spec
;
4532 err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
);
4536 err
= vt1718S_auto_fill_dac_nids(spec
, &spec
->autocfg
);
4539 if (!spec
->autocfg
.line_outs
&& !spec
->autocfg
.hp_pins
[0])
4540 return 0; /* can't find valid BIOS pin config */
4542 err
= vt1718S_auto_create_multi_out_ctls(spec
, &spec
->autocfg
);
4545 err
= vt1718S_auto_create_hp_ctls(spec
, spec
->autocfg
.hp_pins
[0]);
4548 err
= vt1718S_auto_create_analog_input_ctls(codec
, &spec
->autocfg
);
4552 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
4554 fill_dig_outs(codec
);
4556 if (spec
->autocfg
.dig_in_pin
&& codec
->vendor_id
== 0x11060428)
4557 spec
->dig_in_nid
= 0x13;
4559 if (spec
->kctls
.list
)
4560 spec
->mixers
[spec
->num_mixers
++] = spec
->kctls
.list
;
4562 spec
->input_mux
= &spec
->private_imux
[0];
4565 via_hp_build(codec
);
4567 via_smart51_build(spec
);
4572 #ifdef CONFIG_SND_HDA_POWER_SAVE
4573 static const struct hda_amp_list vt1718S_loopbacks
[] = {
4574 { 0x21, HDA_INPUT
, 1 },
4575 { 0x21, HDA_INPUT
, 2 },
4576 { 0x21, HDA_INPUT
, 3 },
4577 { 0x21, HDA_INPUT
, 4 },
4582 static void set_widgets_power_state_vt1718S(struct hda_codec
*codec
)
4584 struct via_spec
*spec
= codec
->spec
;
4587 /* MUX6 (1eh) = stereo mixer */
4589 snd_hda_codec_read(codec
, 0x1e, 0, AC_VERB_GET_CONNECT_SEL
, 0x00) == 5;
4591 /* PW 5/6/7 (29h/2ah/2bh) */
4593 set_pin_power_state(codec
, 0x29, &parm
);
4594 set_pin_power_state(codec
, 0x2a, &parm
);
4595 set_pin_power_state(codec
, 0x2b, &parm
);
4598 /* MUX6/7 (1eh/1fh), AIW 0/1 (10h/11h) */
4599 snd_hda_codec_write(codec
, 0x1e, 0, AC_VERB_SET_POWER_STATE
, parm
);
4600 snd_hda_codec_write(codec
, 0x1f, 0, AC_VERB_SET_POWER_STATE
, parm
);
4601 snd_hda_codec_write(codec
, 0x10, 0, AC_VERB_SET_POWER_STATE
, parm
);
4602 snd_hda_codec_write(codec
, 0x11, 0, AC_VERB_SET_POWER_STATE
, parm
);
4605 /* PW3 (27h), MW2 (1ah), AOW3 (bh) */
4607 set_pin_power_state(codec
, 0x27, &parm
);
4608 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_POWER_STATE
, parm
);
4609 snd_hda_codec_write(codec
, 0xb, 0, AC_VERB_SET_POWER_STATE
, parm
);
4611 /* PW2 (26h), AOW2 (ah) */
4613 set_pin_power_state(codec
, 0x26, &parm
);
4614 if (spec
->smart51_enabled
)
4615 set_pin_power_state(codec
, 0x2b, &parm
);
4616 snd_hda_codec_write(codec
, 0xa, 0, AC_VERB_SET_POWER_STATE
, parm
);
4618 /* PW0 (24h), AOW0 (8h) */
4620 set_pin_power_state(codec
, 0x24, &parm
);
4621 if (!spec
->hp_independent_mode
) /* check for redirected HP */
4622 set_pin_power_state(codec
, 0x28, &parm
);
4623 snd_hda_codec_write(codec
, 0x8, 0, AC_VERB_SET_POWER_STATE
, parm
);
4624 /* MW9 (21h), Mw2 (1ah), AOW0 (8h) */
4625 snd_hda_codec_write(codec
, 0x21, 0, AC_VERB_SET_POWER_STATE
,
4626 imux_is_smixer
? AC_PWRST_D0
: parm
);
4628 /* PW1 (25h), AOW1 (9h) */
4630 set_pin_power_state(codec
, 0x25, &parm
);
4631 if (spec
->smart51_enabled
)
4632 set_pin_power_state(codec
, 0x2a, &parm
);
4633 snd_hda_codec_write(codec
, 0x9, 0, AC_VERB_SET_POWER_STATE
, parm
);
4635 if (spec
->hp_independent_mode
) {
4636 /* PW4 (28h), MW3 (1bh), MUX1(34h), AOW4 (ch) */
4638 set_pin_power_state(codec
, 0x28, &parm
);
4639 snd_hda_codec_write(codec
, 0x1b, 0,
4640 AC_VERB_SET_POWER_STATE
, parm
);
4641 snd_hda_codec_write(codec
, 0x34, 0,
4642 AC_VERB_SET_POWER_STATE
, parm
);
4643 snd_hda_codec_write(codec
, 0xc, 0,
4644 AC_VERB_SET_POWER_STATE
, parm
);
4648 static int patch_vt1718S(struct hda_codec
*codec
)
4650 struct via_spec
*spec
;
4653 /* create a codec specific record */
4654 spec
= via_new_spec(codec
);
4658 /* automatic parse from the BIOS config */
4659 err
= vt1718S_parse_auto_config(codec
);
4664 printk(KERN_INFO
"hda_codec: Cannot set up configuration "
4665 "from BIOS. Using genenic mode...\n");
4668 spec
->init_verbs
[spec
->num_iverbs
++] = vt1718S_volume_init_verbs
;
4669 spec
->init_verbs
[spec
->num_iverbs
++] = vt1718S_uniwill_init_verbs
;
4671 if (codec
->vendor_id
== 0x11060441)
4672 spec
->stream_name_analog
= "VT2020 Analog";
4673 else if (codec
->vendor_id
== 0x11064441)
4674 spec
->stream_name_analog
= "VT1828S Analog";
4676 spec
->stream_name_analog
= "VT1718S Analog";
4677 spec
->stream_analog_playback
= &vt1718S_pcm_analog_playback
;
4678 spec
->stream_analog_capture
= &vt1718S_pcm_analog_capture
;
4680 if (codec
->vendor_id
== 0x11060441)
4681 spec
->stream_name_digital
= "VT2020 Digital";
4682 else if (codec
->vendor_id
== 0x11064441)
4683 spec
->stream_name_digital
= "VT1828S Digital";
4685 spec
->stream_name_digital
= "VT1718S Digital";
4686 spec
->stream_digital_playback
= &vt1718S_pcm_digital_playback
;
4687 if (codec
->vendor_id
== 0x11060428 || codec
->vendor_id
== 0x11060441)
4688 spec
->stream_digital_capture
= &vt1718S_pcm_digital_capture
;
4690 if (!spec
->adc_nids
&& spec
->input_mux
) {
4691 spec
->adc_nids
= vt1718S_adc_nids
;
4692 spec
->num_adc_nids
= ARRAY_SIZE(vt1718S_adc_nids
);
4693 get_mux_nids(codec
);
4694 override_mic_boost(codec
, 0x2b, 0, 3, 40);
4695 override_mic_boost(codec
, 0x29, 0, 3, 40);
4696 spec
->mixers
[spec
->num_mixers
] = vt1718S_capture_mixer
;
4700 codec
->patch_ops
= via_patch_ops
;
4702 codec
->patch_ops
.init
= via_auto_init
;
4703 codec
->patch_ops
.unsol_event
= via_unsol_event
;
4705 #ifdef CONFIG_SND_HDA_POWER_SAVE
4706 spec
->loopback
.amplist
= vt1718S_loopbacks
;
4709 spec
->set_widgets_power_state
= set_widgets_power_state_vt1718S
;
4714 /* Patch for VT1716S */
4716 static int vt1716s_dmic_info(struct snd_kcontrol
*kcontrol
,
4717 struct snd_ctl_elem_info
*uinfo
)
4719 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_BOOLEAN
;
4721 uinfo
->value
.integer
.min
= 0;
4722 uinfo
->value
.integer
.max
= 1;
4726 static int vt1716s_dmic_get(struct snd_kcontrol
*kcontrol
,
4727 struct snd_ctl_elem_value
*ucontrol
)
4729 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
4732 index
= snd_hda_codec_read(codec
, 0x26, 0,
4733 AC_VERB_GET_CONNECT_SEL
, 0);
4735 *ucontrol
->value
.integer
.value
= index
;
4740 static int vt1716s_dmic_put(struct snd_kcontrol
*kcontrol
,
4741 struct snd_ctl_elem_value
*ucontrol
)
4743 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
4744 struct via_spec
*spec
= codec
->spec
;
4745 int index
= *ucontrol
->value
.integer
.value
;
4747 snd_hda_codec_write(codec
, 0x26, 0,
4748 AC_VERB_SET_CONNECT_SEL
, index
);
4749 spec
->dmic_enabled
= index
;
4750 set_widgets_power_state(codec
);
4754 /* capture mixer elements */
4755 static const struct snd_kcontrol_new vt1716S_capture_mixer
[] = {
4756 HDA_CODEC_VOLUME("Capture Volume", 0x13, 0x0, HDA_INPUT
),
4757 HDA_CODEC_MUTE("Capture Switch", 0x13, 0x0, HDA_INPUT
),
4758 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x14, 0x0, HDA_INPUT
),
4759 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x14, 0x0, HDA_INPUT
),
4760 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x1A, 0x0, HDA_INPUT
),
4761 HDA_CODEC_VOLUME("Front Mic Boost Capture Volume", 0x1E, 0x0,
4764 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4765 .name
= "Input Source",
4767 .info
= via_mux_enum_info
,
4768 .get
= via_mux_enum_get
,
4769 .put
= via_mux_enum_put
,
4774 static const struct snd_kcontrol_new vt1716s_dmic_mixer
[] = {
4775 HDA_CODEC_VOLUME("Digital Mic Capture Volume", 0x22, 0x0, HDA_INPUT
),
4777 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4778 .name
= "Digital Mic Capture Switch",
4779 .subdevice
= HDA_SUBDEV_NID_FLAG
| 0x26,
4781 .info
= vt1716s_dmic_info
,
4782 .get
= vt1716s_dmic_get
,
4783 .put
= vt1716s_dmic_put
,
4789 /* mono-out mixer elements */
4790 static const struct snd_kcontrol_new vt1716S_mono_out_mixer
[] = {
4791 HDA_CODEC_MUTE("Mono Playback Switch", 0x2a, 0x0, HDA_OUTPUT
),
4795 static const struct hda_verb vt1716S_volume_init_verbs
[] = {
4797 * Unmute ADC0-1 and set the default input to mic-in
4799 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4800 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4803 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4806 /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */
4807 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4808 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4809 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
4810 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
4811 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
4813 /* MUX Indices: Stereo Mixer = 5 */
4814 {0x17, AC_VERB_SET_CONNECT_SEL
, 0x5},
4816 /* Setup default input of PW4 to MW0 */
4817 {0x1d, AC_VERB_SET_CONNECT_SEL
, 0x0},
4819 /* Setup default input of SW1 as MW0 */
4820 {0x18, AC_VERB_SET_CONNECT_SEL
, 0x1},
4822 /* Setup default input of SW4 as AOW0 */
4823 {0x28, AC_VERB_SET_CONNECT_SEL
, 0x1},
4825 /* PW9 PW10 Output enable */
4826 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40},
4827 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40},
4829 /* Unmute SW1, PW12 */
4830 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4831 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
4832 /* PW12 Output enable */
4833 {0x2a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40},
4834 /* Enable Boost Volume backdoor */
4836 /* don't bybass mixer */
4838 /* Enable mono output */
4844 static const struct hda_verb vt1716S_uniwill_init_verbs
[] = {
4845 {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE
,
4846 AC_USRSP_EN
| VIA_HP_EVENT
| VIA_JACK_EVENT
},
4847 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
4848 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
4849 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
4850 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
,
4851 AC_USRSP_EN
| VIA_MONO_EVENT
| VIA_JACK_EVENT
},
4852 {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
4853 {0x23, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
4857 static const struct hda_pcm_stream vt1716S_pcm_analog_playback
= {
4861 .nid
= 0x10, /* NID to query formats and rates */
4863 .open
= via_playback_pcm_open
,
4864 .prepare
= via_playback_multi_pcm_prepare
,
4865 .cleanup
= via_playback_multi_pcm_cleanup
,
4866 .close
= via_pcm_open_close
,
4870 static const struct hda_pcm_stream vt1716S_pcm_analog_capture
= {
4874 .nid
= 0x13, /* NID to query formats and rates */
4876 .open
= via_pcm_open_close
,
4877 .prepare
= via_capture_pcm_prepare
,
4878 .cleanup
= via_capture_pcm_cleanup
,
4879 .close
= via_pcm_open_close
,
4883 static const struct hda_pcm_stream vt1716S_pcm_digital_playback
= {
4887 /* NID is set in via_build_pcms */
4889 .open
= via_dig_playback_pcm_open
,
4890 .close
= via_dig_playback_pcm_close
,
4891 .prepare
= via_dig_playback_pcm_prepare
,
4892 .cleanup
= via_dig_playback_pcm_cleanup
4896 /* fill in the dac_nids table from the parsed pin configuration */
4897 static int vt1716S_auto_fill_dac_nids(struct via_spec
*spec
,
4898 const struct auto_pin_cfg
*cfg
)
4902 spec
->multiout
.num_dacs
= cfg
->line_outs
;
4904 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
4906 for (i
= 0; i
< 3; i
++) {
4907 nid
= cfg
->line_out_pins
[i
];
4909 /* config dac list */
4911 case AUTO_SEQ_FRONT
:
4912 spec
->private_dac_nids
[i
] = 0x10;
4914 case AUTO_SEQ_CENLFE
:
4915 spec
->private_dac_nids
[i
] = 0x25;
4917 case AUTO_SEQ_SURROUND
:
4918 spec
->private_dac_nids
[i
] = 0x11;
4927 /* add playback controls from the parsed DAC table */
4928 static int vt1716S_auto_create_multi_out_ctls(struct via_spec
*spec
,
4929 const struct auto_pin_cfg
*cfg
)
4932 static const char * const chname
[3] = {
4933 "Front", "Surround", "C/LFE"
4935 hda_nid_t nid_vols
[] = {0x10, 0x11, 0x25};
4936 hda_nid_t nid_mutes
[] = {0x1C, 0x18, 0x27};
4937 hda_nid_t nid
, nid_vol
, nid_mute
;
4940 for (i
= 0; i
<= AUTO_SEQ_CENLFE
; i
++) {
4941 nid
= cfg
->line_out_pins
[i
];
4946 nid_vol
= nid_vols
[i
];
4947 nid_mute
= nid_mutes
[i
];
4949 if (i
== AUTO_SEQ_CENLFE
) {
4950 err
= via_add_control(
4951 spec
, VIA_CTL_WIDGET_VOL
,
4952 "Center Playback Volume",
4953 HDA_COMPOSE_AMP_VAL(nid_vol
, 1, 0, HDA_OUTPUT
));
4956 err
= via_add_control(
4957 spec
, VIA_CTL_WIDGET_VOL
,
4958 "LFE Playback Volume",
4959 HDA_COMPOSE_AMP_VAL(nid_vol
, 2, 0, HDA_OUTPUT
));
4962 err
= via_add_control(
4963 spec
, VIA_CTL_WIDGET_MUTE
,
4964 "Center Playback Switch",
4965 HDA_COMPOSE_AMP_VAL(nid_mute
, 1, 0,
4969 err
= via_add_control(
4970 spec
, VIA_CTL_WIDGET_MUTE
,
4971 "LFE Playback Switch",
4972 HDA_COMPOSE_AMP_VAL(nid_mute
, 2, 0,
4976 } else if (i
== AUTO_SEQ_FRONT
) {
4978 err
= via_add_control(
4979 spec
, VIA_CTL_WIDGET_VOL
,
4980 "Master Front Playback Volume",
4981 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_INPUT
));
4984 err
= via_add_control(
4985 spec
, VIA_CTL_WIDGET_MUTE
,
4986 "Master Front Playback Switch",
4987 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_INPUT
));
4991 sprintf(name
, "%s Playback Volume", chname
[i
]);
4992 err
= via_add_control(
4993 spec
, VIA_CTL_WIDGET_VOL
, name
,
4994 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0, HDA_OUTPUT
));
4997 sprintf(name
, "%s Playback Switch", chname
[i
]);
4998 err
= via_add_control(
4999 spec
, VIA_CTL_WIDGET_MUTE
, name
,
5000 HDA_COMPOSE_AMP_VAL(nid_mute
, 3, 0,
5005 sprintf(name
, "%s Playback Volume", chname
[i
]);
5006 err
= via_add_control(
5007 spec
, VIA_CTL_WIDGET_VOL
, name
,
5008 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0, HDA_OUTPUT
));
5011 sprintf(name
, "%s Playback Switch", chname
[i
]);
5012 err
= via_add_control(
5013 spec
, VIA_CTL_WIDGET_MUTE
, name
,
5014 HDA_COMPOSE_AMP_VAL(nid_mute
, 3, 0,
5023 static int vt1716S_auto_create_hp_ctls(struct via_spec
*spec
, hda_nid_t pin
)
5030 spec
->multiout
.hp_nid
= 0x25; /* AOW3 */
5031 spec
->hp_independent_mode_index
= 1;
5033 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
5034 "Headphone Playback Volume",
5035 HDA_COMPOSE_AMP_VAL(0x25, 3, 0, HDA_OUTPUT
));
5039 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
5040 "Headphone Playback Switch",
5041 HDA_COMPOSE_AMP_VAL(pin
, 3, 0, HDA_OUTPUT
));
5045 create_hp_imux(spec
);
5049 /* create playback/capture controls for input pins */
5050 static int vt1716S_auto_create_analog_input_ctls(struct hda_codec
*codec
,
5051 const struct auto_pin_cfg
*cfg
)
5053 static const hda_nid_t pin_idxs
[] = { 0x1f, 0x1a, 0x1b, 0x1e, 0, 0xff };
5054 return vt_auto_create_analog_input_ctls(codec
, cfg
, 0x16, pin_idxs
,
5055 ARRAY_SIZE(pin_idxs
));
5058 static int vt1716S_parse_auto_config(struct hda_codec
*codec
)
5060 struct via_spec
*spec
= codec
->spec
;
5063 err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
);
5066 err
= vt1716S_auto_fill_dac_nids(spec
, &spec
->autocfg
);
5069 if (!spec
->autocfg
.line_outs
&& !spec
->autocfg
.hp_pins
[0])
5070 return 0; /* can't find valid BIOS pin config */
5072 err
= vt1716S_auto_create_multi_out_ctls(spec
, &spec
->autocfg
);
5075 err
= vt1716S_auto_create_hp_ctls(spec
, spec
->autocfg
.hp_pins
[0]);
5078 err
= vt1716S_auto_create_analog_input_ctls(codec
, &spec
->autocfg
);
5082 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
5084 fill_dig_outs(codec
);
5086 if (spec
->kctls
.list
)
5087 spec
->mixers
[spec
->num_mixers
++] = spec
->kctls
.list
;
5089 spec
->input_mux
= &spec
->private_imux
[0];
5092 via_hp_build(codec
);
5094 via_smart51_build(spec
);
5099 #ifdef CONFIG_SND_HDA_POWER_SAVE
5100 static const struct hda_amp_list vt1716S_loopbacks
[] = {
5101 { 0x16, HDA_INPUT
, 1 },
5102 { 0x16, HDA_INPUT
, 2 },
5103 { 0x16, HDA_INPUT
, 3 },
5104 { 0x16, HDA_INPUT
, 4 },
5109 static void set_widgets_power_state_vt1716S(struct hda_codec
*codec
)
5111 struct via_spec
*spec
= codec
->spec
;
5114 unsigned int mono_out
, present
;
5115 /* SW0 (17h) = stereo mixer */
5117 (snd_hda_codec_read(codec
, 0x17, 0,
5118 AC_VERB_GET_CONNECT_SEL
, 0x00) == 5);
5120 /* PW 1/2/5 (1ah/1bh/1eh) */
5122 set_pin_power_state(codec
, 0x1a, &parm
);
5123 set_pin_power_state(codec
, 0x1b, &parm
);
5124 set_pin_power_state(codec
, 0x1e, &parm
);
5127 /* SW0 (17h), AIW0(13h) */
5128 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_POWER_STATE
, parm
);
5129 snd_hda_codec_write(codec
, 0x13, 0, AC_VERB_SET_POWER_STATE
, parm
);
5132 set_pin_power_state(codec
, 0x1e, &parm
);
5134 if (spec
->dmic_enabled
)
5135 set_pin_power_state(codec
, 0x22, &parm
);
5137 snd_hda_codec_write(codec
, 0x22, 0,
5138 AC_VERB_SET_POWER_STATE
, AC_PWRST_D3
);
5140 /* SW2(26h), AIW1(14h) */
5141 snd_hda_codec_write(codec
, 0x26, 0, AC_VERB_SET_POWER_STATE
, parm
);
5142 snd_hda_codec_write(codec
, 0x14, 0, AC_VERB_SET_POWER_STATE
, parm
);
5145 /* PW0 (19h), SW1 (18h), AOW1 (11h) */
5147 set_pin_power_state(codec
, 0x19, &parm
);
5148 /* Smart 5.1 PW2(1bh) */
5149 if (spec
->smart51_enabled
)
5150 set_pin_power_state(codec
, 0x1b, &parm
);
5151 snd_hda_codec_write(codec
, 0x18, 0, AC_VERB_SET_POWER_STATE
, parm
);
5152 snd_hda_codec_write(codec
, 0x11, 0, AC_VERB_SET_POWER_STATE
, parm
);
5154 /* PW7 (23h), SW3 (27h), AOW3 (25h) */
5156 set_pin_power_state(codec
, 0x23, &parm
);
5157 /* Smart 5.1 PW1(1ah) */
5158 if (spec
->smart51_enabled
)
5159 set_pin_power_state(codec
, 0x1a, &parm
);
5160 snd_hda_codec_write(codec
, 0x27, 0, AC_VERB_SET_POWER_STATE
, parm
);
5162 /* Smart 5.1 PW5(1eh) */
5163 if (spec
->smart51_enabled
)
5164 set_pin_power_state(codec
, 0x1e, &parm
);
5165 snd_hda_codec_write(codec
, 0x25, 0, AC_VERB_SET_POWER_STATE
, parm
);
5168 /* SW4(28h)->MW1(29h)-> PW12 (2ah)*/
5169 present
= snd_hda_jack_detect(codec
, 0x1c);
5174 present
= snd_hda_jack_detect(codec
, 0x1d);
5175 if (!spec
->hp_independent_mode
&& present
)
5180 parm
= mono_out
? AC_PWRST_D0
: AC_PWRST_D3
;
5181 snd_hda_codec_write(codec
, 0x28, 0, AC_VERB_SET_POWER_STATE
, parm
);
5182 snd_hda_codec_write(codec
, 0x29, 0, AC_VERB_SET_POWER_STATE
, parm
);
5183 snd_hda_codec_write(codec
, 0x2a, 0, AC_VERB_SET_POWER_STATE
, parm
);
5185 /* PW 3/4 (1ch/1dh) */
5187 set_pin_power_state(codec
, 0x1c, &parm
);
5188 set_pin_power_state(codec
, 0x1d, &parm
);
5189 /* HP Independent Mode, power on AOW3 */
5190 if (spec
->hp_independent_mode
)
5191 snd_hda_codec_write(codec
, 0x25, 0,
5192 AC_VERB_SET_POWER_STATE
, parm
);
5194 /* force to D0 for internal Speaker */
5195 /* MW0 (16h), AOW0 (10h) */
5196 snd_hda_codec_write(codec
, 0x16, 0, AC_VERB_SET_POWER_STATE
,
5197 imux_is_smixer
? AC_PWRST_D0
: parm
);
5198 snd_hda_codec_write(codec
, 0x10, 0, AC_VERB_SET_POWER_STATE
,
5199 mono_out
? AC_PWRST_D0
: parm
);
5202 static int patch_vt1716S(struct hda_codec
*codec
)
5204 struct via_spec
*spec
;
5207 /* create a codec specific record */
5208 spec
= via_new_spec(codec
);
5212 /* automatic parse from the BIOS config */
5213 err
= vt1716S_parse_auto_config(codec
);
5218 printk(KERN_INFO
"hda_codec: Cannot set up configuration "
5219 "from BIOS. Using genenic mode...\n");
5222 spec
->init_verbs
[spec
->num_iverbs
++] = vt1716S_volume_init_verbs
;
5223 spec
->init_verbs
[spec
->num_iverbs
++] = vt1716S_uniwill_init_verbs
;
5225 spec
->stream_name_analog
= "VT1716S Analog";
5226 spec
->stream_analog_playback
= &vt1716S_pcm_analog_playback
;
5227 spec
->stream_analog_capture
= &vt1716S_pcm_analog_capture
;
5229 spec
->stream_name_digital
= "VT1716S Digital";
5230 spec
->stream_digital_playback
= &vt1716S_pcm_digital_playback
;
5232 if (!spec
->adc_nids
&& spec
->input_mux
) {
5233 spec
->adc_nids
= vt1716S_adc_nids
;
5234 spec
->num_adc_nids
= ARRAY_SIZE(vt1716S_adc_nids
);
5235 get_mux_nids(codec
);
5236 override_mic_boost(codec
, 0x1a, 0, 3, 40);
5237 override_mic_boost(codec
, 0x1e, 0, 3, 40);
5238 spec
->mixers
[spec
->num_mixers
] = vt1716S_capture_mixer
;
5242 spec
->mixers
[spec
->num_mixers
] = vt1716s_dmic_mixer
;
5245 spec
->mixers
[spec
->num_mixers
++] = vt1716S_mono_out_mixer
;
5247 codec
->patch_ops
= via_patch_ops
;
5249 codec
->patch_ops
.init
= via_auto_init
;
5250 codec
->patch_ops
.unsol_event
= via_unsol_event
;
5252 #ifdef CONFIG_SND_HDA_POWER_SAVE
5253 spec
->loopback
.amplist
= vt1716S_loopbacks
;
5256 spec
->set_widgets_power_state
= set_widgets_power_state_vt1716S
;
5262 /* capture mixer elements */
5263 static const struct snd_kcontrol_new vt2002P_capture_mixer
[] = {
5264 HDA_CODEC_VOLUME("Capture Volume", 0x10, 0x0, HDA_INPUT
),
5265 HDA_CODEC_MUTE("Capture Switch", 0x10, 0x0, HDA_INPUT
),
5266 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x11, 0x0, HDA_INPUT
),
5267 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x11, 0x0, HDA_INPUT
),
5268 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x2b, 0x0, HDA_INPUT
),
5269 HDA_CODEC_VOLUME("Front Mic Boost Capture Volume", 0x29, 0x0,
5272 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
5273 /* The multiple "Capture Source" controls confuse alsamixer
5274 * So call somewhat different..
5276 /* .name = "Capture Source", */
5277 .name
= "Input Source",
5279 .info
= via_mux_enum_info
,
5280 .get
= via_mux_enum_get
,
5281 .put
= via_mux_enum_put
,
5286 static const struct hda_verb vt2002P_volume_init_verbs
[] = {
5287 /* Class-D speaker related verbs */
5292 * Unmute ADC0-1 and set the default input to mic-in
5294 {0x8, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5295 {0x9, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5298 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5301 /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */
5302 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
5303 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
5304 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
5305 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
5306 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
5308 /* MUX Indices: Mic = 0 */
5309 {0x1e, AC_VERB_SET_CONNECT_SEL
, 0},
5310 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0},
5312 /* PW9 Output enable */
5313 {0x2d, AC_VERB_SET_PIN_WIDGET_CONTROL
, AC_PINCTL_OUT_EN
},
5315 /* Enable Boost Volume backdoor */
5318 /* MW0/1/4/8: un-mute index 0 (MUXx), un-mute index 1 (MW9) */
5319 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5320 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5321 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5322 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5323 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
5324 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
5325 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
5326 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
5328 /* set MUX0/1/4/8 = 0 (AOW0) */
5329 {0x34, AC_VERB_SET_CONNECT_SEL
, 0},
5330 {0x35, AC_VERB_SET_CONNECT_SEL
, 0},
5331 {0x37, AC_VERB_SET_CONNECT_SEL
, 0},
5332 {0x3b, AC_VERB_SET_CONNECT_SEL
, 0},
5334 /* set PW0 index=0 (MW0) */
5335 {0x24, AC_VERB_SET_CONNECT_SEL
, 0},
5337 /* Enable AOW0 to MW9 */
5341 static const struct hda_verb vt1802_volume_init_verbs
[] = {
5343 * Unmute ADC0-1 and set the default input to mic-in
5345 {0x8, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5346 {0x9, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5349 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5352 /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */
5353 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
5354 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
5355 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
5356 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
5357 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
5359 /* MUX Indices: Mic = 0 */
5360 {0x1e, AC_VERB_SET_CONNECT_SEL
, 0},
5361 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0},
5363 /* PW9 Output enable */
5364 {0x2d, AC_VERB_SET_PIN_WIDGET_CONTROL
, AC_PINCTL_OUT_EN
},
5366 /* Enable Boost Volume backdoor */
5369 /* MW0/1/4/8: un-mute index 0 (MUXx), un-mute index 1 (MW9) */
5370 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5371 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5372 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5373 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5374 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
5375 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
5376 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
5377 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
5379 /* set MUX0/1/4/8 = 0 (AOW0) */
5380 {0x34, AC_VERB_SET_CONNECT_SEL
, 0},
5381 {0x35, AC_VERB_SET_CONNECT_SEL
, 0},
5382 {0x38, AC_VERB_SET_CONNECT_SEL
, 0},
5383 {0x3c, AC_VERB_SET_CONNECT_SEL
, 0},
5385 /* set PW0 index=0 (MW0) */
5386 {0x24, AC_VERB_SET_CONNECT_SEL
, 0},
5388 /* Enable AOW0 to MW9 */
5394 static const struct hda_verb vt2002P_uniwill_init_verbs
[] = {
5395 {0x25, AC_VERB_SET_UNSOLICITED_ENABLE
,
5396 AC_USRSP_EN
| VIA_JACK_EVENT
| VIA_BIND_HP_EVENT
},
5397 {0x26, AC_VERB_SET_UNSOLICITED_ENABLE
,
5398 AC_USRSP_EN
| VIA_JACK_EVENT
| VIA_BIND_HP_EVENT
},
5399 {0x29, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
5400 {0x2a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
5401 {0x2b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
5404 static const struct hda_verb vt1802_uniwill_init_verbs
[] = {
5405 {0x25, AC_VERB_SET_UNSOLICITED_ENABLE
,
5406 AC_USRSP_EN
| VIA_JACK_EVENT
| VIA_BIND_HP_EVENT
},
5407 {0x28, AC_VERB_SET_UNSOLICITED_ENABLE
,
5408 AC_USRSP_EN
| VIA_JACK_EVENT
| VIA_BIND_HP_EVENT
},
5409 {0x29, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
5410 {0x2a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
5411 {0x2b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
5415 static const struct hda_pcm_stream vt2002P_pcm_analog_playback
= {
5419 .nid
= 0x8, /* NID to query formats and rates */
5421 .open
= via_playback_pcm_open
,
5422 .prepare
= via_playback_multi_pcm_prepare
,
5423 .cleanup
= via_playback_multi_pcm_cleanup
,
5424 .close
= via_pcm_open_close
,
5428 static const struct hda_pcm_stream vt2002P_pcm_analog_capture
= {
5432 .nid
= 0x10, /* NID to query formats and rates */
5434 .open
= via_pcm_open_close
,
5435 .prepare
= via_capture_pcm_prepare
,
5436 .cleanup
= via_capture_pcm_cleanup
,
5437 .close
= via_pcm_open_close
,
5441 static const struct hda_pcm_stream vt2002P_pcm_digital_playback
= {
5445 /* NID is set in via_build_pcms */
5447 .open
= via_dig_playback_pcm_open
,
5448 .close
= via_dig_playback_pcm_close
,
5449 .prepare
= via_dig_playback_pcm_prepare
,
5450 .cleanup
= via_dig_playback_pcm_cleanup
5454 /* fill in the dac_nids table from the parsed pin configuration */
5455 static int vt2002P_auto_fill_dac_nids(struct via_spec
*spec
,
5456 const struct auto_pin_cfg
*cfg
)
5458 spec
->multiout
.num_dacs
= 1;
5459 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
5460 if (cfg
->line_out_pins
[0])
5461 spec
->private_dac_nids
[0] = 0x8;
5465 /* add playback controls from the parsed DAC table */
5466 static int vt2002P_auto_create_multi_out_ctls(struct via_spec
*spec
,
5467 const struct auto_pin_cfg
*cfg
)
5472 if (!cfg
->line_out_pins
[0])
5475 if (spec
->codec_type
== VT1802
)
5480 /* Line-Out: PortE */
5481 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
5482 "Master Front Playback Volume",
5483 HDA_COMPOSE_AMP_VAL(0x8, 3, 0, HDA_OUTPUT
));
5486 err
= via_add_control(spec
, VIA_CTL_WIDGET_BIND_PIN_MUTE
,
5487 "Master Front Playback Switch",
5488 HDA_COMPOSE_AMP_VAL(sw_nid
, 3, 0, HDA_OUTPUT
));
5495 static int vt2002P_auto_create_hp_ctls(struct via_spec
*spec
, hda_nid_t pin
)
5502 spec
->multiout
.hp_nid
= 0x9;
5503 spec
->hp_independent_mode_index
= 1;
5505 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
5506 "Headphone Playback Volume",
5507 HDA_COMPOSE_AMP_VAL(
5508 spec
->multiout
.hp_nid
, 3, 0, HDA_OUTPUT
));
5512 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
5513 "Headphone Playback Switch",
5514 HDA_COMPOSE_AMP_VAL(0x25, 3, 0, HDA_OUTPUT
));
5518 create_hp_imux(spec
);
5522 /* create playback/capture controls for input pins */
5523 static int vt2002P_auto_create_analog_input_ctls(struct hda_codec
*codec
,
5524 const struct auto_pin_cfg
*cfg
)
5526 struct via_spec
*spec
= codec
->spec
;
5527 struct hda_input_mux
*imux
= &spec
->private_imux
[0];
5528 static const hda_nid_t pin_idxs
[] = { 0x2b, 0x2a, 0x29, 0xff };
5531 err
= vt_auto_create_analog_input_ctls(codec
, cfg
, 0x21, pin_idxs
,
5532 ARRAY_SIZE(pin_idxs
));
5535 /* build volume/mute control of loopback */
5536 err
= via_new_analog_input(spec
, "Stereo Mixer", 0, 3, 0x21);
5540 /* for digital mic select */
5541 snd_hda_add_imux_item(imux
, "Digital Mic", 4, NULL
);
5546 static int vt2002P_parse_auto_config(struct hda_codec
*codec
)
5548 struct via_spec
*spec
= codec
->spec
;
5552 err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
);
5556 err
= vt2002P_auto_fill_dac_nids(spec
, &spec
->autocfg
);
5560 if (!spec
->autocfg
.line_outs
&& !spec
->autocfg
.hp_pins
[0])
5561 return 0; /* can't find valid BIOS pin config */
5563 err
= vt2002P_auto_create_multi_out_ctls(spec
, &spec
->autocfg
);
5566 err
= vt2002P_auto_create_hp_ctls(spec
, spec
->autocfg
.hp_pins
[0]);
5569 err
= vt2002P_auto_create_analog_input_ctls(codec
, &spec
->autocfg
);
5573 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
5575 fill_dig_outs(codec
);
5577 if (spec
->kctls
.list
)
5578 spec
->mixers
[spec
->num_mixers
++] = spec
->kctls
.list
;
5580 spec
->input_mux
= &spec
->private_imux
[0];
5583 via_hp_build(codec
);
5588 #ifdef CONFIG_SND_HDA_POWER_SAVE
5589 static const struct hda_amp_list vt2002P_loopbacks
[] = {
5590 { 0x21, HDA_INPUT
, 0 },
5591 { 0x21, HDA_INPUT
, 1 },
5592 { 0x21, HDA_INPUT
, 2 },
5597 static void set_widgets_power_state_vt2002P(struct hda_codec
*codec
)
5599 struct via_spec
*spec
= codec
->spec
;
5602 unsigned int present
;
5603 /* MUX9 (1eh) = stereo mixer */
5605 snd_hda_codec_read(codec
, 0x1e, 0, AC_VERB_GET_CONNECT_SEL
, 0x00) == 3;
5607 /* PW 5/6/7 (29h/2ah/2bh) */
5609 set_pin_power_state(codec
, 0x29, &parm
);
5610 set_pin_power_state(codec
, 0x2a, &parm
);
5611 set_pin_power_state(codec
, 0x2b, &parm
);
5613 /* MUX9/10 (1eh/1fh), AIW 0/1 (10h/11h) */
5614 snd_hda_codec_write(codec
, 0x1e, 0, AC_VERB_SET_POWER_STATE
, parm
);
5615 snd_hda_codec_write(codec
, 0x1f, 0, AC_VERB_SET_POWER_STATE
, parm
);
5616 snd_hda_codec_write(codec
, 0x10, 0, AC_VERB_SET_POWER_STATE
, parm
);
5617 snd_hda_codec_write(codec
, 0x11, 0, AC_VERB_SET_POWER_STATE
, parm
);
5621 snd_hda_codec_write(codec
, 0x8, 0, AC_VERB_SET_POWER_STATE
, parm
);
5623 if (spec
->codec_type
== VT1802
) {
5624 /* PW4 (28h), MW4 (18h), MUX4(38h) */
5626 set_pin_power_state(codec
, 0x28, &parm
);
5627 snd_hda_codec_write(codec
, 0x18, 0,
5628 AC_VERB_SET_POWER_STATE
, parm
);
5629 snd_hda_codec_write(codec
, 0x38, 0,
5630 AC_VERB_SET_POWER_STATE
, parm
);
5632 /* PW4 (26h), MW4 (1ch), MUX4(37h) */
5634 set_pin_power_state(codec
, 0x26, &parm
);
5635 snd_hda_codec_write(codec
, 0x1c, 0,
5636 AC_VERB_SET_POWER_STATE
, parm
);
5637 snd_hda_codec_write(codec
, 0x37, 0,
5638 AC_VERB_SET_POWER_STATE
, parm
);
5641 if (spec
->codec_type
== VT1802
) {
5642 /* PW1 (25h), MW1 (15h), MUX1(35h), AOW1 (9h) */
5644 set_pin_power_state(codec
, 0x25, &parm
);
5645 snd_hda_codec_write(codec
, 0x15, 0,
5646 AC_VERB_SET_POWER_STATE
, parm
);
5647 snd_hda_codec_write(codec
, 0x35, 0,
5648 AC_VERB_SET_POWER_STATE
, parm
);
5650 /* PW1 (25h), MW1 (19h), MUX1(35h), AOW1 (9h) */
5652 set_pin_power_state(codec
, 0x25, &parm
);
5653 snd_hda_codec_write(codec
, 0x19, 0,
5654 AC_VERB_SET_POWER_STATE
, parm
);
5655 snd_hda_codec_write(codec
, 0x35, 0,
5656 AC_VERB_SET_POWER_STATE
, parm
);
5659 if (spec
->hp_independent_mode
)
5660 snd_hda_codec_write(codec
, 0x9, 0,
5661 AC_VERB_SET_POWER_STATE
, AC_PWRST_D0
);
5664 /* PW0 (24h), MW0(18h/14h), MUX0(34h) */
5665 present
= snd_hda_jack_detect(codec
, 0x25);
5668 set_pin_power_state(codec
, 0x24, &parm
);
5669 parm
= present
? AC_PWRST_D3
: AC_PWRST_D0
;
5670 if (spec
->codec_type
== VT1802
)
5671 snd_hda_codec_write(codec
, 0x14, 0,
5672 AC_VERB_SET_POWER_STATE
, parm
);
5674 snd_hda_codec_write(codec
, 0x18, 0,
5675 AC_VERB_SET_POWER_STATE
, parm
);
5676 snd_hda_codec_write(codec
, 0x34, 0, AC_VERB_SET_POWER_STATE
, parm
);
5679 present
= snd_hda_jack_detect(codec
, 0x26);
5681 parm
= present
? AC_PWRST_D3
: AC_PWRST_D0
;
5682 if (spec
->codec_type
== VT1802
) {
5683 /* PW15 (33h), MW8(1ch), MUX8(3ch) */
5684 snd_hda_codec_write(codec
, 0x33, 0,
5685 AC_VERB_SET_POWER_STATE
, parm
);
5686 snd_hda_codec_write(codec
, 0x1c, 0,
5687 AC_VERB_SET_POWER_STATE
, parm
);
5688 snd_hda_codec_write(codec
, 0x3c, 0,
5689 AC_VERB_SET_POWER_STATE
, parm
);
5691 /* PW15 (31h), MW8(17h), MUX8(3bh) */
5692 snd_hda_codec_write(codec
, 0x31, 0,
5693 AC_VERB_SET_POWER_STATE
, parm
);
5694 snd_hda_codec_write(codec
, 0x17, 0,
5695 AC_VERB_SET_POWER_STATE
, parm
);
5696 snd_hda_codec_write(codec
, 0x3b, 0,
5697 AC_VERB_SET_POWER_STATE
, parm
);
5700 if (imux_is_smixer
|| !is_aa_path_mute(codec
))
5701 snd_hda_codec_write(codec
, 0x21, 0,
5702 AC_VERB_SET_POWER_STATE
, AC_PWRST_D0
);
5704 snd_hda_codec_write(codec
, 0x21, 0,
5705 AC_VERB_SET_POWER_STATE
, AC_PWRST_D3
);
5708 /* patch for vt2002P */
5709 static int patch_vt2002P(struct hda_codec
*codec
)
5711 struct via_spec
*spec
;
5714 /* create a codec specific record */
5715 spec
= via_new_spec(codec
);
5719 /* automatic parse from the BIOS config */
5720 err
= vt2002P_parse_auto_config(codec
);
5725 printk(KERN_INFO
"hda_codec: Cannot set up configuration "
5726 "from BIOS. Using genenic mode...\n");
5729 if (spec
->codec_type
== VT1802
)
5730 spec
->init_verbs
[spec
->num_iverbs
++] =
5731 vt1802_volume_init_verbs
;
5733 spec
->init_verbs
[spec
->num_iverbs
++] =
5734 vt2002P_volume_init_verbs
;
5736 if (spec
->codec_type
== VT1802
)
5737 spec
->init_verbs
[spec
->num_iverbs
++] =
5738 vt1802_uniwill_init_verbs
;
5740 spec
->init_verbs
[spec
->num_iverbs
++] =
5741 vt2002P_uniwill_init_verbs
;
5743 if (spec
->codec_type
== VT1802
)
5744 spec
->stream_name_analog
= "VT1802 Analog";
5746 spec
->stream_name_analog
= "VT2002P Analog";
5747 spec
->stream_analog_playback
= &vt2002P_pcm_analog_playback
;
5748 spec
->stream_analog_capture
= &vt2002P_pcm_analog_capture
;
5750 if (spec
->codec_type
== VT1802
)
5751 spec
->stream_name_digital
= "VT1802 Digital";
5753 spec
->stream_name_digital
= "VT2002P Digital";
5754 spec
->stream_digital_playback
= &vt2002P_pcm_digital_playback
;
5756 if (!spec
->adc_nids
&& spec
->input_mux
) {
5757 spec
->adc_nids
= vt2002P_adc_nids
;
5758 spec
->num_adc_nids
= ARRAY_SIZE(vt2002P_adc_nids
);
5759 get_mux_nids(codec
);
5760 override_mic_boost(codec
, 0x2b, 0, 3, 40);
5761 override_mic_boost(codec
, 0x29, 0, 3, 40);
5762 spec
->mixers
[spec
->num_mixers
] = vt2002P_capture_mixer
;
5766 codec
->patch_ops
= via_patch_ops
;
5768 codec
->patch_ops
.init
= via_auto_init
;
5769 codec
->patch_ops
.unsol_event
= via_unsol_event
;
5771 #ifdef CONFIG_SND_HDA_POWER_SAVE
5772 spec
->loopback
.amplist
= vt2002P_loopbacks
;
5775 spec
->set_widgets_power_state
= set_widgets_power_state_vt2002P
;
5781 /* capture mixer elements */
5782 static const struct snd_kcontrol_new vt1812_capture_mixer
[] = {
5783 HDA_CODEC_VOLUME("Capture Volume", 0x10, 0x0, HDA_INPUT
),
5784 HDA_CODEC_MUTE("Capture Switch", 0x10, 0x0, HDA_INPUT
),
5785 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x11, 0x0, HDA_INPUT
),
5786 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x11, 0x0, HDA_INPUT
),
5787 HDA_CODEC_MUTE("Mic Boost Capture Volume", 0x2b, 0x0, HDA_INPUT
),
5788 HDA_CODEC_MUTE("Front Mic Boost Capture Volume", 0x29, 0x0,
5791 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
5792 /* The multiple "Capture Source" controls confuse alsamixer
5793 * So call somewhat different..
5795 .name
= "Input Source",
5797 .info
= via_mux_enum_info
,
5798 .get
= via_mux_enum_get
,
5799 .put
= via_mux_enum_put
,
5804 static const struct hda_verb vt1812_volume_init_verbs
[] = {
5806 * Unmute ADC0-1 and set the default input to mic-in
5808 {0x8, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5809 {0x9, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5812 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5815 /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */
5816 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
5817 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
5818 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
5819 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
5820 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
5822 /* MUX Indices: Mic = 0 */
5823 {0x1e, AC_VERB_SET_CONNECT_SEL
, 0},
5824 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0},
5826 /* PW9 Output enable */
5827 {0x2d, AC_VERB_SET_PIN_WIDGET_CONTROL
, AC_PINCTL_OUT_EN
},
5829 /* Enable Boost Volume backdoor */
5832 /* MW0/1/4/13/15: un-mute index 0 (MUXx), un-mute index 1 (MW9) */
5833 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5834 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5835 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5836 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5837 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5838 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
5839 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
5840 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
5841 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
5842 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
5844 /* set MUX0/1/4/13/15 = 0 (AOW0) */
5845 {0x34, AC_VERB_SET_CONNECT_SEL
, 0},
5846 {0x35, AC_VERB_SET_CONNECT_SEL
, 0},
5847 {0x38, AC_VERB_SET_CONNECT_SEL
, 0},
5848 {0x3c, AC_VERB_SET_CONNECT_SEL
, 0},
5849 {0x3d, AC_VERB_SET_CONNECT_SEL
, 0},
5851 /* Enable AOW0 to MW9 */
5857 static const struct hda_verb vt1812_uniwill_init_verbs
[] = {
5858 {0x33, AC_VERB_SET_UNSOLICITED_ENABLE
,
5859 AC_USRSP_EN
| VIA_JACK_EVENT
| VIA_BIND_HP_EVENT
},
5860 {0x25, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
5861 {0x28, AC_VERB_SET_UNSOLICITED_ENABLE
,
5862 AC_USRSP_EN
| VIA_JACK_EVENT
| VIA_BIND_HP_EVENT
},
5863 {0x29, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
5864 {0x2a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
5865 {0x2b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
5869 static const struct hda_pcm_stream vt1812_pcm_analog_playback
= {
5873 .nid
= 0x8, /* NID to query formats and rates */
5875 .open
= via_playback_pcm_open
,
5876 .prepare
= via_playback_multi_pcm_prepare
,
5877 .cleanup
= via_playback_multi_pcm_cleanup
,
5878 .close
= via_pcm_open_close
,
5882 static const struct hda_pcm_stream vt1812_pcm_analog_capture
= {
5886 .nid
= 0x10, /* NID to query formats and rates */
5888 .open
= via_pcm_open_close
,
5889 .prepare
= via_capture_pcm_prepare
,
5890 .cleanup
= via_capture_pcm_cleanup
,
5891 .close
= via_pcm_open_close
,
5895 static const struct hda_pcm_stream vt1812_pcm_digital_playback
= {
5899 /* NID is set in via_build_pcms */
5901 .open
= via_dig_playback_pcm_open
,
5902 .close
= via_dig_playback_pcm_close
,
5903 .prepare
= via_dig_playback_pcm_prepare
,
5904 .cleanup
= via_dig_playback_pcm_cleanup
5907 /* fill in the dac_nids table from the parsed pin configuration */
5908 static int vt1812_auto_fill_dac_nids(struct via_spec
*spec
,
5909 const struct auto_pin_cfg
*cfg
)
5911 spec
->multiout
.num_dacs
= 1;
5912 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
5913 if (cfg
->line_out_pins
[0])
5914 spec
->private_dac_nids
[0] = 0x8;
5919 /* add playback controls from the parsed DAC table */
5920 static int vt1812_auto_create_multi_out_ctls(struct via_spec
*spec
,
5921 const struct auto_pin_cfg
*cfg
)
5925 if (!cfg
->line_out_pins
[0])
5928 /* Line-Out: PortE */
5929 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
5930 "Front Playback Volume",
5931 HDA_COMPOSE_AMP_VAL(0x8, 3, 0, HDA_OUTPUT
));
5934 err
= via_add_control(spec
, VIA_CTL_WIDGET_BIND_PIN_MUTE
,
5935 "Front Playback Switch",
5936 HDA_COMPOSE_AMP_VAL(0x28, 3, 0, HDA_OUTPUT
));
5943 static int vt1812_auto_create_hp_ctls(struct via_spec
*spec
, hda_nid_t pin
)
5950 spec
->multiout
.hp_nid
= 0x9;
5951 spec
->hp_independent_mode_index
= 1;
5954 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
5955 "Headphone Playback Volume",
5956 HDA_COMPOSE_AMP_VAL(
5957 spec
->multiout
.hp_nid
, 3, 0, HDA_OUTPUT
));
5961 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
5962 "Headphone Playback Switch",
5963 HDA_COMPOSE_AMP_VAL(pin
, 3, 0, HDA_OUTPUT
));
5967 create_hp_imux(spec
);
5971 /* create playback/capture controls for input pins */
5972 static int vt1812_auto_create_analog_input_ctls(struct hda_codec
*codec
,
5973 const struct auto_pin_cfg
*cfg
)
5975 struct via_spec
*spec
= codec
->spec
;
5976 struct hda_input_mux
*imux
= &spec
->private_imux
[0];
5977 static const hda_nid_t pin_idxs
[] = { 0x2b, 0x2a, 0x29, 0, 0, 0xff };
5980 err
= vt_auto_create_analog_input_ctls(codec
, cfg
, 0x21, pin_idxs
,
5981 ARRAY_SIZE(pin_idxs
));
5985 /* build volume/mute control of loopback */
5986 err
= via_new_analog_input(spec
, "Stereo Mixer", 0, 5, 0x21);
5990 /* for digital mic select */
5991 snd_hda_add_imux_item(imux
, "Digital Mic", 6, NULL
);
5996 static int vt1812_parse_auto_config(struct hda_codec
*codec
)
5998 struct via_spec
*spec
= codec
->spec
;
6002 err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
);
6005 fill_dig_outs(codec
);
6006 err
= vt1812_auto_fill_dac_nids(spec
, &spec
->autocfg
);
6010 if (!spec
->autocfg
.line_outs
&& !spec
->autocfg
.hp_outs
)
6011 return 0; /* can't find valid BIOS pin config */
6013 err
= vt1812_auto_create_multi_out_ctls(spec
, &spec
->autocfg
);
6016 err
= vt1812_auto_create_hp_ctls(spec
, spec
->autocfg
.hp_pins
[0]);
6019 err
= vt1812_auto_create_analog_input_ctls(codec
, &spec
->autocfg
);
6023 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
6025 fill_dig_outs(codec
);
6027 if (spec
->kctls
.list
)
6028 spec
->mixers
[spec
->num_mixers
++] = spec
->kctls
.list
;
6030 spec
->input_mux
= &spec
->private_imux
[0];
6033 via_hp_build(codec
);
6038 #ifdef CONFIG_SND_HDA_POWER_SAVE
6039 static const struct hda_amp_list vt1812_loopbacks
[] = {
6040 { 0x21, HDA_INPUT
, 0 },
6041 { 0x21, HDA_INPUT
, 1 },
6042 { 0x21, HDA_INPUT
, 2 },
6047 static void set_widgets_power_state_vt1812(struct hda_codec
*codec
)
6049 struct via_spec
*spec
= codec
->spec
;
6050 int imux_is_smixer
=
6051 snd_hda_codec_read(codec
, 0x13, 0, AC_VERB_GET_CONNECT_SEL
, 0x00) == 3;
6053 unsigned int present
;
6054 /* MUX10 (1eh) = stereo mixer */
6056 snd_hda_codec_read(codec
, 0x1e, 0, AC_VERB_GET_CONNECT_SEL
, 0x00) == 5;
6058 /* PW 5/6/7 (29h/2ah/2bh) */
6060 set_pin_power_state(codec
, 0x29, &parm
);
6061 set_pin_power_state(codec
, 0x2a, &parm
);
6062 set_pin_power_state(codec
, 0x2b, &parm
);
6064 /* MUX10/11 (1eh/1fh), AIW 0/1 (10h/11h) */
6065 snd_hda_codec_write(codec
, 0x1e, 0, AC_VERB_SET_POWER_STATE
, parm
);
6066 snd_hda_codec_write(codec
, 0x1f, 0, AC_VERB_SET_POWER_STATE
, parm
);
6067 snd_hda_codec_write(codec
, 0x10, 0, AC_VERB_SET_POWER_STATE
, parm
);
6068 snd_hda_codec_write(codec
, 0x11, 0, AC_VERB_SET_POWER_STATE
, parm
);
6072 snd_hda_codec_write(codec
, 0x8, 0,
6073 AC_VERB_SET_POWER_STATE
, AC_PWRST_D0
);
6075 /* PW4 (28h), MW4 (18h), MUX4(38h) */
6077 set_pin_power_state(codec
, 0x28, &parm
);
6078 snd_hda_codec_write(codec
, 0x18, 0, AC_VERB_SET_POWER_STATE
, parm
);
6079 snd_hda_codec_write(codec
, 0x38, 0, AC_VERB_SET_POWER_STATE
, parm
);
6081 /* PW1 (25h), MW1 (15h), MUX1(35h), AOW1 (9h) */
6083 set_pin_power_state(codec
, 0x25, &parm
);
6084 snd_hda_codec_write(codec
, 0x15, 0, AC_VERB_SET_POWER_STATE
, parm
);
6085 snd_hda_codec_write(codec
, 0x35, 0, AC_VERB_SET_POWER_STATE
, parm
);
6086 if (spec
->hp_independent_mode
)
6087 snd_hda_codec_write(codec
, 0x9, 0,
6088 AC_VERB_SET_POWER_STATE
, AC_PWRST_D0
);
6090 /* Internal Speaker */
6091 /* PW0 (24h), MW0(14h), MUX0(34h) */
6092 present
= snd_hda_jack_detect(codec
, 0x25);
6095 set_pin_power_state(codec
, 0x24, &parm
);
6097 snd_hda_codec_write(codec
, 0x14, 0,
6098 AC_VERB_SET_POWER_STATE
, AC_PWRST_D3
);
6099 snd_hda_codec_write(codec
, 0x34, 0,
6100 AC_VERB_SET_POWER_STATE
, AC_PWRST_D3
);
6102 snd_hda_codec_write(codec
, 0x14, 0,
6103 AC_VERB_SET_POWER_STATE
, AC_PWRST_D0
);
6104 snd_hda_codec_write(codec
, 0x34, 0,
6105 AC_VERB_SET_POWER_STATE
, AC_PWRST_D0
);
6110 /* PW13 (31h), MW13(1ch), MUX13(3ch), MW14(3eh) */
6111 present
= snd_hda_jack_detect(codec
, 0x28);
6114 set_pin_power_state(codec
, 0x31, &parm
);
6116 snd_hda_codec_write(codec
, 0x1c, 0,
6117 AC_VERB_SET_POWER_STATE
, AC_PWRST_D3
);
6118 snd_hda_codec_write(codec
, 0x3c, 0,
6119 AC_VERB_SET_POWER_STATE
, AC_PWRST_D3
);
6120 snd_hda_codec_write(codec
, 0x3e, 0,
6121 AC_VERB_SET_POWER_STATE
, AC_PWRST_D3
);
6123 snd_hda_codec_write(codec
, 0x1c, 0,
6124 AC_VERB_SET_POWER_STATE
, AC_PWRST_D0
);
6125 snd_hda_codec_write(codec
, 0x3c, 0,
6126 AC_VERB_SET_POWER_STATE
, AC_PWRST_D0
);
6127 snd_hda_codec_write(codec
, 0x3e, 0,
6128 AC_VERB_SET_POWER_STATE
, AC_PWRST_D0
);
6131 /* PW15 (33h), MW15 (1dh), MUX15(3dh) */
6133 set_pin_power_state(codec
, 0x33, &parm
);
6134 snd_hda_codec_write(codec
, 0x1d, 0, AC_VERB_SET_POWER_STATE
, parm
);
6135 snd_hda_codec_write(codec
, 0x3d, 0, AC_VERB_SET_POWER_STATE
, parm
);
6139 /* patch for vt1812 */
6140 static int patch_vt1812(struct hda_codec
*codec
)
6142 struct via_spec
*spec
;
6145 /* create a codec specific record */
6146 spec
= via_new_spec(codec
);
6150 /* automatic parse from the BIOS config */
6151 err
= vt1812_parse_auto_config(codec
);
6156 printk(KERN_INFO
"hda_codec: Cannot set up configuration "
6157 "from BIOS. Using genenic mode...\n");
6161 spec
->init_verbs
[spec
->num_iverbs
++] = vt1812_volume_init_verbs
;
6162 spec
->init_verbs
[spec
->num_iverbs
++] = vt1812_uniwill_init_verbs
;
6164 spec
->stream_name_analog
= "VT1812 Analog";
6165 spec
->stream_analog_playback
= &vt1812_pcm_analog_playback
;
6166 spec
->stream_analog_capture
= &vt1812_pcm_analog_capture
;
6168 spec
->stream_name_digital
= "VT1812 Digital";
6169 spec
->stream_digital_playback
= &vt1812_pcm_digital_playback
;
6172 if (!spec
->adc_nids
&& spec
->input_mux
) {
6173 spec
->adc_nids
= vt1812_adc_nids
;
6174 spec
->num_adc_nids
= ARRAY_SIZE(vt1812_adc_nids
);
6175 get_mux_nids(codec
);
6176 override_mic_boost(codec
, 0x2b, 0, 3, 40);
6177 override_mic_boost(codec
, 0x29, 0, 3, 40);
6178 spec
->mixers
[spec
->num_mixers
] = vt1812_capture_mixer
;
6182 codec
->patch_ops
= via_patch_ops
;
6184 codec
->patch_ops
.init
= via_auto_init
;
6185 codec
->patch_ops
.unsol_event
= via_unsol_event
;
6187 #ifdef CONFIG_SND_HDA_POWER_SAVE
6188 spec
->loopback
.amplist
= vt1812_loopbacks
;
6191 spec
->set_widgets_power_state
= set_widgets_power_state_vt1812
;
6198 static const struct hda_codec_preset snd_hda_preset_via
[] = {
6199 { .id
= 0x11061708, .name
= "VT1708", .patch
= patch_vt1708
},
6200 { .id
= 0x11061709, .name
= "VT1708", .patch
= patch_vt1708
},
6201 { .id
= 0x1106170a, .name
= "VT1708", .patch
= patch_vt1708
},
6202 { .id
= 0x1106170b, .name
= "VT1708", .patch
= patch_vt1708
},
6203 { .id
= 0x1106e710, .name
= "VT1709 10-Ch",
6204 .patch
= patch_vt1709_10ch
},
6205 { .id
= 0x1106e711, .name
= "VT1709 10-Ch",
6206 .patch
= patch_vt1709_10ch
},
6207 { .id
= 0x1106e712, .name
= "VT1709 10-Ch",
6208 .patch
= patch_vt1709_10ch
},
6209 { .id
= 0x1106e713, .name
= "VT1709 10-Ch",
6210 .patch
= patch_vt1709_10ch
},
6211 { .id
= 0x1106e714, .name
= "VT1709 6-Ch",
6212 .patch
= patch_vt1709_6ch
},
6213 { .id
= 0x1106e715, .name
= "VT1709 6-Ch",
6214 .patch
= patch_vt1709_6ch
},
6215 { .id
= 0x1106e716, .name
= "VT1709 6-Ch",
6216 .patch
= patch_vt1709_6ch
},
6217 { .id
= 0x1106e717, .name
= "VT1709 6-Ch",
6218 .patch
= patch_vt1709_6ch
},
6219 { .id
= 0x1106e720, .name
= "VT1708B 8-Ch",
6220 .patch
= patch_vt1708B_8ch
},
6221 { .id
= 0x1106e721, .name
= "VT1708B 8-Ch",
6222 .patch
= patch_vt1708B_8ch
},
6223 { .id
= 0x1106e722, .name
= "VT1708B 8-Ch",
6224 .patch
= patch_vt1708B_8ch
},
6225 { .id
= 0x1106e723, .name
= "VT1708B 8-Ch",
6226 .patch
= patch_vt1708B_8ch
},
6227 { .id
= 0x1106e724, .name
= "VT1708B 4-Ch",
6228 .patch
= patch_vt1708B_4ch
},
6229 { .id
= 0x1106e725, .name
= "VT1708B 4-Ch",
6230 .patch
= patch_vt1708B_4ch
},
6231 { .id
= 0x1106e726, .name
= "VT1708B 4-Ch",
6232 .patch
= patch_vt1708B_4ch
},
6233 { .id
= 0x1106e727, .name
= "VT1708B 4-Ch",
6234 .patch
= patch_vt1708B_4ch
},
6235 { .id
= 0x11060397, .name
= "VT1708S",
6236 .patch
= patch_vt1708S
},
6237 { .id
= 0x11061397, .name
= "VT1708S",
6238 .patch
= patch_vt1708S
},
6239 { .id
= 0x11062397, .name
= "VT1708S",
6240 .patch
= patch_vt1708S
},
6241 { .id
= 0x11063397, .name
= "VT1708S",
6242 .patch
= patch_vt1708S
},
6243 { .id
= 0x11064397, .name
= "VT1705",
6244 .patch
= patch_vt1708S
},
6245 { .id
= 0x11065397, .name
= "VT1708S",
6246 .patch
= patch_vt1708S
},
6247 { .id
= 0x11066397, .name
= "VT1708S",
6248 .patch
= patch_vt1708S
},
6249 { .id
= 0x11067397, .name
= "VT1708S",
6250 .patch
= patch_vt1708S
},
6251 { .id
= 0x11060398, .name
= "VT1702",
6252 .patch
= patch_vt1702
},
6253 { .id
= 0x11061398, .name
= "VT1702",
6254 .patch
= patch_vt1702
},
6255 { .id
= 0x11062398, .name
= "VT1702",
6256 .patch
= patch_vt1702
},
6257 { .id
= 0x11063398, .name
= "VT1702",
6258 .patch
= patch_vt1702
},
6259 { .id
= 0x11064398, .name
= "VT1702",
6260 .patch
= patch_vt1702
},
6261 { .id
= 0x11065398, .name
= "VT1702",
6262 .patch
= patch_vt1702
},
6263 { .id
= 0x11066398, .name
= "VT1702",
6264 .patch
= patch_vt1702
},
6265 { .id
= 0x11067398, .name
= "VT1702",
6266 .patch
= patch_vt1702
},
6267 { .id
= 0x11060428, .name
= "VT1718S",
6268 .patch
= patch_vt1718S
},
6269 { .id
= 0x11064428, .name
= "VT1718S",
6270 .patch
= patch_vt1718S
},
6271 { .id
= 0x11060441, .name
= "VT2020",
6272 .patch
= patch_vt1718S
},
6273 { .id
= 0x11064441, .name
= "VT1828S",
6274 .patch
= patch_vt1718S
},
6275 { .id
= 0x11060433, .name
= "VT1716S",
6276 .patch
= patch_vt1716S
},
6277 { .id
= 0x1106a721, .name
= "VT1716S",
6278 .patch
= patch_vt1716S
},
6279 { .id
= 0x11060438, .name
= "VT2002P", .patch
= patch_vt2002P
},
6280 { .id
= 0x11064438, .name
= "VT2002P", .patch
= patch_vt2002P
},
6281 { .id
= 0x11060448, .name
= "VT1812", .patch
= patch_vt1812
},
6282 { .id
= 0x11060440, .name
= "VT1818S",
6283 .patch
= patch_vt1708S
},
6284 { .id
= 0x11060446, .name
= "VT1802",
6285 .patch
= patch_vt2002P
},
6286 { .id
= 0x11068446, .name
= "VT1802",
6287 .patch
= patch_vt2002P
},
6291 MODULE_ALIAS("snd-hda-codec-id:1106*");
6293 static struct hda_codec_preset_list via_list
= {
6294 .preset
= snd_hda_preset_via
,
6295 .owner
= THIS_MODULE
,
6298 MODULE_LICENSE("GPL");
6299 MODULE_DESCRIPTION("VIA HD-audio codec");
6301 static int __init
patch_via_init(void)
6303 return snd_hda_add_codec_preset(&via_list
);
6306 static void __exit
patch_via_exit(void)
6308 snd_hda_delete_codec_preset(&via_list
);
6311 module_init(patch_via_init
)
6312 module_exit(patch_via_exit
)