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 struct snd_kcontrol_new
*mixers
[6];
113 unsigned int num_mixers
;
115 struct hda_verb
*init_verbs
[5];
116 unsigned int num_iverbs
;
118 char *stream_name_analog
;
119 struct hda_pcm_stream
*stream_analog_playback
;
120 struct hda_pcm_stream
*stream_analog_capture
;
122 char *stream_name_digital
;
123 struct hda_pcm_stream
*stream_digital_playback
;
124 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
;
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 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 hda_nid_t vt1708_adc_nids
[2] = {
425 static hda_nid_t vt1709_adc_nids
[3] = {
430 static hda_nid_t vt1708B_adc_nids
[2] = {
435 static hda_nid_t vt1708S_adc_nids
[2] = {
440 static hda_nid_t vt1702_adc_nids
[3] = {
445 static hda_nid_t vt1718S_adc_nids
[2] = {
450 static hda_nid_t vt1716S_adc_nids
[2] = {
455 static hda_nid_t vt2002P_adc_nids
[2] = {
460 static 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 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 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 knew
= via_clone_control(spec
, &via_hp_mixer
[1]);
838 knew
->subdevice
= side_mute_channel(spec
);
843 static void notify_aa_path_ctls(struct hda_codec
*codec
)
846 struct snd_ctl_elem_id id
;
847 const char *labels
[] = {"Mic", "Front Mic", "Line"};
849 memset(&id
, 0, sizeof(id
));
850 id
.iface
= SNDRV_CTL_ELEM_IFACE_MIXER
;
851 for (i
= 0; i
< ARRAY_SIZE(labels
); i
++) {
852 sprintf(id
.name
, "%s Playback Volume", labels
[i
]);
853 snd_ctl_notify(codec
->bus
->card
, SNDRV_CTL_EVENT_MASK_VALUE
,
858 static void mute_aa_path(struct hda_codec
*codec
, int mute
)
860 struct via_spec
*spec
= codec
->spec
;
865 /* get nid of MW0 and start & end index */
866 switch (spec
->codec_type
) {
894 /* check AA path's mute status */
895 for (i
= start_idx
; i
<= end_idx
; i
++) {
896 int val
= mute
? HDA_AMP_MUTE
: HDA_AMP_UNMUTE
;
897 snd_hda_codec_amp_stereo(codec
, nid_mixer
, HDA_INPUT
, i
,
901 static int is_smart51_pins(struct via_spec
*spec
, hda_nid_t pin
)
903 const struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
906 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
907 if (pin
== cfg
->inputs
[i
].pin
)
908 return cfg
->inputs
[i
].type
<= AUTO_PIN_LINE_IN
;
913 static int via_smart51_info(struct snd_kcontrol
*kcontrol
,
914 struct snd_ctl_elem_info
*uinfo
)
916 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_BOOLEAN
;
918 uinfo
->value
.integer
.min
= 0;
919 uinfo
->value
.integer
.max
= 1;
923 static int via_smart51_get(struct snd_kcontrol
*kcontrol
,
924 struct snd_ctl_elem_value
*ucontrol
)
926 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
927 struct via_spec
*spec
= codec
->spec
;
928 const struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
932 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
933 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
934 int ctl
= snd_hda_codec_read(codec
, nid
, 0,
935 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
936 if (cfg
->inputs
[i
].type
> AUTO_PIN_LINE_IN
)
938 if (cfg
->inputs
[i
].type
== AUTO_PIN_MIC
&&
939 spec
->hp_independent_mode
&& spec
->codec_type
!= VT1718S
)
940 continue; /* ignore FMic for independent HP */
941 if ((ctl
& AC_PINCTL_IN_EN
) && !(ctl
& AC_PINCTL_OUT_EN
))
944 *ucontrol
->value
.integer
.value
= on
;
948 static int via_smart51_put(struct snd_kcontrol
*kcontrol
,
949 struct snd_ctl_elem_value
*ucontrol
)
951 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
952 struct via_spec
*spec
= codec
->spec
;
953 const struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
954 int out_in
= *ucontrol
->value
.integer
.value
955 ? AC_PINCTL_OUT_EN
: AC_PINCTL_IN_EN
;
958 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
959 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
962 if (cfg
->inputs
[i
].type
> AUTO_PIN_LINE_IN
)
964 if (cfg
->inputs
[i
].type
== AUTO_PIN_MIC
&&
965 spec
->hp_independent_mode
&& spec
->codec_type
!= VT1718S
)
966 continue; /* don't retask FMic for independent HP */
968 parm
= snd_hda_codec_read(codec
, nid
, 0,
969 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
970 parm
&= ~(AC_PINCTL_IN_EN
| AC_PINCTL_OUT_EN
);
972 snd_hda_codec_write(codec
, nid
, 0,
973 AC_VERB_SET_PIN_WIDGET_CONTROL
,
975 if (out_in
== AC_PINCTL_OUT_EN
) {
976 mute_aa_path(codec
, 1);
977 notify_aa_path_ctls(codec
);
979 if (spec
->codec_type
== VT1718S
) {
980 snd_hda_codec_amp_stereo(
981 codec
, nid
, HDA_OUTPUT
, 0, HDA_AMP_MUTE
,
984 if (cfg
->inputs
[i
].type
== AUTO_PIN_MIC
) {
985 if (spec
->codec_type
== VT1708S
986 || spec
->codec_type
== VT1716S
) {
987 /* input = index 1 (AOW3) */
990 AC_VERB_SET_CONNECT_SEL
, 1);
991 snd_hda_codec_amp_stereo(
992 codec
, nid
, HDA_OUTPUT
,
993 0, HDA_AMP_MUTE
, HDA_AMP_UNMUTE
);
997 spec
->smart51_enabled
= *ucontrol
->value
.integer
.value
;
998 set_widgets_power_state(codec
);
1002 static struct snd_kcontrol_new via_smart51_mixer
[2] = {
1004 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1005 .name
= "Smart 5.1",
1007 .info
= via_smart51_info
,
1008 .get
= via_smart51_get
,
1009 .put
= via_smart51_put
,
1012 .iface
= NID_MAPPING
,
1013 .name
= "Smart 5.1",
1017 static int via_smart51_build(struct via_spec
*spec
)
1019 struct snd_kcontrol_new
*knew
;
1020 const struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
1024 knew
= via_clone_control(spec
, &via_smart51_mixer
[0]);
1028 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
1029 nid
= cfg
->inputs
[i
].pin
;
1030 if (cfg
->inputs
[i
].type
<= AUTO_PIN_LINE_IN
) {
1031 knew
= via_clone_control(spec
, &via_smart51_mixer
[1]);
1034 knew
->subdevice
= nid
;
1042 /* capture mixer elements */
1043 static struct snd_kcontrol_new vt1708_capture_mixer
[] = {
1044 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_INPUT
),
1045 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_INPUT
),
1046 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x27, 0x0, HDA_INPUT
),
1047 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x27, 0x0, HDA_INPUT
),
1049 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1050 /* The multiple "Capture Source" controls confuse alsamixer
1051 * So call somewhat different..
1053 /* .name = "Capture Source", */
1054 .name
= "Input Source",
1056 .info
= via_mux_enum_info
,
1057 .get
= via_mux_enum_get
,
1058 .put
= via_mux_enum_put
,
1063 /* check AA path's mute statue */
1064 static int is_aa_path_mute(struct hda_codec
*codec
)
1067 hda_nid_t nid_mixer
;
1071 struct via_spec
*spec
= codec
->spec
;
1072 /* get nid of MW0 and start & end index */
1073 switch (spec
->codec_type
) {
1102 /* check AA path's mute status */
1103 for (i
= start_idx
; i
<= end_idx
; i
++) {
1104 unsigned int con_list
= snd_hda_codec_read(
1105 codec
, nid_mixer
, 0, AC_VERB_GET_CONNECT_LIST
, i
/4*4);
1106 int shift
= 8 * (i
% 4);
1107 hda_nid_t nid_pin
= (con_list
& (0xff << shift
)) >> shift
;
1108 unsigned int defconf
= snd_hda_codec_get_pincfg(codec
, nid_pin
);
1109 if (get_defcfg_connect(defconf
) == AC_JACK_PORT_COMPLEX
) {
1110 /* check mute status while the pin is connected */
1111 int mute_l
= snd_hda_codec_amp_read(codec
, nid_mixer
, 0,
1113 int mute_r
= snd_hda_codec_amp_read(codec
, nid_mixer
, 1,
1115 if (!mute_l
|| !mute_r
) {
1124 /* enter/exit analog low-current mode */
1125 static void analog_low_current_mode(struct hda_codec
*codec
, int stream_idle
)
1127 struct via_spec
*spec
= codec
->spec
;
1128 static int saved_stream_idle
= 1; /* saved stream idle status */
1129 int enable
= is_aa_path_mute(codec
);
1130 unsigned int verb
= 0;
1131 unsigned int parm
= 0;
1133 if (stream_idle
== -1) /* stream status did not change */
1134 enable
= enable
&& saved_stream_idle
;
1136 enable
= enable
&& stream_idle
;
1137 saved_stream_idle
= stream_idle
;
1140 /* decide low current mode's verb & parameter */
1141 switch (spec
->codec_type
) {
1145 parm
= enable
? 0x02 : 0x00; /* 0x02: 2/3x, 0x00: 1x */
1151 parm
= enable
? 0x51 : 0xe1; /* 0x51: 4/28x, 0xe1: 1x */
1155 parm
= enable
? 0x01 : 0x1d; /* 0x01: 4/40x, 0x1d: 1x */
1161 parm
= enable
? 0x00 : 0xe0; /* 0x00: 4/40x, 0xe0: 1x */
1164 return; /* other codecs are not supported */
1167 snd_hda_codec_write(codec
, codec
->afg
, 0, verb
, parm
);
1171 * generic initialization of ADC, input mixers and output mixers
1173 static struct hda_verb vt1708_volume_init_verbs
[] = {
1175 * Unmute ADC0-1 and set the default input to mic-in
1177 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
1178 {0x27, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
1181 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1184 /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */
1185 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
1186 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
1187 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2)},
1188 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(3)},
1189 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(4)},
1192 * Set up output mixers (0x19 - 0x1b)
1194 /* set vol=0 to output mixers */
1195 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
1196 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
1197 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
1199 /* Setup default input MW0 to PW4 */
1200 {0x20, AC_VERB_SET_CONNECT_SEL
, 0},
1201 /* PW9 Output enable */
1202 {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40},
1203 /* power down jack detect function */
1208 static int via_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
1209 struct hda_codec
*codec
,
1210 struct snd_pcm_substream
*substream
)
1212 struct via_spec
*spec
= codec
->spec
;
1213 int idle
= substream
->pstr
->substream_opened
== 1
1214 && substream
->ref_count
== 0;
1215 analog_low_current_mode(codec
, idle
);
1216 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
1220 static void playback_multi_pcm_prep_0(struct hda_codec
*codec
,
1221 unsigned int stream_tag
,
1222 unsigned int format
,
1223 struct snd_pcm_substream
*substream
)
1225 struct via_spec
*spec
= codec
->spec
;
1226 struct hda_multi_out
*mout
= &spec
->multiout
;
1227 hda_nid_t
*nids
= mout
->dac_nids
;
1228 int chs
= substream
->runtime
->channels
;
1231 mutex_lock(&codec
->spdif_mutex
);
1232 if (mout
->dig_out_nid
&& mout
->dig_out_used
!= HDA_DIG_EXCLUSIVE
) {
1234 snd_hda_is_supported_format(codec
, mout
->dig_out_nid
,
1236 !(codec
->spdif_status
& IEC958_AES0_NONAUDIO
)) {
1237 mout
->dig_out_used
= HDA_DIG_ANALOG_DUP
;
1238 /* turn off SPDIF once; otherwise the IEC958 bits won't
1240 if (codec
->spdif_ctls
& AC_DIG1_ENABLE
)
1241 snd_hda_codec_write(codec
, mout
->dig_out_nid
, 0,
1242 AC_VERB_SET_DIGI_CONVERT_1
,
1244 ~AC_DIG1_ENABLE
& 0xff);
1245 snd_hda_codec_setup_stream(codec
, mout
->dig_out_nid
,
1246 stream_tag
, 0, format
);
1247 /* turn on again (if needed) */
1248 if (codec
->spdif_ctls
& AC_DIG1_ENABLE
)
1249 snd_hda_codec_write(codec
, mout
->dig_out_nid
, 0,
1250 AC_VERB_SET_DIGI_CONVERT_1
,
1251 codec
->spdif_ctls
& 0xff);
1253 mout
->dig_out_used
= 0;
1254 snd_hda_codec_setup_stream(codec
, mout
->dig_out_nid
,
1258 mutex_unlock(&codec
->spdif_mutex
);
1261 snd_hda_codec_setup_stream(codec
, nids
[HDA_FRONT
], stream_tag
,
1264 if (mout
->hp_nid
&& mout
->hp_nid
!= nids
[HDA_FRONT
]
1265 && !spec
->hp_independent_mode
)
1266 /* headphone out will just decode front left/right (stereo) */
1267 snd_hda_codec_setup_stream(codec
, mout
->hp_nid
, stream_tag
,
1270 /* extra outputs copied from front */
1271 for (i
= 0; i
< ARRAY_SIZE(mout
->extra_out_nid
); i
++)
1272 if (mout
->extra_out_nid
[i
])
1273 snd_hda_codec_setup_stream(codec
,
1274 mout
->extra_out_nid
[i
],
1275 stream_tag
, 0, format
);
1278 for (i
= 1; i
< mout
->num_dacs
; i
++) {
1279 if (chs
>= (i
+ 1) * 2) /* independent out */
1280 snd_hda_codec_setup_stream(codec
, nids
[i
], stream_tag
,
1282 else /* copy front */
1283 snd_hda_codec_setup_stream(codec
, nids
[i
], stream_tag
,
1288 static int via_playback_multi_pcm_prepare(struct hda_pcm_stream
*hinfo
,
1289 struct hda_codec
*codec
,
1290 unsigned int stream_tag
,
1291 unsigned int format
,
1292 struct snd_pcm_substream
*substream
)
1294 struct via_spec
*spec
= codec
->spec
;
1295 struct hda_multi_out
*mout
= &spec
->multiout
;
1296 hda_nid_t
*nids
= mout
->dac_nids
;
1298 if (substream
->number
== 0)
1299 playback_multi_pcm_prep_0(codec
, stream_tag
, format
,
1302 if (mout
->hp_nid
&& mout
->hp_nid
!= nids
[HDA_FRONT
] &&
1303 spec
->hp_independent_mode
)
1304 snd_hda_codec_setup_stream(codec
, mout
->hp_nid
,
1305 stream_tag
, 0, format
);
1307 vt1708_start_hp_work(spec
);
1311 static int via_playback_multi_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
1312 struct hda_codec
*codec
,
1313 struct snd_pcm_substream
*substream
)
1315 struct via_spec
*spec
= codec
->spec
;
1316 struct hda_multi_out
*mout
= &spec
->multiout
;
1317 hda_nid_t
*nids
= mout
->dac_nids
;
1320 if (substream
->number
== 0) {
1321 for (i
= 0; i
< mout
->num_dacs
; i
++)
1322 snd_hda_codec_setup_stream(codec
, nids
[i
], 0, 0, 0);
1324 if (mout
->hp_nid
&& !spec
->hp_independent_mode
)
1325 snd_hda_codec_setup_stream(codec
, mout
->hp_nid
,
1328 for (i
= 0; i
< ARRAY_SIZE(mout
->extra_out_nid
); i
++)
1329 if (mout
->extra_out_nid
[i
])
1330 snd_hda_codec_setup_stream(codec
,
1331 mout
->extra_out_nid
[i
],
1333 mutex_lock(&codec
->spdif_mutex
);
1334 if (mout
->dig_out_nid
&&
1335 mout
->dig_out_used
== HDA_DIG_ANALOG_DUP
) {
1336 snd_hda_codec_setup_stream(codec
, mout
->dig_out_nid
,
1338 mout
->dig_out_used
= 0;
1340 mutex_unlock(&codec
->spdif_mutex
);
1342 if (mout
->hp_nid
&& mout
->hp_nid
!= nids
[HDA_FRONT
] &&
1343 spec
->hp_independent_mode
)
1344 snd_hda_codec_setup_stream(codec
, mout
->hp_nid
,
1347 vt1708_stop_hp_work(spec
);
1354 static int via_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
1355 struct hda_codec
*codec
,
1356 struct snd_pcm_substream
*substream
)
1358 struct via_spec
*spec
= codec
->spec
;
1359 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
1362 static int via_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
1363 struct hda_codec
*codec
,
1364 struct snd_pcm_substream
*substream
)
1366 struct via_spec
*spec
= codec
->spec
;
1367 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
1370 static int via_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
1371 struct hda_codec
*codec
,
1372 unsigned int stream_tag
,
1373 unsigned int format
,
1374 struct snd_pcm_substream
*substream
)
1376 struct via_spec
*spec
= codec
->spec
;
1377 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
1378 stream_tag
, format
, substream
);
1381 static int via_dig_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
1382 struct hda_codec
*codec
,
1383 struct snd_pcm_substream
*substream
)
1385 struct via_spec
*spec
= codec
->spec
;
1386 snd_hda_multi_out_dig_cleanup(codec
, &spec
->multiout
);
1393 static int via_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
1394 struct hda_codec
*codec
,
1395 unsigned int stream_tag
,
1396 unsigned int format
,
1397 struct snd_pcm_substream
*substream
)
1399 struct via_spec
*spec
= codec
->spec
;
1401 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
],
1402 stream_tag
, 0, format
);
1406 static int via_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
1407 struct hda_codec
*codec
,
1408 struct snd_pcm_substream
*substream
)
1410 struct via_spec
*spec
= codec
->spec
;
1411 snd_hda_codec_cleanup_stream(codec
, spec
->adc_nids
[substream
->number
]);
1415 static struct hda_pcm_stream vt1708_pcm_analog_playback
= {
1419 .nid
= 0x10, /* NID to query formats and rates */
1421 .open
= via_playback_pcm_open
,
1422 .prepare
= via_playback_multi_pcm_prepare
,
1423 .cleanup
= via_playback_multi_pcm_cleanup
1427 static struct hda_pcm_stream vt1708_pcm_analog_s16_playback
= {
1431 .nid
= 0x10, /* NID to query formats and rates */
1432 /* We got noisy outputs on the right channel on VT1708 when
1433 * 24bit samples are used. Until any workaround is found,
1434 * disable the 24bit format, so far.
1436 .formats
= SNDRV_PCM_FMTBIT_S16_LE
,
1438 .open
= via_playback_pcm_open
,
1439 .prepare
= via_playback_multi_pcm_prepare
,
1440 .cleanup
= via_playback_multi_pcm_cleanup
1444 static struct hda_pcm_stream vt1708_pcm_analog_capture
= {
1448 .nid
= 0x15, /* NID to query formats and rates */
1450 .prepare
= via_capture_pcm_prepare
,
1451 .cleanup
= via_capture_pcm_cleanup
1455 static struct hda_pcm_stream vt1708_pcm_digital_playback
= {
1459 /* NID is set in via_build_pcms */
1461 .open
= via_dig_playback_pcm_open
,
1462 .close
= via_dig_playback_pcm_close
,
1463 .prepare
= via_dig_playback_pcm_prepare
,
1464 .cleanup
= via_dig_playback_pcm_cleanup
1468 static struct hda_pcm_stream vt1708_pcm_digital_capture
= {
1474 static int via_build_controls(struct hda_codec
*codec
)
1476 struct via_spec
*spec
= codec
->spec
;
1477 struct snd_kcontrol
*kctl
;
1478 struct snd_kcontrol_new
*knew
;
1481 for (i
= 0; i
< spec
->num_mixers
; i
++) {
1482 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
1487 if (spec
->multiout
.dig_out_nid
) {
1488 err
= snd_hda_create_spdif_out_ctls(codec
,
1489 spec
->multiout
.dig_out_nid
);
1492 err
= snd_hda_create_spdif_share_sw(codec
,
1496 spec
->multiout
.share_spdif
= 1;
1498 if (spec
->dig_in_nid
) {
1499 err
= snd_hda_create_spdif_in_ctls(codec
, spec
->dig_in_nid
);
1504 /* assign Capture Source enums to NID */
1505 kctl
= snd_hda_find_mixer_ctl(codec
, "Input Source");
1506 for (i
= 0; kctl
&& i
< kctl
->count
; i
++) {
1507 err
= snd_hda_add_nid(codec
, kctl
, i
, spec
->mux_nids
[i
]);
1512 /* other nid->control mapping */
1513 for (i
= 0; i
< spec
->num_mixers
; i
++) {
1514 for (knew
= spec
->mixers
[i
]; knew
->name
; knew
++) {
1515 if (knew
->iface
!= NID_MAPPING
)
1517 kctl
= snd_hda_find_mixer_ctl(codec
, knew
->name
);
1520 err
= snd_hda_add_nid(codec
, kctl
, 0,
1525 /* init power states */
1526 set_widgets_power_state(codec
);
1527 analog_low_current_mode(codec
, 1);
1529 via_free_kctls(codec
); /* no longer needed */
1533 static int via_build_pcms(struct hda_codec
*codec
)
1535 struct via_spec
*spec
= codec
->spec
;
1536 struct hda_pcm
*info
= spec
->pcm_rec
;
1538 codec
->num_pcms
= 1;
1539 codec
->pcm_info
= info
;
1541 info
->name
= spec
->stream_name_analog
;
1542 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] =
1543 *(spec
->stream_analog_playback
);
1544 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
1545 spec
->multiout
.dac_nids
[0];
1546 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *(spec
->stream_analog_capture
);
1547 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
1549 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
=
1550 spec
->multiout
.max_channels
;
1552 if (spec
->multiout
.dig_out_nid
|| spec
->dig_in_nid
) {
1555 info
->name
= spec
->stream_name_digital
;
1556 info
->pcm_type
= HDA_PCM_TYPE_SPDIF
;
1557 if (spec
->multiout
.dig_out_nid
) {
1558 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] =
1559 *(spec
->stream_digital_playback
);
1560 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
1561 spec
->multiout
.dig_out_nid
;
1563 if (spec
->dig_in_nid
) {
1564 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
1565 *(spec
->stream_digital_capture
);
1566 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
=
1574 static void via_free(struct hda_codec
*codec
)
1576 struct via_spec
*spec
= codec
->spec
;
1581 via_free_kctls(codec
);
1582 vt1708_stop_hp_work(spec
);
1586 /* mute internal speaker if HP is plugged */
1587 static void via_hp_automute(struct hda_codec
*codec
)
1589 unsigned int present
= 0;
1590 struct via_spec
*spec
= codec
->spec
;
1592 present
= snd_hda_jack_detect(codec
, spec
->autocfg
.hp_pins
[0]);
1594 if (!spec
->hp_independent_mode
) {
1595 struct snd_ctl_elem_id id
;
1597 snd_hda_codec_amp_stereo(
1598 codec
, spec
->autocfg
.line_out_pins
[0], HDA_OUTPUT
, 0,
1599 HDA_AMP_MUTE
, present
? HDA_AMP_MUTE
: 0);
1601 memset(&id
, 0, sizeof(id
));
1602 id
.iface
= SNDRV_CTL_ELEM_IFACE_MIXER
;
1603 strcpy(id
.name
, "Front Playback Switch");
1604 snd_ctl_notify(codec
->bus
->card
, SNDRV_CTL_EVENT_MASK_VALUE
,
1609 /* mute mono out if HP or Line out is plugged */
1610 static void via_mono_automute(struct hda_codec
*codec
)
1612 unsigned int hp_present
, lineout_present
;
1613 struct via_spec
*spec
= codec
->spec
;
1615 if (spec
->codec_type
!= VT1716S
)
1618 lineout_present
= snd_hda_jack_detect(codec
,
1619 spec
->autocfg
.line_out_pins
[0]);
1621 /* Mute Mono Out if Line Out is plugged */
1622 if (lineout_present
) {
1623 snd_hda_codec_amp_stereo(
1624 codec
, 0x2A, HDA_OUTPUT
, 0, HDA_AMP_MUTE
, HDA_AMP_MUTE
);
1628 hp_present
= snd_hda_jack_detect(codec
, spec
->autocfg
.hp_pins
[0]);
1630 if (!spec
->hp_independent_mode
)
1631 snd_hda_codec_amp_stereo(
1632 codec
, 0x2A, HDA_OUTPUT
, 0, HDA_AMP_MUTE
,
1633 hp_present
? HDA_AMP_MUTE
: 0);
1636 static void via_gpio_control(struct hda_codec
*codec
)
1638 unsigned int gpio_data
;
1639 unsigned int vol_counter
;
1641 unsigned int master_vol
;
1643 struct via_spec
*spec
= codec
->spec
;
1645 gpio_data
= snd_hda_codec_read(codec
, codec
->afg
, 0,
1646 AC_VERB_GET_GPIO_DATA
, 0) & 0x03;
1648 vol_counter
= (snd_hda_codec_read(codec
, codec
->afg
, 0,
1649 0xF84, 0) & 0x3F0000) >> 16;
1651 vol
= vol_counter
& 0x1F;
1652 master_vol
= snd_hda_codec_read(codec
, 0x1A, 0,
1653 AC_VERB_GET_AMP_GAIN_MUTE
,
1656 if (gpio_data
== 0x02) {
1657 /* unmute line out */
1658 snd_hda_codec_amp_stereo(codec
, spec
->autocfg
.line_out_pins
[0],
1659 HDA_OUTPUT
, 0, HDA_AMP_MUTE
, 0);
1661 if (vol_counter
& 0x20) {
1662 /* decrease volume */
1663 if (vol
> master_vol
)
1665 snd_hda_codec_amp_stereo(codec
, 0x1A, HDA_INPUT
,
1669 /* increase volume */
1670 snd_hda_codec_amp_stereo(codec
, 0x1A, HDA_INPUT
, 0,
1672 ((master_vol
+vol
) > 0x2A) ? 0x2A :
1675 } else if (!(gpio_data
& 0x02)) {
1677 snd_hda_codec_amp_stereo(codec
,
1678 spec
->autocfg
.line_out_pins
[0],
1679 HDA_OUTPUT
, 0, HDA_AMP_MUTE
,
1684 /* mute Internal-Speaker if HP is plugged */
1685 static void via_speaker_automute(struct hda_codec
*codec
)
1687 unsigned int hp_present
;
1688 struct via_spec
*spec
= codec
->spec
;
1690 if (!VT2002P_COMPATIBLE(spec
))
1693 hp_present
= snd_hda_jack_detect(codec
, spec
->autocfg
.hp_pins
[0]);
1695 if (!spec
->hp_independent_mode
) {
1696 struct snd_ctl_elem_id id
;
1697 snd_hda_codec_amp_stereo(
1698 codec
, spec
->autocfg
.speaker_pins
[0], HDA_OUTPUT
, 0,
1699 HDA_AMP_MUTE
, hp_present
? HDA_AMP_MUTE
: 0);
1701 memset(&id
, 0, sizeof(id
));
1702 id
.iface
= SNDRV_CTL_ELEM_IFACE_MIXER
;
1703 strcpy(id
.name
, "Speaker Playback Switch");
1704 snd_ctl_notify(codec
->bus
->card
, SNDRV_CTL_EVENT_MASK_VALUE
,
1709 /* mute line-out and internal speaker if HP is plugged */
1710 static void via_hp_bind_automute(struct hda_codec
*codec
)
1712 /* use long instead of int below just to avoid an internal compiler
1713 * error with gcc 4.0.x
1715 unsigned long hp_present
, present
= 0;
1716 struct via_spec
*spec
= codec
->spec
;
1719 if (!spec
->autocfg
.hp_pins
[0] || !spec
->autocfg
.line_out_pins
[0])
1722 hp_present
= snd_hda_jack_detect(codec
, spec
->autocfg
.hp_pins
[0]);
1724 present
= snd_hda_jack_detect(codec
, spec
->autocfg
.line_out_pins
[0]);
1726 if (!spec
->hp_independent_mode
) {
1727 /* Mute Line-Outs */
1728 for (i
= 0; i
< spec
->autocfg
.line_outs
; i
++)
1729 snd_hda_codec_amp_stereo(
1730 codec
, spec
->autocfg
.line_out_pins
[i
],
1732 HDA_AMP_MUTE
, hp_present
? HDA_AMP_MUTE
: 0);
1734 present
= hp_present
;
1737 for (i
= 0; i
< spec
->autocfg
.speaker_outs
; i
++)
1738 snd_hda_codec_amp_stereo(
1739 codec
, spec
->autocfg
.speaker_pins
[i
], HDA_OUTPUT
, 0,
1740 HDA_AMP_MUTE
, present
? HDA_AMP_MUTE
: 0);
1744 /* unsolicited event for jack sensing */
1745 static void via_unsol_event(struct hda_codec
*codec
,
1750 if (res
& VIA_JACK_EVENT
)
1751 set_widgets_power_state(codec
);
1753 res
&= ~VIA_JACK_EVENT
;
1755 if (res
== VIA_HP_EVENT
)
1756 via_hp_automute(codec
);
1757 else if (res
== VIA_GPIO_EVENT
)
1758 via_gpio_control(codec
);
1759 else if (res
== VIA_MONO_EVENT
)
1760 via_mono_automute(codec
);
1761 else if (res
== VIA_SPEAKER_EVENT
)
1762 via_speaker_automute(codec
);
1763 else if (res
== VIA_BIND_HP_EVENT
)
1764 via_hp_bind_automute(codec
);
1767 static int via_init(struct hda_codec
*codec
)
1769 struct via_spec
*spec
= codec
->spec
;
1771 for (i
= 0; i
< spec
->num_iverbs
; i
++)
1772 snd_hda_sequence_write(codec
, spec
->init_verbs
[i
]);
1774 /* Lydia Add for EAPD enable */
1775 if (!spec
->dig_in_nid
) { /* No Digital In connection */
1776 if (spec
->dig_in_pin
) {
1777 snd_hda_codec_write(codec
, spec
->dig_in_pin
, 0,
1778 AC_VERB_SET_PIN_WIDGET_CONTROL
,
1780 snd_hda_codec_write(codec
, spec
->dig_in_pin
, 0,
1781 AC_VERB_SET_EAPD_BTLENABLE
, 0x02);
1783 } else /* enable SPDIF-input pin */
1784 snd_hda_codec_write(codec
, spec
->autocfg
.dig_in_pin
, 0,
1785 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
);
1787 /* assign slave outs */
1788 if (spec
->slave_dig_outs
[0])
1789 codec
->slave_dig_outs
= spec
->slave_dig_outs
;
1794 #ifdef SND_HDA_NEEDS_RESUME
1795 static int via_suspend(struct hda_codec
*codec
, pm_message_t state
)
1797 struct via_spec
*spec
= codec
->spec
;
1798 vt1708_stop_hp_work(spec
);
1803 #ifdef CONFIG_SND_HDA_POWER_SAVE
1804 static int via_check_power_status(struct hda_codec
*codec
, hda_nid_t nid
)
1806 struct via_spec
*spec
= codec
->spec
;
1807 return snd_hda_check_amp_list_power(codec
, &spec
->loopback
, nid
);
1813 static struct hda_codec_ops via_patch_ops
= {
1814 .build_controls
= via_build_controls
,
1815 .build_pcms
= via_build_pcms
,
1818 #ifdef SND_HDA_NEEDS_RESUME
1819 .suspend
= via_suspend
,
1821 #ifdef CONFIG_SND_HDA_POWER_SAVE
1822 .check_power_status
= via_check_power_status
,
1826 /* fill in the dac_nids table from the parsed pin configuration */
1827 static int vt1708_auto_fill_dac_nids(struct via_spec
*spec
,
1828 const struct auto_pin_cfg
*cfg
)
1833 spec
->multiout
.num_dacs
= cfg
->line_outs
;
1835 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
1837 for (i
= 0; i
< 4; i
++) {
1838 nid
= cfg
->line_out_pins
[i
];
1840 /* config dac list */
1842 case AUTO_SEQ_FRONT
:
1843 spec
->multiout
.dac_nids
[i
] = 0x10;
1845 case AUTO_SEQ_CENLFE
:
1846 spec
->multiout
.dac_nids
[i
] = 0x12;
1848 case AUTO_SEQ_SURROUND
:
1849 spec
->multiout
.dac_nids
[i
] = 0x11;
1852 spec
->multiout
.dac_nids
[i
] = 0x13;
1861 /* add playback controls from the parsed DAC table */
1862 static int vt1708_auto_create_multi_out_ctls(struct via_spec
*spec
,
1863 const struct auto_pin_cfg
*cfg
)
1866 static const char * const chname
[4] = {
1867 "Front", "Surround", "C/LFE", "Side"
1869 hda_nid_t nid
, nid_vol
, nid_vols
[] = {0x17, 0x19, 0x1a, 0x1b};
1872 for (i
= 0; i
<= AUTO_SEQ_SIDE
; i
++) {
1873 nid
= cfg
->line_out_pins
[i
];
1878 nid_vol
= nid_vols
[i
];
1880 if (i
== AUTO_SEQ_CENLFE
) {
1882 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
1883 "Center Playback Volume",
1884 HDA_COMPOSE_AMP_VAL(nid_vol
, 1, 0,
1888 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
1889 "LFE Playback Volume",
1890 HDA_COMPOSE_AMP_VAL(nid_vol
, 2, 0,
1894 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
1895 "Center Playback Switch",
1896 HDA_COMPOSE_AMP_VAL(nid_vol
, 1, 0,
1900 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
1901 "LFE Playback Switch",
1902 HDA_COMPOSE_AMP_VAL(nid_vol
, 2, 0,
1906 } else if (i
== AUTO_SEQ_FRONT
) {
1907 /* add control to mixer index 0 */
1908 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
1909 "Master Front Playback Volume",
1910 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0,
1914 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
1915 "Master Front Playback Switch",
1916 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0,
1921 /* add control to PW3 */
1922 sprintf(name
, "%s Playback Volume", chname
[i
]);
1923 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
, name
,
1924 HDA_COMPOSE_AMP_VAL(nid
, 3, 0,
1928 sprintf(name
, "%s Playback Switch", chname
[i
]);
1929 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
, name
,
1930 HDA_COMPOSE_AMP_VAL(nid
, 3, 0,
1935 sprintf(name
, "%s Playback Volume", chname
[i
]);
1936 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
, name
,
1937 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0,
1941 sprintf(name
, "%s Playback Switch", chname
[i
]);
1942 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
, name
,
1943 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0,
1953 static void create_hp_imux(struct via_spec
*spec
)
1956 struct hda_input_mux
*imux
= &spec
->private_imux
[1];
1957 static const char * const texts
[] = { "OFF", "ON", NULL
};
1959 /* for hp mode select */
1960 for (i
= 0; texts
[i
]; i
++)
1961 snd_hda_add_imux_item(imux
, texts
[i
], i
, NULL
);
1963 spec
->hp_mux
= &spec
->private_imux
[1];
1966 static int vt1708_auto_create_hp_ctls(struct via_spec
*spec
, hda_nid_t pin
)
1973 spec
->multiout
.hp_nid
= VT1708_HP_NID
; /* AOW3 */
1974 spec
->hp_independent_mode_index
= 1;
1976 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
1977 "Headphone Playback Volume",
1978 HDA_COMPOSE_AMP_VAL(pin
, 3, 0, HDA_OUTPUT
));
1981 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
1982 "Headphone Playback Switch",
1983 HDA_COMPOSE_AMP_VAL(pin
, 3, 0, HDA_OUTPUT
));
1987 create_hp_imux(spec
);
1992 /* create playback/capture controls for input pins */
1993 static int vt_auto_create_analog_input_ctls(struct hda_codec
*codec
,
1994 const struct auto_pin_cfg
*cfg
,
1996 hda_nid_t pin_idxs
[], int num_idxs
)
1998 struct via_spec
*spec
= codec
->spec
;
1999 struct hda_input_mux
*imux
= &spec
->private_imux
[0];
2000 int i
, err
, idx
, type
, type_idx
= 0;
2002 /* for internal loopback recording select */
2003 for (idx
= 0; idx
< num_idxs
; idx
++) {
2004 if (pin_idxs
[idx
] == 0xff) {
2005 snd_hda_add_imux_item(imux
, "Stereo Mixer", idx
, NULL
);
2010 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
2012 type
= cfg
->inputs
[i
].type
;
2013 for (idx
= 0; idx
< num_idxs
; idx
++)
2014 if (pin_idxs
[idx
] == cfg
->inputs
[i
].pin
)
2016 if (idx
>= num_idxs
)
2018 if (i
> 0 && type
== cfg
->inputs
[i
- 1].type
)
2022 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
2023 if (spec
->codec_type
== VT1708S
||
2024 spec
->codec_type
== VT1702
||
2025 spec
->codec_type
== VT1716S
)
2026 err
= via_new_analog_input(spec
, label
, type_idx
,
2029 err
= via_new_analog_input(spec
, label
, type_idx
,
2033 snd_hda_add_imux_item(imux
, label
, idx
, NULL
);
2038 /* create playback/capture controls for input pins */
2039 static int vt1708_auto_create_analog_input_ctls(struct hda_codec
*codec
,
2040 const struct auto_pin_cfg
*cfg
)
2042 static hda_nid_t pin_idxs
[] = { 0xff, 0x24, 0x1d, 0x1e, 0x21 };
2043 return vt_auto_create_analog_input_ctls(codec
, cfg
, 0x17, pin_idxs
,
2044 ARRAY_SIZE(pin_idxs
));
2047 #ifdef CONFIG_SND_HDA_POWER_SAVE
2048 static struct hda_amp_list vt1708_loopbacks
[] = {
2049 { 0x17, HDA_INPUT
, 1 },
2050 { 0x17, HDA_INPUT
, 2 },
2051 { 0x17, HDA_INPUT
, 3 },
2052 { 0x17, HDA_INPUT
, 4 },
2057 static void vt1708_set_pinconfig_connect(struct hda_codec
*codec
, hda_nid_t nid
)
2059 unsigned int def_conf
;
2060 unsigned char seqassoc
;
2062 def_conf
= snd_hda_codec_get_pincfg(codec
, nid
);
2063 seqassoc
= (unsigned char) get_defcfg_association(def_conf
);
2064 seqassoc
= (seqassoc
<< 4) | get_defcfg_sequence(def_conf
);
2065 if (get_defcfg_connect(def_conf
) == AC_JACK_PORT_NONE
2066 && (seqassoc
== 0xf0 || seqassoc
== 0xff)) {
2067 def_conf
= def_conf
& (~(AC_JACK_PORT_BOTH
<< 30));
2068 snd_hda_codec_set_pincfg(codec
, nid
, def_conf
);
2074 static int vt1708_jack_detectect_get(struct snd_kcontrol
*kcontrol
,
2075 struct snd_ctl_elem_value
*ucontrol
)
2077 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2078 struct via_spec
*spec
= codec
->spec
;
2080 if (spec
->codec_type
!= VT1708
)
2082 spec
->vt1708_jack_detectect
=
2083 !((snd_hda_codec_read(codec
, 0x1, 0, 0xf84, 0) >> 8) & 0x1);
2084 ucontrol
->value
.integer
.value
[0] = spec
->vt1708_jack_detectect
;
2088 static int vt1708_jack_detectect_put(struct snd_kcontrol
*kcontrol
,
2089 struct snd_ctl_elem_value
*ucontrol
)
2091 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2092 struct via_spec
*spec
= codec
->spec
;
2095 if (spec
->codec_type
!= VT1708
)
2097 spec
->vt1708_jack_detectect
= ucontrol
->value
.integer
.value
[0];
2098 change
= (0x1 & (snd_hda_codec_read(codec
, 0x1, 0, 0xf84, 0) >> 8))
2099 == !spec
->vt1708_jack_detectect
;
2100 if (spec
->vt1708_jack_detectect
) {
2101 mute_aa_path(codec
, 1);
2102 notify_aa_path_ctls(codec
);
2107 static struct snd_kcontrol_new vt1708_jack_detectect
[] = {
2109 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2110 .name
= "Jack Detect",
2112 .info
= snd_ctl_boolean_mono_info
,
2113 .get
= vt1708_jack_detectect_get
,
2114 .put
= vt1708_jack_detectect_put
,
2119 static int vt1708_parse_auto_config(struct hda_codec
*codec
)
2121 struct via_spec
*spec
= codec
->spec
;
2124 /* Add HP and CD pin config connect bit re-config action */
2125 vt1708_set_pinconfig_connect(codec
, VT1708_HP_PIN_NID
);
2126 vt1708_set_pinconfig_connect(codec
, VT1708_CD_PIN_NID
);
2128 err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
);
2131 err
= vt1708_auto_fill_dac_nids(spec
, &spec
->autocfg
);
2134 if (!spec
->autocfg
.line_outs
&& !spec
->autocfg
.hp_pins
[0])
2135 return 0; /* can't find valid BIOS pin config */
2137 err
= vt1708_auto_create_multi_out_ctls(spec
, &spec
->autocfg
);
2140 err
= vt1708_auto_create_hp_ctls(spec
, spec
->autocfg
.hp_pins
[0]);
2143 err
= vt1708_auto_create_analog_input_ctls(codec
, &spec
->autocfg
);
2146 /* add jack detect on/off control */
2147 err
= snd_hda_add_new_ctls(codec
, vt1708_jack_detectect
);
2151 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
2153 if (spec
->autocfg
.dig_outs
)
2154 spec
->multiout
.dig_out_nid
= VT1708_DIGOUT_NID
;
2155 spec
->dig_in_pin
= VT1708_DIGIN_PIN
;
2156 if (spec
->autocfg
.dig_in_pin
)
2157 spec
->dig_in_nid
= VT1708_DIGIN_NID
;
2159 if (spec
->kctls
.list
)
2160 spec
->mixers
[spec
->num_mixers
++] = spec
->kctls
.list
;
2162 spec
->init_verbs
[spec
->num_iverbs
++] = vt1708_volume_init_verbs
;
2164 spec
->input_mux
= &spec
->private_imux
[0];
2167 via_hp_build(codec
);
2169 via_smart51_build(spec
);
2173 /* init callback for auto-configuration model -- overriding the default init */
2174 static int via_auto_init(struct hda_codec
*codec
)
2176 struct via_spec
*spec
= codec
->spec
;
2179 via_auto_init_multi_out(codec
);
2180 via_auto_init_hp_out(codec
);
2181 via_auto_init_analog_input(codec
);
2183 if (VT2002P_COMPATIBLE(spec
)) {
2184 via_hp_bind_automute(codec
);
2186 via_hp_automute(codec
);
2187 via_speaker_automute(codec
);
2193 static void vt1708_update_hp_jack_state(struct work_struct
*work
)
2195 struct via_spec
*spec
= container_of(work
, struct via_spec
,
2196 vt1708_hp_work
.work
);
2197 if (spec
->codec_type
!= VT1708
)
2199 /* if jack state toggled */
2200 if (spec
->vt1708_hp_present
2201 != snd_hda_jack_detect(spec
->codec
, spec
->autocfg
.hp_pins
[0])) {
2202 spec
->vt1708_hp_present
^= 1;
2203 via_hp_automute(spec
->codec
);
2205 vt1708_start_hp_work(spec
);
2208 static int get_mux_nids(struct hda_codec
*codec
)
2210 struct via_spec
*spec
= codec
->spec
;
2211 hda_nid_t nid
, conn
[8];
2215 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
2216 nid
= spec
->adc_nids
[i
];
2218 type
= get_wcaps_type(get_wcaps(codec
, nid
));
2219 if (type
== AC_WID_PIN
)
2221 n
= snd_hda_get_connections(codec
, nid
, conn
,
2226 spec
->mux_nids
[i
] = nid
;
2235 static int patch_vt1708(struct hda_codec
*codec
)
2237 struct via_spec
*spec
;
2240 /* create a codec specific record */
2241 spec
= via_new_spec(codec
);
2245 /* automatic parse from the BIOS config */
2246 err
= vt1708_parse_auto_config(codec
);
2251 printk(KERN_INFO
"hda_codec: Cannot set up configuration "
2252 "from BIOS. Using genenic mode...\n");
2256 spec
->stream_name_analog
= "VT1708 Analog";
2257 spec
->stream_analog_playback
= &vt1708_pcm_analog_playback
;
2258 /* disable 32bit format on VT1708 */
2259 if (codec
->vendor_id
== 0x11061708)
2260 spec
->stream_analog_playback
= &vt1708_pcm_analog_s16_playback
;
2261 spec
->stream_analog_capture
= &vt1708_pcm_analog_capture
;
2263 spec
->stream_name_digital
= "VT1708 Digital";
2264 spec
->stream_digital_playback
= &vt1708_pcm_digital_playback
;
2265 spec
->stream_digital_capture
= &vt1708_pcm_digital_capture
;
2268 if (!spec
->adc_nids
&& spec
->input_mux
) {
2269 spec
->adc_nids
= vt1708_adc_nids
;
2270 spec
->num_adc_nids
= ARRAY_SIZE(vt1708_adc_nids
);
2271 get_mux_nids(codec
);
2272 spec
->mixers
[spec
->num_mixers
] = vt1708_capture_mixer
;
2276 codec
->patch_ops
= via_patch_ops
;
2278 codec
->patch_ops
.init
= via_auto_init
;
2279 #ifdef CONFIG_SND_HDA_POWER_SAVE
2280 spec
->loopback
.amplist
= vt1708_loopbacks
;
2282 INIT_DELAYED_WORK(&spec
->vt1708_hp_work
, vt1708_update_hp_jack_state
);
2286 /* capture mixer elements */
2287 static struct snd_kcontrol_new vt1709_capture_mixer
[] = {
2288 HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x0, HDA_INPUT
),
2289 HDA_CODEC_MUTE("Capture Switch", 0x14, 0x0, HDA_INPUT
),
2290 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x15, 0x0, HDA_INPUT
),
2291 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x15, 0x0, HDA_INPUT
),
2292 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x16, 0x0, HDA_INPUT
),
2293 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x16, 0x0, HDA_INPUT
),
2295 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2296 /* The multiple "Capture Source" controls confuse alsamixer
2297 * So call somewhat different..
2299 /* .name = "Capture Source", */
2300 .name
= "Input Source",
2302 .info
= via_mux_enum_info
,
2303 .get
= via_mux_enum_get
,
2304 .put
= via_mux_enum_put
,
2309 static struct hda_verb vt1709_uniwill_init_verbs
[] = {
2310 {0x20, AC_VERB_SET_UNSOLICITED_ENABLE
,
2311 AC_USRSP_EN
| VIA_HP_EVENT
| VIA_JACK_EVENT
},
2316 * generic initialization of ADC, input mixers and output mixers
2318 static struct hda_verb vt1709_10ch_volume_init_verbs
[] = {
2320 * Unmute ADC0-2 and set the default input to mic-in
2322 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2323 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2324 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2327 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2330 /* Amp Indices: AOW0=0, CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */
2331 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2332 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
2333 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2)},
2334 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(3)},
2335 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(4)},
2338 * Set up output selector (0x1a, 0x1b, 0x29)
2340 /* set vol=0 to output mixers */
2341 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2342 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2343 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2346 * Unmute PW3 and PW4
2348 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2349 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2351 /* Set input of PW4 as MW0 */
2352 {0x20, AC_VERB_SET_CONNECT_SEL
, 0},
2353 /* PW9 Output enable */
2354 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40},
2358 static struct hda_pcm_stream vt1709_10ch_pcm_analog_playback
= {
2362 .nid
= 0x10, /* NID to query formats and rates */
2364 .open
= via_playback_pcm_open
,
2365 .prepare
= via_playback_multi_pcm_prepare
,
2366 .cleanup
= via_playback_multi_pcm_cleanup
,
2370 static struct hda_pcm_stream vt1709_6ch_pcm_analog_playback
= {
2374 .nid
= 0x10, /* NID to query formats and rates */
2376 .open
= via_playback_pcm_open
,
2377 .prepare
= via_playback_multi_pcm_prepare
,
2378 .cleanup
= via_playback_multi_pcm_cleanup
,
2382 static struct hda_pcm_stream vt1709_pcm_analog_capture
= {
2386 .nid
= 0x14, /* NID to query formats and rates */
2388 .prepare
= via_capture_pcm_prepare
,
2389 .cleanup
= via_capture_pcm_cleanup
2393 static struct hda_pcm_stream vt1709_pcm_digital_playback
= {
2397 /* NID is set in via_build_pcms */
2399 .open
= via_dig_playback_pcm_open
,
2400 .close
= via_dig_playback_pcm_close
2404 static struct hda_pcm_stream vt1709_pcm_digital_capture
= {
2410 static int vt1709_auto_fill_dac_nids(struct via_spec
*spec
,
2411 const struct auto_pin_cfg
*cfg
)
2416 if (cfg
->line_outs
== 4) /* 10 channels */
2417 spec
->multiout
.num_dacs
= cfg
->line_outs
+1; /* AOW0~AOW4 */
2418 else if (cfg
->line_outs
== 3) /* 6 channels */
2419 spec
->multiout
.num_dacs
= cfg
->line_outs
; /* AOW0~AOW2 */
2421 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
2423 if (cfg
->line_outs
== 4) { /* 10 channels */
2424 for (i
= 0; i
< cfg
->line_outs
; i
++) {
2425 nid
= cfg
->line_out_pins
[i
];
2427 /* config dac list */
2429 case AUTO_SEQ_FRONT
:
2431 spec
->multiout
.dac_nids
[i
] = 0x10;
2433 case AUTO_SEQ_CENLFE
:
2435 spec
->multiout
.dac_nids
[i
] = 0x12;
2437 case AUTO_SEQ_SURROUND
:
2439 spec
->multiout
.dac_nids
[i
] = 0x11;
2443 spec
->multiout
.dac_nids
[i
] = 0x27;
2450 spec
->multiout
.dac_nids
[cfg
->line_outs
] = 0x28; /* AOW4 */
2452 } else if (cfg
->line_outs
== 3) { /* 6 channels */
2453 for (i
= 0; i
< cfg
->line_outs
; i
++) {
2454 nid
= cfg
->line_out_pins
[i
];
2456 /* config dac list */
2458 case AUTO_SEQ_FRONT
:
2460 spec
->multiout
.dac_nids
[i
] = 0x10;
2462 case AUTO_SEQ_CENLFE
:
2464 spec
->multiout
.dac_nids
[i
] = 0x12;
2466 case AUTO_SEQ_SURROUND
:
2468 spec
->multiout
.dac_nids
[i
] = 0x11;
2480 /* add playback controls from the parsed DAC table */
2481 static int vt1709_auto_create_multi_out_ctls(struct via_spec
*spec
,
2482 const struct auto_pin_cfg
*cfg
)
2485 static const char * const chname
[4] = {
2486 "Front", "Surround", "C/LFE", "Side"
2488 hda_nid_t nid
, nid_vol
, nid_vols
[] = {0x18, 0x1a, 0x1b, 0x29};
2491 for (i
= 0; i
<= AUTO_SEQ_SIDE
; i
++) {
2492 nid
= cfg
->line_out_pins
[i
];
2497 nid_vol
= nid_vols
[i
];
2499 if (i
== AUTO_SEQ_CENLFE
) {
2501 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
2502 "Center Playback Volume",
2503 HDA_COMPOSE_AMP_VAL(nid_vol
, 1, 0,
2507 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
2508 "LFE Playback Volume",
2509 HDA_COMPOSE_AMP_VAL(nid_vol
, 2, 0,
2513 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
2514 "Center Playback Switch",
2515 HDA_COMPOSE_AMP_VAL(nid_vol
, 1, 0,
2519 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
2520 "LFE Playback Switch",
2521 HDA_COMPOSE_AMP_VAL(nid_vol
, 2, 0,
2525 } else if (i
== AUTO_SEQ_FRONT
) {
2526 /* ADD control to mixer index 0 */
2527 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
2528 "Master Front Playback Volume",
2529 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0,
2533 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
2534 "Master Front Playback Switch",
2535 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0,
2540 /* add control to PW3 */
2541 sprintf(name
, "%s Playback Volume", chname
[i
]);
2542 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
, name
,
2543 HDA_COMPOSE_AMP_VAL(nid
, 3, 0,
2547 sprintf(name
, "%s Playback Switch", chname
[i
]);
2548 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
, name
,
2549 HDA_COMPOSE_AMP_VAL(nid
, 3, 0,
2553 } else if (i
== AUTO_SEQ_SURROUND
) {
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_vol
, 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_vol
, 3, 0,
2566 } else if (i
== AUTO_SEQ_SIDE
) {
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,
2585 static int vt1709_auto_create_hp_ctls(struct via_spec
*spec
, hda_nid_t pin
)
2592 if (spec
->multiout
.num_dacs
== 5) /* 10 channels */
2593 spec
->multiout
.hp_nid
= VT1709_HP_DAC_NID
;
2594 else if (spec
->multiout
.num_dacs
== 3) /* 6 channels */
2595 spec
->multiout
.hp_nid
= 0;
2596 spec
->hp_independent_mode_index
= 1;
2598 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
2599 "Headphone Playback Volume",
2600 HDA_COMPOSE_AMP_VAL(pin
, 3, 0, HDA_OUTPUT
));
2603 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
2604 "Headphone Playback Switch",
2605 HDA_COMPOSE_AMP_VAL(pin
, 3, 0, HDA_OUTPUT
));
2612 /* create playback/capture controls for input pins */
2613 static int vt1709_auto_create_analog_input_ctls(struct hda_codec
*codec
,
2614 const struct auto_pin_cfg
*cfg
)
2616 static hda_nid_t pin_idxs
[] = { 0xff, 0x23, 0x1d, 0x1e, 0x21 };
2617 return vt_auto_create_analog_input_ctls(codec
, cfg
, 0x18, pin_idxs
,
2618 ARRAY_SIZE(pin_idxs
));
2621 static int vt1709_parse_auto_config(struct hda_codec
*codec
)
2623 struct via_spec
*spec
= codec
->spec
;
2626 err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
);
2629 err
= vt1709_auto_fill_dac_nids(spec
, &spec
->autocfg
);
2632 if (!spec
->autocfg
.line_outs
&& !spec
->autocfg
.hp_pins
[0])
2633 return 0; /* can't find valid BIOS pin config */
2635 err
= vt1709_auto_create_multi_out_ctls(spec
, &spec
->autocfg
);
2638 err
= vt1709_auto_create_hp_ctls(spec
, spec
->autocfg
.hp_pins
[0]);
2641 err
= vt1709_auto_create_analog_input_ctls(codec
, &spec
->autocfg
);
2645 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
2647 if (spec
->autocfg
.dig_outs
)
2648 spec
->multiout
.dig_out_nid
= VT1709_DIGOUT_NID
;
2649 spec
->dig_in_pin
= VT1709_DIGIN_PIN
;
2650 if (spec
->autocfg
.dig_in_pin
)
2651 spec
->dig_in_nid
= VT1709_DIGIN_NID
;
2653 if (spec
->kctls
.list
)
2654 spec
->mixers
[spec
->num_mixers
++] = spec
->kctls
.list
;
2656 spec
->input_mux
= &spec
->private_imux
[0];
2659 via_hp_build(codec
);
2661 via_smart51_build(spec
);
2665 #ifdef CONFIG_SND_HDA_POWER_SAVE
2666 static struct hda_amp_list vt1709_loopbacks
[] = {
2667 { 0x18, HDA_INPUT
, 1 },
2668 { 0x18, HDA_INPUT
, 2 },
2669 { 0x18, HDA_INPUT
, 3 },
2670 { 0x18, HDA_INPUT
, 4 },
2675 static int patch_vt1709_10ch(struct hda_codec
*codec
)
2677 struct via_spec
*spec
;
2680 /* create a codec specific record */
2681 spec
= via_new_spec(codec
);
2685 err
= vt1709_parse_auto_config(codec
);
2690 printk(KERN_INFO
"hda_codec: Cannot set up configuration. "
2691 "Using genenic mode...\n");
2694 spec
->init_verbs
[spec
->num_iverbs
++] = vt1709_10ch_volume_init_verbs
;
2695 spec
->init_verbs
[spec
->num_iverbs
++] = vt1709_uniwill_init_verbs
;
2697 spec
->stream_name_analog
= "VT1709 Analog";
2698 spec
->stream_analog_playback
= &vt1709_10ch_pcm_analog_playback
;
2699 spec
->stream_analog_capture
= &vt1709_pcm_analog_capture
;
2701 spec
->stream_name_digital
= "VT1709 Digital";
2702 spec
->stream_digital_playback
= &vt1709_pcm_digital_playback
;
2703 spec
->stream_digital_capture
= &vt1709_pcm_digital_capture
;
2706 if (!spec
->adc_nids
&& spec
->input_mux
) {
2707 spec
->adc_nids
= vt1709_adc_nids
;
2708 spec
->num_adc_nids
= ARRAY_SIZE(vt1709_adc_nids
);
2709 get_mux_nids(codec
);
2710 spec
->mixers
[spec
->num_mixers
] = vt1709_capture_mixer
;
2714 codec
->patch_ops
= via_patch_ops
;
2716 codec
->patch_ops
.init
= via_auto_init
;
2717 codec
->patch_ops
.unsol_event
= via_unsol_event
;
2718 #ifdef CONFIG_SND_HDA_POWER_SAVE
2719 spec
->loopback
.amplist
= vt1709_loopbacks
;
2725 * generic initialization of ADC, input mixers and output mixers
2727 static struct hda_verb vt1709_6ch_volume_init_verbs
[] = {
2729 * Unmute ADC0-2 and set the default input to mic-in
2731 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2732 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2733 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2736 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2739 /* Amp Indices: AOW0=0, CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */
2740 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2741 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
2742 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2)},
2743 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(3)},
2744 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(4)},
2747 * Set up output selector (0x1a, 0x1b, 0x29)
2749 /* set vol=0 to output mixers */
2750 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2751 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2752 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2755 * Unmute PW3 and PW4
2757 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2758 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2760 /* Set input of PW4 as MW0 */
2761 {0x20, AC_VERB_SET_CONNECT_SEL
, 0},
2762 /* PW9 Output enable */
2763 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40},
2767 static int patch_vt1709_6ch(struct hda_codec
*codec
)
2769 struct via_spec
*spec
;
2772 /* create a codec specific record */
2773 spec
= via_new_spec(codec
);
2777 err
= vt1709_parse_auto_config(codec
);
2782 printk(KERN_INFO
"hda_codec: Cannot set up configuration. "
2783 "Using genenic mode...\n");
2786 spec
->init_verbs
[spec
->num_iverbs
++] = vt1709_6ch_volume_init_verbs
;
2787 spec
->init_verbs
[spec
->num_iverbs
++] = vt1709_uniwill_init_verbs
;
2789 spec
->stream_name_analog
= "VT1709 Analog";
2790 spec
->stream_analog_playback
= &vt1709_6ch_pcm_analog_playback
;
2791 spec
->stream_analog_capture
= &vt1709_pcm_analog_capture
;
2793 spec
->stream_name_digital
= "VT1709 Digital";
2794 spec
->stream_digital_playback
= &vt1709_pcm_digital_playback
;
2795 spec
->stream_digital_capture
= &vt1709_pcm_digital_capture
;
2798 if (!spec
->adc_nids
&& spec
->input_mux
) {
2799 spec
->adc_nids
= vt1709_adc_nids
;
2800 spec
->num_adc_nids
= ARRAY_SIZE(vt1709_adc_nids
);
2801 get_mux_nids(codec
);
2802 spec
->mixers
[spec
->num_mixers
] = vt1709_capture_mixer
;
2806 codec
->patch_ops
= via_patch_ops
;
2808 codec
->patch_ops
.init
= via_auto_init
;
2809 codec
->patch_ops
.unsol_event
= via_unsol_event
;
2810 #ifdef CONFIG_SND_HDA_POWER_SAVE
2811 spec
->loopback
.amplist
= vt1709_loopbacks
;
2816 /* capture mixer elements */
2817 static struct snd_kcontrol_new vt1708B_capture_mixer
[] = {
2818 HDA_CODEC_VOLUME("Capture Volume", 0x13, 0x0, HDA_INPUT
),
2819 HDA_CODEC_MUTE("Capture Switch", 0x13, 0x0, HDA_INPUT
),
2820 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x14, 0x0, HDA_INPUT
),
2821 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x14, 0x0, HDA_INPUT
),
2823 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2824 /* The multiple "Capture Source" controls confuse alsamixer
2825 * So call somewhat different..
2827 /* .name = "Capture Source", */
2828 .name
= "Input Source",
2830 .info
= via_mux_enum_info
,
2831 .get
= via_mux_enum_get
,
2832 .put
= via_mux_enum_put
,
2837 * generic initialization of ADC, input mixers and output mixers
2839 static struct hda_verb vt1708B_8ch_volume_init_verbs
[] = {
2841 * Unmute ADC0-1 and set the default input to mic-in
2843 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2844 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2847 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2850 /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */
2851 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2852 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
2853 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2)},
2854 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(3)},
2855 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(4)},
2858 * Set up output mixers
2860 /* set vol=0 to output mixers */
2861 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2862 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2863 {0x27, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2865 /* Setup default input to PW4 */
2866 {0x1d, AC_VERB_SET_CONNECT_SEL
, 0},
2867 /* PW9 Output enable */
2868 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40},
2869 /* PW10 Input enable */
2870 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20},
2874 static struct hda_verb vt1708B_4ch_volume_init_verbs
[] = {
2876 * Unmute ADC0-1 and set the default input to mic-in
2878 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2879 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2882 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2885 /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */
2886 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2887 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
2888 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2)},
2889 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(3)},
2890 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(4)},
2893 * Set up output mixers
2895 /* set vol=0 to output mixers */
2896 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2897 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2898 {0x27, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2900 /* Setup default input of PW4 to MW0 */
2901 {0x1d, AC_VERB_SET_CONNECT_SEL
, 0x0},
2902 /* PW9 Output enable */
2903 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40},
2904 /* PW10 Input enable */
2905 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20},
2909 static struct hda_verb vt1708B_uniwill_init_verbs
[] = {
2910 {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE
,
2911 AC_USRSP_EN
| VIA_HP_EVENT
| VIA_JACK_EVENT
},
2912 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
2913 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
2914 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
2915 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
2916 {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
2917 {0x22, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
2918 {0x23, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
2922 static int via_pcm_open_close(struct hda_pcm_stream
*hinfo
,
2923 struct hda_codec
*codec
,
2924 struct snd_pcm_substream
*substream
)
2926 int idle
= substream
->pstr
->substream_opened
== 1
2927 && substream
->ref_count
== 0;
2929 analog_low_current_mode(codec
, idle
);
2933 static struct hda_pcm_stream vt1708B_8ch_pcm_analog_playback
= {
2937 .nid
= 0x10, /* NID to query formats and rates */
2939 .open
= via_playback_pcm_open
,
2940 .prepare
= via_playback_multi_pcm_prepare
,
2941 .cleanup
= via_playback_multi_pcm_cleanup
,
2942 .close
= via_pcm_open_close
2946 static struct hda_pcm_stream vt1708B_4ch_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
2958 static struct hda_pcm_stream vt1708B_pcm_analog_capture
= {
2962 .nid
= 0x13, /* NID to query formats and rates */
2964 .open
= via_pcm_open_close
,
2965 .prepare
= via_capture_pcm_prepare
,
2966 .cleanup
= via_capture_pcm_cleanup
,
2967 .close
= via_pcm_open_close
2971 static struct hda_pcm_stream vt1708B_pcm_digital_playback
= {
2975 /* NID is set in via_build_pcms */
2977 .open
= via_dig_playback_pcm_open
,
2978 .close
= via_dig_playback_pcm_close
,
2979 .prepare
= via_dig_playback_pcm_prepare
,
2980 .cleanup
= via_dig_playback_pcm_cleanup
2984 static struct hda_pcm_stream vt1708B_pcm_digital_capture
= {
2990 /* fill in the dac_nids table from the parsed pin configuration */
2991 static int vt1708B_auto_fill_dac_nids(struct via_spec
*spec
,
2992 const struct auto_pin_cfg
*cfg
)
2997 spec
->multiout
.num_dacs
= cfg
->line_outs
;
2999 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
3001 for (i
= 0; i
< 4; i
++) {
3002 nid
= cfg
->line_out_pins
[i
];
3004 /* config dac list */
3006 case AUTO_SEQ_FRONT
:
3007 spec
->multiout
.dac_nids
[i
] = 0x10;
3009 case AUTO_SEQ_CENLFE
:
3010 spec
->multiout
.dac_nids
[i
] = 0x24;
3012 case AUTO_SEQ_SURROUND
:
3013 spec
->multiout
.dac_nids
[i
] = 0x11;
3016 spec
->multiout
.dac_nids
[i
] = 0x25;
3025 /* add playback controls from the parsed DAC table */
3026 static int vt1708B_auto_create_multi_out_ctls(struct via_spec
*spec
,
3027 const struct auto_pin_cfg
*cfg
)
3030 static const char * const chname
[4] = {
3031 "Front", "Surround", "C/LFE", "Side"
3033 hda_nid_t nid_vols
[] = {0x16, 0x18, 0x26, 0x27};
3034 hda_nid_t nid
, nid_vol
= 0;
3037 for (i
= 0; i
<= AUTO_SEQ_SIDE
; i
++) {
3038 nid
= cfg
->line_out_pins
[i
];
3043 nid_vol
= nid_vols
[i
];
3045 if (i
== AUTO_SEQ_CENLFE
) {
3047 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
3048 "Center Playback Volume",
3049 HDA_COMPOSE_AMP_VAL(nid_vol
, 1, 0,
3053 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
3054 "LFE Playback Volume",
3055 HDA_COMPOSE_AMP_VAL(nid_vol
, 2, 0,
3059 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
3060 "Center Playback Switch",
3061 HDA_COMPOSE_AMP_VAL(nid_vol
, 1, 0,
3065 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
3066 "LFE Playback Switch",
3067 HDA_COMPOSE_AMP_VAL(nid_vol
, 2, 0,
3071 } else if (i
== AUTO_SEQ_FRONT
) {
3072 /* add control to mixer index 0 */
3073 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
3074 "Master Front Playback Volume",
3075 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0,
3079 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
3080 "Master Front Playback Switch",
3081 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0,
3086 /* add control to PW3 */
3087 sprintf(name
, "%s Playback Volume", chname
[i
]);
3088 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
, name
,
3089 HDA_COMPOSE_AMP_VAL(nid
, 3, 0,
3093 sprintf(name
, "%s Playback Switch", chname
[i
]);
3094 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
, name
,
3095 HDA_COMPOSE_AMP_VAL(nid
, 3, 0,
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_vol
, 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_vol
, 3, 0,
3118 static int vt1708B_auto_create_hp_ctls(struct via_spec
*spec
, hda_nid_t pin
)
3125 spec
->multiout
.hp_nid
= VT1708B_HP_NID
; /* AOW3 */
3126 spec
->hp_independent_mode_index
= 1;
3128 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
3129 "Headphone Playback Volume",
3130 HDA_COMPOSE_AMP_VAL(pin
, 3, 0, HDA_OUTPUT
));
3133 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
3134 "Headphone Playback Switch",
3135 HDA_COMPOSE_AMP_VAL(pin
, 3, 0, HDA_OUTPUT
));
3139 create_hp_imux(spec
);
3144 /* create playback/capture controls for input pins */
3145 static int vt1708B_auto_create_analog_input_ctls(struct hda_codec
*codec
,
3146 const struct auto_pin_cfg
*cfg
)
3148 static hda_nid_t pin_idxs
[] = { 0xff, 0x1f, 0x1a, 0x1b, 0x1e };
3149 return vt_auto_create_analog_input_ctls(codec
, cfg
, 0x16, pin_idxs
,
3150 ARRAY_SIZE(pin_idxs
));
3153 static int vt1708B_parse_auto_config(struct hda_codec
*codec
)
3155 struct via_spec
*spec
= codec
->spec
;
3158 err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
);
3161 err
= vt1708B_auto_fill_dac_nids(spec
, &spec
->autocfg
);
3164 if (!spec
->autocfg
.line_outs
&& !spec
->autocfg
.hp_pins
[0])
3165 return 0; /* can't find valid BIOS pin config */
3167 err
= vt1708B_auto_create_multi_out_ctls(spec
, &spec
->autocfg
);
3170 err
= vt1708B_auto_create_hp_ctls(spec
, spec
->autocfg
.hp_pins
[0]);
3173 err
= vt1708B_auto_create_analog_input_ctls(codec
, &spec
->autocfg
);
3177 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
3179 if (spec
->autocfg
.dig_outs
)
3180 spec
->multiout
.dig_out_nid
= VT1708B_DIGOUT_NID
;
3181 spec
->dig_in_pin
= VT1708B_DIGIN_PIN
;
3182 if (spec
->autocfg
.dig_in_pin
)
3183 spec
->dig_in_nid
= VT1708B_DIGIN_NID
;
3185 if (spec
->kctls
.list
)
3186 spec
->mixers
[spec
->num_mixers
++] = spec
->kctls
.list
;
3188 spec
->input_mux
= &spec
->private_imux
[0];
3191 via_hp_build(codec
);
3193 via_smart51_build(spec
);
3197 #ifdef CONFIG_SND_HDA_POWER_SAVE
3198 static struct hda_amp_list vt1708B_loopbacks
[] = {
3199 { 0x16, HDA_INPUT
, 1 },
3200 { 0x16, HDA_INPUT
, 2 },
3201 { 0x16, HDA_INPUT
, 3 },
3202 { 0x16, HDA_INPUT
, 4 },
3207 static void set_widgets_power_state_vt1708B(struct hda_codec
*codec
)
3209 struct via_spec
*spec
= codec
->spec
;
3213 if ((spec
->codec_type
!= VT1708B_4CH
) &&
3214 (codec
->vendor_id
!= 0x11064397))
3217 /* SW0 (17h) = stereo mixer */
3219 (snd_hda_codec_read(codec
, 0x17, 0, AC_VERB_GET_CONNECT_SEL
, 0x00)
3220 == ((spec
->codec_type
== VT1708S
) ? 5 : 0));
3222 /* PW 1/2/5 (1ah/1bh/1eh) */
3224 set_pin_power_state(codec
, 0x1a, &parm
);
3225 set_pin_power_state(codec
, 0x1b, &parm
);
3226 set_pin_power_state(codec
, 0x1e, &parm
);
3229 /* SW0 (17h), AIW 0/1 (13h/14h) */
3230 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_POWER_STATE
, parm
);
3231 snd_hda_codec_write(codec
, 0x13, 0, AC_VERB_SET_POWER_STATE
, parm
);
3232 snd_hda_codec_write(codec
, 0x14, 0, AC_VERB_SET_POWER_STATE
, parm
);
3235 /* PW0 (19h), SW1 (18h), AOW1 (11h) */
3237 set_pin_power_state(codec
, 0x19, &parm
);
3238 if (spec
->smart51_enabled
)
3239 set_pin_power_state(codec
, 0x1b, &parm
);
3240 snd_hda_codec_write(codec
, 0x18, 0, AC_VERB_SET_POWER_STATE
, parm
);
3241 snd_hda_codec_write(codec
, 0x11, 0, AC_VERB_SET_POWER_STATE
, parm
);
3243 /* PW6 (22h), SW2 (26h), AOW2 (24h) */
3246 set_pin_power_state(codec
, 0x22, &parm
);
3247 if (spec
->smart51_enabled
)
3248 set_pin_power_state(codec
, 0x1a, &parm
);
3249 snd_hda_codec_write(codec
, 0x26, 0,
3250 AC_VERB_SET_POWER_STATE
, parm
);
3251 snd_hda_codec_write(codec
, 0x24, 0,
3252 AC_VERB_SET_POWER_STATE
, parm
);
3253 } else if (codec
->vendor_id
== 0x11064397) {
3254 /* PW7(23h), SW2(27h), AOW2(25h) */
3256 set_pin_power_state(codec
, 0x23, &parm
);
3257 if (spec
->smart51_enabled
)
3258 set_pin_power_state(codec
, 0x1a, &parm
);
3259 snd_hda_codec_write(codec
, 0x27, 0,
3260 AC_VERB_SET_POWER_STATE
, parm
);
3261 snd_hda_codec_write(codec
, 0x25, 0,
3262 AC_VERB_SET_POWER_STATE
, parm
);
3265 /* PW 3/4/7 (1ch/1dh/23h) */
3267 /* force to D0 for internal Speaker */
3268 set_pin_power_state(codec
, 0x1c, &parm
);
3269 set_pin_power_state(codec
, 0x1d, &parm
);
3271 set_pin_power_state(codec
, 0x23, &parm
);
3273 /* MW0 (16h), Sw3 (27h), AOW 0/3 (10h/25h) */
3274 snd_hda_codec_write(codec
, 0x16, 0, AC_VERB_SET_POWER_STATE
,
3275 imux_is_smixer
? AC_PWRST_D0
: parm
);
3276 snd_hda_codec_write(codec
, 0x10, 0, AC_VERB_SET_POWER_STATE
, parm
);
3278 snd_hda_codec_write(codec
, 0x25, 0,
3279 AC_VERB_SET_POWER_STATE
, parm
);
3280 snd_hda_codec_write(codec
, 0x27, 0,
3281 AC_VERB_SET_POWER_STATE
, parm
);
3282 } else if (codec
->vendor_id
== 0x11064397 && spec
->hp_independent_mode
)
3283 snd_hda_codec_write(codec
, 0x25, 0,
3284 AC_VERB_SET_POWER_STATE
, parm
);
3287 static int patch_vt1708S(struct hda_codec
*codec
);
3288 static int patch_vt1708B_8ch(struct hda_codec
*codec
)
3290 struct via_spec
*spec
;
3293 if (get_codec_type(codec
) == VT1708BCE
)
3294 return patch_vt1708S(codec
);
3295 /* create a codec specific record */
3296 spec
= via_new_spec(codec
);
3300 /* automatic parse from the BIOS config */
3301 err
= vt1708B_parse_auto_config(codec
);
3306 printk(KERN_INFO
"hda_codec: Cannot set up configuration "
3307 "from BIOS. Using genenic mode...\n");
3310 spec
->init_verbs
[spec
->num_iverbs
++] = vt1708B_8ch_volume_init_verbs
;
3311 spec
->init_verbs
[spec
->num_iverbs
++] = vt1708B_uniwill_init_verbs
;
3313 spec
->stream_name_analog
= "VT1708B Analog";
3314 spec
->stream_analog_playback
= &vt1708B_8ch_pcm_analog_playback
;
3315 spec
->stream_analog_capture
= &vt1708B_pcm_analog_capture
;
3317 spec
->stream_name_digital
= "VT1708B Digital";
3318 spec
->stream_digital_playback
= &vt1708B_pcm_digital_playback
;
3319 spec
->stream_digital_capture
= &vt1708B_pcm_digital_capture
;
3321 if (!spec
->adc_nids
&& spec
->input_mux
) {
3322 spec
->adc_nids
= vt1708B_adc_nids
;
3323 spec
->num_adc_nids
= ARRAY_SIZE(vt1708B_adc_nids
);
3324 get_mux_nids(codec
);
3325 spec
->mixers
[spec
->num_mixers
] = vt1708B_capture_mixer
;
3329 codec
->patch_ops
= via_patch_ops
;
3331 codec
->patch_ops
.init
= via_auto_init
;
3332 codec
->patch_ops
.unsol_event
= via_unsol_event
;
3333 #ifdef CONFIG_SND_HDA_POWER_SAVE
3334 spec
->loopback
.amplist
= vt1708B_loopbacks
;
3337 spec
->set_widgets_power_state
= set_widgets_power_state_vt1708B
;
3342 static int patch_vt1708B_4ch(struct hda_codec
*codec
)
3344 struct via_spec
*spec
;
3347 /* create a codec specific record */
3348 spec
= via_new_spec(codec
);
3352 /* automatic parse from the BIOS config */
3353 err
= vt1708B_parse_auto_config(codec
);
3358 printk(KERN_INFO
"hda_codec: Cannot set up configuration "
3359 "from BIOS. Using genenic mode...\n");
3362 spec
->init_verbs
[spec
->num_iverbs
++] = vt1708B_4ch_volume_init_verbs
;
3363 spec
->init_verbs
[spec
->num_iverbs
++] = vt1708B_uniwill_init_verbs
;
3365 spec
->stream_name_analog
= "VT1708B Analog";
3366 spec
->stream_analog_playback
= &vt1708B_4ch_pcm_analog_playback
;
3367 spec
->stream_analog_capture
= &vt1708B_pcm_analog_capture
;
3369 spec
->stream_name_digital
= "VT1708B Digital";
3370 spec
->stream_digital_playback
= &vt1708B_pcm_digital_playback
;
3371 spec
->stream_digital_capture
= &vt1708B_pcm_digital_capture
;
3373 if (!spec
->adc_nids
&& spec
->input_mux
) {
3374 spec
->adc_nids
= vt1708B_adc_nids
;
3375 spec
->num_adc_nids
= ARRAY_SIZE(vt1708B_adc_nids
);
3376 get_mux_nids(codec
);
3377 spec
->mixers
[spec
->num_mixers
] = vt1708B_capture_mixer
;
3381 codec
->patch_ops
= via_patch_ops
;
3383 codec
->patch_ops
.init
= via_auto_init
;
3384 codec
->patch_ops
.unsol_event
= via_unsol_event
;
3385 #ifdef CONFIG_SND_HDA_POWER_SAVE
3386 spec
->loopback
.amplist
= vt1708B_loopbacks
;
3389 spec
->set_widgets_power_state
= set_widgets_power_state_vt1708B
;
3394 /* Patch for VT1708S */
3396 /* capture mixer elements */
3397 static struct snd_kcontrol_new vt1708S_capture_mixer
[] = {
3398 HDA_CODEC_VOLUME("Capture Volume", 0x13, 0x0, HDA_INPUT
),
3399 HDA_CODEC_MUTE("Capture Switch", 0x13, 0x0, HDA_INPUT
),
3400 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x14, 0x0, HDA_INPUT
),
3401 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x14, 0x0, HDA_INPUT
),
3402 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x1A, 0x0, HDA_INPUT
),
3403 HDA_CODEC_VOLUME("Front Mic Boost Capture Volume", 0x1E, 0x0,
3406 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3407 /* The multiple "Capture Source" controls confuse alsamixer
3408 * So call somewhat different..
3410 /* .name = "Capture Source", */
3411 .name
= "Input Source",
3413 .info
= via_mux_enum_info
,
3414 .get
= via_mux_enum_get
,
3415 .put
= via_mux_enum_put
,
3420 static struct hda_verb vt1708S_volume_init_verbs
[] = {
3421 /* Unmute ADC0-1 and set the default input to mic-in */
3422 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3423 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3425 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the
3426 * analog-loopback mixer widget */
3427 /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */
3428 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3429 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3430 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2)},
3431 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(3)},
3432 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(4)},
3434 /* Setup default input of PW4 to MW0 */
3435 {0x1d, AC_VERB_SET_CONNECT_SEL
, 0x0},
3436 /* PW9, PW10 Output enable */
3437 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40},
3438 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40},
3439 /* Enable Mic Boost Volume backdoor */
3441 /* don't bybass mixer */
3446 static struct hda_verb vt1708S_uniwill_init_verbs
[] = {
3447 {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE
,
3448 AC_USRSP_EN
| VIA_HP_EVENT
| VIA_JACK_EVENT
},
3449 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
3450 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
3451 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
3452 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
3453 {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
3454 {0x22, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
3455 {0x23, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
3459 static struct hda_verb vt1705_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 {0x23, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
3471 static struct hda_pcm_stream vt1708S_pcm_analog_playback
= {
3475 .nid
= 0x10, /* NID to query formats and rates */
3477 .open
= via_playback_pcm_open
,
3478 .prepare
= via_playback_multi_pcm_prepare
,
3479 .cleanup
= via_playback_multi_pcm_cleanup
,
3480 .close
= via_pcm_open_close
3484 static struct hda_pcm_stream vt1705_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 struct hda_pcm_stream vt1708S_pcm_analog_capture
= {
3501 .nid
= 0x13, /* NID to query formats and rates */
3503 .open
= via_pcm_open_close
,
3504 .prepare
= via_capture_pcm_prepare
,
3505 .cleanup
= via_capture_pcm_cleanup
,
3506 .close
= via_pcm_open_close
3510 static struct hda_pcm_stream vt1708S_pcm_digital_playback
= {
3514 /* NID is set in via_build_pcms */
3516 .open
= via_dig_playback_pcm_open
,
3517 .close
= via_dig_playback_pcm_close
,
3518 .prepare
= via_dig_playback_pcm_prepare
,
3519 .cleanup
= via_dig_playback_pcm_cleanup
3523 /* fill in the dac_nids table from the parsed pin configuration */
3524 static int vt1708S_auto_fill_dac_nids(struct via_spec
*spec
,
3525 const struct auto_pin_cfg
*cfg
)
3530 spec
->multiout
.num_dacs
= cfg
->line_outs
;
3532 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
3534 for (i
= 0; i
< 4; i
++) {
3535 nid
= cfg
->line_out_pins
[i
];
3537 /* config dac list */
3539 case AUTO_SEQ_FRONT
:
3540 spec
->multiout
.dac_nids
[i
] = 0x10;
3542 case AUTO_SEQ_CENLFE
:
3543 if (spec
->codec
->vendor_id
== 0x11064397)
3544 spec
->multiout
.dac_nids
[i
] = 0x25;
3546 spec
->multiout
.dac_nids
[i
] = 0x24;
3548 case AUTO_SEQ_SURROUND
:
3549 spec
->multiout
.dac_nids
[i
] = 0x11;
3552 spec
->multiout
.dac_nids
[i
] = 0x25;
3558 /* for Smart 5.1, line/mic inputs double as output pins */
3559 if (cfg
->line_outs
== 1) {
3560 spec
->multiout
.num_dacs
= 3;
3561 spec
->multiout
.dac_nids
[AUTO_SEQ_SURROUND
] = 0x11;
3562 if (spec
->codec
->vendor_id
== 0x11064397)
3563 spec
->multiout
.dac_nids
[AUTO_SEQ_CENLFE
] = 0x25;
3565 spec
->multiout
.dac_nids
[AUTO_SEQ_CENLFE
] = 0x24;
3571 /* add playback controls from the parsed DAC table */
3572 static int vt1708S_auto_create_multi_out_ctls(struct hda_codec
*codec
,
3573 const struct auto_pin_cfg
*cfg
)
3575 struct via_spec
*spec
= codec
->spec
;
3577 static const char * const chname
[4] = {
3578 "Front", "Surround", "C/LFE", "Side"
3580 hda_nid_t nid_vols
[2][4] = { {0x10, 0x11, 0x24, 0x25},
3581 {0x10, 0x11, 0x25, 0} };
3582 hda_nid_t nid_mutes
[2][4] = { {0x1C, 0x18, 0x26, 0x27},
3583 {0x1C, 0x18, 0x27, 0} };
3584 hda_nid_t nid
, nid_vol
, nid_mute
;
3587 for (i
= 0; i
<= AUTO_SEQ_SIDE
; i
++) {
3588 nid
= cfg
->line_out_pins
[i
];
3590 /* for Smart 5.1, there are always at least six channels */
3591 if (!nid
&& i
> AUTO_SEQ_CENLFE
)
3594 if (codec
->vendor_id
== 0x11064397) {
3595 nid_vol
= nid_vols
[1][i
];
3596 nid_mute
= nid_mutes
[1][i
];
3598 nid_vol
= nid_vols
[0][i
];
3599 nid_mute
= nid_mutes
[0][i
];
3601 if (!nid_vol
&& !nid_mute
)
3604 if (i
== AUTO_SEQ_CENLFE
) {
3606 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
3607 "Center Playback Volume",
3608 HDA_COMPOSE_AMP_VAL(nid_vol
, 1, 0,
3612 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
3613 "LFE Playback Volume",
3614 HDA_COMPOSE_AMP_VAL(nid_vol
, 2, 0,
3618 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
3619 "Center Playback Switch",
3620 HDA_COMPOSE_AMP_VAL(nid_mute
,
3625 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
3626 "LFE Playback Switch",
3627 HDA_COMPOSE_AMP_VAL(nid_mute
,
3632 } else if (i
== AUTO_SEQ_FRONT
) {
3633 /* add control to mixer index 0 */
3634 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
3635 "Master Front Playback Volume",
3636 HDA_COMPOSE_AMP_VAL(0x16, 3, 0,
3640 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
3641 "Master Front Playback Switch",
3642 HDA_COMPOSE_AMP_VAL(0x16, 3, 0,
3648 sprintf(name
, "%s Playback Volume", chname
[i
]);
3649 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
, name
,
3650 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0,
3654 sprintf(name
, "%s Playback Switch", chname
[i
]);
3655 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
, name
,
3656 HDA_COMPOSE_AMP_VAL(nid_mute
,
3662 sprintf(name
, "%s Playback Volume", chname
[i
]);
3663 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
, name
,
3664 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0,
3668 sprintf(name
, "%s Playback Switch", chname
[i
]);
3669 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
, name
,
3670 HDA_COMPOSE_AMP_VAL(nid_mute
,
3681 static int vt1708S_auto_create_hp_ctls(struct via_spec
*spec
, hda_nid_t pin
)
3688 spec
->multiout
.hp_nid
= VT1708S_HP_NID
; /* AOW3 */
3689 spec
->hp_independent_mode_index
= 1;
3691 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
3692 "Headphone Playback Volume",
3693 HDA_COMPOSE_AMP_VAL(0x25, 3, 0, HDA_OUTPUT
));
3697 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
3698 "Headphone Playback Switch",
3699 HDA_COMPOSE_AMP_VAL(pin
, 3, 0, HDA_OUTPUT
));
3703 create_hp_imux(spec
);
3708 /* create playback/capture controls for input pins */
3709 static int vt1708S_auto_create_analog_input_ctls(struct hda_codec
*codec
,
3710 const struct auto_pin_cfg
*cfg
)
3712 static hda_nid_t pin_idxs
[] = { 0x1f, 0x1a, 0x1b, 0x1e, 0, 0xff };
3713 return vt_auto_create_analog_input_ctls(codec
, cfg
, 0x16, pin_idxs
,
3714 ARRAY_SIZE(pin_idxs
));
3717 /* fill out digital output widgets; one for master and one for slave outputs */
3718 static void fill_dig_outs(struct hda_codec
*codec
)
3720 struct via_spec
*spec
= codec
->spec
;
3723 for (i
= 0; i
< spec
->autocfg
.dig_outs
; i
++) {
3727 nid
= spec
->autocfg
.dig_out_pins
[i
];
3730 conn
= snd_hda_get_connections(codec
, nid
, &nid
, 1);
3733 if (!spec
->multiout
.dig_out_nid
)
3734 spec
->multiout
.dig_out_nid
= nid
;
3736 spec
->slave_dig_outs
[0] = nid
;
3737 break; /* at most two dig outs */
3742 static int vt1708S_parse_auto_config(struct hda_codec
*codec
)
3744 struct via_spec
*spec
= codec
->spec
;
3747 err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
);
3750 err
= vt1708S_auto_fill_dac_nids(spec
, &spec
->autocfg
);
3753 if (!spec
->autocfg
.line_outs
&& !spec
->autocfg
.hp_pins
[0])
3754 return 0; /* can't find valid BIOS pin config */
3756 err
= vt1708S_auto_create_multi_out_ctls(codec
, &spec
->autocfg
);
3759 err
= vt1708S_auto_create_hp_ctls(spec
, spec
->autocfg
.hp_pins
[0]);
3762 err
= vt1708S_auto_create_analog_input_ctls(codec
, &spec
->autocfg
);
3766 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
3768 fill_dig_outs(codec
);
3770 if (spec
->kctls
.list
)
3771 spec
->mixers
[spec
->num_mixers
++] = spec
->kctls
.list
;
3773 spec
->input_mux
= &spec
->private_imux
[0];
3776 via_hp_build(codec
);
3778 via_smart51_build(spec
);
3782 #ifdef CONFIG_SND_HDA_POWER_SAVE
3783 static struct hda_amp_list vt1708S_loopbacks
[] = {
3784 { 0x16, HDA_INPUT
, 1 },
3785 { 0x16, HDA_INPUT
, 2 },
3786 { 0x16, HDA_INPUT
, 3 },
3787 { 0x16, HDA_INPUT
, 4 },
3792 static void override_mic_boost(struct hda_codec
*codec
, hda_nid_t pin
,
3793 int offset
, int num_steps
, int step_size
)
3795 snd_hda_override_amp_caps(codec
, pin
, HDA_INPUT
,
3796 (offset
<< AC_AMPCAP_OFFSET_SHIFT
) |
3797 (num_steps
<< AC_AMPCAP_NUM_STEPS_SHIFT
) |
3798 (step_size
<< AC_AMPCAP_STEP_SIZE_SHIFT
) |
3799 (0 << AC_AMPCAP_MUTE_SHIFT
));
3802 static int patch_vt1708S(struct hda_codec
*codec
)
3804 struct via_spec
*spec
;
3807 /* create a codec specific record */
3808 spec
= via_new_spec(codec
);
3812 /* automatic parse from the BIOS config */
3813 err
= vt1708S_parse_auto_config(codec
);
3818 printk(KERN_INFO
"hda_codec: Cannot set up configuration "
3819 "from BIOS. Using genenic mode...\n");
3822 spec
->init_verbs
[spec
->num_iverbs
++] = vt1708S_volume_init_verbs
;
3823 if (codec
->vendor_id
== 0x11064397)
3824 spec
->init_verbs
[spec
->num_iverbs
++] =
3825 vt1705_uniwill_init_verbs
;
3827 spec
->init_verbs
[spec
->num_iverbs
++] =
3828 vt1708S_uniwill_init_verbs
;
3830 if (codec
->vendor_id
== 0x11060440)
3831 spec
->stream_name_analog
= "VT1818S Analog";
3832 else if (codec
->vendor_id
== 0x11064397)
3833 spec
->stream_name_analog
= "VT1705 Analog";
3835 spec
->stream_name_analog
= "VT1708S Analog";
3836 if (codec
->vendor_id
== 0x11064397)
3837 spec
->stream_analog_playback
= &vt1705_pcm_analog_playback
;
3839 spec
->stream_analog_playback
= &vt1708S_pcm_analog_playback
;
3840 spec
->stream_analog_capture
= &vt1708S_pcm_analog_capture
;
3842 if (codec
->vendor_id
== 0x11060440)
3843 spec
->stream_name_digital
= "VT1818S Digital";
3844 else if (codec
->vendor_id
== 0x11064397)
3845 spec
->stream_name_digital
= "VT1705 Digital";
3847 spec
->stream_name_digital
= "VT1708S Digital";
3848 spec
->stream_digital_playback
= &vt1708S_pcm_digital_playback
;
3850 if (!spec
->adc_nids
&& spec
->input_mux
) {
3851 spec
->adc_nids
= vt1708S_adc_nids
;
3852 spec
->num_adc_nids
= ARRAY_SIZE(vt1708S_adc_nids
);
3853 get_mux_nids(codec
);
3854 override_mic_boost(codec
, 0x1a, 0, 3, 40);
3855 override_mic_boost(codec
, 0x1e, 0, 3, 40);
3856 spec
->mixers
[spec
->num_mixers
] = vt1708S_capture_mixer
;
3860 codec
->patch_ops
= via_patch_ops
;
3862 codec
->patch_ops
.init
= via_auto_init
;
3863 codec
->patch_ops
.unsol_event
= via_unsol_event
;
3864 #ifdef CONFIG_SND_HDA_POWER_SAVE
3865 spec
->loopback
.amplist
= vt1708S_loopbacks
;
3868 /* correct names for VT1708BCE */
3869 if (get_codec_type(codec
) == VT1708BCE
) {
3870 kfree(codec
->chip_name
);
3871 codec
->chip_name
= kstrdup("VT1708BCE", GFP_KERNEL
);
3872 snprintf(codec
->bus
->card
->mixername
,
3873 sizeof(codec
->bus
->card
->mixername
),
3874 "%s %s", codec
->vendor_name
, codec
->chip_name
);
3875 spec
->stream_name_analog
= "VT1708BCE Analog";
3876 spec
->stream_name_digital
= "VT1708BCE Digital";
3878 /* correct names for VT1818S */
3879 if (codec
->vendor_id
== 0x11060440) {
3880 spec
->stream_name_analog
= "VT1818S Analog";
3881 spec
->stream_name_digital
= "VT1818S Digital";
3883 /* correct names for VT1705 */
3884 if (codec
->vendor_id
== 0x11064397) {
3885 kfree(codec
->chip_name
);
3886 codec
->chip_name
= kstrdup("VT1705", GFP_KERNEL
);
3887 snprintf(codec
->bus
->card
->mixername
,
3888 sizeof(codec
->bus
->card
->mixername
),
3889 "%s %s", codec
->vendor_name
, codec
->chip_name
);
3891 spec
->set_widgets_power_state
= set_widgets_power_state_vt1708B
;
3895 /* Patch for VT1702 */
3897 /* capture mixer elements */
3898 static struct snd_kcontrol_new vt1702_capture_mixer
[] = {
3899 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_INPUT
),
3900 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_INPUT
),
3901 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x20, 0x0, HDA_INPUT
),
3902 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x20, 0x0, HDA_INPUT
),
3903 HDA_CODEC_VOLUME("Digital Mic Capture Volume", 0x1F, 0x0, HDA_INPUT
),
3904 HDA_CODEC_MUTE("Digital Mic Capture Switch", 0x1F, 0x0, HDA_INPUT
),
3905 HDA_CODEC_VOLUME("Digital Mic Boost Capture Volume", 0x1E, 0x0,
3908 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3909 /* The multiple "Capture Source" controls confuse alsamixer
3910 * So call somewhat different..
3912 /* .name = "Capture Source", */
3913 .name
= "Input Source",
3915 .info
= via_mux_enum_info
,
3916 .get
= via_mux_enum_get
,
3917 .put
= via_mux_enum_put
,
3922 static struct hda_verb vt1702_volume_init_verbs
[] = {
3924 * Unmute ADC0-1 and set the default input to mic-in
3926 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3927 {0x1F, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3928 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3931 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3934 /* Amp Indices: Mic1 = 1, Line = 1, Mic2 = 3 */
3935 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3936 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3937 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2)},
3938 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(3)},
3939 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
3941 /* Setup default input of PW4 to MW0 */
3942 {0x17, AC_VERB_SET_CONNECT_SEL
, 0x1},
3943 /* PW6 PW7 Output enable */
3944 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40},
3945 {0x1C, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40},
3953 static struct hda_verb vt1702_uniwill_init_verbs
[] = {
3954 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE
,
3955 AC_USRSP_EN
| VIA_HP_EVENT
| VIA_JACK_EVENT
},
3956 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
3957 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
3958 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
3959 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
3963 static struct hda_pcm_stream vt1702_pcm_analog_playback
= {
3967 .nid
= 0x10, /* NID to query formats and rates */
3969 .open
= via_playback_pcm_open
,
3970 .prepare
= via_playback_multi_pcm_prepare
,
3971 .cleanup
= via_playback_multi_pcm_cleanup
,
3972 .close
= via_pcm_open_close
3976 static struct hda_pcm_stream vt1702_pcm_analog_capture
= {
3980 .nid
= 0x12, /* NID to query formats and rates */
3982 .open
= via_pcm_open_close
,
3983 .prepare
= via_capture_pcm_prepare
,
3984 .cleanup
= via_capture_pcm_cleanup
,
3985 .close
= via_pcm_open_close
3989 static struct hda_pcm_stream vt1702_pcm_digital_playback
= {
3993 /* NID is set in via_build_pcms */
3995 .open
= via_dig_playback_pcm_open
,
3996 .close
= via_dig_playback_pcm_close
,
3997 .prepare
= via_dig_playback_pcm_prepare
,
3998 .cleanup
= via_dig_playback_pcm_cleanup
4002 /* fill in the dac_nids table from the parsed pin configuration */
4003 static int vt1702_auto_fill_dac_nids(struct via_spec
*spec
,
4004 const struct auto_pin_cfg
*cfg
)
4006 spec
->multiout
.num_dacs
= 1;
4007 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
4009 if (cfg
->line_out_pins
[0]) {
4010 /* config dac list */
4011 spec
->multiout
.dac_nids
[0] = 0x10;
4017 /* add playback controls from the parsed DAC table */
4018 static int vt1702_auto_create_line_out_ctls(struct via_spec
*spec
,
4019 const struct auto_pin_cfg
*cfg
)
4023 if (!cfg
->line_out_pins
[0])
4026 /* add control to mixer index 0 */
4027 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
4028 "Master Front Playback Volume",
4029 HDA_COMPOSE_AMP_VAL(0x1A, 3, 0, HDA_INPUT
));
4032 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
4033 "Master Front Playback Switch",
4034 HDA_COMPOSE_AMP_VAL(0x1A, 3, 0, HDA_INPUT
));
4039 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
4040 "Front Playback Volume",
4041 HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT
));
4044 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
4045 "Front Playback Switch",
4046 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT
));
4053 static int vt1702_auto_create_hp_ctls(struct via_spec
*spec
, hda_nid_t pin
)
4056 struct hda_input_mux
*imux
;
4057 static const char * const texts
[] = { "ON", "OFF", NULL
};
4060 spec
->multiout
.hp_nid
= 0x1D;
4061 spec
->hp_independent_mode_index
= 0;
4063 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
4064 "Headphone Playback Volume",
4065 HDA_COMPOSE_AMP_VAL(0x1D, 3, 0, HDA_OUTPUT
));
4069 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
4070 "Headphone Playback Switch",
4071 HDA_COMPOSE_AMP_VAL(pin
, 3, 0, HDA_OUTPUT
));
4075 imux
= &spec
->private_imux
[1];
4077 /* for hp mode select */
4078 for (i
= 0; texts
[i
]; i
++)
4079 snd_hda_add_imux_item(imux
, texts
[i
], i
, NULL
);
4081 spec
->hp_mux
= &spec
->private_imux
[1];
4085 /* create playback/capture controls for input pins */
4086 static int vt1702_auto_create_analog_input_ctls(struct hda_codec
*codec
,
4087 const struct auto_pin_cfg
*cfg
)
4089 static hda_nid_t pin_idxs
[] = { 0x14, 0x15, 0x18, 0xff };
4090 return vt_auto_create_analog_input_ctls(codec
, cfg
, 0x1a, pin_idxs
,
4091 ARRAY_SIZE(pin_idxs
));
4094 static int vt1702_parse_auto_config(struct hda_codec
*codec
)
4096 struct via_spec
*spec
= codec
->spec
;
4099 err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
);
4102 err
= vt1702_auto_fill_dac_nids(spec
, &spec
->autocfg
);
4105 if (!spec
->autocfg
.line_outs
&& !spec
->autocfg
.hp_pins
[0])
4106 return 0; /* can't find valid BIOS pin config */
4108 err
= vt1702_auto_create_line_out_ctls(spec
, &spec
->autocfg
);
4111 err
= vt1702_auto_create_hp_ctls(spec
, spec
->autocfg
.hp_pins
[0]);
4114 /* limit AA path volume to 0 dB */
4115 snd_hda_override_amp_caps(codec
, 0x1A, HDA_INPUT
,
4116 (0x17 << AC_AMPCAP_OFFSET_SHIFT
) |
4117 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
4118 (0x5 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
4119 (1 << AC_AMPCAP_MUTE_SHIFT
));
4120 err
= vt1702_auto_create_analog_input_ctls(codec
, &spec
->autocfg
);
4124 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
4126 fill_dig_outs(codec
);
4128 if (spec
->kctls
.list
)
4129 spec
->mixers
[spec
->num_mixers
++] = spec
->kctls
.list
;
4131 spec
->input_mux
= &spec
->private_imux
[0];
4134 via_hp_build(codec
);
4139 #ifdef CONFIG_SND_HDA_POWER_SAVE
4140 static struct hda_amp_list vt1702_loopbacks
[] = {
4141 { 0x1A, HDA_INPUT
, 1 },
4142 { 0x1A, HDA_INPUT
, 2 },
4143 { 0x1A, HDA_INPUT
, 3 },
4144 { 0x1A, HDA_INPUT
, 4 },
4149 static void set_widgets_power_state_vt1702(struct hda_codec
*codec
)
4151 int imux_is_smixer
=
4152 snd_hda_codec_read(codec
, 0x13, 0, AC_VERB_GET_CONNECT_SEL
, 0x00) == 3;
4155 /* PW 1/2/5 (14h/15h/18h) */
4157 set_pin_power_state(codec
, 0x14, &parm
);
4158 set_pin_power_state(codec
, 0x15, &parm
);
4159 set_pin_power_state(codec
, 0x18, &parm
);
4161 parm
= AC_PWRST_D0
; /* SW0 (13h) = stereo mixer (idx 3) */
4162 /* SW0 (13h), AIW 0/1/2 (12h/1fh/20h) */
4163 snd_hda_codec_write(codec
, 0x13, 0, AC_VERB_SET_POWER_STATE
, parm
);
4164 snd_hda_codec_write(codec
, 0x12, 0, AC_VERB_SET_POWER_STATE
, parm
);
4165 snd_hda_codec_write(codec
, 0x1f, 0, AC_VERB_SET_POWER_STATE
, parm
);
4166 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_POWER_STATE
, parm
);
4169 /* PW 3/4 (16h/17h) */
4171 set_pin_power_state(codec
, 0x17, &parm
);
4172 set_pin_power_state(codec
, 0x16, &parm
);
4173 /* MW0 (1ah), AOW 0/1 (10h/1dh) */
4174 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_POWER_STATE
,
4175 imux_is_smixer
? AC_PWRST_D0
: parm
);
4176 snd_hda_codec_write(codec
, 0x10, 0, AC_VERB_SET_POWER_STATE
, parm
);
4177 snd_hda_codec_write(codec
, 0x1d, 0, AC_VERB_SET_POWER_STATE
, parm
);
4180 static int patch_vt1702(struct hda_codec
*codec
)
4182 struct via_spec
*spec
;
4185 /* create a codec specific record */
4186 spec
= via_new_spec(codec
);
4190 /* automatic parse from the BIOS config */
4191 err
= vt1702_parse_auto_config(codec
);
4196 printk(KERN_INFO
"hda_codec: Cannot set up configuration "
4197 "from BIOS. Using genenic mode...\n");
4200 spec
->init_verbs
[spec
->num_iverbs
++] = vt1702_volume_init_verbs
;
4201 spec
->init_verbs
[spec
->num_iverbs
++] = vt1702_uniwill_init_verbs
;
4203 spec
->stream_name_analog
= "VT1702 Analog";
4204 spec
->stream_analog_playback
= &vt1702_pcm_analog_playback
;
4205 spec
->stream_analog_capture
= &vt1702_pcm_analog_capture
;
4207 spec
->stream_name_digital
= "VT1702 Digital";
4208 spec
->stream_digital_playback
= &vt1702_pcm_digital_playback
;
4210 if (!spec
->adc_nids
&& spec
->input_mux
) {
4211 spec
->adc_nids
= vt1702_adc_nids
;
4212 spec
->num_adc_nids
= ARRAY_SIZE(vt1702_adc_nids
);
4213 get_mux_nids(codec
);
4214 spec
->mixers
[spec
->num_mixers
] = vt1702_capture_mixer
;
4218 codec
->patch_ops
= via_patch_ops
;
4220 codec
->patch_ops
.init
= via_auto_init
;
4221 codec
->patch_ops
.unsol_event
= via_unsol_event
;
4222 #ifdef CONFIG_SND_HDA_POWER_SAVE
4223 spec
->loopback
.amplist
= vt1702_loopbacks
;
4226 spec
->set_widgets_power_state
= set_widgets_power_state_vt1702
;
4230 /* Patch for VT1718S */
4232 /* capture mixer elements */
4233 static struct snd_kcontrol_new vt1718S_capture_mixer
[] = {
4234 HDA_CODEC_VOLUME("Capture Volume", 0x10, 0x0, HDA_INPUT
),
4235 HDA_CODEC_MUTE("Capture Switch", 0x10, 0x0, HDA_INPUT
),
4236 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x11, 0x0, HDA_INPUT
),
4237 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x11, 0x0, HDA_INPUT
),
4238 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x2b, 0x0, HDA_INPUT
),
4239 HDA_CODEC_VOLUME("Front Mic Boost Capture Volume", 0x29, 0x0,
4242 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4243 /* The multiple "Capture Source" controls confuse alsamixer
4244 * So call somewhat different..
4246 .name
= "Input Source",
4248 .info
= via_mux_enum_info
,
4249 .get
= via_mux_enum_get
,
4250 .put
= via_mux_enum_put
,
4255 static struct hda_verb vt1718S_volume_init_verbs
[] = {
4257 * Unmute ADC0-1 and set the default input to mic-in
4259 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4260 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4262 /* Enable MW0 adjust Gain 5 */
4264 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4267 /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */
4268 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4269 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4270 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
4271 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
4272 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(5)},
4274 /* Setup default input of Front HP to MW9 */
4275 {0x28, AC_VERB_SET_CONNECT_SEL
, 0x1},
4276 /* PW9 PW10 Output enable */
4277 {0x2d, AC_VERB_SET_PIN_WIDGET_CONTROL
, AC_PINCTL_OUT_EN
},
4278 {0x2e, AC_VERB_SET_PIN_WIDGET_CONTROL
, AC_PINCTL_OUT_EN
},
4279 /* PW11 Input enable */
4280 {0x2f, AC_VERB_SET_PIN_WIDGET_CONTROL
, AC_PINCTL_IN_EN
},
4281 /* Enable Boost Volume backdoor */
4283 /* MW0/1/2/3/4: un-mute index 0 (AOWx), mute index 1 (MW9) */
4284 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4285 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4286 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4287 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4288 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4289 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4290 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4291 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4292 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4293 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4294 /* set MUX1 = 2 (AOW4), MUX2 = 1 (AOW3) */
4295 {0x34, AC_VERB_SET_CONNECT_SEL
, 0x2},
4296 {0x35, AC_VERB_SET_CONNECT_SEL
, 0x1},
4297 /* Unmute MW4's index 0 */
4298 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4303 static struct hda_verb vt1718S_uniwill_init_verbs
[] = {
4304 {0x28, AC_VERB_SET_UNSOLICITED_ENABLE
,
4305 AC_USRSP_EN
| VIA_HP_EVENT
| VIA_JACK_EVENT
},
4306 {0x24, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
4307 {0x25, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
4308 {0x26, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
4309 {0x27, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
4310 {0x29, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
4311 {0x2a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
4312 {0x2b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
4316 static struct hda_pcm_stream vt1718S_pcm_analog_playback
= {
4320 .nid
= 0x8, /* NID to query formats and rates */
4322 .open
= via_playback_pcm_open
,
4323 .prepare
= via_playback_multi_pcm_prepare
,
4324 .cleanup
= via_playback_multi_pcm_cleanup
,
4325 .close
= via_pcm_open_close
,
4329 static struct hda_pcm_stream vt1718S_pcm_analog_capture
= {
4333 .nid
= 0x10, /* NID to query formats and rates */
4335 .open
= via_pcm_open_close
,
4336 .prepare
= via_capture_pcm_prepare
,
4337 .cleanup
= via_capture_pcm_cleanup
,
4338 .close
= via_pcm_open_close
,
4342 static struct hda_pcm_stream vt1718S_pcm_digital_playback
= {
4346 /* NID is set in via_build_pcms */
4348 .open
= via_dig_playback_pcm_open
,
4349 .close
= via_dig_playback_pcm_close
,
4350 .prepare
= via_dig_playback_pcm_prepare
,
4351 .cleanup
= via_dig_playback_pcm_cleanup
4355 static struct hda_pcm_stream vt1718S_pcm_digital_capture
= {
4361 /* fill in the dac_nids table from the parsed pin configuration */
4362 static int vt1718S_auto_fill_dac_nids(struct via_spec
*spec
,
4363 const struct auto_pin_cfg
*cfg
)
4368 spec
->multiout
.num_dacs
= cfg
->line_outs
;
4370 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
4372 for (i
= 0; i
< 4; i
++) {
4373 nid
= cfg
->line_out_pins
[i
];
4375 /* config dac list */
4377 case AUTO_SEQ_FRONT
:
4378 spec
->multiout
.dac_nids
[i
] = 0x8;
4380 case AUTO_SEQ_CENLFE
:
4381 spec
->multiout
.dac_nids
[i
] = 0xa;
4383 case AUTO_SEQ_SURROUND
:
4384 spec
->multiout
.dac_nids
[i
] = 0x9;
4387 spec
->multiout
.dac_nids
[i
] = 0xb;
4396 /* add playback controls from the parsed DAC table */
4397 static int vt1718S_auto_create_multi_out_ctls(struct via_spec
*spec
,
4398 const struct auto_pin_cfg
*cfg
)
4401 static const char * const chname
[4] = {
4402 "Front", "Surround", "C/LFE", "Side"
4404 hda_nid_t nid_vols
[] = {0x8, 0x9, 0xa, 0xb};
4405 hda_nid_t nid_mutes
[] = {0x24, 0x25, 0x26, 0x27};
4406 hda_nid_t nid
, nid_vol
, nid_mute
= 0;
4409 for (i
= 0; i
<= AUTO_SEQ_SIDE
; i
++) {
4410 nid
= cfg
->line_out_pins
[i
];
4414 nid_vol
= nid_vols
[i
];
4415 nid_mute
= nid_mutes
[i
];
4417 if (i
== AUTO_SEQ_CENLFE
) {
4419 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
4420 "Center Playback Volume",
4421 HDA_COMPOSE_AMP_VAL(nid_vol
, 1, 0,
4425 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
4426 "LFE Playback Volume",
4427 HDA_COMPOSE_AMP_VAL(nid_vol
, 2, 0,
4431 err
= via_add_control(
4432 spec
, VIA_CTL_WIDGET_MUTE
,
4433 "Center Playback Switch",
4434 HDA_COMPOSE_AMP_VAL(nid_mute
, 1, 0,
4438 err
= via_add_control(
4439 spec
, VIA_CTL_WIDGET_MUTE
,
4440 "LFE Playback Switch",
4441 HDA_COMPOSE_AMP_VAL(nid_mute
, 2, 0,
4445 } else if (i
== AUTO_SEQ_FRONT
) {
4447 sprintf(name
, "%s Playback Volume", chname
[i
]);
4448 err
= via_add_control(
4449 spec
, VIA_CTL_WIDGET_VOL
, name
,
4450 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0, HDA_OUTPUT
));
4453 sprintf(name
, "%s Playback Switch", chname
[i
]);
4454 err
= via_add_control(
4455 spec
, VIA_CTL_WIDGET_MUTE
, name
,
4456 HDA_COMPOSE_AMP_VAL(nid_mute
, 3, 0,
4461 sprintf(name
, "%s Playback Volume", chname
[i
]);
4462 err
= via_add_control(
4463 spec
, VIA_CTL_WIDGET_VOL
, name
,
4464 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0, HDA_OUTPUT
));
4467 sprintf(name
, "%s Playback Switch", chname
[i
]);
4468 err
= via_add_control(
4469 spec
, VIA_CTL_WIDGET_MUTE
, name
,
4470 HDA_COMPOSE_AMP_VAL(nid_mute
, 3, 0,
4479 static int vt1718S_auto_create_hp_ctls(struct via_spec
*spec
, hda_nid_t pin
)
4486 spec
->multiout
.hp_nid
= 0xc; /* AOW4 */
4487 spec
->hp_independent_mode_index
= 1;
4489 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
4490 "Headphone Playback Volume",
4491 HDA_COMPOSE_AMP_VAL(0xc, 3, 0, HDA_OUTPUT
));
4495 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
4496 "Headphone Playback Switch",
4497 HDA_COMPOSE_AMP_VAL(pin
, 3, 0, HDA_OUTPUT
));
4501 create_hp_imux(spec
);
4505 /* create playback/capture controls for input pins */
4506 static int vt1718S_auto_create_analog_input_ctls(struct hda_codec
*codec
,
4507 const struct auto_pin_cfg
*cfg
)
4509 static hda_nid_t pin_idxs
[] = { 0x2c, 0x2b, 0x2a, 0x29, 0, 0xff };
4510 return vt_auto_create_analog_input_ctls(codec
, cfg
, 0x21, pin_idxs
,
4511 ARRAY_SIZE(pin_idxs
));
4514 static int vt1718S_parse_auto_config(struct hda_codec
*codec
)
4516 struct via_spec
*spec
= codec
->spec
;
4519 err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
);
4523 err
= vt1718S_auto_fill_dac_nids(spec
, &spec
->autocfg
);
4526 if (!spec
->autocfg
.line_outs
&& !spec
->autocfg
.hp_pins
[0])
4527 return 0; /* can't find valid BIOS pin config */
4529 err
= vt1718S_auto_create_multi_out_ctls(spec
, &spec
->autocfg
);
4532 err
= vt1718S_auto_create_hp_ctls(spec
, spec
->autocfg
.hp_pins
[0]);
4535 err
= vt1718S_auto_create_analog_input_ctls(codec
, &spec
->autocfg
);
4539 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
4541 fill_dig_outs(codec
);
4543 if (spec
->autocfg
.dig_in_pin
&& codec
->vendor_id
== 0x11060428)
4544 spec
->dig_in_nid
= 0x13;
4546 if (spec
->kctls
.list
)
4547 spec
->mixers
[spec
->num_mixers
++] = spec
->kctls
.list
;
4549 spec
->input_mux
= &spec
->private_imux
[0];
4552 via_hp_build(codec
);
4554 via_smart51_build(spec
);
4559 #ifdef CONFIG_SND_HDA_POWER_SAVE
4560 static struct hda_amp_list vt1718S_loopbacks
[] = {
4561 { 0x21, HDA_INPUT
, 1 },
4562 { 0x21, HDA_INPUT
, 2 },
4563 { 0x21, HDA_INPUT
, 3 },
4564 { 0x21, HDA_INPUT
, 4 },
4569 static void set_widgets_power_state_vt1718S(struct hda_codec
*codec
)
4571 struct via_spec
*spec
= codec
->spec
;
4574 /* MUX6 (1eh) = stereo mixer */
4576 snd_hda_codec_read(codec
, 0x1e, 0, AC_VERB_GET_CONNECT_SEL
, 0x00) == 5;
4578 /* PW 5/6/7 (29h/2ah/2bh) */
4580 set_pin_power_state(codec
, 0x29, &parm
);
4581 set_pin_power_state(codec
, 0x2a, &parm
);
4582 set_pin_power_state(codec
, 0x2b, &parm
);
4585 /* MUX6/7 (1eh/1fh), AIW 0/1 (10h/11h) */
4586 snd_hda_codec_write(codec
, 0x1e, 0, AC_VERB_SET_POWER_STATE
, parm
);
4587 snd_hda_codec_write(codec
, 0x1f, 0, AC_VERB_SET_POWER_STATE
, parm
);
4588 snd_hda_codec_write(codec
, 0x10, 0, AC_VERB_SET_POWER_STATE
, parm
);
4589 snd_hda_codec_write(codec
, 0x11, 0, AC_VERB_SET_POWER_STATE
, parm
);
4592 /* PW3 (27h), MW2 (1ah), AOW3 (bh) */
4594 set_pin_power_state(codec
, 0x27, &parm
);
4595 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_POWER_STATE
, parm
);
4596 snd_hda_codec_write(codec
, 0xb, 0, AC_VERB_SET_POWER_STATE
, parm
);
4598 /* PW2 (26h), AOW2 (ah) */
4600 set_pin_power_state(codec
, 0x26, &parm
);
4601 if (spec
->smart51_enabled
)
4602 set_pin_power_state(codec
, 0x2b, &parm
);
4603 snd_hda_codec_write(codec
, 0xa, 0, AC_VERB_SET_POWER_STATE
, parm
);
4605 /* PW0 (24h), AOW0 (8h) */
4607 set_pin_power_state(codec
, 0x24, &parm
);
4608 if (!spec
->hp_independent_mode
) /* check for redirected HP */
4609 set_pin_power_state(codec
, 0x28, &parm
);
4610 snd_hda_codec_write(codec
, 0x8, 0, AC_VERB_SET_POWER_STATE
, parm
);
4611 /* MW9 (21h), Mw2 (1ah), AOW0 (8h) */
4612 snd_hda_codec_write(codec
, 0x21, 0, AC_VERB_SET_POWER_STATE
,
4613 imux_is_smixer
? AC_PWRST_D0
: parm
);
4615 /* PW1 (25h), AOW1 (9h) */
4617 set_pin_power_state(codec
, 0x25, &parm
);
4618 if (spec
->smart51_enabled
)
4619 set_pin_power_state(codec
, 0x2a, &parm
);
4620 snd_hda_codec_write(codec
, 0x9, 0, AC_VERB_SET_POWER_STATE
, parm
);
4622 if (spec
->hp_independent_mode
) {
4623 /* PW4 (28h), MW3 (1bh), MUX1(34h), AOW4 (ch) */
4625 set_pin_power_state(codec
, 0x28, &parm
);
4626 snd_hda_codec_write(codec
, 0x1b, 0,
4627 AC_VERB_SET_POWER_STATE
, parm
);
4628 snd_hda_codec_write(codec
, 0x34, 0,
4629 AC_VERB_SET_POWER_STATE
, parm
);
4630 snd_hda_codec_write(codec
, 0xc, 0,
4631 AC_VERB_SET_POWER_STATE
, parm
);
4635 static int patch_vt1718S(struct hda_codec
*codec
)
4637 struct via_spec
*spec
;
4640 /* create a codec specific record */
4641 spec
= via_new_spec(codec
);
4645 /* automatic parse from the BIOS config */
4646 err
= vt1718S_parse_auto_config(codec
);
4651 printk(KERN_INFO
"hda_codec: Cannot set up configuration "
4652 "from BIOS. Using genenic mode...\n");
4655 spec
->init_verbs
[spec
->num_iverbs
++] = vt1718S_volume_init_verbs
;
4656 spec
->init_verbs
[spec
->num_iverbs
++] = vt1718S_uniwill_init_verbs
;
4658 if (codec
->vendor_id
== 0x11060441)
4659 spec
->stream_name_analog
= "VT2020 Analog";
4660 else if (codec
->vendor_id
== 0x11064441)
4661 spec
->stream_name_analog
= "VT1828S Analog";
4663 spec
->stream_name_analog
= "VT1718S Analog";
4664 spec
->stream_analog_playback
= &vt1718S_pcm_analog_playback
;
4665 spec
->stream_analog_capture
= &vt1718S_pcm_analog_capture
;
4667 if (codec
->vendor_id
== 0x11060441)
4668 spec
->stream_name_digital
= "VT2020 Digital";
4669 else if (codec
->vendor_id
== 0x11064441)
4670 spec
->stream_name_digital
= "VT1828S Digital";
4672 spec
->stream_name_digital
= "VT1718S Digital";
4673 spec
->stream_digital_playback
= &vt1718S_pcm_digital_playback
;
4674 if (codec
->vendor_id
== 0x11060428 || codec
->vendor_id
== 0x11060441)
4675 spec
->stream_digital_capture
= &vt1718S_pcm_digital_capture
;
4677 if (!spec
->adc_nids
&& spec
->input_mux
) {
4678 spec
->adc_nids
= vt1718S_adc_nids
;
4679 spec
->num_adc_nids
= ARRAY_SIZE(vt1718S_adc_nids
);
4680 get_mux_nids(codec
);
4681 override_mic_boost(codec
, 0x2b, 0, 3, 40);
4682 override_mic_boost(codec
, 0x29, 0, 3, 40);
4683 spec
->mixers
[spec
->num_mixers
] = vt1718S_capture_mixer
;
4687 codec
->patch_ops
= via_patch_ops
;
4689 codec
->patch_ops
.init
= via_auto_init
;
4690 codec
->patch_ops
.unsol_event
= via_unsol_event
;
4692 #ifdef CONFIG_SND_HDA_POWER_SAVE
4693 spec
->loopback
.amplist
= vt1718S_loopbacks
;
4696 spec
->set_widgets_power_state
= set_widgets_power_state_vt1718S
;
4701 /* Patch for VT1716S */
4703 static int vt1716s_dmic_info(struct snd_kcontrol
*kcontrol
,
4704 struct snd_ctl_elem_info
*uinfo
)
4706 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_BOOLEAN
;
4708 uinfo
->value
.integer
.min
= 0;
4709 uinfo
->value
.integer
.max
= 1;
4713 static int vt1716s_dmic_get(struct snd_kcontrol
*kcontrol
,
4714 struct snd_ctl_elem_value
*ucontrol
)
4716 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
4719 index
= snd_hda_codec_read(codec
, 0x26, 0,
4720 AC_VERB_GET_CONNECT_SEL
, 0);
4722 *ucontrol
->value
.integer
.value
= index
;
4727 static int vt1716s_dmic_put(struct snd_kcontrol
*kcontrol
,
4728 struct snd_ctl_elem_value
*ucontrol
)
4730 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
4731 struct via_spec
*spec
= codec
->spec
;
4732 int index
= *ucontrol
->value
.integer
.value
;
4734 snd_hda_codec_write(codec
, 0x26, 0,
4735 AC_VERB_SET_CONNECT_SEL
, index
);
4736 spec
->dmic_enabled
= index
;
4737 set_widgets_power_state(codec
);
4741 /* capture mixer elements */
4742 static struct snd_kcontrol_new vt1716S_capture_mixer
[] = {
4743 HDA_CODEC_VOLUME("Capture Volume", 0x13, 0x0, HDA_INPUT
),
4744 HDA_CODEC_MUTE("Capture Switch", 0x13, 0x0, HDA_INPUT
),
4745 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x14, 0x0, HDA_INPUT
),
4746 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x14, 0x0, HDA_INPUT
),
4747 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x1A, 0x0, HDA_INPUT
),
4748 HDA_CODEC_VOLUME("Front Mic Boost Capture Volume", 0x1E, 0x0,
4751 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4752 .name
= "Input Source",
4754 .info
= via_mux_enum_info
,
4755 .get
= via_mux_enum_get
,
4756 .put
= via_mux_enum_put
,
4761 static struct snd_kcontrol_new vt1716s_dmic_mixer
[] = {
4762 HDA_CODEC_VOLUME("Digital Mic Capture Volume", 0x22, 0x0, HDA_INPUT
),
4764 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4765 .name
= "Digital Mic Capture Switch",
4766 .subdevice
= HDA_SUBDEV_NID_FLAG
| 0x26,
4768 .info
= vt1716s_dmic_info
,
4769 .get
= vt1716s_dmic_get
,
4770 .put
= vt1716s_dmic_put
,
4776 /* mono-out mixer elements */
4777 static struct snd_kcontrol_new vt1716S_mono_out_mixer
[] = {
4778 HDA_CODEC_MUTE("Mono Playback Switch", 0x2a, 0x0, HDA_OUTPUT
),
4782 static struct hda_verb vt1716S_volume_init_verbs
[] = {
4784 * Unmute ADC0-1 and set the default input to mic-in
4786 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4787 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4790 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4793 /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */
4794 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4795 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4796 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
4797 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
4798 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
4800 /* MUX Indices: Stereo Mixer = 5 */
4801 {0x17, AC_VERB_SET_CONNECT_SEL
, 0x5},
4803 /* Setup default input of PW4 to MW0 */
4804 {0x1d, AC_VERB_SET_CONNECT_SEL
, 0x0},
4806 /* Setup default input of SW1 as MW0 */
4807 {0x18, AC_VERB_SET_CONNECT_SEL
, 0x1},
4809 /* Setup default input of SW4 as AOW0 */
4810 {0x28, AC_VERB_SET_CONNECT_SEL
, 0x1},
4812 /* PW9 PW10 Output enable */
4813 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40},
4814 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40},
4816 /* Unmute SW1, PW12 */
4817 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4818 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
4819 /* PW12 Output enable */
4820 {0x2a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40},
4821 /* Enable Boost Volume backdoor */
4823 /* don't bybass mixer */
4825 /* Enable mono output */
4831 static struct hda_verb vt1716S_uniwill_init_verbs
[] = {
4832 {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE
,
4833 AC_USRSP_EN
| VIA_HP_EVENT
| VIA_JACK_EVENT
},
4834 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
4835 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
4836 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
4837 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
,
4838 AC_USRSP_EN
| VIA_MONO_EVENT
| VIA_JACK_EVENT
},
4839 {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
4840 {0x23, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
4844 static struct hda_pcm_stream vt1716S_pcm_analog_playback
= {
4848 .nid
= 0x10, /* NID to query formats and rates */
4850 .open
= via_playback_pcm_open
,
4851 .prepare
= via_playback_multi_pcm_prepare
,
4852 .cleanup
= via_playback_multi_pcm_cleanup
,
4853 .close
= via_pcm_open_close
,
4857 static struct hda_pcm_stream vt1716S_pcm_analog_capture
= {
4861 .nid
= 0x13, /* NID to query formats and rates */
4863 .open
= via_pcm_open_close
,
4864 .prepare
= via_capture_pcm_prepare
,
4865 .cleanup
= via_capture_pcm_cleanup
,
4866 .close
= via_pcm_open_close
,
4870 static struct hda_pcm_stream vt1716S_pcm_digital_playback
= {
4874 /* NID is set in via_build_pcms */
4876 .open
= via_dig_playback_pcm_open
,
4877 .close
= via_dig_playback_pcm_close
,
4878 .prepare
= via_dig_playback_pcm_prepare
,
4879 .cleanup
= via_dig_playback_pcm_cleanup
4883 /* fill in the dac_nids table from the parsed pin configuration */
4884 static int vt1716S_auto_fill_dac_nids(struct via_spec
*spec
,
4885 const struct auto_pin_cfg
*cfg
)
4889 spec
->multiout
.num_dacs
= cfg
->line_outs
;
4891 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
4893 for (i
= 0; i
< 3; i
++) {
4894 nid
= cfg
->line_out_pins
[i
];
4896 /* config dac list */
4898 case AUTO_SEQ_FRONT
:
4899 spec
->multiout
.dac_nids
[i
] = 0x10;
4901 case AUTO_SEQ_CENLFE
:
4902 spec
->multiout
.dac_nids
[i
] = 0x25;
4904 case AUTO_SEQ_SURROUND
:
4905 spec
->multiout
.dac_nids
[i
] = 0x11;
4914 /* add playback controls from the parsed DAC table */
4915 static int vt1716S_auto_create_multi_out_ctls(struct via_spec
*spec
,
4916 const struct auto_pin_cfg
*cfg
)
4919 static const char * const chname
[3] = {
4920 "Front", "Surround", "C/LFE"
4922 hda_nid_t nid_vols
[] = {0x10, 0x11, 0x25};
4923 hda_nid_t nid_mutes
[] = {0x1C, 0x18, 0x27};
4924 hda_nid_t nid
, nid_vol
, nid_mute
;
4927 for (i
= 0; i
<= AUTO_SEQ_CENLFE
; i
++) {
4928 nid
= cfg
->line_out_pins
[i
];
4933 nid_vol
= nid_vols
[i
];
4934 nid_mute
= nid_mutes
[i
];
4936 if (i
== AUTO_SEQ_CENLFE
) {
4937 err
= via_add_control(
4938 spec
, VIA_CTL_WIDGET_VOL
,
4939 "Center Playback Volume",
4940 HDA_COMPOSE_AMP_VAL(nid_vol
, 1, 0, HDA_OUTPUT
));
4943 err
= via_add_control(
4944 spec
, VIA_CTL_WIDGET_VOL
,
4945 "LFE Playback Volume",
4946 HDA_COMPOSE_AMP_VAL(nid_vol
, 2, 0, HDA_OUTPUT
));
4949 err
= via_add_control(
4950 spec
, VIA_CTL_WIDGET_MUTE
,
4951 "Center Playback Switch",
4952 HDA_COMPOSE_AMP_VAL(nid_mute
, 1, 0,
4956 err
= via_add_control(
4957 spec
, VIA_CTL_WIDGET_MUTE
,
4958 "LFE Playback Switch",
4959 HDA_COMPOSE_AMP_VAL(nid_mute
, 2, 0,
4963 } else if (i
== AUTO_SEQ_FRONT
) {
4965 err
= via_add_control(
4966 spec
, VIA_CTL_WIDGET_VOL
,
4967 "Master Front Playback Volume",
4968 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_INPUT
));
4971 err
= via_add_control(
4972 spec
, VIA_CTL_WIDGET_MUTE
,
4973 "Master Front Playback Switch",
4974 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_INPUT
));
4978 sprintf(name
, "%s Playback Volume", chname
[i
]);
4979 err
= via_add_control(
4980 spec
, VIA_CTL_WIDGET_VOL
, name
,
4981 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0, HDA_OUTPUT
));
4984 sprintf(name
, "%s Playback Switch", chname
[i
]);
4985 err
= via_add_control(
4986 spec
, VIA_CTL_WIDGET_MUTE
, name
,
4987 HDA_COMPOSE_AMP_VAL(nid_mute
, 3, 0,
4992 sprintf(name
, "%s Playback Volume", chname
[i
]);
4993 err
= via_add_control(
4994 spec
, VIA_CTL_WIDGET_VOL
, name
,
4995 HDA_COMPOSE_AMP_VAL(nid_vol
, 3, 0, HDA_OUTPUT
));
4998 sprintf(name
, "%s Playback Switch", chname
[i
]);
4999 err
= via_add_control(
5000 spec
, VIA_CTL_WIDGET_MUTE
, name
,
5001 HDA_COMPOSE_AMP_VAL(nid_mute
, 3, 0,
5010 static int vt1716S_auto_create_hp_ctls(struct via_spec
*spec
, hda_nid_t pin
)
5017 spec
->multiout
.hp_nid
= 0x25; /* AOW3 */
5018 spec
->hp_independent_mode_index
= 1;
5020 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
5021 "Headphone Playback Volume",
5022 HDA_COMPOSE_AMP_VAL(0x25, 3, 0, HDA_OUTPUT
));
5026 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
5027 "Headphone Playback Switch",
5028 HDA_COMPOSE_AMP_VAL(pin
, 3, 0, HDA_OUTPUT
));
5032 create_hp_imux(spec
);
5036 /* create playback/capture controls for input pins */
5037 static int vt1716S_auto_create_analog_input_ctls(struct hda_codec
*codec
,
5038 const struct auto_pin_cfg
*cfg
)
5040 static hda_nid_t pin_idxs
[] = { 0x1f, 0x1a, 0x1b, 0x1e, 0, 0xff };
5041 return vt_auto_create_analog_input_ctls(codec
, cfg
, 0x16, pin_idxs
,
5042 ARRAY_SIZE(pin_idxs
));
5045 static int vt1716S_parse_auto_config(struct hda_codec
*codec
)
5047 struct via_spec
*spec
= codec
->spec
;
5050 err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
);
5053 err
= vt1716S_auto_fill_dac_nids(spec
, &spec
->autocfg
);
5056 if (!spec
->autocfg
.line_outs
&& !spec
->autocfg
.hp_pins
[0])
5057 return 0; /* can't find valid BIOS pin config */
5059 err
= vt1716S_auto_create_multi_out_ctls(spec
, &spec
->autocfg
);
5062 err
= vt1716S_auto_create_hp_ctls(spec
, spec
->autocfg
.hp_pins
[0]);
5065 err
= vt1716S_auto_create_analog_input_ctls(codec
, &spec
->autocfg
);
5069 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
5071 fill_dig_outs(codec
);
5073 if (spec
->kctls
.list
)
5074 spec
->mixers
[spec
->num_mixers
++] = spec
->kctls
.list
;
5076 spec
->input_mux
= &spec
->private_imux
[0];
5079 via_hp_build(codec
);
5081 via_smart51_build(spec
);
5086 #ifdef CONFIG_SND_HDA_POWER_SAVE
5087 static struct hda_amp_list vt1716S_loopbacks
[] = {
5088 { 0x16, HDA_INPUT
, 1 },
5089 { 0x16, HDA_INPUT
, 2 },
5090 { 0x16, HDA_INPUT
, 3 },
5091 { 0x16, HDA_INPUT
, 4 },
5096 static void set_widgets_power_state_vt1716S(struct hda_codec
*codec
)
5098 struct via_spec
*spec
= codec
->spec
;
5101 unsigned int mono_out
, present
;
5102 /* SW0 (17h) = stereo mixer */
5104 (snd_hda_codec_read(codec
, 0x17, 0,
5105 AC_VERB_GET_CONNECT_SEL
, 0x00) == 5);
5107 /* PW 1/2/5 (1ah/1bh/1eh) */
5109 set_pin_power_state(codec
, 0x1a, &parm
);
5110 set_pin_power_state(codec
, 0x1b, &parm
);
5111 set_pin_power_state(codec
, 0x1e, &parm
);
5114 /* SW0 (17h), AIW0(13h) */
5115 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_POWER_STATE
, parm
);
5116 snd_hda_codec_write(codec
, 0x13, 0, AC_VERB_SET_POWER_STATE
, parm
);
5119 set_pin_power_state(codec
, 0x1e, &parm
);
5121 if (spec
->dmic_enabled
)
5122 set_pin_power_state(codec
, 0x22, &parm
);
5124 snd_hda_codec_write(codec
, 0x22, 0,
5125 AC_VERB_SET_POWER_STATE
, AC_PWRST_D3
);
5127 /* SW2(26h), AIW1(14h) */
5128 snd_hda_codec_write(codec
, 0x26, 0, AC_VERB_SET_POWER_STATE
, parm
);
5129 snd_hda_codec_write(codec
, 0x14, 0, AC_VERB_SET_POWER_STATE
, parm
);
5132 /* PW0 (19h), SW1 (18h), AOW1 (11h) */
5134 set_pin_power_state(codec
, 0x19, &parm
);
5135 /* Smart 5.1 PW2(1bh) */
5136 if (spec
->smart51_enabled
)
5137 set_pin_power_state(codec
, 0x1b, &parm
);
5138 snd_hda_codec_write(codec
, 0x18, 0, AC_VERB_SET_POWER_STATE
, parm
);
5139 snd_hda_codec_write(codec
, 0x11, 0, AC_VERB_SET_POWER_STATE
, parm
);
5141 /* PW7 (23h), SW3 (27h), AOW3 (25h) */
5143 set_pin_power_state(codec
, 0x23, &parm
);
5144 /* Smart 5.1 PW1(1ah) */
5145 if (spec
->smart51_enabled
)
5146 set_pin_power_state(codec
, 0x1a, &parm
);
5147 snd_hda_codec_write(codec
, 0x27, 0, AC_VERB_SET_POWER_STATE
, parm
);
5149 /* Smart 5.1 PW5(1eh) */
5150 if (spec
->smart51_enabled
)
5151 set_pin_power_state(codec
, 0x1e, &parm
);
5152 snd_hda_codec_write(codec
, 0x25, 0, AC_VERB_SET_POWER_STATE
, parm
);
5155 /* SW4(28h)->MW1(29h)-> PW12 (2ah)*/
5156 present
= snd_hda_jack_detect(codec
, 0x1c);
5161 present
= snd_hda_jack_detect(codec
, 0x1d);
5162 if (!spec
->hp_independent_mode
&& present
)
5167 parm
= mono_out
? AC_PWRST_D0
: AC_PWRST_D3
;
5168 snd_hda_codec_write(codec
, 0x28, 0, AC_VERB_SET_POWER_STATE
, parm
);
5169 snd_hda_codec_write(codec
, 0x29, 0, AC_VERB_SET_POWER_STATE
, parm
);
5170 snd_hda_codec_write(codec
, 0x2a, 0, AC_VERB_SET_POWER_STATE
, parm
);
5172 /* PW 3/4 (1ch/1dh) */
5174 set_pin_power_state(codec
, 0x1c, &parm
);
5175 set_pin_power_state(codec
, 0x1d, &parm
);
5176 /* HP Independent Mode, power on AOW3 */
5177 if (spec
->hp_independent_mode
)
5178 snd_hda_codec_write(codec
, 0x25, 0,
5179 AC_VERB_SET_POWER_STATE
, parm
);
5181 /* force to D0 for internal Speaker */
5182 /* MW0 (16h), AOW0 (10h) */
5183 snd_hda_codec_write(codec
, 0x16, 0, AC_VERB_SET_POWER_STATE
,
5184 imux_is_smixer
? AC_PWRST_D0
: parm
);
5185 snd_hda_codec_write(codec
, 0x10, 0, AC_VERB_SET_POWER_STATE
,
5186 mono_out
? AC_PWRST_D0
: parm
);
5189 static int patch_vt1716S(struct hda_codec
*codec
)
5191 struct via_spec
*spec
;
5194 /* create a codec specific record */
5195 spec
= via_new_spec(codec
);
5199 /* automatic parse from the BIOS config */
5200 err
= vt1716S_parse_auto_config(codec
);
5205 printk(KERN_INFO
"hda_codec: Cannot set up configuration "
5206 "from BIOS. Using genenic mode...\n");
5209 spec
->init_verbs
[spec
->num_iverbs
++] = vt1716S_volume_init_verbs
;
5210 spec
->init_verbs
[spec
->num_iverbs
++] = vt1716S_uniwill_init_verbs
;
5212 spec
->stream_name_analog
= "VT1716S Analog";
5213 spec
->stream_analog_playback
= &vt1716S_pcm_analog_playback
;
5214 spec
->stream_analog_capture
= &vt1716S_pcm_analog_capture
;
5216 spec
->stream_name_digital
= "VT1716S Digital";
5217 spec
->stream_digital_playback
= &vt1716S_pcm_digital_playback
;
5219 if (!spec
->adc_nids
&& spec
->input_mux
) {
5220 spec
->adc_nids
= vt1716S_adc_nids
;
5221 spec
->num_adc_nids
= ARRAY_SIZE(vt1716S_adc_nids
);
5222 get_mux_nids(codec
);
5223 override_mic_boost(codec
, 0x1a, 0, 3, 40);
5224 override_mic_boost(codec
, 0x1e, 0, 3, 40);
5225 spec
->mixers
[spec
->num_mixers
] = vt1716S_capture_mixer
;
5229 spec
->mixers
[spec
->num_mixers
] = vt1716s_dmic_mixer
;
5232 spec
->mixers
[spec
->num_mixers
++] = vt1716S_mono_out_mixer
;
5234 codec
->patch_ops
= via_patch_ops
;
5236 codec
->patch_ops
.init
= via_auto_init
;
5237 codec
->patch_ops
.unsol_event
= via_unsol_event
;
5239 #ifdef CONFIG_SND_HDA_POWER_SAVE
5240 spec
->loopback
.amplist
= vt1716S_loopbacks
;
5243 spec
->set_widgets_power_state
= set_widgets_power_state_vt1716S
;
5249 /* capture mixer elements */
5250 static struct snd_kcontrol_new vt2002P_capture_mixer
[] = {
5251 HDA_CODEC_VOLUME("Capture Volume", 0x10, 0x0, HDA_INPUT
),
5252 HDA_CODEC_MUTE("Capture Switch", 0x10, 0x0, HDA_INPUT
),
5253 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x11, 0x0, HDA_INPUT
),
5254 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x11, 0x0, HDA_INPUT
),
5255 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x2b, 0x0, HDA_INPUT
),
5256 HDA_CODEC_VOLUME("Front Mic Boost Capture Volume", 0x29, 0x0,
5259 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
5260 /* The multiple "Capture Source" controls confuse alsamixer
5261 * So call somewhat different..
5263 /* .name = "Capture Source", */
5264 .name
= "Input Source",
5266 .info
= via_mux_enum_info
,
5267 .get
= via_mux_enum_get
,
5268 .put
= via_mux_enum_put
,
5273 static struct hda_verb vt2002P_volume_init_verbs
[] = {
5274 /* Class-D speaker related verbs */
5279 * Unmute ADC0-1 and set the default input to mic-in
5281 {0x8, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5282 {0x9, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5285 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5288 /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */
5289 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
5290 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
5291 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
5292 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
5293 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
5295 /* MUX Indices: Mic = 0 */
5296 {0x1e, AC_VERB_SET_CONNECT_SEL
, 0},
5297 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0},
5299 /* PW9 Output enable */
5300 {0x2d, AC_VERB_SET_PIN_WIDGET_CONTROL
, AC_PINCTL_OUT_EN
},
5302 /* Enable Boost Volume backdoor */
5305 /* MW0/1/4/8: un-mute index 0 (MUXx), un-mute index 1 (MW9) */
5306 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5307 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5308 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5309 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5310 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
5311 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
5312 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
5313 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
5315 /* set MUX0/1/4/8 = 0 (AOW0) */
5316 {0x34, AC_VERB_SET_CONNECT_SEL
, 0},
5317 {0x35, AC_VERB_SET_CONNECT_SEL
, 0},
5318 {0x37, AC_VERB_SET_CONNECT_SEL
, 0},
5319 {0x3b, AC_VERB_SET_CONNECT_SEL
, 0},
5321 /* set PW0 index=0 (MW0) */
5322 {0x24, AC_VERB_SET_CONNECT_SEL
, 0},
5324 /* Enable AOW0 to MW9 */
5328 static struct hda_verb vt1802_volume_init_verbs
[] = {
5330 * Unmute ADC0-1 and set the default input to mic-in
5332 {0x8, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5333 {0x9, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5336 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5339 /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */
5340 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
5341 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
5342 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
5343 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
5344 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
5346 /* MUX Indices: Mic = 0 */
5347 {0x1e, AC_VERB_SET_CONNECT_SEL
, 0},
5348 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0},
5350 /* PW9 Output enable */
5351 {0x2d, AC_VERB_SET_PIN_WIDGET_CONTROL
, AC_PINCTL_OUT_EN
},
5353 /* Enable Boost Volume backdoor */
5356 /* MW0/1/4/8: un-mute index 0 (MUXx), un-mute index 1 (MW9) */
5357 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5358 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5359 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5360 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5361 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
5362 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
5363 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
5364 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
5366 /* set MUX0/1/4/8 = 0 (AOW0) */
5367 {0x34, AC_VERB_SET_CONNECT_SEL
, 0},
5368 {0x35, AC_VERB_SET_CONNECT_SEL
, 0},
5369 {0x38, AC_VERB_SET_CONNECT_SEL
, 0},
5370 {0x3c, AC_VERB_SET_CONNECT_SEL
, 0},
5372 /* set PW0 index=0 (MW0) */
5373 {0x24, AC_VERB_SET_CONNECT_SEL
, 0},
5375 /* Enable AOW0 to MW9 */
5381 static struct hda_verb vt2002P_uniwill_init_verbs
[] = {
5382 {0x25, AC_VERB_SET_UNSOLICITED_ENABLE
,
5383 AC_USRSP_EN
| VIA_JACK_EVENT
| VIA_BIND_HP_EVENT
},
5384 {0x26, AC_VERB_SET_UNSOLICITED_ENABLE
,
5385 AC_USRSP_EN
| VIA_JACK_EVENT
| VIA_BIND_HP_EVENT
},
5386 {0x29, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
5387 {0x2a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
5388 {0x2b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
5391 static struct hda_verb vt1802_uniwill_init_verbs
[] = {
5392 {0x25, AC_VERB_SET_UNSOLICITED_ENABLE
,
5393 AC_USRSP_EN
| VIA_JACK_EVENT
| VIA_BIND_HP_EVENT
},
5394 {0x28, AC_VERB_SET_UNSOLICITED_ENABLE
,
5395 AC_USRSP_EN
| VIA_JACK_EVENT
| VIA_BIND_HP_EVENT
},
5396 {0x29, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
5397 {0x2a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
5398 {0x2b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
5402 static struct hda_pcm_stream vt2002P_pcm_analog_playback
= {
5406 .nid
= 0x8, /* NID to query formats and rates */
5408 .open
= via_playback_pcm_open
,
5409 .prepare
= via_playback_multi_pcm_prepare
,
5410 .cleanup
= via_playback_multi_pcm_cleanup
,
5411 .close
= via_pcm_open_close
,
5415 static struct hda_pcm_stream vt2002P_pcm_analog_capture
= {
5419 .nid
= 0x10, /* NID to query formats and rates */
5421 .open
= via_pcm_open_close
,
5422 .prepare
= via_capture_pcm_prepare
,
5423 .cleanup
= via_capture_pcm_cleanup
,
5424 .close
= via_pcm_open_close
,
5428 static struct hda_pcm_stream vt2002P_pcm_digital_playback
= {
5432 /* NID is set in via_build_pcms */
5434 .open
= via_dig_playback_pcm_open
,
5435 .close
= via_dig_playback_pcm_close
,
5436 .prepare
= via_dig_playback_pcm_prepare
,
5437 .cleanup
= via_dig_playback_pcm_cleanup
5441 /* fill in the dac_nids table from the parsed pin configuration */
5442 static int vt2002P_auto_fill_dac_nids(struct via_spec
*spec
,
5443 const struct auto_pin_cfg
*cfg
)
5445 spec
->multiout
.num_dacs
= 1;
5446 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
5447 if (cfg
->line_out_pins
[0])
5448 spec
->multiout
.dac_nids
[0] = 0x8;
5452 /* add playback controls from the parsed DAC table */
5453 static int vt2002P_auto_create_multi_out_ctls(struct via_spec
*spec
,
5454 const struct auto_pin_cfg
*cfg
)
5459 if (!cfg
->line_out_pins
[0])
5462 if (spec
->codec_type
== VT1802
)
5467 /* Line-Out: PortE */
5468 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
5469 "Master Front Playback Volume",
5470 HDA_COMPOSE_AMP_VAL(0x8, 3, 0, HDA_OUTPUT
));
5473 err
= via_add_control(spec
, VIA_CTL_WIDGET_BIND_PIN_MUTE
,
5474 "Master Front Playback Switch",
5475 HDA_COMPOSE_AMP_VAL(sw_nid
, 3, 0, HDA_OUTPUT
));
5482 static int vt2002P_auto_create_hp_ctls(struct via_spec
*spec
, hda_nid_t pin
)
5489 spec
->multiout
.hp_nid
= 0x9;
5490 spec
->hp_independent_mode_index
= 1;
5492 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
5493 "Headphone Playback Volume",
5494 HDA_COMPOSE_AMP_VAL(
5495 spec
->multiout
.hp_nid
, 3, 0, HDA_OUTPUT
));
5499 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
5500 "Headphone Playback Switch",
5501 HDA_COMPOSE_AMP_VAL(0x25, 3, 0, HDA_OUTPUT
));
5505 create_hp_imux(spec
);
5509 /* create playback/capture controls for input pins */
5510 static int vt2002P_auto_create_analog_input_ctls(struct hda_codec
*codec
,
5511 const struct auto_pin_cfg
*cfg
)
5513 struct via_spec
*spec
= codec
->spec
;
5514 struct hda_input_mux
*imux
= &spec
->private_imux
[0];
5515 static hda_nid_t pin_idxs
[] = { 0x2b, 0x2a, 0x29, 0xff };
5518 err
= vt_auto_create_analog_input_ctls(codec
, cfg
, 0x21, pin_idxs
,
5519 ARRAY_SIZE(pin_idxs
));
5522 /* build volume/mute control of loopback */
5523 err
= via_new_analog_input(spec
, "Stereo Mixer", 0, 3, 0x21);
5527 /* for digital mic select */
5528 snd_hda_add_imux_item(imux
, "Digital Mic", 4, NULL
);
5533 static int vt2002P_parse_auto_config(struct hda_codec
*codec
)
5535 struct via_spec
*spec
= codec
->spec
;
5539 err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
);
5543 err
= vt2002P_auto_fill_dac_nids(spec
, &spec
->autocfg
);
5547 if (!spec
->autocfg
.line_outs
&& !spec
->autocfg
.hp_pins
[0])
5548 return 0; /* can't find valid BIOS pin config */
5550 err
= vt2002P_auto_create_multi_out_ctls(spec
, &spec
->autocfg
);
5553 err
= vt2002P_auto_create_hp_ctls(spec
, spec
->autocfg
.hp_pins
[0]);
5556 err
= vt2002P_auto_create_analog_input_ctls(codec
, &spec
->autocfg
);
5560 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
5562 fill_dig_outs(codec
);
5564 if (spec
->kctls
.list
)
5565 spec
->mixers
[spec
->num_mixers
++] = spec
->kctls
.list
;
5567 spec
->input_mux
= &spec
->private_imux
[0];
5570 via_hp_build(codec
);
5575 #ifdef CONFIG_SND_HDA_POWER_SAVE
5576 static struct hda_amp_list vt2002P_loopbacks
[] = {
5577 { 0x21, HDA_INPUT
, 0 },
5578 { 0x21, HDA_INPUT
, 1 },
5579 { 0x21, HDA_INPUT
, 2 },
5584 static void set_widgets_power_state_vt2002P(struct hda_codec
*codec
)
5586 struct via_spec
*spec
= codec
->spec
;
5589 unsigned int present
;
5590 /* MUX9 (1eh) = stereo mixer */
5592 snd_hda_codec_read(codec
, 0x1e, 0, AC_VERB_GET_CONNECT_SEL
, 0x00) == 3;
5594 /* PW 5/6/7 (29h/2ah/2bh) */
5596 set_pin_power_state(codec
, 0x29, &parm
);
5597 set_pin_power_state(codec
, 0x2a, &parm
);
5598 set_pin_power_state(codec
, 0x2b, &parm
);
5600 /* MUX9/10 (1eh/1fh), AIW 0/1 (10h/11h) */
5601 snd_hda_codec_write(codec
, 0x1e, 0, AC_VERB_SET_POWER_STATE
, parm
);
5602 snd_hda_codec_write(codec
, 0x1f, 0, AC_VERB_SET_POWER_STATE
, parm
);
5603 snd_hda_codec_write(codec
, 0x10, 0, AC_VERB_SET_POWER_STATE
, parm
);
5604 snd_hda_codec_write(codec
, 0x11, 0, AC_VERB_SET_POWER_STATE
, parm
);
5608 snd_hda_codec_write(codec
, 0x8, 0, AC_VERB_SET_POWER_STATE
, parm
);
5610 if (spec
->codec_type
== VT1802
) {
5611 /* PW4 (28h), MW4 (18h), MUX4(38h) */
5613 set_pin_power_state(codec
, 0x28, &parm
);
5614 snd_hda_codec_write(codec
, 0x18, 0,
5615 AC_VERB_SET_POWER_STATE
, parm
);
5616 snd_hda_codec_write(codec
, 0x38, 0,
5617 AC_VERB_SET_POWER_STATE
, parm
);
5619 /* PW4 (26h), MW4 (1ch), MUX4(37h) */
5621 set_pin_power_state(codec
, 0x26, &parm
);
5622 snd_hda_codec_write(codec
, 0x1c, 0,
5623 AC_VERB_SET_POWER_STATE
, parm
);
5624 snd_hda_codec_write(codec
, 0x37, 0,
5625 AC_VERB_SET_POWER_STATE
, parm
);
5628 if (spec
->codec_type
== VT1802
) {
5629 /* PW1 (25h), MW1 (15h), MUX1(35h), AOW1 (9h) */
5631 set_pin_power_state(codec
, 0x25, &parm
);
5632 snd_hda_codec_write(codec
, 0x15, 0,
5633 AC_VERB_SET_POWER_STATE
, parm
);
5634 snd_hda_codec_write(codec
, 0x35, 0,
5635 AC_VERB_SET_POWER_STATE
, parm
);
5637 /* PW1 (25h), MW1 (19h), MUX1(35h), AOW1 (9h) */
5639 set_pin_power_state(codec
, 0x25, &parm
);
5640 snd_hda_codec_write(codec
, 0x19, 0,
5641 AC_VERB_SET_POWER_STATE
, parm
);
5642 snd_hda_codec_write(codec
, 0x35, 0,
5643 AC_VERB_SET_POWER_STATE
, parm
);
5646 if (spec
->hp_independent_mode
)
5647 snd_hda_codec_write(codec
, 0x9, 0,
5648 AC_VERB_SET_POWER_STATE
, AC_PWRST_D0
);
5651 /* PW0 (24h), MW0(18h/14h), MUX0(34h) */
5652 present
= snd_hda_jack_detect(codec
, 0x25);
5655 set_pin_power_state(codec
, 0x24, &parm
);
5656 parm
= present
? AC_PWRST_D3
: AC_PWRST_D0
;
5657 if (spec
->codec_type
== VT1802
)
5658 snd_hda_codec_write(codec
, 0x14, 0,
5659 AC_VERB_SET_POWER_STATE
, parm
);
5661 snd_hda_codec_write(codec
, 0x18, 0,
5662 AC_VERB_SET_POWER_STATE
, parm
);
5663 snd_hda_codec_write(codec
, 0x34, 0, AC_VERB_SET_POWER_STATE
, parm
);
5666 present
= snd_hda_jack_detect(codec
, 0x26);
5668 parm
= present
? AC_PWRST_D3
: AC_PWRST_D0
;
5669 if (spec
->codec_type
== VT1802
) {
5670 /* PW15 (33h), MW8(1ch), MUX8(3ch) */
5671 snd_hda_codec_write(codec
, 0x33, 0,
5672 AC_VERB_SET_POWER_STATE
, parm
);
5673 snd_hda_codec_write(codec
, 0x1c, 0,
5674 AC_VERB_SET_POWER_STATE
, parm
);
5675 snd_hda_codec_write(codec
, 0x3c, 0,
5676 AC_VERB_SET_POWER_STATE
, parm
);
5678 /* PW15 (31h), MW8(17h), MUX8(3bh) */
5679 snd_hda_codec_write(codec
, 0x31, 0,
5680 AC_VERB_SET_POWER_STATE
, parm
);
5681 snd_hda_codec_write(codec
, 0x17, 0,
5682 AC_VERB_SET_POWER_STATE
, parm
);
5683 snd_hda_codec_write(codec
, 0x3b, 0,
5684 AC_VERB_SET_POWER_STATE
, parm
);
5687 if (imux_is_smixer
|| !is_aa_path_mute(codec
))
5688 snd_hda_codec_write(codec
, 0x21, 0,
5689 AC_VERB_SET_POWER_STATE
, AC_PWRST_D0
);
5691 snd_hda_codec_write(codec
, 0x21, 0,
5692 AC_VERB_SET_POWER_STATE
, AC_PWRST_D3
);
5695 /* patch for vt2002P */
5696 static int patch_vt2002P(struct hda_codec
*codec
)
5698 struct via_spec
*spec
;
5701 /* create a codec specific record */
5702 spec
= via_new_spec(codec
);
5706 /* automatic parse from the BIOS config */
5707 err
= vt2002P_parse_auto_config(codec
);
5712 printk(KERN_INFO
"hda_codec: Cannot set up configuration "
5713 "from BIOS. Using genenic mode...\n");
5716 if (spec
->codec_type
== VT1802
)
5717 spec
->init_verbs
[spec
->num_iverbs
++] =
5718 vt1802_volume_init_verbs
;
5720 spec
->init_verbs
[spec
->num_iverbs
++] =
5721 vt2002P_volume_init_verbs
;
5723 if (spec
->codec_type
== VT1802
)
5724 spec
->init_verbs
[spec
->num_iverbs
++] =
5725 vt1802_uniwill_init_verbs
;
5727 spec
->init_verbs
[spec
->num_iverbs
++] =
5728 vt2002P_uniwill_init_verbs
;
5730 if (spec
->codec_type
== VT1802
)
5731 spec
->stream_name_analog
= "VT1802 Analog";
5733 spec
->stream_name_analog
= "VT2002P Analog";
5734 spec
->stream_analog_playback
= &vt2002P_pcm_analog_playback
;
5735 spec
->stream_analog_capture
= &vt2002P_pcm_analog_capture
;
5737 if (spec
->codec_type
== VT1802
)
5738 spec
->stream_name_digital
= "VT1802 Digital";
5740 spec
->stream_name_digital
= "VT2002P Digital";
5741 spec
->stream_digital_playback
= &vt2002P_pcm_digital_playback
;
5743 if (!spec
->adc_nids
&& spec
->input_mux
) {
5744 spec
->adc_nids
= vt2002P_adc_nids
;
5745 spec
->num_adc_nids
= ARRAY_SIZE(vt2002P_adc_nids
);
5746 get_mux_nids(codec
);
5747 override_mic_boost(codec
, 0x2b, 0, 3, 40);
5748 override_mic_boost(codec
, 0x29, 0, 3, 40);
5749 spec
->mixers
[spec
->num_mixers
] = vt2002P_capture_mixer
;
5753 codec
->patch_ops
= via_patch_ops
;
5755 codec
->patch_ops
.init
= via_auto_init
;
5756 codec
->patch_ops
.unsol_event
= via_unsol_event
;
5758 #ifdef CONFIG_SND_HDA_POWER_SAVE
5759 spec
->loopback
.amplist
= vt2002P_loopbacks
;
5762 spec
->set_widgets_power_state
= set_widgets_power_state_vt2002P
;
5768 /* capture mixer elements */
5769 static struct snd_kcontrol_new vt1812_capture_mixer
[] = {
5770 HDA_CODEC_VOLUME("Capture Volume", 0x10, 0x0, HDA_INPUT
),
5771 HDA_CODEC_MUTE("Capture Switch", 0x10, 0x0, HDA_INPUT
),
5772 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x11, 0x0, HDA_INPUT
),
5773 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x11, 0x0, HDA_INPUT
),
5774 HDA_CODEC_MUTE("Mic Boost Capture Volume", 0x2b, 0x0, HDA_INPUT
),
5775 HDA_CODEC_MUTE("Front Mic Boost Capture Volume", 0x29, 0x0,
5778 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
5779 /* The multiple "Capture Source" controls confuse alsamixer
5780 * So call somewhat different..
5782 .name
= "Input Source",
5784 .info
= via_mux_enum_info
,
5785 .get
= via_mux_enum_get
,
5786 .put
= via_mux_enum_put
,
5791 static struct hda_verb vt1812_volume_init_verbs
[] = {
5793 * Unmute ADC0-1 and set the default input to mic-in
5795 {0x8, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5796 {0x9, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5799 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5802 /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */
5803 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
5804 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
5805 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
5806 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
5807 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
5809 /* MUX Indices: Mic = 0 */
5810 {0x1e, AC_VERB_SET_CONNECT_SEL
, 0},
5811 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0},
5813 /* PW9 Output enable */
5814 {0x2d, AC_VERB_SET_PIN_WIDGET_CONTROL
, AC_PINCTL_OUT_EN
},
5816 /* Enable Boost Volume backdoor */
5819 /* MW0/1/4/13/15: un-mute index 0 (MUXx), un-mute index 1 (MW9) */
5820 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5821 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5822 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5823 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5824 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5825 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
5826 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
5827 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
5828 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
5829 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
5831 /* set MUX0/1/4/13/15 = 0 (AOW0) */
5832 {0x34, AC_VERB_SET_CONNECT_SEL
, 0},
5833 {0x35, AC_VERB_SET_CONNECT_SEL
, 0},
5834 {0x38, AC_VERB_SET_CONNECT_SEL
, 0},
5835 {0x3c, AC_VERB_SET_CONNECT_SEL
, 0},
5836 {0x3d, AC_VERB_SET_CONNECT_SEL
, 0},
5838 /* Enable AOW0 to MW9 */
5844 static struct hda_verb vt1812_uniwill_init_verbs
[] = {
5845 {0x33, AC_VERB_SET_UNSOLICITED_ENABLE
,
5846 AC_USRSP_EN
| VIA_JACK_EVENT
| VIA_BIND_HP_EVENT
},
5847 {0x25, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
5848 {0x28, AC_VERB_SET_UNSOLICITED_ENABLE
,
5849 AC_USRSP_EN
| VIA_JACK_EVENT
| VIA_BIND_HP_EVENT
},
5850 {0x29, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
5851 {0x2a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
5852 {0x2b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| VIA_JACK_EVENT
},
5856 static struct hda_pcm_stream vt1812_pcm_analog_playback
= {
5860 .nid
= 0x8, /* NID to query formats and rates */
5862 .open
= via_playback_pcm_open
,
5863 .prepare
= via_playback_multi_pcm_prepare
,
5864 .cleanup
= via_playback_multi_pcm_cleanup
,
5865 .close
= via_pcm_open_close
,
5869 static struct hda_pcm_stream vt1812_pcm_analog_capture
= {
5873 .nid
= 0x10, /* NID to query formats and rates */
5875 .open
= via_pcm_open_close
,
5876 .prepare
= via_capture_pcm_prepare
,
5877 .cleanup
= via_capture_pcm_cleanup
,
5878 .close
= via_pcm_open_close
,
5882 static struct hda_pcm_stream vt1812_pcm_digital_playback
= {
5886 /* NID is set in via_build_pcms */
5888 .open
= via_dig_playback_pcm_open
,
5889 .close
= via_dig_playback_pcm_close
,
5890 .prepare
= via_dig_playback_pcm_prepare
,
5891 .cleanup
= via_dig_playback_pcm_cleanup
5894 /* fill in the dac_nids table from the parsed pin configuration */
5895 static int vt1812_auto_fill_dac_nids(struct via_spec
*spec
,
5896 const struct auto_pin_cfg
*cfg
)
5898 spec
->multiout
.num_dacs
= 1;
5899 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
5900 if (cfg
->line_out_pins
[0])
5901 spec
->multiout
.dac_nids
[0] = 0x8;
5906 /* add playback controls from the parsed DAC table */
5907 static int vt1812_auto_create_multi_out_ctls(struct via_spec
*spec
,
5908 const struct auto_pin_cfg
*cfg
)
5912 if (!cfg
->line_out_pins
[0])
5915 /* Line-Out: PortE */
5916 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
5917 "Front Playback Volume",
5918 HDA_COMPOSE_AMP_VAL(0x8, 3, 0, HDA_OUTPUT
));
5921 err
= via_add_control(spec
, VIA_CTL_WIDGET_BIND_PIN_MUTE
,
5922 "Front Playback Switch",
5923 HDA_COMPOSE_AMP_VAL(0x28, 3, 0, HDA_OUTPUT
));
5930 static int vt1812_auto_create_hp_ctls(struct via_spec
*spec
, hda_nid_t pin
)
5937 spec
->multiout
.hp_nid
= 0x9;
5938 spec
->hp_independent_mode_index
= 1;
5941 err
= via_add_control(spec
, VIA_CTL_WIDGET_VOL
,
5942 "Headphone Playback Volume",
5943 HDA_COMPOSE_AMP_VAL(
5944 spec
->multiout
.hp_nid
, 3, 0, HDA_OUTPUT
));
5948 err
= via_add_control(spec
, VIA_CTL_WIDGET_MUTE
,
5949 "Headphone Playback Switch",
5950 HDA_COMPOSE_AMP_VAL(pin
, 3, 0, HDA_OUTPUT
));
5954 create_hp_imux(spec
);
5958 /* create playback/capture controls for input pins */
5959 static int vt1812_auto_create_analog_input_ctls(struct hda_codec
*codec
,
5960 const struct auto_pin_cfg
*cfg
)
5962 struct via_spec
*spec
= codec
->spec
;
5963 struct hda_input_mux
*imux
= &spec
->private_imux
[0];
5964 static hda_nid_t pin_idxs
[] = { 0x2b, 0x2a, 0x29, 0, 0, 0xff };
5967 err
= vt_auto_create_analog_input_ctls(codec
, cfg
, 0x21, pin_idxs
,
5968 ARRAY_SIZE(pin_idxs
));
5972 /* build volume/mute control of loopback */
5973 err
= via_new_analog_input(spec
, "Stereo Mixer", 0, 5, 0x21);
5977 /* for digital mic select */
5978 snd_hda_add_imux_item(imux
, "Digital Mic", 6, NULL
);
5983 static int vt1812_parse_auto_config(struct hda_codec
*codec
)
5985 struct via_spec
*spec
= codec
->spec
;
5989 err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
);
5992 fill_dig_outs(codec
);
5993 err
= vt1812_auto_fill_dac_nids(spec
, &spec
->autocfg
);
5997 if (!spec
->autocfg
.line_outs
&& !spec
->autocfg
.hp_outs
)
5998 return 0; /* can't find valid BIOS pin config */
6000 err
= vt1812_auto_create_multi_out_ctls(spec
, &spec
->autocfg
);
6003 err
= vt1812_auto_create_hp_ctls(spec
, spec
->autocfg
.hp_pins
[0]);
6006 err
= vt1812_auto_create_analog_input_ctls(codec
, &spec
->autocfg
);
6010 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
6012 fill_dig_outs(codec
);
6014 if (spec
->kctls
.list
)
6015 spec
->mixers
[spec
->num_mixers
++] = spec
->kctls
.list
;
6017 spec
->input_mux
= &spec
->private_imux
[0];
6020 via_hp_build(codec
);
6025 #ifdef CONFIG_SND_HDA_POWER_SAVE
6026 static struct hda_amp_list vt1812_loopbacks
[] = {
6027 { 0x21, HDA_INPUT
, 0 },
6028 { 0x21, HDA_INPUT
, 1 },
6029 { 0x21, HDA_INPUT
, 2 },
6034 static void set_widgets_power_state_vt1812(struct hda_codec
*codec
)
6036 struct via_spec
*spec
= codec
->spec
;
6037 int imux_is_smixer
=
6038 snd_hda_codec_read(codec
, 0x13, 0, AC_VERB_GET_CONNECT_SEL
, 0x00) == 3;
6040 unsigned int present
;
6041 /* MUX10 (1eh) = stereo mixer */
6043 snd_hda_codec_read(codec
, 0x1e, 0, AC_VERB_GET_CONNECT_SEL
, 0x00) == 5;
6045 /* PW 5/6/7 (29h/2ah/2bh) */
6047 set_pin_power_state(codec
, 0x29, &parm
);
6048 set_pin_power_state(codec
, 0x2a, &parm
);
6049 set_pin_power_state(codec
, 0x2b, &parm
);
6051 /* MUX10/11 (1eh/1fh), AIW 0/1 (10h/11h) */
6052 snd_hda_codec_write(codec
, 0x1e, 0, AC_VERB_SET_POWER_STATE
, parm
);
6053 snd_hda_codec_write(codec
, 0x1f, 0, AC_VERB_SET_POWER_STATE
, parm
);
6054 snd_hda_codec_write(codec
, 0x10, 0, AC_VERB_SET_POWER_STATE
, parm
);
6055 snd_hda_codec_write(codec
, 0x11, 0, AC_VERB_SET_POWER_STATE
, parm
);
6059 snd_hda_codec_write(codec
, 0x8, 0,
6060 AC_VERB_SET_POWER_STATE
, AC_PWRST_D0
);
6062 /* PW4 (28h), MW4 (18h), MUX4(38h) */
6064 set_pin_power_state(codec
, 0x28, &parm
);
6065 snd_hda_codec_write(codec
, 0x18, 0, AC_VERB_SET_POWER_STATE
, parm
);
6066 snd_hda_codec_write(codec
, 0x38, 0, AC_VERB_SET_POWER_STATE
, parm
);
6068 /* PW1 (25h), MW1 (15h), MUX1(35h), AOW1 (9h) */
6070 set_pin_power_state(codec
, 0x25, &parm
);
6071 snd_hda_codec_write(codec
, 0x15, 0, AC_VERB_SET_POWER_STATE
, parm
);
6072 snd_hda_codec_write(codec
, 0x35, 0, AC_VERB_SET_POWER_STATE
, parm
);
6073 if (spec
->hp_independent_mode
)
6074 snd_hda_codec_write(codec
, 0x9, 0,
6075 AC_VERB_SET_POWER_STATE
, AC_PWRST_D0
);
6077 /* Internal Speaker */
6078 /* PW0 (24h), MW0(14h), MUX0(34h) */
6079 present
= snd_hda_jack_detect(codec
, 0x25);
6082 set_pin_power_state(codec
, 0x24, &parm
);
6084 snd_hda_codec_write(codec
, 0x14, 0,
6085 AC_VERB_SET_POWER_STATE
, AC_PWRST_D3
);
6086 snd_hda_codec_write(codec
, 0x34, 0,
6087 AC_VERB_SET_POWER_STATE
, AC_PWRST_D3
);
6089 snd_hda_codec_write(codec
, 0x14, 0,
6090 AC_VERB_SET_POWER_STATE
, AC_PWRST_D0
);
6091 snd_hda_codec_write(codec
, 0x34, 0,
6092 AC_VERB_SET_POWER_STATE
, AC_PWRST_D0
);
6097 /* PW13 (31h), MW13(1ch), MUX13(3ch), MW14(3eh) */
6098 present
= snd_hda_jack_detect(codec
, 0x28);
6101 set_pin_power_state(codec
, 0x31, &parm
);
6103 snd_hda_codec_write(codec
, 0x1c, 0,
6104 AC_VERB_SET_POWER_STATE
, AC_PWRST_D3
);
6105 snd_hda_codec_write(codec
, 0x3c, 0,
6106 AC_VERB_SET_POWER_STATE
, AC_PWRST_D3
);
6107 snd_hda_codec_write(codec
, 0x3e, 0,
6108 AC_VERB_SET_POWER_STATE
, AC_PWRST_D3
);
6110 snd_hda_codec_write(codec
, 0x1c, 0,
6111 AC_VERB_SET_POWER_STATE
, AC_PWRST_D0
);
6112 snd_hda_codec_write(codec
, 0x3c, 0,
6113 AC_VERB_SET_POWER_STATE
, AC_PWRST_D0
);
6114 snd_hda_codec_write(codec
, 0x3e, 0,
6115 AC_VERB_SET_POWER_STATE
, AC_PWRST_D0
);
6118 /* PW15 (33h), MW15 (1dh), MUX15(3dh) */
6120 set_pin_power_state(codec
, 0x33, &parm
);
6121 snd_hda_codec_write(codec
, 0x1d, 0, AC_VERB_SET_POWER_STATE
, parm
);
6122 snd_hda_codec_write(codec
, 0x3d, 0, AC_VERB_SET_POWER_STATE
, parm
);
6126 /* patch for vt1812 */
6127 static int patch_vt1812(struct hda_codec
*codec
)
6129 struct via_spec
*spec
;
6132 /* create a codec specific record */
6133 spec
= via_new_spec(codec
);
6137 /* automatic parse from the BIOS config */
6138 err
= vt1812_parse_auto_config(codec
);
6143 printk(KERN_INFO
"hda_codec: Cannot set up configuration "
6144 "from BIOS. Using genenic mode...\n");
6148 spec
->init_verbs
[spec
->num_iverbs
++] = vt1812_volume_init_verbs
;
6149 spec
->init_verbs
[spec
->num_iverbs
++] = vt1812_uniwill_init_verbs
;
6151 spec
->stream_name_analog
= "VT1812 Analog";
6152 spec
->stream_analog_playback
= &vt1812_pcm_analog_playback
;
6153 spec
->stream_analog_capture
= &vt1812_pcm_analog_capture
;
6155 spec
->stream_name_digital
= "VT1812 Digital";
6156 spec
->stream_digital_playback
= &vt1812_pcm_digital_playback
;
6159 if (!spec
->adc_nids
&& spec
->input_mux
) {
6160 spec
->adc_nids
= vt1812_adc_nids
;
6161 spec
->num_adc_nids
= ARRAY_SIZE(vt1812_adc_nids
);
6162 get_mux_nids(codec
);
6163 override_mic_boost(codec
, 0x2b, 0, 3, 40);
6164 override_mic_boost(codec
, 0x29, 0, 3, 40);
6165 spec
->mixers
[spec
->num_mixers
] = vt1812_capture_mixer
;
6169 codec
->patch_ops
= via_patch_ops
;
6171 codec
->patch_ops
.init
= via_auto_init
;
6172 codec
->patch_ops
.unsol_event
= via_unsol_event
;
6174 #ifdef CONFIG_SND_HDA_POWER_SAVE
6175 spec
->loopback
.amplist
= vt1812_loopbacks
;
6178 spec
->set_widgets_power_state
= set_widgets_power_state_vt1812
;
6185 static struct hda_codec_preset snd_hda_preset_via
[] = {
6186 { .id
= 0x11061708, .name
= "VT1708", .patch
= patch_vt1708
},
6187 { .id
= 0x11061709, .name
= "VT1708", .patch
= patch_vt1708
},
6188 { .id
= 0x1106170a, .name
= "VT1708", .patch
= patch_vt1708
},
6189 { .id
= 0x1106170b, .name
= "VT1708", .patch
= patch_vt1708
},
6190 { .id
= 0x1106e710, .name
= "VT1709 10-Ch",
6191 .patch
= patch_vt1709_10ch
},
6192 { .id
= 0x1106e711, .name
= "VT1709 10-Ch",
6193 .patch
= patch_vt1709_10ch
},
6194 { .id
= 0x1106e712, .name
= "VT1709 10-Ch",
6195 .patch
= patch_vt1709_10ch
},
6196 { .id
= 0x1106e713, .name
= "VT1709 10-Ch",
6197 .patch
= patch_vt1709_10ch
},
6198 { .id
= 0x1106e714, .name
= "VT1709 6-Ch",
6199 .patch
= patch_vt1709_6ch
},
6200 { .id
= 0x1106e715, .name
= "VT1709 6-Ch",
6201 .patch
= patch_vt1709_6ch
},
6202 { .id
= 0x1106e716, .name
= "VT1709 6-Ch",
6203 .patch
= patch_vt1709_6ch
},
6204 { .id
= 0x1106e717, .name
= "VT1709 6-Ch",
6205 .patch
= patch_vt1709_6ch
},
6206 { .id
= 0x1106e720, .name
= "VT1708B 8-Ch",
6207 .patch
= patch_vt1708B_8ch
},
6208 { .id
= 0x1106e721, .name
= "VT1708B 8-Ch",
6209 .patch
= patch_vt1708B_8ch
},
6210 { .id
= 0x1106e722, .name
= "VT1708B 8-Ch",
6211 .patch
= patch_vt1708B_8ch
},
6212 { .id
= 0x1106e723, .name
= "VT1708B 8-Ch",
6213 .patch
= patch_vt1708B_8ch
},
6214 { .id
= 0x1106e724, .name
= "VT1708B 4-Ch",
6215 .patch
= patch_vt1708B_4ch
},
6216 { .id
= 0x1106e725, .name
= "VT1708B 4-Ch",
6217 .patch
= patch_vt1708B_4ch
},
6218 { .id
= 0x1106e726, .name
= "VT1708B 4-Ch",
6219 .patch
= patch_vt1708B_4ch
},
6220 { .id
= 0x1106e727, .name
= "VT1708B 4-Ch",
6221 .patch
= patch_vt1708B_4ch
},
6222 { .id
= 0x11060397, .name
= "VT1708S",
6223 .patch
= patch_vt1708S
},
6224 { .id
= 0x11061397, .name
= "VT1708S",
6225 .patch
= patch_vt1708S
},
6226 { .id
= 0x11062397, .name
= "VT1708S",
6227 .patch
= patch_vt1708S
},
6228 { .id
= 0x11063397, .name
= "VT1708S",
6229 .patch
= patch_vt1708S
},
6230 { .id
= 0x11064397, .name
= "VT1705",
6231 .patch
= patch_vt1708S
},
6232 { .id
= 0x11065397, .name
= "VT1708S",
6233 .patch
= patch_vt1708S
},
6234 { .id
= 0x11066397, .name
= "VT1708S",
6235 .patch
= patch_vt1708S
},
6236 { .id
= 0x11067397, .name
= "VT1708S",
6237 .patch
= patch_vt1708S
},
6238 { .id
= 0x11060398, .name
= "VT1702",
6239 .patch
= patch_vt1702
},
6240 { .id
= 0x11061398, .name
= "VT1702",
6241 .patch
= patch_vt1702
},
6242 { .id
= 0x11062398, .name
= "VT1702",
6243 .patch
= patch_vt1702
},
6244 { .id
= 0x11063398, .name
= "VT1702",
6245 .patch
= patch_vt1702
},
6246 { .id
= 0x11064398, .name
= "VT1702",
6247 .patch
= patch_vt1702
},
6248 { .id
= 0x11065398, .name
= "VT1702",
6249 .patch
= patch_vt1702
},
6250 { .id
= 0x11066398, .name
= "VT1702",
6251 .patch
= patch_vt1702
},
6252 { .id
= 0x11067398, .name
= "VT1702",
6253 .patch
= patch_vt1702
},
6254 { .id
= 0x11060428, .name
= "VT1718S",
6255 .patch
= patch_vt1718S
},
6256 { .id
= 0x11064428, .name
= "VT1718S",
6257 .patch
= patch_vt1718S
},
6258 { .id
= 0x11060441, .name
= "VT2020",
6259 .patch
= patch_vt1718S
},
6260 { .id
= 0x11064441, .name
= "VT1828S",
6261 .patch
= patch_vt1718S
},
6262 { .id
= 0x11060433, .name
= "VT1716S",
6263 .patch
= patch_vt1716S
},
6264 { .id
= 0x1106a721, .name
= "VT1716S",
6265 .patch
= patch_vt1716S
},
6266 { .id
= 0x11060438, .name
= "VT2002P", .patch
= patch_vt2002P
},
6267 { .id
= 0x11064438, .name
= "VT2002P", .patch
= patch_vt2002P
},
6268 { .id
= 0x11060448, .name
= "VT1812", .patch
= patch_vt1812
},
6269 { .id
= 0x11060440, .name
= "VT1818S",
6270 .patch
= patch_vt1708S
},
6271 { .id
= 0x11060446, .name
= "VT1802",
6272 .patch
= patch_vt2002P
},
6273 { .id
= 0x11068446, .name
= "VT1802",
6274 .patch
= patch_vt2002P
},
6278 MODULE_ALIAS("snd-hda-codec-id:1106*");
6280 static struct hda_codec_preset_list via_list
= {
6281 .preset
= snd_hda_preset_via
,
6282 .owner
= THIS_MODULE
,
6285 MODULE_LICENSE("GPL");
6286 MODULE_DESCRIPTION("VIA HD-audio codec");
6288 static int __init
patch_via_init(void)
6290 return snd_hda_add_codec_preset(&via_list
);
6293 static void __exit
patch_via_exit(void)
6295 snd_hda_delete_codec_preset(&via_list
);
6298 module_init(patch_via_init
)
6299 module_exit(patch_via_exit
)