2 * HD audio interface patch for Conexant HDA audio codec
4 * Copyright (c) 2006 Pototskiy Akex <alex.pototskiy@gmail.com>
5 * Takashi Iwai <tiwai@suse.de>
6 * Tobin Davis <tdavis@dsl-only.net>
8 * This driver is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This driver is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <linux/init.h>
24 #include <linux/delay.h>
25 #include <linux/slab.h>
26 #include <linux/pci.h>
27 #include <sound/core.h>
28 #include <sound/jack.h>
30 #include "hda_codec.h"
31 #include "hda_local.h"
34 #define CXT_PIN_DIR_IN 0x00
35 #define CXT_PIN_DIR_OUT 0x01
36 #define CXT_PIN_DIR_INOUT 0x02
37 #define CXT_PIN_DIR_IN_NOMICBIAS 0x03
38 #define CXT_PIN_DIR_INOUT_NOMICBIAS 0x04
40 #define CONEXANT_HP_EVENT 0x37
41 #define CONEXANT_MIC_EVENT 0x38
42 #define CONEXANT_LINE_EVENT 0x39
44 /* Conexant 5051 specific */
46 #define CXT5051_SPDIF_OUT 0x12
47 #define CXT5051_PORTB_EVENT 0x38
48 #define CXT5051_PORTC_EVENT 0x39
50 #define AUTO_MIC_PORTB (1 << 1)
51 #define AUTO_MIC_PORTC (1 << 2)
60 hda_nid_t pin
; /* input pin NID */
61 hda_nid_t adc
; /* connected ADC NID */
62 hda_nid_t boost
; /* optional boost volume NID */
63 int index
; /* corresponding to autocfg.input */
66 struct conexant_spec
{
68 const struct snd_kcontrol_new
*mixers
[5];
70 hda_nid_t vmaster_nid
;
72 const struct hda_verb
*init_verbs
[5]; /* initialization verbs
76 unsigned int num_init_verbs
;
79 struct hda_multi_out multiout
; /* playback set-up
80 * max_channels, dacs must be set
81 * dig_out_nid and hp_nid are optional
83 unsigned int cur_eapd
;
84 unsigned int hp_present
;
85 unsigned int line_present
;
86 unsigned int auto_mic
;
87 int auto_mic_ext
; /* imux_pins[] index for ext mic */
88 int auto_mic_dock
; /* imux_pins[] index for dock mic */
89 int auto_mic_int
; /* imux_pins[] index for int mic */
90 unsigned int need_dac_fix
;
91 hda_nid_t slave_dig_outs
[2];
94 unsigned int num_adc_nids
;
95 const hda_nid_t
*adc_nids
;
96 hda_nid_t dig_in_nid
; /* digital-in NID; optional */
98 unsigned int cur_adc_idx
;
100 unsigned int cur_adc_stream_tag
;
101 unsigned int cur_adc_format
;
103 const struct hda_pcm_stream
*capture_stream
;
106 const struct hda_input_mux
*input_mux
;
107 const hda_nid_t
*capsrc_nids
;
108 unsigned int cur_mux
[3];
111 const struct hda_channel_mode
*channel_mode
;
112 int num_channel_mode
;
114 /* PCM information */
115 struct hda_pcm pcm_rec
[2]; /* used in build_pcms() */
117 unsigned int spdif_route
;
119 /* dynamic controls, init_verbs and input_mux */
120 struct auto_pin_cfg autocfg
;
121 struct hda_input_mux private_imux
;
122 struct imux_info imux_info
[HDA_MAX_NUM_INPUTS
];
123 hda_nid_t private_adc_nids
[HDA_MAX_NUM_INPUTS
];
124 hda_nid_t private_dac_nids
[AUTO_CFG_MAX_OUTS
];
125 struct pin_dac_pair dac_info
[8];
128 unsigned int port_d_mode
;
129 unsigned int auto_mute
:1; /* used in auto-parser */
130 unsigned int detect_line
:1; /* Line-out detection enabled */
131 unsigned int automute_lines
:1; /* automute line-out as well */
132 unsigned int automute_hp_lo
:1; /* both HP and LO available */
133 unsigned int dell_automute
:1;
134 unsigned int dell_vostro
:1;
135 unsigned int ideapad
:1;
136 unsigned int thinkpad
:1;
137 unsigned int hp_laptop
:1;
140 unsigned int adc_switching
:1;
142 unsigned int ext_mic_present
;
143 unsigned int recording
;
144 void (*capture_prepare
)(struct hda_codec
*codec
);
145 void (*capture_cleanup
)(struct hda_codec
*codec
);
147 /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors)
148 * through the microphone jack.
149 * When the user enables this through a mixer switch, both internal and
150 * external microphones are disabled. Gain is fixed at 0dB. In this mode,
151 * we also allow the bias to be configured through a separate mixer
153 unsigned int dc_enable
;
154 unsigned int dc_input_bias
; /* offset into cxt5066_olpc_dc_bias */
155 unsigned int mic_boost
; /* offset into cxt5066_analog_mic_boost */
157 unsigned int beep_amp
;
160 static int conexant_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
161 struct hda_codec
*codec
,
162 struct snd_pcm_substream
*substream
)
164 struct conexant_spec
*spec
= codec
->spec
;
165 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
169 static int conexant_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
170 struct hda_codec
*codec
,
171 unsigned int stream_tag
,
173 struct snd_pcm_substream
*substream
)
175 struct conexant_spec
*spec
= codec
->spec
;
176 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
,
181 static int conexant_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
182 struct hda_codec
*codec
,
183 struct snd_pcm_substream
*substream
)
185 struct conexant_spec
*spec
= codec
->spec
;
186 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
192 static int conexant_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
193 struct hda_codec
*codec
,
194 struct snd_pcm_substream
*substream
)
196 struct conexant_spec
*spec
= codec
->spec
;
197 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
200 static int conexant_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
201 struct hda_codec
*codec
,
202 struct snd_pcm_substream
*substream
)
204 struct conexant_spec
*spec
= codec
->spec
;
205 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
208 static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
209 struct hda_codec
*codec
,
210 unsigned int stream_tag
,
212 struct snd_pcm_substream
*substream
)
214 struct conexant_spec
*spec
= codec
->spec
;
215 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
223 static int conexant_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
224 struct hda_codec
*codec
,
225 unsigned int stream_tag
,
227 struct snd_pcm_substream
*substream
)
229 struct conexant_spec
*spec
= codec
->spec
;
230 if (spec
->capture_prepare
)
231 spec
->capture_prepare(codec
);
232 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
],
233 stream_tag
, 0, format
);
237 static int conexant_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
238 struct hda_codec
*codec
,
239 struct snd_pcm_substream
*substream
)
241 struct conexant_spec
*spec
= codec
->spec
;
242 snd_hda_codec_cleanup_stream(codec
, spec
->adc_nids
[substream
->number
]);
243 if (spec
->capture_cleanup
)
244 spec
->capture_cleanup(codec
);
250 static const struct hda_pcm_stream conexant_pcm_analog_playback
= {
254 .nid
= 0, /* fill later */
256 .open
= conexant_playback_pcm_open
,
257 .prepare
= conexant_playback_pcm_prepare
,
258 .cleanup
= conexant_playback_pcm_cleanup
262 static const struct hda_pcm_stream conexant_pcm_analog_capture
= {
266 .nid
= 0, /* fill later */
268 .prepare
= conexant_capture_pcm_prepare
,
269 .cleanup
= conexant_capture_pcm_cleanup
274 static const struct hda_pcm_stream conexant_pcm_digital_playback
= {
278 .nid
= 0, /* fill later */
280 .open
= conexant_dig_playback_pcm_open
,
281 .close
= conexant_dig_playback_pcm_close
,
282 .prepare
= conexant_dig_playback_pcm_prepare
286 static const struct hda_pcm_stream conexant_pcm_digital_capture
= {
290 /* NID is set in alc_build_pcms */
293 static int cx5051_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
294 struct hda_codec
*codec
,
295 unsigned int stream_tag
,
297 struct snd_pcm_substream
*substream
)
299 struct conexant_spec
*spec
= codec
->spec
;
300 spec
->cur_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
301 spec
->cur_adc_stream_tag
= stream_tag
;
302 spec
->cur_adc_format
= format
;
303 snd_hda_codec_setup_stream(codec
, spec
->cur_adc
, stream_tag
, 0, format
);
307 static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
308 struct hda_codec
*codec
,
309 struct snd_pcm_substream
*substream
)
311 struct conexant_spec
*spec
= codec
->spec
;
312 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
317 static const struct hda_pcm_stream cx5051_pcm_analog_capture
= {
321 .nid
= 0, /* fill later */
323 .prepare
= cx5051_capture_pcm_prepare
,
324 .cleanup
= cx5051_capture_pcm_cleanup
328 static int conexant_build_pcms(struct hda_codec
*codec
)
330 struct conexant_spec
*spec
= codec
->spec
;
331 struct hda_pcm
*info
= spec
->pcm_rec
;
334 codec
->pcm_info
= info
;
336 info
->name
= "CONEXANT Analog";
337 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = conexant_pcm_analog_playback
;
338 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
=
339 spec
->multiout
.max_channels
;
340 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
341 spec
->multiout
.dac_nids
[0];
342 if (spec
->capture_stream
)
343 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *spec
->capture_stream
;
345 if (codec
->vendor_id
== 0x14f15051)
346 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
347 cx5051_pcm_analog_capture
;
349 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
350 conexant_pcm_analog_capture
;
351 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
=
355 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
357 if (spec
->multiout
.dig_out_nid
) {
360 info
->name
= "Conexant Digital";
361 info
->pcm_type
= HDA_PCM_TYPE_SPDIF
;
362 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] =
363 conexant_pcm_digital_playback
;
364 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
365 spec
->multiout
.dig_out_nid
;
366 if (spec
->dig_in_nid
) {
367 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
368 conexant_pcm_digital_capture
;
369 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
=
372 if (spec
->slave_dig_outs
[0])
373 codec
->slave_dig_outs
= spec
->slave_dig_outs
;
379 static int conexant_mux_enum_info(struct snd_kcontrol
*kcontrol
,
380 struct snd_ctl_elem_info
*uinfo
)
382 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
383 struct conexant_spec
*spec
= codec
->spec
;
385 return snd_hda_input_mux_info(spec
->input_mux
, uinfo
);
388 static int conexant_mux_enum_get(struct snd_kcontrol
*kcontrol
,
389 struct snd_ctl_elem_value
*ucontrol
)
391 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
392 struct conexant_spec
*spec
= codec
->spec
;
393 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
395 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
399 static int conexant_mux_enum_put(struct snd_kcontrol
*kcontrol
,
400 struct snd_ctl_elem_value
*ucontrol
)
402 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
403 struct conexant_spec
*spec
= codec
->spec
;
404 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
406 return snd_hda_input_mux_put(codec
, spec
->input_mux
, ucontrol
,
407 spec
->capsrc_nids
[adc_idx
],
408 &spec
->cur_mux
[adc_idx
]);
411 static int conexant_init_jacks(struct hda_codec
*codec
)
413 #ifdef CONFIG_SND_HDA_INPUT_JACK
414 struct conexant_spec
*spec
= codec
->spec
;
417 for (i
= 0; i
< spec
->num_init_verbs
; i
++) {
418 const struct hda_verb
*hv
;
420 hv
= spec
->init_verbs
[i
];
423 switch (hv
->param
^ AC_USRSP_EN
) {
424 case CONEXANT_HP_EVENT
:
425 err
= snd_hda_input_jack_add(codec
, hv
->nid
,
426 SND_JACK_HEADPHONE
, NULL
);
427 snd_hda_input_jack_report(codec
, hv
->nid
);
429 case CXT5051_PORTC_EVENT
:
430 case CONEXANT_MIC_EVENT
:
431 err
= snd_hda_input_jack_add(codec
, hv
->nid
,
432 SND_JACK_MICROPHONE
, NULL
);
433 snd_hda_input_jack_report(codec
, hv
->nid
);
441 #endif /* CONFIG_SND_HDA_INPUT_JACK */
445 static int conexant_init(struct hda_codec
*codec
)
447 struct conexant_spec
*spec
= codec
->spec
;
450 for (i
= 0; i
< spec
->num_init_verbs
; i
++)
451 snd_hda_sequence_write(codec
, spec
->init_verbs
[i
]);
455 static void conexant_free(struct hda_codec
*codec
)
457 snd_hda_input_jack_free(codec
);
458 snd_hda_detach_beep_device(codec
);
462 static const struct snd_kcontrol_new cxt_capture_mixers
[] = {
464 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
465 .name
= "Capture Source",
466 .info
= conexant_mux_enum_info
,
467 .get
= conexant_mux_enum_get
,
468 .put
= conexant_mux_enum_put
473 #ifdef CONFIG_SND_HDA_INPUT_BEEP
474 /* additional beep mixers; the actual parameters are overwritten at build */
475 static const struct snd_kcontrol_new cxt_beep_mixer
[] = {
476 HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT
),
477 HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT
),
482 static const char * const slave_vols
[] = {
483 "Headphone Playback Volume",
484 "Speaker Playback Volume",
485 "Front Playback Volume",
486 "Surround Playback Volume",
487 "CLFE Playback Volume",
491 static const char * const slave_sws
[] = {
492 "Headphone Playback Switch",
493 "Speaker Playback Switch",
494 "Front Playback Switch",
495 "Surround Playback Switch",
496 "CLFE Playback Switch",
500 static int conexant_build_controls(struct hda_codec
*codec
)
502 struct conexant_spec
*spec
= codec
->spec
;
506 for (i
= 0; i
< spec
->num_mixers
; i
++) {
507 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
511 if (spec
->multiout
.dig_out_nid
) {
512 err
= snd_hda_create_spdif_out_ctls(codec
,
513 spec
->multiout
.dig_out_nid
);
516 err
= snd_hda_create_spdif_share_sw(codec
,
520 spec
->multiout
.share_spdif
= 1;
522 if (spec
->dig_in_nid
) {
523 err
= snd_hda_create_spdif_in_ctls(codec
,spec
->dig_in_nid
);
528 /* if we have no master control, let's create it */
529 if (spec
->vmaster_nid
&&
530 !snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
531 unsigned int vmaster_tlv
[4];
532 snd_hda_set_vmaster_tlv(codec
, spec
->vmaster_nid
,
533 HDA_OUTPUT
, vmaster_tlv
);
534 err
= snd_hda_add_vmaster(codec
, "Master Playback Volume",
535 vmaster_tlv
, slave_vols
);
539 if (spec
->vmaster_nid
&&
540 !snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
541 err
= snd_hda_add_vmaster(codec
, "Master Playback Switch",
547 if (spec
->input_mux
) {
548 err
= snd_hda_add_new_ctls(codec
, cxt_capture_mixers
);
553 #ifdef CONFIG_SND_HDA_INPUT_BEEP
554 /* create beep controls if needed */
555 if (spec
->beep_amp
) {
556 const struct snd_kcontrol_new
*knew
;
557 for (knew
= cxt_beep_mixer
; knew
->name
; knew
++) {
558 struct snd_kcontrol
*kctl
;
559 kctl
= snd_ctl_new1(knew
, codec
);
562 kctl
->private_value
= spec
->beep_amp
;
563 err
= snd_hda_ctl_add(codec
, 0, kctl
);
573 #ifdef CONFIG_SND_HDA_POWER_SAVE
574 static int conexant_suspend(struct hda_codec
*codec
, pm_message_t state
)
576 snd_hda_shutup_pins(codec
);
581 static const struct hda_codec_ops conexant_patch_ops
= {
582 .build_controls
= conexant_build_controls
,
583 .build_pcms
= conexant_build_pcms
,
584 .init
= conexant_init
,
585 .free
= conexant_free
,
586 #ifdef CONFIG_SND_HDA_POWER_SAVE
587 .suspend
= conexant_suspend
,
589 .reboot_notify
= snd_hda_shutup_pins
,
592 #ifdef CONFIG_SND_HDA_INPUT_BEEP
593 #define set_beep_amp(spec, nid, idx, dir) \
594 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir))
596 #define set_beep_amp(spec, nid, idx, dir) /* NOP */
599 static int patch_conexant_auto(struct hda_codec
*codec
);
602 * the private value = nid | (invert << 8)
605 #define cxt_eapd_info snd_ctl_boolean_mono_info
607 static int cxt_eapd_get(struct snd_kcontrol
*kcontrol
,
608 struct snd_ctl_elem_value
*ucontrol
)
610 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
611 struct conexant_spec
*spec
= codec
->spec
;
612 int invert
= (kcontrol
->private_value
>> 8) & 1;
614 ucontrol
->value
.integer
.value
[0] = !spec
->cur_eapd
;
616 ucontrol
->value
.integer
.value
[0] = spec
->cur_eapd
;
621 static int cxt_eapd_put(struct snd_kcontrol
*kcontrol
,
622 struct snd_ctl_elem_value
*ucontrol
)
624 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
625 struct conexant_spec
*spec
= codec
->spec
;
626 int invert
= (kcontrol
->private_value
>> 8) & 1;
627 hda_nid_t nid
= kcontrol
->private_value
& 0xff;
630 eapd
= !!ucontrol
->value
.integer
.value
[0];
633 if (eapd
== spec
->cur_eapd
)
636 spec
->cur_eapd
= eapd
;
637 snd_hda_codec_write_cache(codec
, nid
,
638 0, AC_VERB_SET_EAPD_BTLENABLE
,
643 /* controls for test mode */
644 #ifdef CONFIG_SND_DEBUG
646 #define CXT_EAPD_SWITCH(xname, nid, mask) \
647 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
648 .info = cxt_eapd_info, \
649 .get = cxt_eapd_get, \
650 .put = cxt_eapd_put, \
651 .private_value = nid | (mask<<16) }
655 static int conexant_ch_mode_info(struct snd_kcontrol
*kcontrol
,
656 struct snd_ctl_elem_info
*uinfo
)
658 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
659 struct conexant_spec
*spec
= codec
->spec
;
660 return snd_hda_ch_mode_info(codec
, uinfo
, spec
->channel_mode
,
661 spec
->num_channel_mode
);
664 static int conexant_ch_mode_get(struct snd_kcontrol
*kcontrol
,
665 struct snd_ctl_elem_value
*ucontrol
)
667 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
668 struct conexant_spec
*spec
= codec
->spec
;
669 return snd_hda_ch_mode_get(codec
, ucontrol
, spec
->channel_mode
,
670 spec
->num_channel_mode
,
671 spec
->multiout
.max_channels
);
674 static int conexant_ch_mode_put(struct snd_kcontrol
*kcontrol
,
675 struct snd_ctl_elem_value
*ucontrol
)
677 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
678 struct conexant_spec
*spec
= codec
->spec
;
679 int err
= snd_hda_ch_mode_put(codec
, ucontrol
, spec
->channel_mode
,
680 spec
->num_channel_mode
,
681 &spec
->multiout
.max_channels
);
682 if (err
>= 0 && spec
->need_dac_fix
)
683 spec
->multiout
.num_dacs
= spec
->multiout
.max_channels
/ 2;
687 #define CXT_PIN_MODE(xname, nid, dir) \
688 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
689 .info = conexant_ch_mode_info, \
690 .get = conexant_ch_mode_get, \
691 .put = conexant_ch_mode_put, \
692 .private_value = nid | (dir<<16) }
694 #endif /* CONFIG_SND_DEBUG */
696 /* Conexant 5045 specific */
698 static const hda_nid_t cxt5045_dac_nids
[1] = { 0x19 };
699 static const hda_nid_t cxt5045_adc_nids
[1] = { 0x1a };
700 static const hda_nid_t cxt5045_capsrc_nids
[1] = { 0x1a };
701 #define CXT5045_SPDIF_OUT 0x18
703 static const struct hda_channel_mode cxt5045_modes
[1] = {
707 static const struct hda_input_mux cxt5045_capture_source
= {
715 static const struct hda_input_mux cxt5045_capture_source_benq
= {
726 static const struct hda_input_mux cxt5045_capture_source_hp530
= {
734 /* turn on/off EAPD (+ mute HP) as a master switch */
735 static int cxt5045_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
736 struct snd_ctl_elem_value
*ucontrol
)
738 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
739 struct conexant_spec
*spec
= codec
->spec
;
742 if (!cxt_eapd_put(kcontrol
, ucontrol
))
745 /* toggle internal speakers mute depending of presence of
748 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
749 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
752 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
753 snd_hda_codec_amp_stereo(codec
, 0x11, HDA_OUTPUT
, 0,
758 /* bind volumes of both NID 0x10 and 0x11 */
759 static const struct hda_bind_ctls cxt5045_hp_bind_master_vol
= {
760 .ops
= &snd_hda_bind_vol
,
762 HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT
),
763 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT
),
768 /* toggle input of built-in and mic jack appropriately */
769 static void cxt5045_hp_automic(struct hda_codec
*codec
)
771 static const struct hda_verb mic_jack_on
[] = {
772 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
773 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
776 static const struct hda_verb mic_jack_off
[] = {
777 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
778 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
781 unsigned int present
;
783 present
= snd_hda_jack_detect(codec
, 0x12);
785 snd_hda_sequence_write(codec
, mic_jack_on
);
787 snd_hda_sequence_write(codec
, mic_jack_off
);
791 /* mute internal speaker if HP is plugged */
792 static void cxt5045_hp_automute(struct hda_codec
*codec
)
794 struct conexant_spec
*spec
= codec
->spec
;
797 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x11);
799 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
800 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
804 /* unsolicited event for HP jack sensing */
805 static void cxt5045_hp_unsol_event(struct hda_codec
*codec
,
810 case CONEXANT_HP_EVENT
:
811 cxt5045_hp_automute(codec
);
813 case CONEXANT_MIC_EVENT
:
814 cxt5045_hp_automic(codec
);
820 static const struct snd_kcontrol_new cxt5045_mixers
[] = {
821 HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x1a, 0x01, HDA_INPUT
),
822 HDA_CODEC_MUTE("Internal Mic Capture Switch", 0x1a, 0x01, HDA_INPUT
),
823 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1a, 0x02, HDA_INPUT
),
824 HDA_CODEC_MUTE("Mic Capture Switch", 0x1a, 0x02, HDA_INPUT
),
825 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT
),
826 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT
),
827 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
828 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x1, HDA_INPUT
),
829 HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
830 HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
831 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol
),
833 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
834 .name
= "Master Playback Switch",
835 .info
= cxt_eapd_info
,
837 .put
= cxt5045_hp_master_sw_put
,
838 .private_value
= 0x10,
844 static const struct snd_kcontrol_new cxt5045_benq_mixers
[] = {
845 HDA_CODEC_VOLUME("CD Capture Volume", 0x1a, 0x04, HDA_INPUT
),
846 HDA_CODEC_MUTE("CD Capture Switch", 0x1a, 0x04, HDA_INPUT
),
847 HDA_CODEC_VOLUME("CD Playback Volume", 0x17, 0x4, HDA_INPUT
),
848 HDA_CODEC_MUTE("CD Playback Switch", 0x17, 0x4, HDA_INPUT
),
850 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1a, 0x03, HDA_INPUT
),
851 HDA_CODEC_MUTE("Line In Capture Switch", 0x1a, 0x03, HDA_INPUT
),
852 HDA_CODEC_VOLUME("Line In Playback Volume", 0x17, 0x3, HDA_INPUT
),
853 HDA_CODEC_MUTE("Line In Playback Switch", 0x17, 0x3, HDA_INPUT
),
855 HDA_CODEC_VOLUME("Mixer Capture Volume", 0x1a, 0x0, HDA_INPUT
),
856 HDA_CODEC_MUTE("Mixer Capture Switch", 0x1a, 0x0, HDA_INPUT
),
861 static const struct snd_kcontrol_new cxt5045_mixers_hp530
[] = {
862 HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x1a, 0x02, HDA_INPUT
),
863 HDA_CODEC_MUTE("Internal Mic Capture Switch", 0x1a, 0x02, HDA_INPUT
),
864 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1a, 0x01, HDA_INPUT
),
865 HDA_CODEC_MUTE("Mic Capture Switch", 0x1a, 0x01, HDA_INPUT
),
866 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT
),
867 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT
),
868 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
869 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
870 HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
871 HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x1, HDA_INPUT
),
872 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol
),
874 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
875 .name
= "Master Playback Switch",
876 .info
= cxt_eapd_info
,
878 .put
= cxt5045_hp_master_sw_put
,
879 .private_value
= 0x10,
885 static const struct hda_verb cxt5045_init_verbs
[] = {
887 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
888 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
890 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
891 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
892 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
893 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
894 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
895 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
896 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
897 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
898 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
899 /* Record selector: Internal mic */
900 {0x1a, AC_VERB_SET_CONNECT_SEL
,0x1},
901 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
902 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
903 /* SPDIF route: PCM */
904 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
905 { 0x13, AC_VERB_SET_CONNECT_SEL
, 0x0 },
907 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2 }, /* default on */
911 static const struct hda_verb cxt5045_benq_init_verbs
[] = {
912 /* Internal Mic, Mic */
913 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
914 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
915 /* Line In,HP, Amp */
916 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
917 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
918 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
919 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
920 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
921 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
922 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
923 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
924 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
925 /* Record selector: Internal mic */
926 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x1},
927 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
928 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
929 /* SPDIF route: PCM */
930 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
931 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0},
933 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
937 static const struct hda_verb cxt5045_hp_sense_init_verbs
[] = {
938 /* pin sensing on HP jack */
939 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
943 static const struct hda_verb cxt5045_mic_sense_init_verbs
[] = {
944 /* pin sensing on HP jack */
945 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
949 #ifdef CONFIG_SND_DEBUG
950 /* Test configuration for debugging, modelled after the ALC260 test
953 static const struct hda_input_mux cxt5045_test_capture_source
= {
958 { "LINE1 pin", 0x2 },
959 { "HP-OUT pin", 0x3 },
964 static const struct snd_kcontrol_new cxt5045_test_mixer
[] = {
966 /* Output controls */
967 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT
),
968 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT
),
969 HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
970 HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
971 HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
972 HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
974 /* Modes for retasking pin widgets */
975 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT
),
976 CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT
),
978 /* EAPD Switch Control */
979 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
981 /* Loopback mixer controls */
983 HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT
),
984 HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT
),
985 HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT
),
986 HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT
),
987 HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT
),
988 HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT
),
989 HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT
),
990 HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT
),
991 HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT
),
992 HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT
),
994 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
995 .name
= "Input Source",
996 .info
= conexant_mux_enum_info
,
997 .get
= conexant_mux_enum_get
,
998 .put
= conexant_mux_enum_put
,
1000 /* Audio input controls */
1001 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT
),
1002 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT
),
1003 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT
),
1004 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT
),
1005 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT
),
1006 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT
),
1007 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT
),
1008 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT
),
1009 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT
),
1010 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT
),
1014 static const struct hda_verb cxt5045_test_init_verbs
[] = {
1015 /* Set connections */
1016 { 0x10, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1017 { 0x11, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1018 { 0x12, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1019 /* Enable retasking pins as output, initially without power amp */
1020 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1021 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1023 /* Disable digital (SPDIF) pins initially, but users can enable
1024 * them via a mixer switch. In the case of SPDIF-out, this initverb
1025 * payload also sets the generation to 0, output to be in "consumer"
1026 * PCM format, copyright asserted, no pre-emphasis and no validity
1029 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1030 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
1032 /* Start with output sum widgets muted and their output gains at min */
1033 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1034 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1036 /* Unmute retasking pin widget output buffers since the default
1037 * state appears to be output. As the pin mode is changed by the
1038 * user the pin mode control will take care of enabling the pin's
1039 * input/output buffers as needed.
1041 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1042 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1044 /* Mute capture amp left and right */
1045 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1047 /* Set ADC connection select to match default mixer setting (mic1
1050 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1051 {0x17, AC_VERB_SET_CONNECT_SEL
, 0x00},
1053 /* Mute all inputs to mixer widget (even unconnected ones) */
1054 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* Mixer pin */
1055 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* Mic1 pin */
1056 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* Line pin */
1057 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* HP pin */
1058 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
1065 /* initialize jack-sensing, too */
1066 static int cxt5045_init(struct hda_codec
*codec
)
1068 conexant_init(codec
);
1069 cxt5045_hp_automute(codec
);
1075 CXT5045_LAPTOP_HPSENSE
,
1076 CXT5045_LAPTOP_MICSENSE
,
1077 CXT5045_LAPTOP_HPMICSENSE
,
1079 CXT5045_LAPTOP_HP530
,
1080 #ifdef CONFIG_SND_DEBUG
1087 static const char * const cxt5045_models
[CXT5045_MODELS
] = {
1088 [CXT5045_LAPTOP_HPSENSE
] = "laptop-hpsense",
1089 [CXT5045_LAPTOP_MICSENSE
] = "laptop-micsense",
1090 [CXT5045_LAPTOP_HPMICSENSE
] = "laptop-hpmicsense",
1091 [CXT5045_BENQ
] = "benq",
1092 [CXT5045_LAPTOP_HP530
] = "laptop-hp530",
1093 #ifdef CONFIG_SND_DEBUG
1094 [CXT5045_TEST
] = "test",
1096 [CXT5045_AUTO
] = "auto",
1099 static const struct snd_pci_quirk cxt5045_cfg_tbl
[] = {
1100 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530
),
1101 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1102 CXT5045_LAPTOP_HPSENSE
),
1103 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE
),
1104 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ
),
1105 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE
),
1106 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE
),
1107 SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505",
1108 CXT5045_LAPTOP_HPMICSENSE
),
1109 SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1110 SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1111 SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1112 SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell",
1113 CXT5045_LAPTOP_HPMICSENSE
),
1114 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE
),
1118 static int patch_cxt5045(struct hda_codec
*codec
)
1120 struct conexant_spec
*spec
;
1123 board_config
= snd_hda_check_board_config(codec
, CXT5045_MODELS
,
1126 #if 0 /* use the old method just for safety */
1127 if (board_config
< 0)
1128 board_config
= CXT5045_AUTO
;
1130 if (board_config
== CXT5045_AUTO
)
1131 return patch_conexant_auto(codec
);
1133 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1137 codec
->pin_amp_workaround
= 1;
1139 spec
->multiout
.max_channels
= 2;
1140 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5045_dac_nids
);
1141 spec
->multiout
.dac_nids
= cxt5045_dac_nids
;
1142 spec
->multiout
.dig_out_nid
= CXT5045_SPDIF_OUT
;
1143 spec
->num_adc_nids
= 1;
1144 spec
->adc_nids
= cxt5045_adc_nids
;
1145 spec
->capsrc_nids
= cxt5045_capsrc_nids
;
1146 spec
->input_mux
= &cxt5045_capture_source
;
1147 spec
->num_mixers
= 1;
1148 spec
->mixers
[0] = cxt5045_mixers
;
1149 spec
->num_init_verbs
= 1;
1150 spec
->init_verbs
[0] = cxt5045_init_verbs
;
1151 spec
->spdif_route
= 0;
1152 spec
->num_channel_mode
= ARRAY_SIZE(cxt5045_modes
);
1153 spec
->channel_mode
= cxt5045_modes
;
1155 set_beep_amp(spec
, 0x16, 0, 1);
1157 codec
->patch_ops
= conexant_patch_ops
;
1159 switch (board_config
) {
1160 case CXT5045_LAPTOP_HPSENSE
:
1161 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1162 spec
->input_mux
= &cxt5045_capture_source
;
1163 spec
->num_init_verbs
= 2;
1164 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1165 spec
->mixers
[0] = cxt5045_mixers
;
1166 codec
->patch_ops
.init
= cxt5045_init
;
1168 case CXT5045_LAPTOP_MICSENSE
:
1169 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1170 spec
->input_mux
= &cxt5045_capture_source
;
1171 spec
->num_init_verbs
= 2;
1172 spec
->init_verbs
[1] = cxt5045_mic_sense_init_verbs
;
1173 spec
->mixers
[0] = cxt5045_mixers
;
1174 codec
->patch_ops
.init
= cxt5045_init
;
1177 case CXT5045_LAPTOP_HPMICSENSE
:
1178 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1179 spec
->input_mux
= &cxt5045_capture_source
;
1180 spec
->num_init_verbs
= 3;
1181 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1182 spec
->init_verbs
[2] = cxt5045_mic_sense_init_verbs
;
1183 spec
->mixers
[0] = cxt5045_mixers
;
1184 codec
->patch_ops
.init
= cxt5045_init
;
1187 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1188 spec
->input_mux
= &cxt5045_capture_source_benq
;
1189 spec
->num_init_verbs
= 1;
1190 spec
->init_verbs
[0] = cxt5045_benq_init_verbs
;
1191 spec
->mixers
[0] = cxt5045_mixers
;
1192 spec
->mixers
[1] = cxt5045_benq_mixers
;
1193 spec
->num_mixers
= 2;
1194 codec
->patch_ops
.init
= cxt5045_init
;
1196 case CXT5045_LAPTOP_HP530
:
1197 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1198 spec
->input_mux
= &cxt5045_capture_source_hp530
;
1199 spec
->num_init_verbs
= 2;
1200 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1201 spec
->mixers
[0] = cxt5045_mixers_hp530
;
1202 codec
->patch_ops
.init
= cxt5045_init
;
1204 #ifdef CONFIG_SND_DEBUG
1206 spec
->input_mux
= &cxt5045_test_capture_source
;
1207 spec
->mixers
[0] = cxt5045_test_mixer
;
1208 spec
->init_verbs
[0] = cxt5045_test_init_verbs
;
1214 switch (codec
->subsystem_id
>> 16) {
1219 /* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have
1220 * really bad sound over 0dB on NID 0x17. Fix max PCM level to
1221 * 0 dB (originally it has 0x2b steps with 0dB offset 0x14)
1223 snd_hda_override_amp_caps(codec
, 0x17, HDA_INPUT
,
1224 (0x14 << AC_AMPCAP_OFFSET_SHIFT
) |
1225 (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
1226 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
1227 (1 << AC_AMPCAP_MUTE_SHIFT
));
1232 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
1238 /* Conexant 5047 specific */
1239 #define CXT5047_SPDIF_OUT 0x11
1241 static const hda_nid_t cxt5047_dac_nids
[1] = { 0x10 }; /* 0x1c */
1242 static const hda_nid_t cxt5047_adc_nids
[1] = { 0x12 };
1243 static const hda_nid_t cxt5047_capsrc_nids
[1] = { 0x1a };
1245 static const struct hda_channel_mode cxt5047_modes
[1] = {
1249 static const struct hda_input_mux cxt5047_toshiba_capture_source
= {
1257 /* turn on/off EAPD (+ mute HP) as a master switch */
1258 static int cxt5047_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1259 struct snd_ctl_elem_value
*ucontrol
)
1261 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1262 struct conexant_spec
*spec
= codec
->spec
;
1265 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1268 /* toggle internal speakers mute depending of presence of
1269 * the headphone jack
1271 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
1272 /* NOTE: Conexat codec needs the index for *OUTPUT* amp of
1273 * pin widgets unlike other codecs. In this case, we need to
1274 * set index 0x01 for the volume from the mixer amp 0x19.
1276 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0x01,
1277 HDA_AMP_MUTE
, bits
);
1278 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
1279 snd_hda_codec_amp_stereo(codec
, 0x13, HDA_OUTPUT
, 0,
1280 HDA_AMP_MUTE
, bits
);
1284 /* mute internal speaker if HP is plugged */
1285 static void cxt5047_hp_automute(struct hda_codec
*codec
)
1287 struct conexant_spec
*spec
= codec
->spec
;
1290 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x13);
1292 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
1293 /* See the note in cxt5047_hp_master_sw_put */
1294 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0x01,
1295 HDA_AMP_MUTE
, bits
);
1298 /* toggle input of built-in and mic jack appropriately */
1299 static void cxt5047_hp_automic(struct hda_codec
*codec
)
1301 static const struct hda_verb mic_jack_on
[] = {
1302 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1303 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1306 static const struct hda_verb mic_jack_off
[] = {
1307 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1308 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1311 unsigned int present
;
1313 present
= snd_hda_jack_detect(codec
, 0x15);
1315 snd_hda_sequence_write(codec
, mic_jack_on
);
1317 snd_hda_sequence_write(codec
, mic_jack_off
);
1320 /* unsolicited event for HP jack sensing */
1321 static void cxt5047_hp_unsol_event(struct hda_codec
*codec
,
1324 switch (res
>> 26) {
1325 case CONEXANT_HP_EVENT
:
1326 cxt5047_hp_automute(codec
);
1328 case CONEXANT_MIC_EVENT
:
1329 cxt5047_hp_automic(codec
);
1334 static const struct snd_kcontrol_new cxt5047_base_mixers
[] = {
1335 HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT
),
1336 HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT
),
1337 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT
),
1338 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT
),
1339 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT
),
1340 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT
),
1341 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT
),
1343 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1344 .name
= "Master Playback Switch",
1345 .info
= cxt_eapd_info
,
1346 .get
= cxt_eapd_get
,
1347 .put
= cxt5047_hp_master_sw_put
,
1348 .private_value
= 0x13,
1354 static const struct snd_kcontrol_new cxt5047_hp_spk_mixers
[] = {
1355 /* See the note in cxt5047_hp_master_sw_put */
1356 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT
),
1357 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1361 static const struct snd_kcontrol_new cxt5047_hp_only_mixers
[] = {
1362 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1366 static const struct hda_verb cxt5047_init_verbs
[] = {
1367 /* Line in, Mic, Built-in Mic */
1368 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1369 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1370 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1372 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1373 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* mixer(0x19) */
1374 {0x1d, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* mixer(0x19) */
1375 /* Record selector: Mic */
1376 {0x12, AC_VERB_SET_CONNECT_SEL
,0x03},
1377 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
,
1378 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
1379 {0x1A, AC_VERB_SET_CONNECT_SEL
,0x02},
1380 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1381 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x00},
1382 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1383 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x03},
1384 /* SPDIF route: PCM */
1385 { 0x18, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1386 /* Enable unsolicited events */
1387 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
1388 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
1392 /* configuration for Toshiba Laptops */
1393 static const struct hda_verb cxt5047_toshiba_init_verbs
[] = {
1394 {0x13, AC_VERB_SET_EAPD_BTLENABLE
, 0x0}, /* default off */
1398 /* Test configuration for debugging, modelled after the ALC260 test
1401 #ifdef CONFIG_SND_DEBUG
1402 static const struct hda_input_mux cxt5047_test_capture_source
= {
1405 { "LINE1 pin", 0x0 },
1406 { "MIC1 pin", 0x1 },
1407 { "MIC2 pin", 0x2 },
1412 static const struct snd_kcontrol_new cxt5047_test_mixer
[] = {
1414 /* Output only controls */
1415 HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT
),
1416 HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT
),
1417 HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT
),
1418 HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT
),
1419 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
1420 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT
),
1421 HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
1422 HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
1423 HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT
),
1424 HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT
),
1425 HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT
),
1426 HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT
),
1428 /* Modes for retasking pin widgets */
1429 CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT
),
1430 CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT
),
1432 /* EAPD Switch Control */
1433 CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0),
1435 /* Loopback mixer controls */
1436 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT
),
1437 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT
),
1438 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT
),
1439 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT
),
1440 HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT
),
1441 HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT
),
1442 HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT
),
1443 HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT
),
1445 HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT
),
1446 HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT
),
1447 HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT
),
1448 HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT
),
1449 HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT
),
1450 HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT
),
1451 HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT
),
1452 HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT
),
1454 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1455 .name
= "Input Source",
1456 .info
= conexant_mux_enum_info
,
1457 .get
= conexant_mux_enum_get
,
1458 .put
= conexant_mux_enum_put
,
1460 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT
),
1465 static const struct hda_verb cxt5047_test_init_verbs
[] = {
1466 /* Enable retasking pins as output, initially without power amp */
1467 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1468 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1469 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1471 /* Disable digital (SPDIF) pins initially, but users can enable
1472 * them via a mixer switch. In the case of SPDIF-out, this initverb
1473 * payload also sets the generation to 0, output to be in "consumer"
1474 * PCM format, copyright asserted, no pre-emphasis and no validity
1477 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
1479 /* Ensure mic1, mic2, line1 pin widgets take input from the
1480 * OUT1 sum bus when acting as an output.
1482 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0},
1483 {0x1b, AC_VERB_SET_CONNECT_SEL
, 0},
1485 /* Start with output sum widgets muted and their output gains at min */
1486 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1487 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1489 /* Unmute retasking pin widget output buffers since the default
1490 * state appears to be output. As the pin mode is changed by the
1491 * user the pin mode control will take care of enabling the pin's
1492 * input/output buffers as needed.
1494 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1495 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1496 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1498 /* Mute capture amp left and right */
1499 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1501 /* Set ADC connection select to match default mixer setting (mic1
1504 {0x12, AC_VERB_SET_CONNECT_SEL
, 0x00},
1506 /* Mute all inputs to mixer widget (even unconnected ones) */
1507 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* mic1 pin */
1508 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* mic2 pin */
1509 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* line1 pin */
1510 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* line2 pin */
1511 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
1512 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)}, /* Beep-gen pin */
1513 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)}, /* Line-out pin */
1514 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)}, /* HP-pin pin */
1521 /* initialize jack-sensing, too */
1522 static int cxt5047_hp_init(struct hda_codec
*codec
)
1524 conexant_init(codec
);
1525 cxt5047_hp_automute(codec
);
1531 CXT5047_LAPTOP
, /* Laptops w/o EAPD support */
1532 CXT5047_LAPTOP_HP
, /* Some HP laptops */
1533 CXT5047_LAPTOP_EAPD
, /* Laptops with EAPD support */
1534 #ifdef CONFIG_SND_DEBUG
1541 static const char * const cxt5047_models
[CXT5047_MODELS
] = {
1542 [CXT5047_LAPTOP
] = "laptop",
1543 [CXT5047_LAPTOP_HP
] = "laptop-hp",
1544 [CXT5047_LAPTOP_EAPD
] = "laptop-eapd",
1545 #ifdef CONFIG_SND_DEBUG
1546 [CXT5047_TEST
] = "test",
1548 [CXT5047_AUTO
] = "auto",
1551 static const struct snd_pci_quirk cxt5047_cfg_tbl
[] = {
1552 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP
),
1553 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1555 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD
),
1559 static int patch_cxt5047(struct hda_codec
*codec
)
1561 struct conexant_spec
*spec
;
1564 board_config
= snd_hda_check_board_config(codec
, CXT5047_MODELS
,
1567 #if 0 /* not enabled as default, as BIOS often broken for this codec */
1568 if (board_config
< 0)
1569 board_config
= CXT5047_AUTO
;
1571 if (board_config
== CXT5047_AUTO
)
1572 return patch_conexant_auto(codec
);
1574 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1578 codec
->pin_amp_workaround
= 1;
1580 spec
->multiout
.max_channels
= 2;
1581 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5047_dac_nids
);
1582 spec
->multiout
.dac_nids
= cxt5047_dac_nids
;
1583 spec
->multiout
.dig_out_nid
= CXT5047_SPDIF_OUT
;
1584 spec
->num_adc_nids
= 1;
1585 spec
->adc_nids
= cxt5047_adc_nids
;
1586 spec
->capsrc_nids
= cxt5047_capsrc_nids
;
1587 spec
->num_mixers
= 1;
1588 spec
->mixers
[0] = cxt5047_base_mixers
;
1589 spec
->num_init_verbs
= 1;
1590 spec
->init_verbs
[0] = cxt5047_init_verbs
;
1591 spec
->spdif_route
= 0;
1592 spec
->num_channel_mode
= ARRAY_SIZE(cxt5047_modes
),
1593 spec
->channel_mode
= cxt5047_modes
,
1595 codec
->patch_ops
= conexant_patch_ops
;
1597 switch (board_config
) {
1598 case CXT5047_LAPTOP
:
1599 spec
->num_mixers
= 2;
1600 spec
->mixers
[1] = cxt5047_hp_spk_mixers
;
1601 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1603 case CXT5047_LAPTOP_HP
:
1604 spec
->num_mixers
= 2;
1605 spec
->mixers
[1] = cxt5047_hp_only_mixers
;
1606 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1607 codec
->patch_ops
.init
= cxt5047_hp_init
;
1609 case CXT5047_LAPTOP_EAPD
:
1610 spec
->input_mux
= &cxt5047_toshiba_capture_source
;
1611 spec
->num_mixers
= 2;
1612 spec
->mixers
[1] = cxt5047_hp_spk_mixers
;
1613 spec
->num_init_verbs
= 2;
1614 spec
->init_verbs
[1] = cxt5047_toshiba_init_verbs
;
1615 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1617 #ifdef CONFIG_SND_DEBUG
1619 spec
->input_mux
= &cxt5047_test_capture_source
;
1620 spec
->mixers
[0] = cxt5047_test_mixer
;
1621 spec
->init_verbs
[0] = cxt5047_test_init_verbs
;
1622 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1625 spec
->vmaster_nid
= 0x13;
1627 switch (codec
->subsystem_id
>> 16) {
1629 /* HP laptops have really bad sound over 0 dB on NID 0x10.
1630 * Fix max PCM level to 0 dB (originally it has 0x1e steps
1631 * with 0 dB offset 0x17)
1633 snd_hda_override_amp_caps(codec
, 0x10, HDA_INPUT
,
1634 (0x17 << AC_AMPCAP_OFFSET_SHIFT
) |
1635 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
1636 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
1637 (1 << AC_AMPCAP_MUTE_SHIFT
));
1644 /* Conexant 5051 specific */
1645 static const hda_nid_t cxt5051_dac_nids
[1] = { 0x10 };
1646 static const hda_nid_t cxt5051_adc_nids
[2] = { 0x14, 0x15 };
1648 static const struct hda_channel_mode cxt5051_modes
[1] = {
1652 static void cxt5051_update_speaker(struct hda_codec
*codec
)
1654 struct conexant_spec
*spec
= codec
->spec
;
1655 unsigned int pinctl
;
1657 pinctl
= (spec
->hp_present
&& spec
->cur_eapd
) ? PIN_HP
: 0;
1658 snd_hda_codec_write(codec
, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1661 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
1662 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1664 /* on ideapad there is an aditional speaker (subwoofer) to mute */
1666 snd_hda_codec_write(codec
, 0x1b, 0,
1667 AC_VERB_SET_PIN_WIDGET_CONTROL
,
1671 /* turn on/off EAPD (+ mute HP) as a master switch */
1672 static int cxt5051_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1673 struct snd_ctl_elem_value
*ucontrol
)
1675 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1677 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1679 cxt5051_update_speaker(codec
);
1683 /* toggle input of built-in and mic jack appropriately */
1684 static void cxt5051_portb_automic(struct hda_codec
*codec
)
1686 struct conexant_spec
*spec
= codec
->spec
;
1687 unsigned int present
;
1689 if (!(spec
->auto_mic
& AUTO_MIC_PORTB
))
1691 present
= snd_hda_jack_detect(codec
, 0x17);
1692 snd_hda_codec_write(codec
, 0x14, 0,
1693 AC_VERB_SET_CONNECT_SEL
,
1694 present
? 0x01 : 0x00);
1697 /* switch the current ADC according to the jack state */
1698 static void cxt5051_portc_automic(struct hda_codec
*codec
)
1700 struct conexant_spec
*spec
= codec
->spec
;
1701 unsigned int present
;
1704 if (!(spec
->auto_mic
& AUTO_MIC_PORTC
))
1706 present
= snd_hda_jack_detect(codec
, 0x18);
1708 spec
->cur_adc_idx
= 1;
1710 spec
->cur_adc_idx
= 0;
1711 new_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
1712 if (spec
->cur_adc
&& spec
->cur_adc
!= new_adc
) {
1713 /* stream is running, let's swap the current ADC */
1714 __snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
, 1);
1715 spec
->cur_adc
= new_adc
;
1716 snd_hda_codec_setup_stream(codec
, new_adc
,
1717 spec
->cur_adc_stream_tag
, 0,
1718 spec
->cur_adc_format
);
1722 /* mute internal speaker if HP is plugged */
1723 static void cxt5051_hp_automute(struct hda_codec
*codec
)
1725 struct conexant_spec
*spec
= codec
->spec
;
1727 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x16);
1728 cxt5051_update_speaker(codec
);
1731 /* unsolicited event for HP jack sensing */
1732 static void cxt5051_hp_unsol_event(struct hda_codec
*codec
,
1735 int nid
= (res
& AC_UNSOL_RES_SUBTAG
) >> 20;
1736 switch (res
>> 26) {
1737 case CONEXANT_HP_EVENT
:
1738 cxt5051_hp_automute(codec
);
1740 case CXT5051_PORTB_EVENT
:
1741 cxt5051_portb_automic(codec
);
1743 case CXT5051_PORTC_EVENT
:
1744 cxt5051_portc_automic(codec
);
1747 snd_hda_input_jack_report(codec
, nid
);
1750 static const struct snd_kcontrol_new cxt5051_playback_mixers
[] = {
1751 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
1753 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1754 .name
= "Master Playback Switch",
1755 .info
= cxt_eapd_info
,
1756 .get
= cxt_eapd_get
,
1757 .put
= cxt5051_hp_master_sw_put
,
1758 .private_value
= 0x1a,
1763 static const struct snd_kcontrol_new cxt5051_capture_mixers
[] = {
1764 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1765 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1766 HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT
),
1767 HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT
),
1768 HDA_CODEC_VOLUME("Docking Mic Volume", 0x15, 0x00, HDA_INPUT
),
1769 HDA_CODEC_MUTE("Docking Mic Switch", 0x15, 0x00, HDA_INPUT
),
1773 static const struct snd_kcontrol_new cxt5051_hp_mixers
[] = {
1774 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1775 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1776 HDA_CODEC_VOLUME("Mic Volume", 0x15, 0x00, HDA_INPUT
),
1777 HDA_CODEC_MUTE("Mic Switch", 0x15, 0x00, HDA_INPUT
),
1781 static const struct snd_kcontrol_new cxt5051_hp_dv6736_mixers
[] = {
1782 HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x00, HDA_INPUT
),
1783 HDA_CODEC_MUTE("Capture Switch", 0x14, 0x00, HDA_INPUT
),
1787 static const struct snd_kcontrol_new cxt5051_f700_mixers
[] = {
1788 HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x01, HDA_INPUT
),
1789 HDA_CODEC_MUTE("Capture Switch", 0x14, 0x01, HDA_INPUT
),
1793 static const struct snd_kcontrol_new cxt5051_toshiba_mixers
[] = {
1794 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1795 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1796 HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT
),
1797 HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT
),
1801 static const struct hda_verb cxt5051_init_verbs
[] = {
1803 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1804 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1805 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1806 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1807 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1808 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1810 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1811 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1813 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1814 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1816 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1817 /* Record selector: Internal mic */
1818 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1819 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1820 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1821 /* SPDIF route: PCM */
1822 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1823 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1825 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1826 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1830 static const struct hda_verb cxt5051_hp_dv6736_init_verbs
[] = {
1832 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1833 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1834 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1835 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1837 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1838 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1840 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1841 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1843 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1844 /* Record selector: Internal mic */
1845 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1846 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x1},
1847 /* SPDIF route: PCM */
1848 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1850 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1851 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1855 static const struct hda_verb cxt5051_lenovo_x200_init_verbs
[] = {
1857 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1858 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1859 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1860 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1861 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1862 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1864 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1865 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1867 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1868 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1870 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1871 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00},
1873 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1874 /* Record selector: Internal mic */
1875 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1876 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1877 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1878 /* SPDIF route: PCM */
1879 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
}, /* needed for W500 Advanced Mini Dock 250410 */
1880 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1882 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1883 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1884 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1888 static const struct hda_verb cxt5051_f700_init_verbs
[] = {
1890 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1891 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1892 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1893 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1895 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1896 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1898 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1899 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1901 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1902 /* Record selector: Internal mic */
1903 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1904 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x1},
1905 /* SPDIF route: PCM */
1906 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1908 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1909 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1913 static void cxt5051_init_mic_port(struct hda_codec
*codec
, hda_nid_t nid
,
1916 snd_hda_codec_write(codec
, nid
, 0,
1917 AC_VERB_SET_UNSOLICITED_ENABLE
,
1918 AC_USRSP_EN
| event
);
1919 snd_hda_input_jack_add(codec
, nid
, SND_JACK_MICROPHONE
, NULL
);
1920 snd_hda_input_jack_report(codec
, nid
);
1923 static const struct hda_verb cxt5051_ideapad_init_verbs
[] = {
1925 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1926 {0x1b, AC_VERB_SET_CONNECT_SEL
, 0x00},
1930 /* initialize jack-sensing, too */
1931 static int cxt5051_init(struct hda_codec
*codec
)
1933 struct conexant_spec
*spec
= codec
->spec
;
1935 conexant_init(codec
);
1936 conexant_init_jacks(codec
);
1938 if (spec
->auto_mic
& AUTO_MIC_PORTB
)
1939 cxt5051_init_mic_port(codec
, 0x17, CXT5051_PORTB_EVENT
);
1940 if (spec
->auto_mic
& AUTO_MIC_PORTC
)
1941 cxt5051_init_mic_port(codec
, 0x18, CXT5051_PORTC_EVENT
);
1943 if (codec
->patch_ops
.unsol_event
) {
1944 cxt5051_hp_automute(codec
);
1945 cxt5051_portb_automic(codec
);
1946 cxt5051_portc_automic(codec
);
1953 CXT5051_LAPTOP
, /* Laptops w/ EAPD support */
1954 CXT5051_HP
, /* no docking */
1955 CXT5051_HP_DV6736
, /* HP without mic switch */
1956 CXT5051_LENOVO_X200
, /* Lenovo X200 laptop, also used for Advanced Mini Dock 250410 */
1957 CXT5051_F700
, /* HP Compaq Presario F700 */
1958 CXT5051_TOSHIBA
, /* Toshiba M300 & co */
1959 CXT5051_IDEAPAD
, /* Lenovo IdeaPad Y430 */
1960 CXT5051_AUTO
, /* auto-parser */
1964 static const char *const cxt5051_models
[CXT5051_MODELS
] = {
1965 [CXT5051_LAPTOP
] = "laptop",
1966 [CXT5051_HP
] = "hp",
1967 [CXT5051_HP_DV6736
] = "hp-dv6736",
1968 [CXT5051_LENOVO_X200
] = "lenovo-x200",
1969 [CXT5051_F700
] = "hp-700",
1970 [CXT5051_TOSHIBA
] = "toshiba",
1971 [CXT5051_IDEAPAD
] = "ideapad",
1972 [CXT5051_AUTO
] = "auto",
1975 static const struct snd_pci_quirk cxt5051_cfg_tbl
[] = {
1976 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736
),
1977 SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP
),
1978 SND_PCI_QUIRK(0x103c, 0x30ea, "Compaq Presario F700", CXT5051_F700
),
1979 SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba M30x", CXT5051_TOSHIBA
),
1980 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
1982 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP
),
1983 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT5051_LENOVO_X200
),
1984 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo IdeaPad", CXT5051_IDEAPAD
),
1988 static int patch_cxt5051(struct hda_codec
*codec
)
1990 struct conexant_spec
*spec
;
1993 board_config
= snd_hda_check_board_config(codec
, CXT5051_MODELS
,
1996 #if 0 /* use the old method just for safety */
1997 if (board_config
< 0)
1998 board_config
= CXT5051_AUTO
;
2000 if (board_config
== CXT5051_AUTO
)
2001 return patch_conexant_auto(codec
);
2003 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
2007 codec
->pin_amp_workaround
= 1;
2009 codec
->patch_ops
= conexant_patch_ops
;
2010 codec
->patch_ops
.init
= cxt5051_init
;
2012 spec
->multiout
.max_channels
= 2;
2013 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5051_dac_nids
);
2014 spec
->multiout
.dac_nids
= cxt5051_dac_nids
;
2015 spec
->multiout
.dig_out_nid
= CXT5051_SPDIF_OUT
;
2016 spec
->num_adc_nids
= 1; /* not 2; via auto-mic switch */
2017 spec
->adc_nids
= cxt5051_adc_nids
;
2018 spec
->num_mixers
= 2;
2019 spec
->mixers
[0] = cxt5051_capture_mixers
;
2020 spec
->mixers
[1] = cxt5051_playback_mixers
;
2021 spec
->num_init_verbs
= 1;
2022 spec
->init_verbs
[0] = cxt5051_init_verbs
;
2023 spec
->spdif_route
= 0;
2024 spec
->num_channel_mode
= ARRAY_SIZE(cxt5051_modes
);
2025 spec
->channel_mode
= cxt5051_modes
;
2027 spec
->cur_adc_idx
= 0;
2029 set_beep_amp(spec
, 0x13, 0, HDA_OUTPUT
);
2031 codec
->patch_ops
.unsol_event
= cxt5051_hp_unsol_event
;
2033 spec
->auto_mic
= AUTO_MIC_PORTB
| AUTO_MIC_PORTC
;
2034 switch (board_config
) {
2036 spec
->mixers
[0] = cxt5051_hp_mixers
;
2038 case CXT5051_HP_DV6736
:
2039 spec
->init_verbs
[0] = cxt5051_hp_dv6736_init_verbs
;
2040 spec
->mixers
[0] = cxt5051_hp_dv6736_mixers
;
2043 case CXT5051_LENOVO_X200
:
2044 spec
->init_verbs
[0] = cxt5051_lenovo_x200_init_verbs
;
2045 /* Thinkpad X301 does not have S/PDIF wired and no ability
2046 to use a docking station. */
2047 if (codec
->subsystem_id
== 0x17aa211f)
2048 spec
->multiout
.dig_out_nid
= 0;
2051 spec
->init_verbs
[0] = cxt5051_f700_init_verbs
;
2052 spec
->mixers
[0] = cxt5051_f700_mixers
;
2055 case CXT5051_TOSHIBA
:
2056 spec
->mixers
[0] = cxt5051_toshiba_mixers
;
2057 spec
->auto_mic
= AUTO_MIC_PORTB
;
2059 case CXT5051_IDEAPAD
:
2060 spec
->init_verbs
[spec
->num_init_verbs
++] =
2061 cxt5051_ideapad_init_verbs
;
2067 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
2072 /* Conexant 5066 specific */
2074 static const hda_nid_t cxt5066_dac_nids
[1] = { 0x10 };
2075 static const hda_nid_t cxt5066_adc_nids
[3] = { 0x14, 0x15, 0x16 };
2076 static const hda_nid_t cxt5066_capsrc_nids
[1] = { 0x17 };
2077 static const hda_nid_t cxt5066_digout_pin_nids
[2] = { 0x20, 0x22 };
2079 /* OLPC's microphone port is DC coupled for use with external sensors,
2080 * therefore we use a 50% mic bias in order to center the input signal with
2081 * the DC input range of the codec. */
2082 #define CXT5066_OLPC_EXT_MIC_BIAS PIN_VREF50
2084 static const struct hda_channel_mode cxt5066_modes
[1] = {
2088 #define HP_PRESENT_PORT_A (1 << 0)
2089 #define HP_PRESENT_PORT_D (1 << 1)
2090 #define hp_port_a_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_A)
2091 #define hp_port_d_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_D)
2093 static void cxt5066_update_speaker(struct hda_codec
*codec
)
2095 struct conexant_spec
*spec
= codec
->spec
;
2096 unsigned int pinctl
;
2098 snd_printdd("CXT5066: update speaker, hp_present=%d, cur_eapd=%d\n",
2099 spec
->hp_present
, spec
->cur_eapd
);
2102 pinctl
= (hp_port_a_present(spec
) && spec
->cur_eapd
) ? PIN_HP
: 0;
2103 snd_hda_codec_write(codec
, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2106 /* Port D (HP/LO) */
2107 pinctl
= spec
->cur_eapd
? spec
->port_d_mode
: 0;
2108 if (spec
->dell_automute
|| spec
->thinkpad
) {
2109 /* Mute if Port A is connected */
2110 if (hp_port_a_present(spec
))
2113 /* Thinkpad/Dell doesn't give pin-D status */
2114 if (!hp_port_d_present(spec
))
2117 snd_hda_codec_write(codec
, 0x1c, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2121 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
2122 snd_hda_codec_write(codec
, 0x1f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2126 /* turn on/off EAPD (+ mute HP) as a master switch */
2127 static int cxt5066_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
2128 struct snd_ctl_elem_value
*ucontrol
)
2130 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2132 if (!cxt_eapd_put(kcontrol
, ucontrol
))
2135 cxt5066_update_speaker(codec
);
2139 static const struct hda_input_mux cxt5066_olpc_dc_bias
= {
2143 { "50%", PIN_VREF50
},
2144 { "80%", PIN_VREF80
},
2148 static int cxt5066_set_olpc_dc_bias(struct hda_codec
*codec
)
2150 struct conexant_spec
*spec
= codec
->spec
;
2151 /* Even though port F is the DC input, the bias is controlled on port B.
2152 * we also leave that port as an active input (but unselected) in DC mode
2153 * just in case that is necessary to make the bias setting take effect. */
2154 return snd_hda_codec_write_cache(codec
, 0x1a, 0,
2155 AC_VERB_SET_PIN_WIDGET_CONTROL
,
2156 cxt5066_olpc_dc_bias
.items
[spec
->dc_input_bias
].index
);
2159 /* OLPC defers mic widget control until when capture is started because the
2160 * microphone LED comes on as soon as these settings are put in place. if we
2161 * did this before recording, it would give the false indication that recording
2162 * is happening when it is not. */
2163 static void cxt5066_olpc_select_mic(struct hda_codec
*codec
)
2165 struct conexant_spec
*spec
= codec
->spec
;
2166 if (!spec
->recording
)
2169 if (spec
->dc_enable
) {
2170 /* in DC mode we ignore presence detection and just use the jack
2171 * through our special DC port */
2172 const struct hda_verb enable_dc_mode
[] = {
2173 /* disble internal mic, port C */
2174 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2176 /* enable DC capture, port F */
2177 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2181 snd_hda_sequence_write(codec
, enable_dc_mode
);
2182 /* port B input disabled (and bias set) through the following call */
2183 cxt5066_set_olpc_dc_bias(codec
);
2187 /* disable DC (port F) */
2188 snd_hda_codec_write(codec
, 0x1e, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0);
2190 /* external mic, port B */
2191 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2192 spec
->ext_mic_present
? CXT5066_OLPC_EXT_MIC_BIAS
: 0);
2194 /* internal mic, port C */
2195 snd_hda_codec_write(codec
, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2196 spec
->ext_mic_present
? 0 : PIN_VREF80
);
2199 /* toggle input of built-in and mic jack appropriately */
2200 static void cxt5066_olpc_automic(struct hda_codec
*codec
)
2202 struct conexant_spec
*spec
= codec
->spec
;
2203 unsigned int present
;
2205 if (spec
->dc_enable
) /* don't do presence detection in DC mode */
2208 present
= snd_hda_codec_read(codec
, 0x1a, 0,
2209 AC_VERB_GET_PIN_SENSE
, 0) & 0x80000000;
2211 snd_printdd("CXT5066: external microphone detected\n");
2213 snd_printdd("CXT5066: external microphone absent\n");
2215 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_CONNECT_SEL
,
2217 spec
->ext_mic_present
= !!present
;
2219 cxt5066_olpc_select_mic(codec
);
2222 /* toggle input of built-in digital mic and mic jack appropriately */
2223 static void cxt5066_vostro_automic(struct hda_codec
*codec
)
2225 unsigned int present
;
2227 struct hda_verb ext_mic_present
[] = {
2228 /* enable external mic, port B */
2229 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2231 /* switch to external mic input */
2232 {0x17, AC_VERB_SET_CONNECT_SEL
, 0},
2233 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2235 /* disable internal digital mic */
2236 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2239 static const struct hda_verb ext_mic_absent
[] = {
2240 /* enable internal mic, port C */
2241 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2243 /* switch to internal mic input */
2244 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2246 /* disable external mic, port B */
2247 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2251 present
= snd_hda_jack_detect(codec
, 0x1a);
2253 snd_printdd("CXT5066: external microphone detected\n");
2254 snd_hda_sequence_write(codec
, ext_mic_present
);
2256 snd_printdd("CXT5066: external microphone absent\n");
2257 snd_hda_sequence_write(codec
, ext_mic_absent
);
2261 /* toggle input of built-in digital mic and mic jack appropriately */
2262 static void cxt5066_ideapad_automic(struct hda_codec
*codec
)
2264 unsigned int present
;
2266 struct hda_verb ext_mic_present
[] = {
2267 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2268 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2269 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2272 static const struct hda_verb ext_mic_absent
[] = {
2273 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2274 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2275 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2279 present
= snd_hda_jack_detect(codec
, 0x1b);
2281 snd_printdd("CXT5066: external microphone detected\n");
2282 snd_hda_sequence_write(codec
, ext_mic_present
);
2284 snd_printdd("CXT5066: external microphone absent\n");
2285 snd_hda_sequence_write(codec
, ext_mic_absent
);
2290 /* toggle input of built-in digital mic and mic jack appropriately */
2291 static void cxt5066_asus_automic(struct hda_codec
*codec
)
2293 unsigned int present
;
2295 present
= snd_hda_jack_detect(codec
, 0x1b);
2296 snd_printdd("CXT5066: external microphone present=%d\n", present
);
2297 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_CONNECT_SEL
,
2302 /* toggle input of built-in digital mic and mic jack appropriately */
2303 static void cxt5066_hp_laptop_automic(struct hda_codec
*codec
)
2305 unsigned int present
;
2307 present
= snd_hda_jack_detect(codec
, 0x1b);
2308 snd_printdd("CXT5066: external microphone present=%d\n", present
);
2309 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_CONNECT_SEL
,
2314 /* toggle input of built-in digital mic and mic jack appropriately
2315 order is: external mic -> dock mic -> interal mic */
2316 static void cxt5066_thinkpad_automic(struct hda_codec
*codec
)
2318 unsigned int ext_present
, dock_present
;
2320 static const struct hda_verb ext_mic_present
[] = {
2321 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2322 {0x17, AC_VERB_SET_CONNECT_SEL
, 1},
2323 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2324 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2325 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2328 static const struct hda_verb dock_mic_present
[] = {
2329 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2330 {0x17, AC_VERB_SET_CONNECT_SEL
, 0},
2331 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2332 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2333 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2336 static const struct hda_verb ext_mic_absent
[] = {
2337 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2338 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2339 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2340 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2344 ext_present
= snd_hda_jack_detect(codec
, 0x1b);
2345 dock_present
= snd_hda_jack_detect(codec
, 0x1a);
2347 snd_printdd("CXT5066: external microphone detected\n");
2348 snd_hda_sequence_write(codec
, ext_mic_present
);
2349 } else if (dock_present
) {
2350 snd_printdd("CXT5066: dock microphone detected\n");
2351 snd_hda_sequence_write(codec
, dock_mic_present
);
2353 snd_printdd("CXT5066: external microphone absent\n");
2354 snd_hda_sequence_write(codec
, ext_mic_absent
);
2358 /* mute internal speaker if HP is plugged */
2359 static void cxt5066_hp_automute(struct hda_codec
*codec
)
2361 struct conexant_spec
*spec
= codec
->spec
;
2362 unsigned int portA
, portD
;
2365 portA
= snd_hda_jack_detect(codec
, 0x19);
2368 portD
= snd_hda_jack_detect(codec
, 0x1c);
2370 spec
->hp_present
= portA
? HP_PRESENT_PORT_A
: 0;
2371 spec
->hp_present
|= portD
? HP_PRESENT_PORT_D
: 0;
2372 snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n",
2373 portA
, portD
, spec
->hp_present
);
2374 cxt5066_update_speaker(codec
);
2377 /* Dispatch the right mic autoswitch function */
2378 static void cxt5066_automic(struct hda_codec
*codec
)
2380 struct conexant_spec
*spec
= codec
->spec
;
2382 if (spec
->dell_vostro
)
2383 cxt5066_vostro_automic(codec
);
2384 else if (spec
->ideapad
)
2385 cxt5066_ideapad_automic(codec
);
2386 else if (spec
->thinkpad
)
2387 cxt5066_thinkpad_automic(codec
);
2388 else if (spec
->hp_laptop
)
2389 cxt5066_hp_laptop_automic(codec
);
2390 else if (spec
->asus
)
2391 cxt5066_asus_automic(codec
);
2394 /* unsolicited event for jack sensing */
2395 static void cxt5066_olpc_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2397 struct conexant_spec
*spec
= codec
->spec
;
2398 snd_printdd("CXT5066: unsol event %x (%x)\n", res
, res
>> 26);
2399 switch (res
>> 26) {
2400 case CONEXANT_HP_EVENT
:
2401 cxt5066_hp_automute(codec
);
2403 case CONEXANT_MIC_EVENT
:
2404 /* ignore mic events in DC mode; we're always using the jack */
2405 if (!spec
->dc_enable
)
2406 cxt5066_olpc_automic(codec
);
2411 /* unsolicited event for jack sensing */
2412 static void cxt5066_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2414 snd_printdd("CXT5066: unsol event %x (%x)\n", res
, res
>> 26);
2415 switch (res
>> 26) {
2416 case CONEXANT_HP_EVENT
:
2417 cxt5066_hp_automute(codec
);
2419 case CONEXANT_MIC_EVENT
:
2420 cxt5066_automic(codec
);
2426 static const struct hda_input_mux cxt5066_analog_mic_boost
= {
2437 static void cxt5066_set_mic_boost(struct hda_codec
*codec
)
2439 struct conexant_spec
*spec
= codec
->spec
;
2440 snd_hda_codec_write_cache(codec
, 0x17, 0,
2441 AC_VERB_SET_AMP_GAIN_MUTE
,
2442 AC_AMP_SET_RIGHT
| AC_AMP_SET_LEFT
| AC_AMP_SET_OUTPUT
|
2443 cxt5066_analog_mic_boost
.items
[spec
->mic_boost
].index
);
2444 if (spec
->ideapad
|| spec
->thinkpad
) {
2445 /* adjust the internal mic as well...it is not through 0x17 */
2446 snd_hda_codec_write_cache(codec
, 0x23, 0,
2447 AC_VERB_SET_AMP_GAIN_MUTE
,
2448 AC_AMP_SET_RIGHT
| AC_AMP_SET_LEFT
| AC_AMP_SET_INPUT
|
2449 cxt5066_analog_mic_boost
.
2450 items
[spec
->mic_boost
].index
);
2454 static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol
*kcontrol
,
2455 struct snd_ctl_elem_info
*uinfo
)
2457 return snd_hda_input_mux_info(&cxt5066_analog_mic_boost
, uinfo
);
2460 static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol
*kcontrol
,
2461 struct snd_ctl_elem_value
*ucontrol
)
2463 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2464 struct conexant_spec
*spec
= codec
->spec
;
2465 ucontrol
->value
.enumerated
.item
[0] = spec
->mic_boost
;
2469 static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol
*kcontrol
,
2470 struct snd_ctl_elem_value
*ucontrol
)
2472 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2473 struct conexant_spec
*spec
= codec
->spec
;
2474 const struct hda_input_mux
*imux
= &cxt5066_analog_mic_boost
;
2476 idx
= ucontrol
->value
.enumerated
.item
[0];
2477 if (idx
>= imux
->num_items
)
2478 idx
= imux
->num_items
- 1;
2480 spec
->mic_boost
= idx
;
2481 if (!spec
->dc_enable
)
2482 cxt5066_set_mic_boost(codec
);
2486 static void cxt5066_enable_dc(struct hda_codec
*codec
)
2488 const struct hda_verb enable_dc_mode
[] = {
2490 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2492 /* switch to DC input */
2493 {0x17, AC_VERB_SET_CONNECT_SEL
, 3},
2497 /* configure as input source */
2498 snd_hda_sequence_write(codec
, enable_dc_mode
);
2499 cxt5066_olpc_select_mic(codec
); /* also sets configured bias */
2502 static void cxt5066_disable_dc(struct hda_codec
*codec
)
2504 /* reconfigure input source */
2505 cxt5066_set_mic_boost(codec
);
2506 /* automic also selects the right mic if we're recording */
2507 cxt5066_olpc_automic(codec
);
2510 static int cxt5066_olpc_dc_get(struct snd_kcontrol
*kcontrol
,
2511 struct snd_ctl_elem_value
*ucontrol
)
2513 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2514 struct conexant_spec
*spec
= codec
->spec
;
2515 ucontrol
->value
.integer
.value
[0] = spec
->dc_enable
;
2519 static int cxt5066_olpc_dc_put(struct snd_kcontrol
*kcontrol
,
2520 struct snd_ctl_elem_value
*ucontrol
)
2522 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2523 struct conexant_spec
*spec
= codec
->spec
;
2524 int dc_enable
= !!ucontrol
->value
.integer
.value
[0];
2526 if (dc_enable
== spec
->dc_enable
)
2529 spec
->dc_enable
= dc_enable
;
2531 cxt5066_enable_dc(codec
);
2533 cxt5066_disable_dc(codec
);
2538 static int cxt5066_olpc_dc_bias_enum_info(struct snd_kcontrol
*kcontrol
,
2539 struct snd_ctl_elem_info
*uinfo
)
2541 return snd_hda_input_mux_info(&cxt5066_olpc_dc_bias
, uinfo
);
2544 static int cxt5066_olpc_dc_bias_enum_get(struct snd_kcontrol
*kcontrol
,
2545 struct snd_ctl_elem_value
*ucontrol
)
2547 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2548 struct conexant_spec
*spec
= codec
->spec
;
2549 ucontrol
->value
.enumerated
.item
[0] = spec
->dc_input_bias
;
2553 static int cxt5066_olpc_dc_bias_enum_put(struct snd_kcontrol
*kcontrol
,
2554 struct snd_ctl_elem_value
*ucontrol
)
2556 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2557 struct conexant_spec
*spec
= codec
->spec
;
2558 const struct hda_input_mux
*imux
= &cxt5066_analog_mic_boost
;
2561 idx
= ucontrol
->value
.enumerated
.item
[0];
2562 if (idx
>= imux
->num_items
)
2563 idx
= imux
->num_items
- 1;
2565 spec
->dc_input_bias
= idx
;
2566 if (spec
->dc_enable
)
2567 cxt5066_set_olpc_dc_bias(codec
);
2571 static void cxt5066_olpc_capture_prepare(struct hda_codec
*codec
)
2573 struct conexant_spec
*spec
= codec
->spec
;
2574 /* mark as recording and configure the microphone widget so that the
2575 * recording LED comes on. */
2576 spec
->recording
= 1;
2577 cxt5066_olpc_select_mic(codec
);
2580 static void cxt5066_olpc_capture_cleanup(struct hda_codec
*codec
)
2582 struct conexant_spec
*spec
= codec
->spec
;
2583 const struct hda_verb disable_mics
[] = {
2584 /* disable external mic, port B */
2585 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2587 /* disble internal mic, port C */
2588 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2590 /* disable DC capture, port F */
2591 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2595 snd_hda_sequence_write(codec
, disable_mics
);
2596 spec
->recording
= 0;
2599 static void conexant_check_dig_outs(struct hda_codec
*codec
,
2600 const hda_nid_t
*dig_pins
,
2603 struct conexant_spec
*spec
= codec
->spec
;
2604 hda_nid_t
*nid_loc
= &spec
->multiout
.dig_out_nid
;
2607 for (i
= 0; i
< num_pins
; i
++, dig_pins
++) {
2608 unsigned int cfg
= snd_hda_codec_get_pincfg(codec
, *dig_pins
);
2609 if (get_defcfg_connect(cfg
) == AC_JACK_PORT_NONE
)
2611 if (snd_hda_get_connections(codec
, *dig_pins
, nid_loc
, 1) != 1)
2613 if (spec
->slave_dig_outs
[0])
2616 nid_loc
= spec
->slave_dig_outs
;
2620 static const struct hda_input_mux cxt5066_capture_source
= {
2630 static const struct hda_bind_ctls cxt5066_bind_capture_vol_others
= {
2631 .ops
= &snd_hda_bind_vol
,
2633 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT
),
2634 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT
),
2639 static const struct hda_bind_ctls cxt5066_bind_capture_sw_others
= {
2640 .ops
= &snd_hda_bind_sw
,
2642 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT
),
2643 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT
),
2648 static const struct snd_kcontrol_new cxt5066_mixer_master
[] = {
2649 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
2653 static const struct snd_kcontrol_new cxt5066_mixer_master_olpc
[] = {
2655 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2656 .name
= "Master Playback Volume",
2657 .access
= SNDRV_CTL_ELEM_ACCESS_READWRITE
|
2658 SNDRV_CTL_ELEM_ACCESS_TLV_READ
|
2659 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK
,
2660 .subdevice
= HDA_SUBDEV_AMP_FLAG
,
2661 .info
= snd_hda_mixer_amp_volume_info
,
2662 .get
= snd_hda_mixer_amp_volume_get
,
2663 .put
= snd_hda_mixer_amp_volume_put
,
2664 .tlv
= { .c
= snd_hda_mixer_amp_tlv
},
2665 /* offset by 28 volume steps to limit minimum gain to -46dB */
2667 HDA_COMPOSE_AMP_VAL_OFS(0x10, 3, 0, HDA_OUTPUT
, 28),
2672 static const struct snd_kcontrol_new cxt5066_mixer_olpc_dc
[] = {
2674 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2675 .name
= "DC Mode Enable Switch",
2676 .info
= snd_ctl_boolean_mono_info
,
2677 .get
= cxt5066_olpc_dc_get
,
2678 .put
= cxt5066_olpc_dc_put
,
2681 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2682 .name
= "DC Input Bias Enum",
2683 .info
= cxt5066_olpc_dc_bias_enum_info
,
2684 .get
= cxt5066_olpc_dc_bias_enum_get
,
2685 .put
= cxt5066_olpc_dc_bias_enum_put
,
2690 static const struct snd_kcontrol_new cxt5066_mixers
[] = {
2692 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2693 .name
= "Master Playback Switch",
2694 .info
= cxt_eapd_info
,
2695 .get
= cxt_eapd_get
,
2696 .put
= cxt5066_hp_master_sw_put
,
2697 .private_value
= 0x1d,
2701 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2702 .name
= "Analog Mic Boost Capture Enum",
2703 .info
= cxt5066_mic_boost_mux_enum_info
,
2704 .get
= cxt5066_mic_boost_mux_enum_get
,
2705 .put
= cxt5066_mic_boost_mux_enum_put
,
2708 HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others
),
2709 HDA_BIND_SW("Capture Switch", &cxt5066_bind_capture_sw_others
),
2713 static const struct snd_kcontrol_new cxt5066_vostro_mixers
[] = {
2715 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2716 .name
= "Internal Mic Boost Capture Enum",
2717 .info
= cxt5066_mic_boost_mux_enum_info
,
2718 .get
= cxt5066_mic_boost_mux_enum_get
,
2719 .put
= cxt5066_mic_boost_mux_enum_put
,
2720 .private_value
= 0x23 | 0x100,
2725 static const struct hda_verb cxt5066_init_verbs
[] = {
2726 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port B */
2727 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port C */
2728 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2729 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2732 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2733 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2736 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2737 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2739 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2740 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2743 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2745 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2746 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2747 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2748 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2749 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2750 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2752 /* no digital microphone support yet */
2753 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2755 /* Audio input selector */
2756 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2758 /* SPDIF route: PCM */
2759 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2760 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2762 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2763 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2766 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2768 /* not handling these yet */
2769 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2770 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2771 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2772 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2773 {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2774 {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2775 {0x20, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2776 {0x22, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2780 static const struct hda_verb cxt5066_init_verbs_olpc
[] = {
2781 /* Port A: headphones */
2782 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2783 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2785 /* Port B: external microphone */
2786 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2788 /* Port C: internal microphone */
2789 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2791 /* Port D: unused */
2792 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2794 /* Port E: unused, but has primary EAPD */
2795 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2796 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2798 /* Port F: external DC input through microphone port */
2799 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2801 /* Port G: internal speakers */
2802 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2803 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2806 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2809 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2811 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2812 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2813 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2814 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2815 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2816 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2817 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2818 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2819 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2820 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2821 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2822 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2824 /* Disable digital microphone port */
2825 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2827 /* Audio input selectors */
2828 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2829 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2832 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2833 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2835 /* enable unsolicited events for Port A and B */
2836 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2837 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2841 static const struct hda_verb cxt5066_init_verbs_vostro
[] = {
2842 /* Port A: headphones */
2843 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2844 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2846 /* Port B: external microphone */
2847 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2849 /* Port C: unused */
2850 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2852 /* Port D: unused */
2853 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2855 /* Port E: unused, but has primary EAPD */
2856 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2857 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2859 /* Port F: unused */
2860 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2862 /* Port G: internal speakers */
2863 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2864 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2867 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2870 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2872 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2873 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2874 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2875 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2876 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2877 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2878 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2879 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2880 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2881 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2882 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2883 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2885 /* Digital microphone port */
2886 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2888 /* Audio input selectors */
2889 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2890 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2893 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2894 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2896 /* enable unsolicited events for Port A and B */
2897 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2898 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2902 static const struct hda_verb cxt5066_init_verbs_ideapad
[] = {
2903 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port B */
2904 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port C */
2905 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2906 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2909 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2910 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2913 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2914 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2916 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2917 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2920 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2922 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2923 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2924 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2925 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2926 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2927 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2928 {0x14, AC_VERB_SET_CONNECT_SEL
, 2}, /* default to internal mic */
2930 /* Audio input selector */
2931 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x2},
2932 {0x17, AC_VERB_SET_CONNECT_SEL
, 1}, /* route ext mic */
2934 /* SPDIF route: PCM */
2935 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2936 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2938 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2939 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2941 /* internal microphone */
2942 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* enable internal mic */
2945 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2947 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2948 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2952 static const struct hda_verb cxt5066_init_verbs_thinkpad
[] = {
2953 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2954 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2956 /* Port G: internal speakers */
2957 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2958 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2960 /* Port A: HP, Amp */
2961 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2962 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2964 /* Port B: Mic Dock */
2965 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2968 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2970 /* Port D: HP Dock, Amp */
2971 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2972 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2975 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2977 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2978 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2979 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2980 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2981 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2982 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2983 {0x14, AC_VERB_SET_CONNECT_SEL
, 2}, /* default to internal mic */
2985 /* Audio input selector */
2986 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x2},
2987 {0x17, AC_VERB_SET_CONNECT_SEL
, 1}, /* route ext mic */
2989 /* SPDIF route: PCM */
2990 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2991 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2993 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2994 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2996 /* internal microphone */
2997 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* enable internal mic */
3000 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
3002 /* enable unsolicited events for Port A, B, C and D */
3003 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
3004 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
3005 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
3006 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
3010 static const struct hda_verb cxt5066_init_verbs_portd_lo
[] = {
3011 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
3016 static const struct hda_verb cxt5066_init_verbs_hp_laptop
[] = {
3017 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x0},
3018 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
3019 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
3023 /* initialize jack-sensing, too */
3024 static int cxt5066_init(struct hda_codec
*codec
)
3026 snd_printdd("CXT5066: init\n");
3027 conexant_init(codec
);
3028 if (codec
->patch_ops
.unsol_event
) {
3029 cxt5066_hp_automute(codec
);
3030 cxt5066_automic(codec
);
3032 cxt5066_set_mic_boost(codec
);
3036 static int cxt5066_olpc_init(struct hda_codec
*codec
)
3038 struct conexant_spec
*spec
= codec
->spec
;
3039 snd_printdd("CXT5066: init\n");
3040 conexant_init(codec
);
3041 cxt5066_hp_automute(codec
);
3042 if (!spec
->dc_enable
) {
3043 cxt5066_set_mic_boost(codec
);
3044 cxt5066_olpc_automic(codec
);
3046 cxt5066_enable_dc(codec
);
3052 CXT5066_LAPTOP
, /* Laptops w/ EAPD support */
3053 CXT5066_DELL_LAPTOP
, /* Dell Laptop */
3054 CXT5066_OLPC_XO_1_5
, /* OLPC XO 1.5 */
3055 CXT5066_DELL_VOSTRO
, /* Dell Vostro 1015i */
3056 CXT5066_IDEAPAD
, /* Lenovo IdeaPad U150 */
3057 CXT5066_THINKPAD
, /* Lenovo ThinkPad T410s, others? */
3058 CXT5066_ASUS
, /* Asus K52JU, Lenovo G560 - Int mic at 0x1a and Ext mic at 0x1b */
3059 CXT5066_HP_LAPTOP
, /* HP Laptop */
3060 CXT5066_AUTO
, /* BIOS auto-parser */
3064 static const char * const cxt5066_models
[CXT5066_MODELS
] = {
3065 [CXT5066_LAPTOP
] = "laptop",
3066 [CXT5066_DELL_LAPTOP
] = "dell-laptop",
3067 [CXT5066_OLPC_XO_1_5
] = "olpc-xo-1_5",
3068 [CXT5066_DELL_VOSTRO
] = "dell-vostro",
3069 [CXT5066_IDEAPAD
] = "ideapad",
3070 [CXT5066_THINKPAD
] = "thinkpad",
3071 [CXT5066_ASUS
] = "asus",
3072 [CXT5066_HP_LAPTOP
] = "hp-laptop",
3073 [CXT5066_AUTO
] = "auto",
3076 static const struct snd_pci_quirk cxt5066_cfg_tbl
[] = {
3077 SND_PCI_QUIRK(0x1025, 0x054c, "Acer Aspire 3830TG", CXT5066_AUTO
),
3078 SND_PCI_QUIRK_MASK(0x1025, 0xff00, 0x0400, "Acer", CXT5066_IDEAPAD
),
3079 SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTRO
),
3080 SND_PCI_QUIRK(0x1028, 0x02f5, "Dell Vostro 320", CXT5066_IDEAPAD
),
3081 SND_PCI_QUIRK(0x1028, 0x0401, "Dell Vostro 1014", CXT5066_DELL_VOSTRO
),
3082 SND_PCI_QUIRK(0x1028, 0x0402, "Dell Vostro", CXT5066_DELL_VOSTRO
),
3083 SND_PCI_QUIRK(0x1028, 0x0408, "Dell Inspiron One 19T", CXT5066_IDEAPAD
),
3084 SND_PCI_QUIRK(0x1028, 0x050f, "Dell Inspiron", CXT5066_IDEAPAD
),
3085 SND_PCI_QUIRK(0x1028, 0x0510, "Dell Vostro", CXT5066_IDEAPAD
),
3086 SND_PCI_QUIRK(0x103c, 0x360b, "HP G60", CXT5066_HP_LAPTOP
),
3087 SND_PCI_QUIRK(0x1043, 0x13f3, "Asus A52J", CXT5066_ASUS
),
3088 SND_PCI_QUIRK(0x1043, 0x1643, "Asus K52JU", CXT5066_ASUS
),
3089 SND_PCI_QUIRK(0x1043, 0x1993, "Asus U50F", CXT5066_ASUS
),
3090 SND_PCI_QUIRK(0x1179, 0xff1e, "Toshiba Satellite C650D", CXT5066_IDEAPAD
),
3091 SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba Satellite P500-PSPGSC-01800T", CXT5066_OLPC_XO_1_5
),
3092 SND_PCI_QUIRK(0x1179, 0xffe0, "Toshiba Satellite Pro T130-15F", CXT5066_OLPC_XO_1_5
),
3093 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
3095 SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5
),
3096 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400s", CXT5066_THINKPAD
),
3097 SND_PCI_QUIRK(0x17aa, 0x21c5, "Thinkpad Edge 13", CXT5066_THINKPAD
),
3098 SND_PCI_QUIRK(0x17aa, 0x21c6, "Thinkpad Edge 13", CXT5066_ASUS
),
3099 SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo Thinkpad", CXT5066_THINKPAD
),
3100 SND_PCI_QUIRK(0x17aa, 0x21da, "Lenovo X220", CXT5066_THINKPAD
),
3101 SND_PCI_QUIRK(0x17aa, 0x21db, "Lenovo X220-tablet", CXT5066_THINKPAD
),
3102 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo U350", CXT5066_ASUS
),
3103 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo G560", CXT5066_ASUS
),
3104 SND_PCI_QUIRK(0x17aa, 0x3938, "Lenovo G565", CXT5066_AUTO
),
3105 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", CXT5066_IDEAPAD
), /* Fallback for Lenovos without dock mic */
3106 SND_PCI_QUIRK(0x1b0a, 0x2092, "CyberpowerPC Gamer Xplorer N57001", CXT5066_AUTO
),
3110 static int patch_cxt5066(struct hda_codec
*codec
)
3112 struct conexant_spec
*spec
;
3115 board_config
= snd_hda_check_board_config(codec
, CXT5066_MODELS
,
3116 cxt5066_models
, cxt5066_cfg_tbl
);
3117 #if 0 /* use the old method just for safety */
3118 if (board_config
< 0)
3119 board_config
= CXT5066_AUTO
;
3121 if (board_config
== CXT5066_AUTO
)
3122 return patch_conexant_auto(codec
);
3124 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
3129 codec
->patch_ops
= conexant_patch_ops
;
3130 codec
->patch_ops
.init
= conexant_init
;
3132 spec
->dell_automute
= 0;
3133 spec
->multiout
.max_channels
= 2;
3134 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5066_dac_nids
);
3135 spec
->multiout
.dac_nids
= cxt5066_dac_nids
;
3136 conexant_check_dig_outs(codec
, cxt5066_digout_pin_nids
,
3137 ARRAY_SIZE(cxt5066_digout_pin_nids
));
3138 spec
->num_adc_nids
= 1;
3139 spec
->adc_nids
= cxt5066_adc_nids
;
3140 spec
->capsrc_nids
= cxt5066_capsrc_nids
;
3141 spec
->input_mux
= &cxt5066_capture_source
;
3143 spec
->port_d_mode
= PIN_HP
;
3145 spec
->num_init_verbs
= 1;
3146 spec
->init_verbs
[0] = cxt5066_init_verbs
;
3147 spec
->num_channel_mode
= ARRAY_SIZE(cxt5066_modes
);
3148 spec
->channel_mode
= cxt5066_modes
;
3150 spec
->cur_adc_idx
= 0;
3152 set_beep_amp(spec
, 0x13, 0, HDA_OUTPUT
);
3154 switch (board_config
) {
3156 case CXT5066_LAPTOP
:
3157 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3158 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3160 case CXT5066_DELL_LAPTOP
:
3161 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3162 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3164 spec
->port_d_mode
= PIN_OUT
;
3165 spec
->init_verbs
[spec
->num_init_verbs
] = cxt5066_init_verbs_portd_lo
;
3166 spec
->num_init_verbs
++;
3167 spec
->dell_automute
= 1;
3170 case CXT5066_HP_LAPTOP
:
3171 codec
->patch_ops
.init
= cxt5066_init
;
3172 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
3173 spec
->init_verbs
[spec
->num_init_verbs
] =
3174 cxt5066_init_verbs_hp_laptop
;
3175 spec
->num_init_verbs
++;
3176 spec
->hp_laptop
= board_config
== CXT5066_HP_LAPTOP
;
3177 spec
->asus
= board_config
== CXT5066_ASUS
;
3178 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3179 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3181 if (board_config
== CXT5066_HP_LAPTOP
)
3182 spec
->multiout
.dig_out_nid
= 0;
3183 /* input source automatically selected */
3184 spec
->input_mux
= NULL
;
3185 spec
->port_d_mode
= 0;
3186 spec
->mic_boost
= 3; /* default 30dB gain */
3189 case CXT5066_OLPC_XO_1_5
:
3190 codec
->patch_ops
.init
= cxt5066_olpc_init
;
3191 codec
->patch_ops
.unsol_event
= cxt5066_olpc_unsol_event
;
3192 spec
->init_verbs
[0] = cxt5066_init_verbs_olpc
;
3193 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master_olpc
;
3194 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_olpc_dc
;
3195 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3196 spec
->port_d_mode
= 0;
3197 spec
->mic_boost
= 3; /* default 30dB gain */
3200 spec
->multiout
.dig_out_nid
= 0;
3202 /* input source automatically selected */
3203 spec
->input_mux
= NULL
;
3205 /* our capture hooks which allow us to turn on the microphone LED
3206 * at the right time */
3207 spec
->capture_prepare
= cxt5066_olpc_capture_prepare
;
3208 spec
->capture_cleanup
= cxt5066_olpc_capture_cleanup
;
3210 case CXT5066_DELL_VOSTRO
:
3211 codec
->patch_ops
.init
= cxt5066_init
;
3212 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
3213 spec
->init_verbs
[0] = cxt5066_init_verbs_vostro
;
3214 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master_olpc
;
3215 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3216 spec
->mixers
[spec
->num_mixers
++] = cxt5066_vostro_mixers
;
3217 spec
->port_d_mode
= 0;
3218 spec
->dell_vostro
= 1;
3219 spec
->mic_boost
= 3; /* default 30dB gain */
3222 spec
->multiout
.dig_out_nid
= 0;
3224 /* input source automatically selected */
3225 spec
->input_mux
= NULL
;
3227 case CXT5066_IDEAPAD
:
3228 codec
->patch_ops
.init
= cxt5066_init
;
3229 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
3230 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3231 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3232 spec
->init_verbs
[0] = cxt5066_init_verbs_ideapad
;
3233 spec
->port_d_mode
= 0;
3235 spec
->mic_boost
= 2; /* default 20dB gain */
3238 spec
->multiout
.dig_out_nid
= 0;
3240 /* input source automatically selected */
3241 spec
->input_mux
= NULL
;
3243 case CXT5066_THINKPAD
:
3244 codec
->patch_ops
.init
= cxt5066_init
;
3245 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
3246 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3247 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3248 spec
->init_verbs
[0] = cxt5066_init_verbs_thinkpad
;
3250 spec
->port_d_mode
= PIN_OUT
;
3251 spec
->mic_boost
= 2; /* default 20dB gain */
3254 spec
->multiout
.dig_out_nid
= 0;
3256 /* input source automatically selected */
3257 spec
->input_mux
= NULL
;
3262 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
3268 * Automatic parser for CX20641 & co
3271 static int cx_auto_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
3272 struct hda_codec
*codec
,
3273 unsigned int stream_tag
,
3274 unsigned int format
,
3275 struct snd_pcm_substream
*substream
)
3277 struct conexant_spec
*spec
= codec
->spec
;
3278 hda_nid_t adc
= spec
->imux_info
[spec
->cur_mux
[0]].adc
;
3279 if (spec
->adc_switching
) {
3280 spec
->cur_adc
= adc
;
3281 spec
->cur_adc_stream_tag
= stream_tag
;
3282 spec
->cur_adc_format
= format
;
3284 snd_hda_codec_setup_stream(codec
, adc
, stream_tag
, 0, format
);
3288 static int cx_auto_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
3289 struct hda_codec
*codec
,
3290 struct snd_pcm_substream
*substream
)
3292 struct conexant_spec
*spec
= codec
->spec
;
3293 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
3298 static const struct hda_pcm_stream cx_auto_pcm_analog_capture
= {
3302 .nid
= 0, /* fill later */
3304 .prepare
= cx_auto_capture_pcm_prepare
,
3305 .cleanup
= cx_auto_capture_pcm_cleanup
3309 static const hda_nid_t cx_auto_adc_nids
[] = { 0x14 };
3311 /* get the connection index of @nid in the widget @mux */
3312 static int get_connection_index(struct hda_codec
*codec
, hda_nid_t mux
,
3315 hda_nid_t conn
[HDA_MAX_NUM_INPUTS
];
3318 nums
= snd_hda_get_connections(codec
, mux
, conn
, ARRAY_SIZE(conn
));
3319 for (i
= 0; i
< nums
; i
++)
3325 /* get an unassigned DAC from the given list.
3326 * Return the nid if found and reduce the DAC list, or return zero if
3329 static hda_nid_t
get_unassigned_dac(struct hda_codec
*codec
, hda_nid_t pin
,
3330 hda_nid_t
*dacs
, int *num_dacs
)
3332 int i
, nums
= *num_dacs
;
3335 for (i
= 0; i
< nums
; i
++) {
3336 if (get_connection_index(codec
, pin
, dacs
[i
]) >= 0) {
3344 memmove(dacs
, dacs
+ 1, nums
* sizeof(hda_nid_t
));
3349 #define MAX_AUTO_DACS 5
3351 /* fill analog DAC list from the widget tree */
3352 static int fill_cx_auto_dacs(struct hda_codec
*codec
, hda_nid_t
*dacs
)
3354 hda_nid_t nid
, end_nid
;
3357 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
3358 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++) {
3359 unsigned int wcaps
= get_wcaps(codec
, nid
);
3360 unsigned int type
= get_wcaps_type(wcaps
);
3361 if (type
== AC_WID_AUD_OUT
&& !(wcaps
& AC_WCAP_DIGITAL
)) {
3363 if (nums
>= MAX_AUTO_DACS
)
3370 /* fill pin_dac_pair list from the pin and dac list */
3371 static int fill_dacs_for_pins(struct hda_codec
*codec
, hda_nid_t
*pins
,
3372 int num_pins
, hda_nid_t
*dacs
, int *rest
,
3373 struct pin_dac_pair
*filled
, int type
)
3378 for (i
= 0; i
< num_pins
; i
++) {
3379 filled
[nums
].pin
= pins
[i
];
3380 filled
[nums
].type
= type
;
3381 filled
[nums
].dac
= get_unassigned_dac(codec
, pins
[i
], dacs
, rest
);
3387 /* parse analog output paths */
3388 static void cx_auto_parse_output(struct hda_codec
*codec
)
3390 struct conexant_spec
*spec
= codec
->spec
;
3391 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3392 hda_nid_t dacs
[MAX_AUTO_DACS
];
3393 int i
, j
, nums
, rest
;
3395 rest
= fill_cx_auto_dacs(codec
, dacs
);
3396 /* parse all analog output pins */
3397 nums
= fill_dacs_for_pins(codec
, cfg
->line_out_pins
, cfg
->line_outs
,
3398 dacs
, &rest
, spec
->dac_info
,
3400 nums
+= fill_dacs_for_pins(codec
, cfg
->hp_pins
, cfg
->hp_outs
,
3401 dacs
, &rest
, spec
->dac_info
+ nums
,
3403 nums
+= fill_dacs_for_pins(codec
, cfg
->speaker_pins
, cfg
->speaker_outs
,
3404 dacs
, &rest
, spec
->dac_info
+ nums
,
3405 AUTO_PIN_SPEAKER_OUT
);
3406 spec
->dac_info_filled
= nums
;
3407 /* fill multiout struct */
3408 for (i
= 0; i
< nums
; i
++) {
3409 hda_nid_t dac
= spec
->dac_info
[i
].dac
;
3412 switch (spec
->dac_info
[i
].type
) {
3413 case AUTO_PIN_LINE_OUT
:
3414 spec
->private_dac_nids
[spec
->multiout
.num_dacs
] = dac
;
3415 spec
->multiout
.num_dacs
++;
3417 case AUTO_PIN_HP_OUT
:
3418 case AUTO_PIN_SPEAKER_OUT
:
3419 if (!spec
->multiout
.hp_nid
) {
3420 spec
->multiout
.hp_nid
= dac
;
3423 for (j
= 0; j
< ARRAY_SIZE(spec
->multiout
.extra_out_nid
); j
++)
3424 if (!spec
->multiout
.extra_out_nid
[j
]) {
3425 spec
->multiout
.extra_out_nid
[j
] = dac
;
3431 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
3432 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
3434 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
3435 if (is_jack_detectable(codec
, cfg
->hp_pins
[i
])) {
3436 spec
->auto_mute
= 1;
3440 if (spec
->auto_mute
&&
3441 cfg
->line_out_pins
[0] &&
3442 cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
&&
3443 cfg
->line_out_pins
[0] != cfg
->hp_pins
[0] &&
3444 cfg
->line_out_pins
[0] != cfg
->speaker_pins
[0]) {
3445 for (i
= 0; i
< cfg
->line_outs
; i
++) {
3446 if (is_jack_detectable(codec
, cfg
->line_out_pins
[i
])) {
3447 spec
->detect_line
= 1;
3451 spec
->automute_lines
= spec
->detect_line
;
3454 spec
->vmaster_nid
= spec
->private_dac_nids
[0];
3457 static void cx_auto_turn_eapd(struct hda_codec
*codec
, int num_pins
,
3458 hda_nid_t
*pins
, bool on
);
3460 static void do_automute(struct hda_codec
*codec
, int num_pins
,
3461 hda_nid_t
*pins
, bool on
)
3464 for (i
= 0; i
< num_pins
; i
++)
3465 snd_hda_codec_write(codec
, pins
[i
], 0,
3466 AC_VERB_SET_PIN_WIDGET_CONTROL
,
3468 cx_auto_turn_eapd(codec
, num_pins
, pins
, on
);
3471 static int detect_jacks(struct hda_codec
*codec
, int num_pins
, hda_nid_t
*pins
)
3475 for (i
= 0; i
< num_pins
; i
++) {
3476 hda_nid_t nid
= pins
[i
];
3477 if (!nid
|| !is_jack_detectable(codec
, nid
))
3479 snd_hda_input_jack_report(codec
, nid
);
3480 present
|= snd_hda_jack_detect(codec
, nid
);
3485 /* auto-mute/unmute speaker and line outs according to headphone jack */
3486 static void cx_auto_update_speakers(struct hda_codec
*codec
)
3488 struct conexant_spec
*spec
= codec
->spec
;
3489 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3492 /* turn on HP EAPD when HP jacks are present */
3493 if (spec
->auto_mute
)
3494 on
= spec
->hp_present
;
3495 cx_auto_turn_eapd(codec
, cfg
->hp_outs
, cfg
->hp_pins
, on
);
3496 /* mute speakers in auto-mode if HP or LO jacks are plugged */
3497 if (spec
->auto_mute
)
3498 on
= !(spec
->hp_present
||
3499 (spec
->detect_line
&& spec
->line_present
));
3500 do_automute(codec
, cfg
->speaker_outs
, cfg
->speaker_pins
, on
);
3502 /* toggle line-out mutes if needed, too */
3503 /* if LO is a copy of either HP or Speaker, don't need to handle it */
3504 if (cfg
->line_out_pins
[0] == cfg
->hp_pins
[0] ||
3505 cfg
->line_out_pins
[0] == cfg
->speaker_pins
[0])
3507 if (spec
->auto_mute
) {
3508 /* mute LO in auto-mode when HP jack is present */
3509 if (cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
||
3510 spec
->automute_lines
)
3511 on
= !spec
->hp_present
;
3515 do_automute(codec
, cfg
->line_outs
, cfg
->line_out_pins
, on
);
3518 static void cx_auto_hp_automute(struct hda_codec
*codec
)
3520 struct conexant_spec
*spec
= codec
->spec
;
3521 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3523 if (!spec
->auto_mute
)
3525 spec
->hp_present
= detect_jacks(codec
, cfg
->hp_outs
, cfg
->hp_pins
);
3526 cx_auto_update_speakers(codec
);
3529 static void cx_auto_line_automute(struct hda_codec
*codec
)
3531 struct conexant_spec
*spec
= codec
->spec
;
3532 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3534 if (!spec
->auto_mute
|| !spec
->detect_line
)
3536 spec
->line_present
= detect_jacks(codec
, cfg
->line_outs
,
3537 cfg
->line_out_pins
);
3538 cx_auto_update_speakers(codec
);
3541 static int cx_automute_mode_info(struct snd_kcontrol
*kcontrol
,
3542 struct snd_ctl_elem_info
*uinfo
)
3544 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3545 struct conexant_spec
*spec
= codec
->spec
;
3546 static const char * const texts2
[] = {
3547 "Disabled", "Enabled"
3549 static const char * const texts3
[] = {
3550 "Disabled", "Speaker Only", "Line-Out+Speaker"
3552 const char * const *texts
;
3554 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
3556 if (spec
->automute_hp_lo
) {
3557 uinfo
->value
.enumerated
.items
= 3;
3560 uinfo
->value
.enumerated
.items
= 2;
3563 if (uinfo
->value
.enumerated
.item
>= uinfo
->value
.enumerated
.items
)
3564 uinfo
->value
.enumerated
.item
= uinfo
->value
.enumerated
.items
- 1;
3565 strcpy(uinfo
->value
.enumerated
.name
,
3566 texts
[uinfo
->value
.enumerated
.item
]);
3570 static int cx_automute_mode_get(struct snd_kcontrol
*kcontrol
,
3571 struct snd_ctl_elem_value
*ucontrol
)
3573 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3574 struct conexant_spec
*spec
= codec
->spec
;
3576 if (!spec
->auto_mute
)
3578 else if (!spec
->automute_lines
)
3582 ucontrol
->value
.enumerated
.item
[0] = val
;
3586 static int cx_automute_mode_put(struct snd_kcontrol
*kcontrol
,
3587 struct snd_ctl_elem_value
*ucontrol
)
3589 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3590 struct conexant_spec
*spec
= codec
->spec
;
3592 switch (ucontrol
->value
.enumerated
.item
[0]) {
3594 if (!spec
->auto_mute
)
3596 spec
->auto_mute
= 0;
3599 if (spec
->auto_mute
&& !spec
->automute_lines
)
3601 spec
->auto_mute
= 1;
3602 spec
->automute_lines
= 0;
3605 if (!spec
->automute_hp_lo
)
3607 if (spec
->auto_mute
&& spec
->automute_lines
)
3609 spec
->auto_mute
= 1;
3610 spec
->automute_lines
= 1;
3615 cx_auto_update_speakers(codec
);
3619 static const struct snd_kcontrol_new cx_automute_mode_enum
[] = {
3621 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3622 .name
= "Auto-Mute Mode",
3623 .info
= cx_automute_mode_info
,
3624 .get
= cx_automute_mode_get
,
3625 .put
= cx_automute_mode_put
,
3630 static int cx_auto_mux_enum_info(struct snd_kcontrol
*kcontrol
,
3631 struct snd_ctl_elem_info
*uinfo
)
3633 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3634 struct conexant_spec
*spec
= codec
->spec
;
3636 return snd_hda_input_mux_info(&spec
->private_imux
, uinfo
);
3639 static int cx_auto_mux_enum_get(struct snd_kcontrol
*kcontrol
,
3640 struct snd_ctl_elem_value
*ucontrol
)
3642 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3643 struct conexant_spec
*spec
= codec
->spec
;
3645 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[0];
3649 /* look for the route the given pin from mux and return the index;
3650 * if do_select is set, actually select the route.
3652 static int __select_input_connection(struct hda_codec
*codec
, hda_nid_t mux
,
3653 hda_nid_t pin
, hda_nid_t
*srcp
,
3654 bool do_select
, int depth
)
3656 hda_nid_t conn
[HDA_MAX_NUM_INPUTS
];
3659 switch (get_wcaps_type(get_wcaps(codec
, mux
))) {
3661 case AC_WID_AUD_SEL
:
3662 case AC_WID_AUD_MIX
:
3668 nums
= snd_hda_get_connections(codec
, mux
, conn
, ARRAY_SIZE(conn
));
3669 for (i
= 0; i
< nums
; i
++)
3670 if (conn
[i
] == pin
) {
3672 snd_hda_codec_write(codec
, mux
, 0,
3673 AC_VERB_SET_CONNECT_SEL
, i
);
3681 for (i
= 0; i
< nums
; i
++) {
3682 int ret
= __select_input_connection(codec
, conn
[i
], pin
, srcp
,
3686 snd_hda_codec_write(codec
, mux
, 0,
3687 AC_VERB_SET_CONNECT_SEL
, i
);
3694 static void select_input_connection(struct hda_codec
*codec
, hda_nid_t mux
,
3697 __select_input_connection(codec
, mux
, pin
, NULL
, true, 0);
3700 static int get_input_connection(struct hda_codec
*codec
, hda_nid_t mux
,
3703 return __select_input_connection(codec
, mux
, pin
, NULL
, false, 0);
3706 static int cx_auto_mux_enum_update(struct hda_codec
*codec
,
3707 const struct hda_input_mux
*imux
,
3710 struct conexant_spec
*spec
= codec
->spec
;
3714 if (!imux
->num_items
)
3716 if (idx
>= imux
->num_items
)
3717 idx
= imux
->num_items
- 1;
3718 if (spec
->cur_mux
[0] == idx
)
3720 adc
= spec
->imux_info
[idx
].adc
;
3721 select_input_connection(codec
, spec
->imux_info
[idx
].adc
,
3722 spec
->imux_info
[idx
].pin
);
3723 if (spec
->cur_adc
&& spec
->cur_adc
!= adc
) {
3724 /* stream is running, let's swap the current ADC */
3725 __snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
, 1);
3726 spec
->cur_adc
= adc
;
3727 snd_hda_codec_setup_stream(codec
, adc
,
3728 spec
->cur_adc_stream_tag
, 0,
3729 spec
->cur_adc_format
);
3731 spec
->cur_mux
[0] = idx
;
3735 static int cx_auto_mux_enum_put(struct snd_kcontrol
*kcontrol
,
3736 struct snd_ctl_elem_value
*ucontrol
)
3738 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3739 struct conexant_spec
*spec
= codec
->spec
;
3741 return cx_auto_mux_enum_update(codec
, &spec
->private_imux
,
3742 ucontrol
->value
.enumerated
.item
[0]);
3745 static const struct snd_kcontrol_new cx_auto_capture_mixers
[] = {
3747 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3748 .name
= "Capture Source",
3749 .info
= cx_auto_mux_enum_info
,
3750 .get
= cx_auto_mux_enum_get
,
3751 .put
= cx_auto_mux_enum_put
3756 static bool select_automic(struct hda_codec
*codec
, int idx
, bool detect
)
3758 struct conexant_spec
*spec
= codec
->spec
;
3761 if (detect
&& !snd_hda_jack_detect(codec
, spec
->imux_info
[idx
].pin
))
3763 cx_auto_mux_enum_update(codec
, &spec
->private_imux
, idx
);
3767 /* automatic switch internal and external mic */
3768 static void cx_auto_automic(struct hda_codec
*codec
)
3770 struct conexant_spec
*spec
= codec
->spec
;
3772 if (!spec
->auto_mic
)
3774 if (!select_automic(codec
, spec
->auto_mic_ext
, true))
3775 if (!select_automic(codec
, spec
->auto_mic_dock
, true))
3776 select_automic(codec
, spec
->auto_mic_int
, false);
3779 static void cx_auto_unsol_event(struct hda_codec
*codec
, unsigned int res
)
3781 int nid
= (res
& AC_UNSOL_RES_SUBTAG
) >> 20;
3782 switch (res
>> 26) {
3783 case CONEXANT_HP_EVENT
:
3784 cx_auto_hp_automute(codec
);
3786 case CONEXANT_LINE_EVENT
:
3787 cx_auto_line_automute(codec
);
3789 case CONEXANT_MIC_EVENT
:
3790 cx_auto_automic(codec
);
3791 snd_hda_input_jack_report(codec
, nid
);
3796 /* check whether the pin config is suitable for auto-mic switching;
3797 * auto-mic is enabled only when one int-mic and one ext- and/or
3798 * one dock-mic exist
3800 static void cx_auto_check_auto_mic(struct hda_codec
*codec
)
3802 struct conexant_spec
*spec
= codec
->spec
;
3803 int pset
[INPUT_PIN_ATTR_NORMAL
+ 1];
3806 for (i
= 0; i
< ARRAY_SIZE(pset
); i
++)
3808 for (i
= 0; i
< spec
->private_imux
.num_items
; i
++) {
3809 hda_nid_t pin
= spec
->imux_info
[i
].pin
;
3810 unsigned int def_conf
= snd_hda_codec_get_pincfg(codec
, pin
);
3812 attr
= snd_hda_get_input_pin_attr(def_conf
);
3813 if (attr
== INPUT_PIN_ATTR_UNUSED
)
3814 return; /* invalid entry */
3815 if (attr
> INPUT_PIN_ATTR_NORMAL
)
3816 attr
= INPUT_PIN_ATTR_NORMAL
;
3817 if (attr
!= INPUT_PIN_ATTR_INT
&&
3818 !is_jack_detectable(codec
, pin
))
3819 return; /* non-detectable pin */
3820 type
= get_defcfg_device(def_conf
);
3821 if (type
!= AC_JACK_MIC_IN
&&
3822 (attr
!= INPUT_PIN_ATTR_DOCK
|| type
!= AC_JACK_LINE_IN
))
3823 return; /* no valid input type */
3824 if (pset
[attr
] >= 0)
3825 return; /* already occupied */
3828 if (pset
[INPUT_PIN_ATTR_INT
] < 0 ||
3829 (pset
[INPUT_PIN_ATTR_NORMAL
] < 0 && pset
[INPUT_PIN_ATTR_DOCK
]))
3830 return; /* no input to switch*/
3832 spec
->auto_mic_ext
= pset
[INPUT_PIN_ATTR_NORMAL
];
3833 spec
->auto_mic_dock
= pset
[INPUT_PIN_ATTR_DOCK
];
3834 spec
->auto_mic_int
= pset
[INPUT_PIN_ATTR_INT
];
3837 static void cx_auto_parse_input(struct hda_codec
*codec
)
3839 struct conexant_spec
*spec
= codec
->spec
;
3840 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3841 struct hda_input_mux
*imux
;
3844 imux
= &spec
->private_imux
;
3845 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3846 for (j
= 0; j
< spec
->num_adc_nids
; j
++) {
3847 hda_nid_t adc
= spec
->adc_nids
[j
];
3848 int idx
= get_input_connection(codec
, adc
,
3849 cfg
->inputs
[i
].pin
);
3852 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
3853 spec
->imux_info
[imux
->num_items
].index
= i
;
3854 spec
->imux_info
[imux
->num_items
].boost
= 0;
3855 spec
->imux_info
[imux
->num_items
].adc
= adc
;
3856 spec
->imux_info
[imux
->num_items
].pin
=
3858 snd_hda_add_imux_item(imux
, label
, idx
, NULL
);
3863 if (imux
->num_items
>= 2 && cfg
->num_inputs
== imux
->num_items
)
3864 cx_auto_check_auto_mic(codec
);
3865 if (imux
->num_items
> 1 && !spec
->auto_mic
) {
3866 for (i
= 1; i
< imux
->num_items
; i
++) {
3867 if (spec
->imux_info
[i
].adc
!= spec
->imux_info
[0].adc
) {
3868 spec
->adc_switching
= 1;
3875 /* get digital-input audio widget corresponding to the given pin */
3876 static hda_nid_t
cx_auto_get_dig_in(struct hda_codec
*codec
, hda_nid_t pin
)
3878 hda_nid_t nid
, end_nid
;
3880 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
3881 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++) {
3882 unsigned int wcaps
= get_wcaps(codec
, nid
);
3883 unsigned int type
= get_wcaps_type(wcaps
);
3884 if (type
== AC_WID_AUD_IN
&& (wcaps
& AC_WCAP_DIGITAL
)) {
3885 if (get_connection_index(codec
, nid
, pin
) >= 0)
3892 static void cx_auto_parse_digital(struct hda_codec
*codec
)
3894 struct conexant_spec
*spec
= codec
->spec
;
3895 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3898 if (cfg
->dig_outs
&&
3899 snd_hda_get_connections(codec
, cfg
->dig_out_pins
[0], &nid
, 1) == 1)
3900 spec
->multiout
.dig_out_nid
= nid
;
3901 if (cfg
->dig_in_pin
)
3902 spec
->dig_in_nid
= cx_auto_get_dig_in(codec
, cfg
->dig_in_pin
);
3905 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3906 static void cx_auto_parse_beep(struct hda_codec
*codec
)
3908 struct conexant_spec
*spec
= codec
->spec
;
3909 hda_nid_t nid
, end_nid
;
3911 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
3912 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++)
3913 if (get_wcaps_type(get_wcaps(codec
, nid
)) == AC_WID_BEEP
) {
3914 set_beep_amp(spec
, nid
, 0, HDA_OUTPUT
);
3919 #define cx_auto_parse_beep(codec)
3922 static int cx_auto_parse_auto_config(struct hda_codec
*codec
)
3924 struct conexant_spec
*spec
= codec
->spec
;
3927 err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
);
3931 cx_auto_parse_output(codec
);
3932 cx_auto_parse_input(codec
);
3933 cx_auto_parse_digital(codec
);
3934 cx_auto_parse_beep(codec
);
3938 static void cx_auto_turn_eapd(struct hda_codec
*codec
, int num_pins
,
3939 hda_nid_t
*pins
, bool on
)
3942 for (i
= 0; i
< num_pins
; i
++) {
3943 if (snd_hda_query_pin_caps(codec
, pins
[i
]) & AC_PINCAP_EAPD
)
3944 snd_hda_codec_write(codec
, pins
[i
], 0,
3945 AC_VERB_SET_EAPD_BTLENABLE
,
3950 static void select_connection(struct hda_codec
*codec
, hda_nid_t pin
,
3953 int idx
= get_connection_index(codec
, pin
, src
);
3955 snd_hda_codec_write(codec
, pin
, 0,
3956 AC_VERB_SET_CONNECT_SEL
, idx
);
3959 static void mute_outputs(struct hda_codec
*codec
, int num_nids
,
3960 const hda_nid_t
*nids
)
3964 for (i
= 0; i
< num_nids
; i
++) {
3965 hda_nid_t nid
= nids
[i
];
3966 if (!(get_wcaps(codec
, nid
) & AC_WCAP_OUT_AMP
))
3968 if (query_amp_caps(codec
, nid
, HDA_OUTPUT
) & AC_AMPCAP_MUTE
)
3972 snd_hda_codec_write(codec
, nid
, 0,
3973 AC_VERB_SET_AMP_GAIN_MUTE
, val
);
3977 static void enable_unsol_pins(struct hda_codec
*codec
, int num_pins
,
3978 hda_nid_t
*pins
, unsigned int tag
)
3981 for (i
= 0; i
< num_pins
; i
++)
3982 snd_hda_codec_write(codec
, pins
[i
], 0,
3983 AC_VERB_SET_UNSOLICITED_ENABLE
,
3987 static void cx_auto_init_output(struct hda_codec
*codec
)
3989 struct conexant_spec
*spec
= codec
->spec
;
3990 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3994 mute_outputs(codec
, spec
->multiout
.num_dacs
, spec
->multiout
.dac_nids
);
3995 for (i
= 0; i
< cfg
->hp_outs
; i
++)
3996 snd_hda_codec_write(codec
, cfg
->hp_pins
[i
], 0,
3997 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
);
3998 mute_outputs(codec
, cfg
->hp_outs
, cfg
->hp_pins
);
3999 mute_outputs(codec
, cfg
->line_outs
, cfg
->line_out_pins
);
4000 mute_outputs(codec
, cfg
->speaker_outs
, cfg
->speaker_pins
);
4001 for (i
= 0; i
< spec
->dac_info_filled
; i
++) {
4002 nid
= spec
->dac_info
[i
].dac
;
4004 nid
= spec
->multiout
.dac_nids
[0];
4005 select_connection(codec
, spec
->dac_info
[i
].pin
, nid
);
4007 if (spec
->auto_mute
) {
4008 enable_unsol_pins(codec
, cfg
->hp_outs
, cfg
->hp_pins
,
4010 spec
->hp_present
= detect_jacks(codec
, cfg
->hp_outs
,
4012 if (spec
->detect_line
) {
4013 enable_unsol_pins(codec
, cfg
->line_outs
,
4015 CONEXANT_LINE_EVENT
);
4016 spec
->line_present
=
4017 detect_jacks(codec
, cfg
->line_outs
,
4018 cfg
->line_out_pins
);
4021 cx_auto_update_speakers(codec
);
4024 static void cx_auto_init_input(struct hda_codec
*codec
)
4026 struct conexant_spec
*spec
= codec
->spec
;
4027 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4030 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
4031 hda_nid_t nid
= spec
->adc_nids
[i
];
4032 if (!(get_wcaps(codec
, nid
) & AC_WCAP_IN_AMP
))
4034 if (query_amp_caps(codec
, nid
, HDA_INPUT
) & AC_AMPCAP_MUTE
)
4035 val
= AMP_IN_MUTE(0);
4037 val
= AMP_IN_UNMUTE(0);
4038 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
4042 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
4044 if (cfg
->inputs
[i
].type
== AUTO_PIN_MIC
)
4048 snd_hda_codec_write(codec
, cfg
->inputs
[i
].pin
, 0,
4049 AC_VERB_SET_PIN_WIDGET_CONTROL
, type
);
4052 if (spec
->auto_mic
) {
4053 if (spec
->auto_mic_ext
>= 0) {
4054 snd_hda_codec_write(codec
,
4055 cfg
->inputs
[spec
->auto_mic_ext
].pin
, 0,
4056 AC_VERB_SET_UNSOLICITED_ENABLE
,
4057 AC_USRSP_EN
| CONEXANT_MIC_EVENT
);
4059 if (spec
->auto_mic_dock
>= 0) {
4060 snd_hda_codec_write(codec
,
4061 cfg
->inputs
[spec
->auto_mic_dock
].pin
, 0,
4062 AC_VERB_SET_UNSOLICITED_ENABLE
,
4063 AC_USRSP_EN
| CONEXANT_MIC_EVENT
);
4065 cx_auto_automic(codec
);
4067 select_input_connection(codec
, spec
->imux_info
[0].adc
,
4068 spec
->imux_info
[0].pin
);
4072 static void cx_auto_init_digital(struct hda_codec
*codec
)
4074 struct conexant_spec
*spec
= codec
->spec
;
4075 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4077 if (spec
->multiout
.dig_out_nid
)
4078 snd_hda_codec_write(codec
, cfg
->dig_out_pins
[0], 0,
4079 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
);
4080 if (spec
->dig_in_nid
)
4081 snd_hda_codec_write(codec
, cfg
->dig_in_pin
, 0,
4082 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
);
4085 static int cx_auto_init(struct hda_codec
*codec
)
4087 /*snd_hda_sequence_write(codec, cx_auto_init_verbs);*/
4088 cx_auto_init_output(codec
);
4089 cx_auto_init_input(codec
);
4090 cx_auto_init_digital(codec
);
4094 static int cx_auto_add_volume_idx(struct hda_codec
*codec
, const char *basename
,
4095 const char *dir
, int cidx
,
4096 hda_nid_t nid
, int hda_dir
, int amp_idx
)
4098 static char name
[32];
4099 static struct snd_kcontrol_new knew
[] = {
4100 HDA_CODEC_VOLUME(name
, 0, 0, 0),
4101 HDA_CODEC_MUTE(name
, 0, 0, 0),
4103 static const char * const sfx
[2] = { "Volume", "Switch" };
4106 for (i
= 0; i
< 2; i
++) {
4107 struct snd_kcontrol
*kctl
;
4108 knew
[i
].private_value
= HDA_COMPOSE_AMP_VAL(nid
, 3, amp_idx
,
4110 knew
[i
].subdevice
= HDA_SUBDEV_AMP_FLAG
;
4111 knew
[i
].index
= cidx
;
4112 snprintf(name
, sizeof(name
), "%s%s %s", basename
, dir
, sfx
[i
]);
4113 kctl
= snd_ctl_new1(&knew
[i
], codec
);
4116 err
= snd_hda_ctl_add(codec
, nid
, kctl
);
4119 if (!(query_amp_caps(codec
, nid
, hda_dir
) & AC_AMPCAP_MUTE
))
4125 #define cx_auto_add_volume(codec, str, dir, cidx, nid, hda_dir) \
4126 cx_auto_add_volume_idx(codec, str, dir, cidx, nid, hda_dir, 0)
4128 #define cx_auto_add_pb_volume(codec, nid, str, idx) \
4129 cx_auto_add_volume(codec, str, " Playback", idx, nid, HDA_OUTPUT)
4131 static int try_add_pb_volume(struct hda_codec
*codec
, hda_nid_t dac
,
4132 hda_nid_t pin
, const char *name
, int idx
)
4135 caps
= query_amp_caps(codec
, dac
, HDA_OUTPUT
);
4136 if (caps
& AC_AMPCAP_NUM_STEPS
)
4137 return cx_auto_add_pb_volume(codec
, dac
, name
, idx
);
4138 caps
= query_amp_caps(codec
, pin
, HDA_OUTPUT
);
4139 if (caps
& AC_AMPCAP_NUM_STEPS
)
4140 return cx_auto_add_pb_volume(codec
, pin
, name
, idx
);
4144 static int cx_auto_build_output_controls(struct hda_codec
*codec
)
4146 struct conexant_spec
*spec
= codec
->spec
;
4148 int num_line
= 0, num_hp
= 0, num_spk
= 0;
4149 static const char * const texts
[3] = { "Front", "Surround", "CLFE" };
4151 if (spec
->dac_info_filled
== 1)
4152 return try_add_pb_volume(codec
, spec
->dac_info
[0].dac
,
4153 spec
->dac_info
[0].pin
,
4156 for (i
= 0; i
< spec
->dac_info_filled
; i
++) {
4159 if (!spec
->dac_info
[i
].dac
)
4161 type
= spec
->dac_info
[i
].type
;
4162 if (type
== AUTO_PIN_LINE_OUT
)
4163 type
= spec
->autocfg
.line_out_type
;
4165 case AUTO_PIN_LINE_OUT
:
4167 label
= texts
[num_line
++];
4170 case AUTO_PIN_HP_OUT
:
4171 label
= "Headphone";
4174 case AUTO_PIN_SPEAKER_OUT
:
4179 err
= try_add_pb_volume(codec
, spec
->dac_info
[i
].dac
,
4180 spec
->dac_info
[i
].pin
,
4186 if (spec
->auto_mute
) {
4187 err
= snd_hda_add_new_ctls(codec
, cx_automute_mode_enum
);
4195 static int cx_auto_add_capture_volume(struct hda_codec
*codec
, hda_nid_t nid
,
4196 const char *label
, const char *pfx
,
4199 struct conexant_spec
*spec
= codec
->spec
;
4202 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
4203 hda_nid_t adc_nid
= spec
->adc_nids
[i
];
4204 int idx
= get_input_connection(codec
, adc_nid
, nid
);
4207 return cx_auto_add_volume_idx(codec
, label
, pfx
,
4208 cidx
, adc_nid
, HDA_INPUT
, idx
);
4213 static int cx_auto_add_boost_volume(struct hda_codec
*codec
, int idx
,
4214 const char *label
, int cidx
)
4216 struct conexant_spec
*spec
= codec
->spec
;
4220 nid
= spec
->imux_info
[idx
].pin
;
4221 if (get_wcaps(codec
, nid
) & AC_WCAP_IN_AMP
)
4222 return cx_auto_add_volume(codec
, label
, " Boost", cidx
,
4224 con
= __select_input_connection(codec
, spec
->imux_info
[idx
].adc
, nid
,
4228 for (i
= 0; i
< idx
; i
++) {
4229 if (spec
->imux_info
[i
].boost
== mux
)
4230 return 0; /* already present */
4233 if (get_wcaps(codec
, mux
) & AC_WCAP_OUT_AMP
) {
4234 spec
->imux_info
[idx
].boost
= mux
;
4235 return cx_auto_add_volume(codec
, label
, " Boost", 0,
4241 static int cx_auto_build_input_controls(struct hda_codec
*codec
)
4243 struct conexant_spec
*spec
= codec
->spec
;
4244 struct hda_input_mux
*imux
= &spec
->private_imux
;
4245 const char *prev_label
;
4246 int input_conn
[HDA_MAX_NUM_INPUTS
];
4248 int multi_connection
;
4250 multi_connection
= 0;
4251 for (i
= 0; i
< imux
->num_items
; i
++) {
4252 cidx
= get_input_connection(codec
, spec
->imux_info
[i
].adc
,
4253 spec
->imux_info
[i
].pin
);
4254 input_conn
[i
] = (spec
->imux_info
[i
].adc
<< 8) | cidx
;
4255 if (i
> 0 && input_conn
[i
] != input_conn
[0])
4256 multi_connection
= 1;
4261 for (i
= 0; i
< imux
->num_items
; i
++) {
4262 hda_nid_t nid
= spec
->imux_info
[i
].pin
;
4265 label
= hda_get_autocfg_input_label(codec
, &spec
->autocfg
,
4266 spec
->imux_info
[i
].index
);
4267 if (label
== prev_label
)
4273 err
= cx_auto_add_boost_volume(codec
, i
, label
, cidx
);
4277 if (!multi_connection
) {
4280 err
= cx_auto_add_capture_volume(codec
, nid
,
4281 "Capture", "", cidx
);
4283 err
= cx_auto_add_capture_volume(codec
, nid
,
4284 label
, " Capture", cidx
);
4290 if (spec
->private_imux
.num_items
> 1 && !spec
->auto_mic
) {
4291 err
= snd_hda_add_new_ctls(codec
, cx_auto_capture_mixers
);
4299 static int cx_auto_build_controls(struct hda_codec
*codec
)
4303 err
= cx_auto_build_output_controls(codec
);
4306 err
= cx_auto_build_input_controls(codec
);
4309 return conexant_build_controls(codec
);
4312 static int cx_auto_search_adcs(struct hda_codec
*codec
)
4314 struct conexant_spec
*spec
= codec
->spec
;
4315 hda_nid_t nid
, end_nid
;
4317 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
4318 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++) {
4319 unsigned int caps
= get_wcaps(codec
, nid
);
4320 if (get_wcaps_type(caps
) != AC_WID_AUD_IN
)
4322 if (caps
& AC_WCAP_DIGITAL
)
4324 if (snd_BUG_ON(spec
->num_adc_nids
>=
4325 ARRAY_SIZE(spec
->private_adc_nids
)))
4327 spec
->private_adc_nids
[spec
->num_adc_nids
++] = nid
;
4329 spec
->adc_nids
= spec
->private_adc_nids
;
4334 static const struct hda_codec_ops cx_auto_patch_ops
= {
4335 .build_controls
= cx_auto_build_controls
,
4336 .build_pcms
= conexant_build_pcms
,
4337 .init
= cx_auto_init
,
4338 .free
= conexant_free
,
4339 .unsol_event
= cx_auto_unsol_event
,
4340 #ifdef CONFIG_SND_HDA_POWER_SAVE
4341 .suspend
= conexant_suspend
,
4343 .reboot_notify
= snd_hda_shutup_pins
,
4346 static int patch_conexant_auto(struct hda_codec
*codec
)
4348 struct conexant_spec
*spec
;
4351 printk(KERN_INFO
"hda_codec: %s: BIOS auto-probing.\n",
4354 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4358 codec
->pin_amp_workaround
= 1;
4359 err
= cx_auto_search_adcs(codec
);
4362 err
= cx_auto_parse_auto_config(codec
);
4368 spec
->capture_stream
= &cx_auto_pcm_analog_capture
;
4369 codec
->patch_ops
= cx_auto_patch_ops
;
4371 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
4378 static const struct hda_codec_preset snd_hda_preset_conexant
[] = {
4379 { .id
= 0x14f15045, .name
= "CX20549 (Venice)",
4380 .patch
= patch_cxt5045
},
4381 { .id
= 0x14f15047, .name
= "CX20551 (Waikiki)",
4382 .patch
= patch_cxt5047
},
4383 { .id
= 0x14f15051, .name
= "CX20561 (Hermosa)",
4384 .patch
= patch_cxt5051
},
4385 { .id
= 0x14f15066, .name
= "CX20582 (Pebble)",
4386 .patch
= patch_cxt5066
},
4387 { .id
= 0x14f15067, .name
= "CX20583 (Pebble HSF)",
4388 .patch
= patch_cxt5066
},
4389 { .id
= 0x14f15068, .name
= "CX20584",
4390 .patch
= patch_cxt5066
},
4391 { .id
= 0x14f15069, .name
= "CX20585",
4392 .patch
= patch_cxt5066
},
4393 { .id
= 0x14f1506c, .name
= "CX20588",
4394 .patch
= patch_cxt5066
},
4395 { .id
= 0x14f1506e, .name
= "CX20590",
4396 .patch
= patch_cxt5066
},
4397 { .id
= 0x14f15097, .name
= "CX20631",
4398 .patch
= patch_conexant_auto
},
4399 { .id
= 0x14f15098, .name
= "CX20632",
4400 .patch
= patch_conexant_auto
},
4401 { .id
= 0x14f150a1, .name
= "CX20641",
4402 .patch
= patch_conexant_auto
},
4403 { .id
= 0x14f150a2, .name
= "CX20642",
4404 .patch
= patch_conexant_auto
},
4405 { .id
= 0x14f150ab, .name
= "CX20651",
4406 .patch
= patch_conexant_auto
},
4407 { .id
= 0x14f150ac, .name
= "CX20652",
4408 .patch
= patch_conexant_auto
},
4409 { .id
= 0x14f150b8, .name
= "CX20664",
4410 .patch
= patch_conexant_auto
},
4411 { .id
= 0x14f150b9, .name
= "CX20665",
4412 .patch
= patch_conexant_auto
},
4416 MODULE_ALIAS("snd-hda-codec-id:14f15045");
4417 MODULE_ALIAS("snd-hda-codec-id:14f15047");
4418 MODULE_ALIAS("snd-hda-codec-id:14f15051");
4419 MODULE_ALIAS("snd-hda-codec-id:14f15066");
4420 MODULE_ALIAS("snd-hda-codec-id:14f15067");
4421 MODULE_ALIAS("snd-hda-codec-id:14f15068");
4422 MODULE_ALIAS("snd-hda-codec-id:14f15069");
4423 MODULE_ALIAS("snd-hda-codec-id:14f1506c");
4424 MODULE_ALIAS("snd-hda-codec-id:14f1506e");
4425 MODULE_ALIAS("snd-hda-codec-id:14f15097");
4426 MODULE_ALIAS("snd-hda-codec-id:14f15098");
4427 MODULE_ALIAS("snd-hda-codec-id:14f150a1");
4428 MODULE_ALIAS("snd-hda-codec-id:14f150a2");
4429 MODULE_ALIAS("snd-hda-codec-id:14f150ab");
4430 MODULE_ALIAS("snd-hda-codec-id:14f150ac");
4431 MODULE_ALIAS("snd-hda-codec-id:14f150b8");
4432 MODULE_ALIAS("snd-hda-codec-id:14f150b9");
4434 MODULE_LICENSE("GPL");
4435 MODULE_DESCRIPTION("Conexant HD-audio codec");
4437 static struct hda_codec_preset_list conexant_list
= {
4438 .preset
= snd_hda_preset_conexant
,
4439 .owner
= THIS_MODULE
,
4442 static int __init
patch_conexant_init(void)
4444 return snd_hda_add_codec_preset(&conexant_list
);
4447 static void __exit
patch_conexant_exit(void)
4449 snd_hda_delete_codec_preset(&conexant_list
);
4452 module_init(patch_conexant_init
)
4453 module_exit(patch_conexant_exit
)