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
43 /* Conexant 5051 specific */
45 #define CXT5051_SPDIF_OUT 0x12
46 #define CXT5051_PORTB_EVENT 0x38
47 #define CXT5051_PORTC_EVENT 0x39
49 #define AUTO_MIC_PORTB (1 << 1)
50 #define AUTO_MIC_PORTC (1 << 2)
52 struct conexant_jack
{
56 struct snd_jack
*jack
;
66 struct conexant_spec
{
68 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 auto_mic
;
86 int auto_mic_ext
; /* autocfg.inputs[] index for ext mic */
87 unsigned int need_dac_fix
;
90 unsigned int num_adc_nids
;
92 hda_nid_t dig_in_nid
; /* digital-in NID; optional */
94 unsigned int cur_adc_idx
;
96 unsigned int cur_adc_stream_tag
;
97 unsigned int cur_adc_format
;
100 const struct hda_input_mux
*input_mux
;
101 hda_nid_t
*capsrc_nids
;
102 unsigned int cur_mux
[3];
105 const struct hda_channel_mode
*channel_mode
;
106 int num_channel_mode
;
108 /* PCM information */
109 struct hda_pcm pcm_rec
[2]; /* used in build_pcms() */
111 unsigned int spdif_route
;
114 struct snd_array jacks
;
116 /* dynamic controls, init_verbs and input_mux */
117 struct auto_pin_cfg autocfg
;
118 struct hda_input_mux private_imux
;
119 hda_nid_t private_dac_nids
[AUTO_CFG_MAX_OUTS
];
120 struct pin_dac_pair dac_info
[8];
123 unsigned int port_d_mode
;
124 unsigned int auto_mute
:1; /* used in auto-parser */
125 unsigned int dell_automute
:1;
126 unsigned int dell_vostro
:1;
127 unsigned int ideapad
:1;
128 unsigned int thinkpad
:1;
129 unsigned int hp_laptop
:1;
131 unsigned int ext_mic_present
;
132 unsigned int recording
;
133 void (*capture_prepare
)(struct hda_codec
*codec
);
134 void (*capture_cleanup
)(struct hda_codec
*codec
);
136 /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors)
137 * through the microphone jack.
138 * When the user enables this through a mixer switch, both internal and
139 * external microphones are disabled. Gain is fixed at 0dB. In this mode,
140 * we also allow the bias to be configured through a separate mixer
142 unsigned int dc_enable
;
143 unsigned int dc_input_bias
; /* offset into cxt5066_olpc_dc_bias */
144 unsigned int mic_boost
; /* offset into cxt5066_analog_mic_boost */
146 unsigned int beep_amp
;
149 static int conexant_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
150 struct hda_codec
*codec
,
151 struct snd_pcm_substream
*substream
)
153 struct conexant_spec
*spec
= codec
->spec
;
154 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
158 static int conexant_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
159 struct hda_codec
*codec
,
160 unsigned int stream_tag
,
162 struct snd_pcm_substream
*substream
)
164 struct conexant_spec
*spec
= codec
->spec
;
165 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
,
170 static int conexant_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
171 struct hda_codec
*codec
,
172 struct snd_pcm_substream
*substream
)
174 struct conexant_spec
*spec
= codec
->spec
;
175 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
181 static int conexant_dig_playback_pcm_open(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_dig_open(codec
, &spec
->multiout
);
189 static int conexant_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
190 struct hda_codec
*codec
,
191 struct snd_pcm_substream
*substream
)
193 struct conexant_spec
*spec
= codec
->spec
;
194 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
197 static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
198 struct hda_codec
*codec
,
199 unsigned int stream_tag
,
201 struct snd_pcm_substream
*substream
)
203 struct conexant_spec
*spec
= codec
->spec
;
204 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
212 static int conexant_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
213 struct hda_codec
*codec
,
214 unsigned int stream_tag
,
216 struct snd_pcm_substream
*substream
)
218 struct conexant_spec
*spec
= codec
->spec
;
219 if (spec
->capture_prepare
)
220 spec
->capture_prepare(codec
);
221 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
],
222 stream_tag
, 0, format
);
226 static int conexant_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
227 struct hda_codec
*codec
,
228 struct snd_pcm_substream
*substream
)
230 struct conexant_spec
*spec
= codec
->spec
;
231 snd_hda_codec_cleanup_stream(codec
, spec
->adc_nids
[substream
->number
]);
232 if (spec
->capture_cleanup
)
233 spec
->capture_cleanup(codec
);
239 static struct hda_pcm_stream conexant_pcm_analog_playback
= {
243 .nid
= 0, /* fill later */
245 .open
= conexant_playback_pcm_open
,
246 .prepare
= conexant_playback_pcm_prepare
,
247 .cleanup
= conexant_playback_pcm_cleanup
251 static struct hda_pcm_stream conexant_pcm_analog_capture
= {
255 .nid
= 0, /* fill later */
257 .prepare
= conexant_capture_pcm_prepare
,
258 .cleanup
= conexant_capture_pcm_cleanup
263 static struct hda_pcm_stream conexant_pcm_digital_playback
= {
267 .nid
= 0, /* fill later */
269 .open
= conexant_dig_playback_pcm_open
,
270 .close
= conexant_dig_playback_pcm_close
,
271 .prepare
= conexant_dig_playback_pcm_prepare
275 static struct hda_pcm_stream conexant_pcm_digital_capture
= {
279 /* NID is set in alc_build_pcms */
282 static int cx5051_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
283 struct hda_codec
*codec
,
284 unsigned int stream_tag
,
286 struct snd_pcm_substream
*substream
)
288 struct conexant_spec
*spec
= codec
->spec
;
289 spec
->cur_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
290 spec
->cur_adc_stream_tag
= stream_tag
;
291 spec
->cur_adc_format
= format
;
292 snd_hda_codec_setup_stream(codec
, spec
->cur_adc
, stream_tag
, 0, format
);
296 static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
297 struct hda_codec
*codec
,
298 struct snd_pcm_substream
*substream
)
300 struct conexant_spec
*spec
= codec
->spec
;
301 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
306 static struct hda_pcm_stream cx5051_pcm_analog_capture
= {
310 .nid
= 0, /* fill later */
312 .prepare
= cx5051_capture_pcm_prepare
,
313 .cleanup
= cx5051_capture_pcm_cleanup
317 static int conexant_build_pcms(struct hda_codec
*codec
)
319 struct conexant_spec
*spec
= codec
->spec
;
320 struct hda_pcm
*info
= spec
->pcm_rec
;
323 codec
->pcm_info
= info
;
325 info
->name
= "CONEXANT Analog";
326 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = conexant_pcm_analog_playback
;
327 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
=
328 spec
->multiout
.max_channels
;
329 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
330 spec
->multiout
.dac_nids
[0];
331 if (codec
->vendor_id
== 0x14f15051)
332 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
333 cx5051_pcm_analog_capture
;
335 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
336 conexant_pcm_analog_capture
;
337 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
= spec
->num_adc_nids
;
338 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
340 if (spec
->multiout
.dig_out_nid
) {
343 info
->name
= "Conexant Digital";
344 info
->pcm_type
= HDA_PCM_TYPE_SPDIF
;
345 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] =
346 conexant_pcm_digital_playback
;
347 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
348 spec
->multiout
.dig_out_nid
;
349 if (spec
->dig_in_nid
) {
350 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
351 conexant_pcm_digital_capture
;
352 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
=
360 static int conexant_mux_enum_info(struct snd_kcontrol
*kcontrol
,
361 struct snd_ctl_elem_info
*uinfo
)
363 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
364 struct conexant_spec
*spec
= codec
->spec
;
366 return snd_hda_input_mux_info(spec
->input_mux
, uinfo
);
369 static int conexant_mux_enum_get(struct snd_kcontrol
*kcontrol
,
370 struct snd_ctl_elem_value
*ucontrol
)
372 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
373 struct conexant_spec
*spec
= codec
->spec
;
374 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
376 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
380 static int conexant_mux_enum_put(struct snd_kcontrol
*kcontrol
,
381 struct snd_ctl_elem_value
*ucontrol
)
383 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
384 struct conexant_spec
*spec
= codec
->spec
;
385 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
387 return snd_hda_input_mux_put(codec
, spec
->input_mux
, ucontrol
,
388 spec
->capsrc_nids
[adc_idx
],
389 &spec
->cur_mux
[adc_idx
]);
392 #ifdef CONFIG_SND_HDA_INPUT_JACK
393 static void conexant_free_jack_priv(struct snd_jack
*jack
)
395 struct conexant_jack
*jacks
= jack
->private_data
;
400 static int conexant_add_jack(struct hda_codec
*codec
,
401 hda_nid_t nid
, int type
)
403 struct conexant_spec
*spec
;
404 struct conexant_jack
*jack
;
409 snd_array_init(&spec
->jacks
, sizeof(*jack
), 32);
410 jack
= snd_array_new(&spec
->jacks
);
411 name
= (type
== SND_JACK_HEADPHONE
) ? "Headphone" : "Mic" ;
419 err
= snd_jack_new(codec
->bus
->card
, name
, type
, &jack
->jack
);
422 jack
->jack
->private_data
= jack
;
423 jack
->jack
->private_free
= conexant_free_jack_priv
;
427 static void conexant_report_jack(struct hda_codec
*codec
, hda_nid_t nid
)
429 struct conexant_spec
*spec
= codec
->spec
;
430 struct conexant_jack
*jacks
= spec
->jacks
.list
;
434 for (i
= 0; i
< spec
->jacks
.used
; i
++) {
435 if (jacks
->nid
== nid
) {
436 unsigned int present
;
437 present
= snd_hda_jack_detect(codec
, nid
);
439 present
= (present
) ? jacks
->type
: 0 ;
441 snd_jack_report(jacks
->jack
,
449 static int conexant_init_jacks(struct hda_codec
*codec
)
451 struct conexant_spec
*spec
= codec
->spec
;
454 for (i
= 0; i
< spec
->num_init_verbs
; i
++) {
455 const struct hda_verb
*hv
;
457 hv
= spec
->init_verbs
[i
];
460 switch (hv
->param
^ AC_USRSP_EN
) {
461 case CONEXANT_HP_EVENT
:
462 err
= conexant_add_jack(codec
, hv
->nid
,
464 conexant_report_jack(codec
, hv
->nid
);
466 case CXT5051_PORTC_EVENT
:
467 case CONEXANT_MIC_EVENT
:
468 err
= conexant_add_jack(codec
, hv
->nid
,
469 SND_JACK_MICROPHONE
);
470 conexant_report_jack(codec
, hv
->nid
);
482 static inline void conexant_report_jack(struct hda_codec
*codec
, hda_nid_t nid
)
486 static inline int conexant_init_jacks(struct hda_codec
*codec
)
492 static int conexant_init(struct hda_codec
*codec
)
494 struct conexant_spec
*spec
= codec
->spec
;
497 for (i
= 0; i
< spec
->num_init_verbs
; i
++)
498 snd_hda_sequence_write(codec
, spec
->init_verbs
[i
]);
502 static void conexant_free(struct hda_codec
*codec
)
504 #ifdef CONFIG_SND_HDA_INPUT_JACK
505 struct conexant_spec
*spec
= codec
->spec
;
506 if (spec
->jacks
.list
) {
507 struct conexant_jack
*jacks
= spec
->jacks
.list
;
509 for (i
= 0; i
< spec
->jacks
.used
; i
++, jacks
++) {
511 snd_device_free(codec
->bus
->card
, jacks
->jack
);
513 snd_array_free(&spec
->jacks
);
516 snd_hda_detach_beep_device(codec
);
520 static struct snd_kcontrol_new cxt_capture_mixers
[] = {
522 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
523 .name
= "Capture Source",
524 .info
= conexant_mux_enum_info
,
525 .get
= conexant_mux_enum_get
,
526 .put
= conexant_mux_enum_put
531 #ifdef CONFIG_SND_HDA_INPUT_BEEP
532 /* additional beep mixers; the actual parameters are overwritten at build */
533 static struct snd_kcontrol_new cxt_beep_mixer
[] = {
534 HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT
),
535 HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT
),
540 static const char * const slave_vols
[] = {
541 "Headphone Playback Volume",
542 "Speaker Playback Volume",
546 static const char * const slave_sws
[] = {
547 "Headphone Playback Switch",
548 "Speaker Playback Switch",
552 static int conexant_build_controls(struct hda_codec
*codec
)
554 struct conexant_spec
*spec
= codec
->spec
;
558 for (i
= 0; i
< spec
->num_mixers
; i
++) {
559 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
563 if (spec
->multiout
.dig_out_nid
) {
564 err
= snd_hda_create_spdif_out_ctls(codec
,
565 spec
->multiout
.dig_out_nid
);
568 err
= snd_hda_create_spdif_share_sw(codec
,
572 spec
->multiout
.share_spdif
= 1;
574 if (spec
->dig_in_nid
) {
575 err
= snd_hda_create_spdif_in_ctls(codec
,spec
->dig_in_nid
);
580 /* if we have no master control, let's create it */
581 if (spec
->vmaster_nid
&&
582 !snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
583 unsigned int vmaster_tlv
[4];
584 snd_hda_set_vmaster_tlv(codec
, spec
->vmaster_nid
,
585 HDA_OUTPUT
, vmaster_tlv
);
586 err
= snd_hda_add_vmaster(codec
, "Master Playback Volume",
587 vmaster_tlv
, slave_vols
);
591 if (spec
->vmaster_nid
&&
592 !snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
593 err
= snd_hda_add_vmaster(codec
, "Master Playback Switch",
599 if (spec
->input_mux
) {
600 err
= snd_hda_add_new_ctls(codec
, cxt_capture_mixers
);
605 #ifdef CONFIG_SND_HDA_INPUT_BEEP
606 /* create beep controls if needed */
607 if (spec
->beep_amp
) {
608 struct snd_kcontrol_new
*knew
;
609 for (knew
= cxt_beep_mixer
; knew
->name
; knew
++) {
610 struct snd_kcontrol
*kctl
;
611 kctl
= snd_ctl_new1(knew
, codec
);
614 kctl
->private_value
= spec
->beep_amp
;
615 err
= snd_hda_ctl_add(codec
, 0, kctl
);
625 #ifdef CONFIG_SND_HDA_POWER_SAVE
626 static int conexant_suspend(struct hda_codec
*codec
, pm_message_t state
)
628 snd_hda_shutup_pins(codec
);
633 static struct hda_codec_ops conexant_patch_ops
= {
634 .build_controls
= conexant_build_controls
,
635 .build_pcms
= conexant_build_pcms
,
636 .init
= conexant_init
,
637 .free
= conexant_free
,
638 #ifdef CONFIG_SND_HDA_POWER_SAVE
639 .suspend
= conexant_suspend
,
641 .reboot_notify
= snd_hda_shutup_pins
,
644 #ifdef CONFIG_SND_HDA_INPUT_BEEP
645 #define set_beep_amp(spec, nid, idx, dir) \
646 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir))
648 #define set_beep_amp(spec, nid, idx, dir) /* NOP */
653 * the private value = nid | (invert << 8)
656 #define cxt_eapd_info snd_ctl_boolean_mono_info
658 static int cxt_eapd_get(struct snd_kcontrol
*kcontrol
,
659 struct snd_ctl_elem_value
*ucontrol
)
661 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
662 struct conexant_spec
*spec
= codec
->spec
;
663 int invert
= (kcontrol
->private_value
>> 8) & 1;
665 ucontrol
->value
.integer
.value
[0] = !spec
->cur_eapd
;
667 ucontrol
->value
.integer
.value
[0] = spec
->cur_eapd
;
672 static int cxt_eapd_put(struct snd_kcontrol
*kcontrol
,
673 struct snd_ctl_elem_value
*ucontrol
)
675 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
676 struct conexant_spec
*spec
= codec
->spec
;
677 int invert
= (kcontrol
->private_value
>> 8) & 1;
678 hda_nid_t nid
= kcontrol
->private_value
& 0xff;
681 eapd
= !!ucontrol
->value
.integer
.value
[0];
684 if (eapd
== spec
->cur_eapd
)
687 spec
->cur_eapd
= eapd
;
688 snd_hda_codec_write_cache(codec
, nid
,
689 0, AC_VERB_SET_EAPD_BTLENABLE
,
694 /* controls for test mode */
695 #ifdef CONFIG_SND_DEBUG
697 #define CXT_EAPD_SWITCH(xname, nid, mask) \
698 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
699 .info = cxt_eapd_info, \
700 .get = cxt_eapd_get, \
701 .put = cxt_eapd_put, \
702 .private_value = nid | (mask<<16) }
706 static int conexant_ch_mode_info(struct snd_kcontrol
*kcontrol
,
707 struct snd_ctl_elem_info
*uinfo
)
709 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
710 struct conexant_spec
*spec
= codec
->spec
;
711 return snd_hda_ch_mode_info(codec
, uinfo
, spec
->channel_mode
,
712 spec
->num_channel_mode
);
715 static int conexant_ch_mode_get(struct snd_kcontrol
*kcontrol
,
716 struct snd_ctl_elem_value
*ucontrol
)
718 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
719 struct conexant_spec
*spec
= codec
->spec
;
720 return snd_hda_ch_mode_get(codec
, ucontrol
, spec
->channel_mode
,
721 spec
->num_channel_mode
,
722 spec
->multiout
.max_channels
);
725 static int conexant_ch_mode_put(struct snd_kcontrol
*kcontrol
,
726 struct snd_ctl_elem_value
*ucontrol
)
728 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
729 struct conexant_spec
*spec
= codec
->spec
;
730 int err
= snd_hda_ch_mode_put(codec
, ucontrol
, spec
->channel_mode
,
731 spec
->num_channel_mode
,
732 &spec
->multiout
.max_channels
);
733 if (err
>= 0 && spec
->need_dac_fix
)
734 spec
->multiout
.num_dacs
= spec
->multiout
.max_channels
/ 2;
738 #define CXT_PIN_MODE(xname, nid, dir) \
739 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
740 .info = conexant_ch_mode_info, \
741 .get = conexant_ch_mode_get, \
742 .put = conexant_ch_mode_put, \
743 .private_value = nid | (dir<<16) }
745 #endif /* CONFIG_SND_DEBUG */
747 /* Conexant 5045 specific */
749 static hda_nid_t cxt5045_dac_nids
[1] = { 0x19 };
750 static hda_nid_t cxt5045_adc_nids
[1] = { 0x1a };
751 static hda_nid_t cxt5045_capsrc_nids
[1] = { 0x1a };
752 #define CXT5045_SPDIF_OUT 0x18
754 static struct hda_channel_mode cxt5045_modes
[1] = {
758 static struct hda_input_mux cxt5045_capture_source
= {
766 static struct hda_input_mux cxt5045_capture_source_benq
= {
777 static struct hda_input_mux cxt5045_capture_source_hp530
= {
785 /* turn on/off EAPD (+ mute HP) as a master switch */
786 static int cxt5045_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
787 struct snd_ctl_elem_value
*ucontrol
)
789 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
790 struct conexant_spec
*spec
= codec
->spec
;
793 if (!cxt_eapd_put(kcontrol
, ucontrol
))
796 /* toggle internal speakers mute depending of presence of
799 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
800 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
803 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
804 snd_hda_codec_amp_stereo(codec
, 0x11, HDA_OUTPUT
, 0,
809 /* bind volumes of both NID 0x10 and 0x11 */
810 static struct hda_bind_ctls cxt5045_hp_bind_master_vol
= {
811 .ops
= &snd_hda_bind_vol
,
813 HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT
),
814 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT
),
819 /* toggle input of built-in and mic jack appropriately */
820 static void cxt5045_hp_automic(struct hda_codec
*codec
)
822 static struct hda_verb mic_jack_on
[] = {
823 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
824 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
827 static struct hda_verb mic_jack_off
[] = {
828 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
829 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
832 unsigned int present
;
834 present
= snd_hda_jack_detect(codec
, 0x12);
836 snd_hda_sequence_write(codec
, mic_jack_on
);
838 snd_hda_sequence_write(codec
, mic_jack_off
);
842 /* mute internal speaker if HP is plugged */
843 static void cxt5045_hp_automute(struct hda_codec
*codec
)
845 struct conexant_spec
*spec
= codec
->spec
;
848 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x11);
850 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
851 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
855 /* unsolicited event for HP jack sensing */
856 static void cxt5045_hp_unsol_event(struct hda_codec
*codec
,
861 case CONEXANT_HP_EVENT
:
862 cxt5045_hp_automute(codec
);
864 case CONEXANT_MIC_EVENT
:
865 cxt5045_hp_automic(codec
);
871 static struct snd_kcontrol_new cxt5045_mixers
[] = {
872 HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x1a, 0x01, HDA_INPUT
),
873 HDA_CODEC_MUTE("Internal Mic Capture Switch", 0x1a, 0x01, HDA_INPUT
),
874 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1a, 0x02, HDA_INPUT
),
875 HDA_CODEC_MUTE("Mic Capture Switch", 0x1a, 0x02, HDA_INPUT
),
876 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT
),
877 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT
),
878 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
879 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x1, HDA_INPUT
),
880 HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
881 HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
882 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol
),
884 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
885 .name
= "Master Playback Switch",
886 .info
= cxt_eapd_info
,
888 .put
= cxt5045_hp_master_sw_put
,
889 .private_value
= 0x10,
895 static struct snd_kcontrol_new cxt5045_benq_mixers
[] = {
896 HDA_CODEC_VOLUME("CD Capture Volume", 0x1a, 0x04, HDA_INPUT
),
897 HDA_CODEC_MUTE("CD Capture Switch", 0x1a, 0x04, HDA_INPUT
),
898 HDA_CODEC_VOLUME("CD Playback Volume", 0x17, 0x4, HDA_INPUT
),
899 HDA_CODEC_MUTE("CD Playback Switch", 0x17, 0x4, HDA_INPUT
),
901 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1a, 0x03, HDA_INPUT
),
902 HDA_CODEC_MUTE("Line In Capture Switch", 0x1a, 0x03, HDA_INPUT
),
903 HDA_CODEC_VOLUME("Line In Playback Volume", 0x17, 0x3, HDA_INPUT
),
904 HDA_CODEC_MUTE("Line In Playback Switch", 0x17, 0x3, HDA_INPUT
),
906 HDA_CODEC_VOLUME("Mixer Capture Volume", 0x1a, 0x0, HDA_INPUT
),
907 HDA_CODEC_MUTE("Mixer Capture Switch", 0x1a, 0x0, HDA_INPUT
),
912 static struct snd_kcontrol_new cxt5045_mixers_hp530
[] = {
913 HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x1a, 0x02, HDA_INPUT
),
914 HDA_CODEC_MUTE("Internal Mic Capture Switch", 0x1a, 0x02, HDA_INPUT
),
915 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1a, 0x01, HDA_INPUT
),
916 HDA_CODEC_MUTE("Mic Capture Switch", 0x1a, 0x01, HDA_INPUT
),
917 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT
),
918 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT
),
919 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
920 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
921 HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
922 HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x1, HDA_INPUT
),
923 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol
),
925 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
926 .name
= "Master Playback Switch",
927 .info
= cxt_eapd_info
,
929 .put
= cxt5045_hp_master_sw_put
,
930 .private_value
= 0x10,
936 static struct hda_verb cxt5045_init_verbs
[] = {
938 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
939 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
941 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
942 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
943 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
944 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
945 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
946 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
947 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
948 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
949 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
950 /* Record selector: Internal mic */
951 {0x1a, AC_VERB_SET_CONNECT_SEL
,0x1},
952 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
953 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
954 /* SPDIF route: PCM */
955 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
956 { 0x13, AC_VERB_SET_CONNECT_SEL
, 0x0 },
958 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2 }, /* default on */
962 static struct hda_verb cxt5045_benq_init_verbs
[] = {
963 /* Internal Mic, Mic */
964 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
965 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
966 /* Line In,HP, Amp */
967 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
968 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
969 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
970 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
971 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
972 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
973 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
974 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
975 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
976 /* Record selector: Internal mic */
977 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x1},
978 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
979 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
980 /* SPDIF route: PCM */
981 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
982 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0},
984 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
988 static struct hda_verb cxt5045_hp_sense_init_verbs
[] = {
989 /* pin sensing on HP jack */
990 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
994 static struct hda_verb cxt5045_mic_sense_init_verbs
[] = {
995 /* pin sensing on HP jack */
996 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
1000 #ifdef CONFIG_SND_DEBUG
1001 /* Test configuration for debugging, modelled after the ALC260 test
1004 static struct hda_input_mux cxt5045_test_capture_source
= {
1008 { "MIC1 pin", 0x1 },
1009 { "LINE1 pin", 0x2 },
1010 { "HP-OUT pin", 0x3 },
1015 static struct snd_kcontrol_new cxt5045_test_mixer
[] = {
1017 /* Output controls */
1018 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT
),
1019 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT
),
1020 HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
1021 HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
1022 HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
1023 HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
1025 /* Modes for retasking pin widgets */
1026 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT
),
1027 CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT
),
1029 /* EAPD Switch Control */
1030 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
1032 /* Loopback mixer controls */
1034 HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT
),
1035 HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT
),
1036 HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT
),
1037 HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT
),
1038 HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT
),
1039 HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT
),
1040 HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT
),
1041 HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT
),
1042 HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT
),
1043 HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT
),
1045 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1046 .name
= "Input Source",
1047 .info
= conexant_mux_enum_info
,
1048 .get
= conexant_mux_enum_get
,
1049 .put
= conexant_mux_enum_put
,
1051 /* Audio input controls */
1052 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT
),
1053 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT
),
1054 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT
),
1055 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT
),
1056 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT
),
1057 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT
),
1058 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT
),
1059 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT
),
1060 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT
),
1061 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT
),
1065 static struct hda_verb cxt5045_test_init_verbs
[] = {
1066 /* Set connections */
1067 { 0x10, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1068 { 0x11, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1069 { 0x12, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1070 /* Enable retasking pins as output, initially without power amp */
1071 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1072 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1074 /* Disable digital (SPDIF) pins initially, but users can enable
1075 * them via a mixer switch. In the case of SPDIF-out, this initverb
1076 * payload also sets the generation to 0, output to be in "consumer"
1077 * PCM format, copyright asserted, no pre-emphasis and no validity
1080 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1081 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
1083 /* Start with output sum widgets muted and their output gains at min */
1084 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1085 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1087 /* Unmute retasking pin widget output buffers since the default
1088 * state appears to be output. As the pin mode is changed by the
1089 * user the pin mode control will take care of enabling the pin's
1090 * input/output buffers as needed.
1092 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1093 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1095 /* Mute capture amp left and right */
1096 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1098 /* Set ADC connection select to match default mixer setting (mic1
1101 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1102 {0x17, AC_VERB_SET_CONNECT_SEL
, 0x00},
1104 /* Mute all inputs to mixer widget (even unconnected ones) */
1105 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* Mixer pin */
1106 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* Mic1 pin */
1107 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* Line pin */
1108 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* HP pin */
1109 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
1116 /* initialize jack-sensing, too */
1117 static int cxt5045_init(struct hda_codec
*codec
)
1119 conexant_init(codec
);
1120 cxt5045_hp_automute(codec
);
1126 CXT5045_LAPTOP_HPSENSE
,
1127 CXT5045_LAPTOP_MICSENSE
,
1128 CXT5045_LAPTOP_HPMICSENSE
,
1130 CXT5045_LAPTOP_HP530
,
1131 #ifdef CONFIG_SND_DEBUG
1137 static const char * const cxt5045_models
[CXT5045_MODELS
] = {
1138 [CXT5045_LAPTOP_HPSENSE
] = "laptop-hpsense",
1139 [CXT5045_LAPTOP_MICSENSE
] = "laptop-micsense",
1140 [CXT5045_LAPTOP_HPMICSENSE
] = "laptop-hpmicsense",
1141 [CXT5045_BENQ
] = "benq",
1142 [CXT5045_LAPTOP_HP530
] = "laptop-hp530",
1143 #ifdef CONFIG_SND_DEBUG
1144 [CXT5045_TEST
] = "test",
1148 static struct snd_pci_quirk cxt5045_cfg_tbl
[] = {
1149 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530
),
1150 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1151 CXT5045_LAPTOP_HPSENSE
),
1152 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE
),
1153 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ
),
1154 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE
),
1155 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE
),
1156 SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505",
1157 CXT5045_LAPTOP_HPMICSENSE
),
1158 SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1159 SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1160 SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1161 SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell",
1162 CXT5045_LAPTOP_HPMICSENSE
),
1163 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE
),
1167 static int patch_cxt5045(struct hda_codec
*codec
)
1169 struct conexant_spec
*spec
;
1172 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1176 codec
->pin_amp_workaround
= 1;
1178 spec
->multiout
.max_channels
= 2;
1179 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5045_dac_nids
);
1180 spec
->multiout
.dac_nids
= cxt5045_dac_nids
;
1181 spec
->multiout
.dig_out_nid
= CXT5045_SPDIF_OUT
;
1182 spec
->num_adc_nids
= 1;
1183 spec
->adc_nids
= cxt5045_adc_nids
;
1184 spec
->capsrc_nids
= cxt5045_capsrc_nids
;
1185 spec
->input_mux
= &cxt5045_capture_source
;
1186 spec
->num_mixers
= 1;
1187 spec
->mixers
[0] = cxt5045_mixers
;
1188 spec
->num_init_verbs
= 1;
1189 spec
->init_verbs
[0] = cxt5045_init_verbs
;
1190 spec
->spdif_route
= 0;
1191 spec
->num_channel_mode
= ARRAY_SIZE(cxt5045_modes
);
1192 spec
->channel_mode
= cxt5045_modes
;
1194 set_beep_amp(spec
, 0x16, 0, 1);
1196 codec
->patch_ops
= conexant_patch_ops
;
1198 board_config
= snd_hda_check_board_config(codec
, CXT5045_MODELS
,
1201 switch (board_config
) {
1202 case CXT5045_LAPTOP_HPSENSE
:
1203 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1204 spec
->input_mux
= &cxt5045_capture_source
;
1205 spec
->num_init_verbs
= 2;
1206 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1207 spec
->mixers
[0] = cxt5045_mixers
;
1208 codec
->patch_ops
.init
= cxt5045_init
;
1210 case CXT5045_LAPTOP_MICSENSE
:
1211 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1212 spec
->input_mux
= &cxt5045_capture_source
;
1213 spec
->num_init_verbs
= 2;
1214 spec
->init_verbs
[1] = cxt5045_mic_sense_init_verbs
;
1215 spec
->mixers
[0] = cxt5045_mixers
;
1216 codec
->patch_ops
.init
= cxt5045_init
;
1219 case CXT5045_LAPTOP_HPMICSENSE
:
1220 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1221 spec
->input_mux
= &cxt5045_capture_source
;
1222 spec
->num_init_verbs
= 3;
1223 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1224 spec
->init_verbs
[2] = cxt5045_mic_sense_init_verbs
;
1225 spec
->mixers
[0] = cxt5045_mixers
;
1226 codec
->patch_ops
.init
= cxt5045_init
;
1229 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1230 spec
->input_mux
= &cxt5045_capture_source_benq
;
1231 spec
->num_init_verbs
= 1;
1232 spec
->init_verbs
[0] = cxt5045_benq_init_verbs
;
1233 spec
->mixers
[0] = cxt5045_mixers
;
1234 spec
->mixers
[1] = cxt5045_benq_mixers
;
1235 spec
->num_mixers
= 2;
1236 codec
->patch_ops
.init
= cxt5045_init
;
1238 case CXT5045_LAPTOP_HP530
:
1239 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1240 spec
->input_mux
= &cxt5045_capture_source_hp530
;
1241 spec
->num_init_verbs
= 2;
1242 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1243 spec
->mixers
[0] = cxt5045_mixers_hp530
;
1244 codec
->patch_ops
.init
= cxt5045_init
;
1246 #ifdef CONFIG_SND_DEBUG
1248 spec
->input_mux
= &cxt5045_test_capture_source
;
1249 spec
->mixers
[0] = cxt5045_test_mixer
;
1250 spec
->init_verbs
[0] = cxt5045_test_init_verbs
;
1256 switch (codec
->subsystem_id
>> 16) {
1261 /* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have
1262 * really bad sound over 0dB on NID 0x17. Fix max PCM level to
1263 * 0 dB (originally it has 0x2b steps with 0dB offset 0x14)
1265 snd_hda_override_amp_caps(codec
, 0x17, HDA_INPUT
,
1266 (0x14 << AC_AMPCAP_OFFSET_SHIFT
) |
1267 (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
1268 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
1269 (1 << AC_AMPCAP_MUTE_SHIFT
));
1274 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
1280 /* Conexant 5047 specific */
1281 #define CXT5047_SPDIF_OUT 0x11
1283 static hda_nid_t cxt5047_dac_nids
[1] = { 0x10 }; /* 0x1c */
1284 static hda_nid_t cxt5047_adc_nids
[1] = { 0x12 };
1285 static hda_nid_t cxt5047_capsrc_nids
[1] = { 0x1a };
1287 static struct hda_channel_mode cxt5047_modes
[1] = {
1291 static struct hda_input_mux cxt5047_toshiba_capture_source
= {
1299 /* turn on/off EAPD (+ mute HP) as a master switch */
1300 static int cxt5047_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1301 struct snd_ctl_elem_value
*ucontrol
)
1303 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1304 struct conexant_spec
*spec
= codec
->spec
;
1307 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1310 /* toggle internal speakers mute depending of presence of
1311 * the headphone jack
1313 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
1314 /* NOTE: Conexat codec needs the index for *OUTPUT* amp of
1315 * pin widgets unlike other codecs. In this case, we need to
1316 * set index 0x01 for the volume from the mixer amp 0x19.
1318 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0x01,
1319 HDA_AMP_MUTE
, bits
);
1320 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
1321 snd_hda_codec_amp_stereo(codec
, 0x13, HDA_OUTPUT
, 0,
1322 HDA_AMP_MUTE
, bits
);
1326 /* mute internal speaker if HP is plugged */
1327 static void cxt5047_hp_automute(struct hda_codec
*codec
)
1329 struct conexant_spec
*spec
= codec
->spec
;
1332 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x13);
1334 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
1335 /* See the note in cxt5047_hp_master_sw_put */
1336 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0x01,
1337 HDA_AMP_MUTE
, bits
);
1340 /* toggle input of built-in and mic jack appropriately */
1341 static void cxt5047_hp_automic(struct hda_codec
*codec
)
1343 static struct hda_verb mic_jack_on
[] = {
1344 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1345 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1348 static struct hda_verb mic_jack_off
[] = {
1349 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1350 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1353 unsigned int present
;
1355 present
= snd_hda_jack_detect(codec
, 0x15);
1357 snd_hda_sequence_write(codec
, mic_jack_on
);
1359 snd_hda_sequence_write(codec
, mic_jack_off
);
1362 /* unsolicited event for HP jack sensing */
1363 static void cxt5047_hp_unsol_event(struct hda_codec
*codec
,
1366 switch (res
>> 26) {
1367 case CONEXANT_HP_EVENT
:
1368 cxt5047_hp_automute(codec
);
1370 case CONEXANT_MIC_EVENT
:
1371 cxt5047_hp_automic(codec
);
1376 static struct snd_kcontrol_new cxt5047_base_mixers
[] = {
1377 HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT
),
1378 HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT
),
1379 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT
),
1380 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT
),
1381 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT
),
1382 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT
),
1383 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT
),
1385 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1386 .name
= "Master Playback Switch",
1387 .info
= cxt_eapd_info
,
1388 .get
= cxt_eapd_get
,
1389 .put
= cxt5047_hp_master_sw_put
,
1390 .private_value
= 0x13,
1396 static struct snd_kcontrol_new cxt5047_hp_spk_mixers
[] = {
1397 /* See the note in cxt5047_hp_master_sw_put */
1398 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT
),
1399 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1403 static struct snd_kcontrol_new cxt5047_hp_only_mixers
[] = {
1404 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1408 static struct hda_verb cxt5047_init_verbs
[] = {
1409 /* Line in, Mic, Built-in Mic */
1410 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1411 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1412 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1414 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1415 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* mixer(0x19) */
1416 {0x1d, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* mixer(0x19) */
1417 /* Record selector: Mic */
1418 {0x12, AC_VERB_SET_CONNECT_SEL
,0x03},
1419 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
,
1420 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
1421 {0x1A, AC_VERB_SET_CONNECT_SEL
,0x02},
1422 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1423 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x00},
1424 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1425 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x03},
1426 /* SPDIF route: PCM */
1427 { 0x18, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1428 /* Enable unsolicited events */
1429 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
1430 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
1434 /* configuration for Toshiba Laptops */
1435 static struct hda_verb cxt5047_toshiba_init_verbs
[] = {
1436 {0x13, AC_VERB_SET_EAPD_BTLENABLE
, 0x0}, /* default off */
1440 /* Test configuration for debugging, modelled after the ALC260 test
1443 #ifdef CONFIG_SND_DEBUG
1444 static struct hda_input_mux cxt5047_test_capture_source
= {
1447 { "LINE1 pin", 0x0 },
1448 { "MIC1 pin", 0x1 },
1449 { "MIC2 pin", 0x2 },
1454 static struct snd_kcontrol_new cxt5047_test_mixer
[] = {
1456 /* Output only controls */
1457 HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT
),
1458 HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT
),
1459 HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT
),
1460 HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT
),
1461 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
1462 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT
),
1463 HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
1464 HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
1465 HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT
),
1466 HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT
),
1467 HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT
),
1468 HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT
),
1470 /* Modes for retasking pin widgets */
1471 CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT
),
1472 CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT
),
1474 /* EAPD Switch Control */
1475 CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0),
1477 /* Loopback mixer controls */
1478 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT
),
1479 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT
),
1480 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT
),
1481 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT
),
1482 HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT
),
1483 HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT
),
1484 HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT
),
1485 HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT
),
1487 HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT
),
1488 HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT
),
1489 HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT
),
1490 HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT
),
1491 HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT
),
1492 HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT
),
1493 HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT
),
1494 HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT
),
1496 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1497 .name
= "Input Source",
1498 .info
= conexant_mux_enum_info
,
1499 .get
= conexant_mux_enum_get
,
1500 .put
= conexant_mux_enum_put
,
1502 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT
),
1507 static struct hda_verb cxt5047_test_init_verbs
[] = {
1508 /* Enable retasking pins as output, initially without power amp */
1509 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1510 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1511 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1513 /* Disable digital (SPDIF) pins initially, but users can enable
1514 * them via a mixer switch. In the case of SPDIF-out, this initverb
1515 * payload also sets the generation to 0, output to be in "consumer"
1516 * PCM format, copyright asserted, no pre-emphasis and no validity
1519 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
1521 /* Ensure mic1, mic2, line1 pin widgets take input from the
1522 * OUT1 sum bus when acting as an output.
1524 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0},
1525 {0x1b, AC_VERB_SET_CONNECT_SEL
, 0},
1527 /* Start with output sum widgets muted and their output gains at min */
1528 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1529 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1531 /* Unmute retasking pin widget output buffers since the default
1532 * state appears to be output. As the pin mode is changed by the
1533 * user the pin mode control will take care of enabling the pin's
1534 * input/output buffers as needed.
1536 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1537 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1538 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1540 /* Mute capture amp left and right */
1541 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1543 /* Set ADC connection select to match default mixer setting (mic1
1546 {0x12, AC_VERB_SET_CONNECT_SEL
, 0x00},
1548 /* Mute all inputs to mixer widget (even unconnected ones) */
1549 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* mic1 pin */
1550 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* mic2 pin */
1551 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* line1 pin */
1552 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* line2 pin */
1553 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
1554 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)}, /* Beep-gen pin */
1555 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)}, /* Line-out pin */
1556 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)}, /* HP-pin pin */
1563 /* initialize jack-sensing, too */
1564 static int cxt5047_hp_init(struct hda_codec
*codec
)
1566 conexant_init(codec
);
1567 cxt5047_hp_automute(codec
);
1573 CXT5047_LAPTOP
, /* Laptops w/o EAPD support */
1574 CXT5047_LAPTOP_HP
, /* Some HP laptops */
1575 CXT5047_LAPTOP_EAPD
, /* Laptops with EAPD support */
1576 #ifdef CONFIG_SND_DEBUG
1582 static const char * const cxt5047_models
[CXT5047_MODELS
] = {
1583 [CXT5047_LAPTOP
] = "laptop",
1584 [CXT5047_LAPTOP_HP
] = "laptop-hp",
1585 [CXT5047_LAPTOP_EAPD
] = "laptop-eapd",
1586 #ifdef CONFIG_SND_DEBUG
1587 [CXT5047_TEST
] = "test",
1591 static struct snd_pci_quirk cxt5047_cfg_tbl
[] = {
1592 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP
),
1593 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1595 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD
),
1599 static int patch_cxt5047(struct hda_codec
*codec
)
1601 struct conexant_spec
*spec
;
1604 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1608 codec
->pin_amp_workaround
= 1;
1610 spec
->multiout
.max_channels
= 2;
1611 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5047_dac_nids
);
1612 spec
->multiout
.dac_nids
= cxt5047_dac_nids
;
1613 spec
->multiout
.dig_out_nid
= CXT5047_SPDIF_OUT
;
1614 spec
->num_adc_nids
= 1;
1615 spec
->adc_nids
= cxt5047_adc_nids
;
1616 spec
->capsrc_nids
= cxt5047_capsrc_nids
;
1617 spec
->num_mixers
= 1;
1618 spec
->mixers
[0] = cxt5047_base_mixers
;
1619 spec
->num_init_verbs
= 1;
1620 spec
->init_verbs
[0] = cxt5047_init_verbs
;
1621 spec
->spdif_route
= 0;
1622 spec
->num_channel_mode
= ARRAY_SIZE(cxt5047_modes
),
1623 spec
->channel_mode
= cxt5047_modes
,
1625 codec
->patch_ops
= conexant_patch_ops
;
1627 board_config
= snd_hda_check_board_config(codec
, CXT5047_MODELS
,
1630 switch (board_config
) {
1631 case CXT5047_LAPTOP
:
1632 spec
->num_mixers
= 2;
1633 spec
->mixers
[1] = cxt5047_hp_spk_mixers
;
1634 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1636 case CXT5047_LAPTOP_HP
:
1637 spec
->num_mixers
= 2;
1638 spec
->mixers
[1] = cxt5047_hp_only_mixers
;
1639 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1640 codec
->patch_ops
.init
= cxt5047_hp_init
;
1642 case CXT5047_LAPTOP_EAPD
:
1643 spec
->input_mux
= &cxt5047_toshiba_capture_source
;
1644 spec
->num_mixers
= 2;
1645 spec
->mixers
[1] = cxt5047_hp_spk_mixers
;
1646 spec
->num_init_verbs
= 2;
1647 spec
->init_verbs
[1] = cxt5047_toshiba_init_verbs
;
1648 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1650 #ifdef CONFIG_SND_DEBUG
1652 spec
->input_mux
= &cxt5047_test_capture_source
;
1653 spec
->mixers
[0] = cxt5047_test_mixer
;
1654 spec
->init_verbs
[0] = cxt5047_test_init_verbs
;
1655 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1658 spec
->vmaster_nid
= 0x13;
1660 switch (codec
->subsystem_id
>> 16) {
1662 /* HP laptops have really bad sound over 0 dB on NID 0x10.
1663 * Fix max PCM level to 0 dB (originally it has 0x1e steps
1664 * with 0 dB offset 0x17)
1666 snd_hda_override_amp_caps(codec
, 0x10, HDA_INPUT
,
1667 (0x17 << AC_AMPCAP_OFFSET_SHIFT
) |
1668 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
1669 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
1670 (1 << AC_AMPCAP_MUTE_SHIFT
));
1677 /* Conexant 5051 specific */
1678 static hda_nid_t cxt5051_dac_nids
[1] = { 0x10 };
1679 static hda_nid_t cxt5051_adc_nids
[2] = { 0x14, 0x15 };
1681 static struct hda_channel_mode cxt5051_modes
[1] = {
1685 static void cxt5051_update_speaker(struct hda_codec
*codec
)
1687 struct conexant_spec
*spec
= codec
->spec
;
1688 unsigned int pinctl
;
1690 pinctl
= (spec
->hp_present
&& spec
->cur_eapd
) ? PIN_HP
: 0;
1691 snd_hda_codec_write(codec
, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1694 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
1695 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1697 /* on ideapad there is an aditional speaker (subwoofer) to mute */
1699 snd_hda_codec_write(codec
, 0x1b, 0,
1700 AC_VERB_SET_PIN_WIDGET_CONTROL
,
1704 /* turn on/off EAPD (+ mute HP) as a master switch */
1705 static int cxt5051_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1706 struct snd_ctl_elem_value
*ucontrol
)
1708 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1710 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1712 cxt5051_update_speaker(codec
);
1716 /* toggle input of built-in and mic jack appropriately */
1717 static void cxt5051_portb_automic(struct hda_codec
*codec
)
1719 struct conexant_spec
*spec
= codec
->spec
;
1720 unsigned int present
;
1722 if (!(spec
->auto_mic
& AUTO_MIC_PORTB
))
1724 present
= snd_hda_jack_detect(codec
, 0x17);
1725 snd_hda_codec_write(codec
, 0x14, 0,
1726 AC_VERB_SET_CONNECT_SEL
,
1727 present
? 0x01 : 0x00);
1730 /* switch the current ADC according to the jack state */
1731 static void cxt5051_portc_automic(struct hda_codec
*codec
)
1733 struct conexant_spec
*spec
= codec
->spec
;
1734 unsigned int present
;
1737 if (!(spec
->auto_mic
& AUTO_MIC_PORTC
))
1739 present
= snd_hda_jack_detect(codec
, 0x18);
1741 spec
->cur_adc_idx
= 1;
1743 spec
->cur_adc_idx
= 0;
1744 new_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
1745 if (spec
->cur_adc
&& spec
->cur_adc
!= new_adc
) {
1746 /* stream is running, let's swap the current ADC */
1747 __snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
, 1);
1748 spec
->cur_adc
= new_adc
;
1749 snd_hda_codec_setup_stream(codec
, new_adc
,
1750 spec
->cur_adc_stream_tag
, 0,
1751 spec
->cur_adc_format
);
1755 /* mute internal speaker if HP is plugged */
1756 static void cxt5051_hp_automute(struct hda_codec
*codec
)
1758 struct conexant_spec
*spec
= codec
->spec
;
1760 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x16);
1761 cxt5051_update_speaker(codec
);
1764 /* unsolicited event for HP jack sensing */
1765 static void cxt5051_hp_unsol_event(struct hda_codec
*codec
,
1768 int nid
= (res
& AC_UNSOL_RES_SUBTAG
) >> 20;
1769 switch (res
>> 26) {
1770 case CONEXANT_HP_EVENT
:
1771 cxt5051_hp_automute(codec
);
1773 case CXT5051_PORTB_EVENT
:
1774 cxt5051_portb_automic(codec
);
1776 case CXT5051_PORTC_EVENT
:
1777 cxt5051_portc_automic(codec
);
1780 conexant_report_jack(codec
, nid
);
1783 static struct snd_kcontrol_new cxt5051_playback_mixers
[] = {
1784 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
1786 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1787 .name
= "Master Playback Switch",
1788 .info
= cxt_eapd_info
,
1789 .get
= cxt_eapd_get
,
1790 .put
= cxt5051_hp_master_sw_put
,
1791 .private_value
= 0x1a,
1796 static struct snd_kcontrol_new cxt5051_capture_mixers
[] = {
1797 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1798 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1799 HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT
),
1800 HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT
),
1801 HDA_CODEC_VOLUME("Docking Mic Volume", 0x15, 0x00, HDA_INPUT
),
1802 HDA_CODEC_MUTE("Docking Mic Switch", 0x15, 0x00, HDA_INPUT
),
1806 static struct snd_kcontrol_new cxt5051_hp_mixers
[] = {
1807 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1808 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1809 HDA_CODEC_VOLUME("Mic Volume", 0x15, 0x00, HDA_INPUT
),
1810 HDA_CODEC_MUTE("Mic Switch", 0x15, 0x00, HDA_INPUT
),
1814 static struct snd_kcontrol_new cxt5051_hp_dv6736_mixers
[] = {
1815 HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x00, HDA_INPUT
),
1816 HDA_CODEC_MUTE("Capture Switch", 0x14, 0x00, HDA_INPUT
),
1820 static struct snd_kcontrol_new cxt5051_f700_mixers
[] = {
1821 HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x01, HDA_INPUT
),
1822 HDA_CODEC_MUTE("Capture Switch", 0x14, 0x01, HDA_INPUT
),
1826 static struct snd_kcontrol_new cxt5051_toshiba_mixers
[] = {
1827 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1828 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1829 HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT
),
1830 HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT
),
1834 static struct hda_verb cxt5051_init_verbs
[] = {
1836 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1837 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1838 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1839 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1840 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1841 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1843 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1844 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1846 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1847 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1849 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1850 /* Record selector: Internal mic */
1851 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1852 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1853 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1854 /* SPDIF route: PCM */
1855 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1856 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1858 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1859 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1863 static struct hda_verb cxt5051_hp_dv6736_init_verbs
[] = {
1865 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1866 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1867 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1868 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1870 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1871 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1873 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1874 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1876 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1877 /* Record selector: Internal mic */
1878 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1879 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x1},
1880 /* SPDIF route: PCM */
1881 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1883 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1884 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1888 static struct hda_verb cxt5051_lenovo_x200_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_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1893 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1894 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1895 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1897 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1898 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1900 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1901 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1903 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1904 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00},
1906 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1907 /* Record selector: Internal mic */
1908 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1909 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1910 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1911 /* SPDIF route: PCM */
1912 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
}, /* needed for W500 Advanced Mini Dock 250410 */
1913 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1915 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1916 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1917 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1921 static struct hda_verb cxt5051_f700_init_verbs
[] = {
1923 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1924 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1925 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1926 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1928 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1929 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1931 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1932 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1934 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1935 /* Record selector: Internal mic */
1936 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1937 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x1},
1938 /* SPDIF route: PCM */
1939 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1941 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1942 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1946 static void cxt5051_init_mic_port(struct hda_codec
*codec
, hda_nid_t nid
,
1949 snd_hda_codec_write(codec
, nid
, 0,
1950 AC_VERB_SET_UNSOLICITED_ENABLE
,
1951 AC_USRSP_EN
| event
);
1952 #ifdef CONFIG_SND_HDA_INPUT_JACK
1953 conexant_add_jack(codec
, nid
, SND_JACK_MICROPHONE
);
1954 conexant_report_jack(codec
, nid
);
1958 static struct hda_verb cxt5051_ideapad_init_verbs
[] = {
1960 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1961 {0x1b, AC_VERB_SET_CONNECT_SEL
, 0x00},
1965 /* initialize jack-sensing, too */
1966 static int cxt5051_init(struct hda_codec
*codec
)
1968 struct conexant_spec
*spec
= codec
->spec
;
1970 conexant_init(codec
);
1971 conexant_init_jacks(codec
);
1973 if (spec
->auto_mic
& AUTO_MIC_PORTB
)
1974 cxt5051_init_mic_port(codec
, 0x17, CXT5051_PORTB_EVENT
);
1975 if (spec
->auto_mic
& AUTO_MIC_PORTC
)
1976 cxt5051_init_mic_port(codec
, 0x18, CXT5051_PORTC_EVENT
);
1978 if (codec
->patch_ops
.unsol_event
) {
1979 cxt5051_hp_automute(codec
);
1980 cxt5051_portb_automic(codec
);
1981 cxt5051_portc_automic(codec
);
1988 CXT5051_LAPTOP
, /* Laptops w/ EAPD support */
1989 CXT5051_HP
, /* no docking */
1990 CXT5051_HP_DV6736
, /* HP without mic switch */
1991 CXT5051_LENOVO_X200
, /* Lenovo X200 laptop, also used for Advanced Mini Dock 250410 */
1992 CXT5051_F700
, /* HP Compaq Presario F700 */
1993 CXT5051_TOSHIBA
, /* Toshiba M300 & co */
1994 CXT5051_IDEAPAD
, /* Lenovo IdeaPad Y430 */
1998 static const char *const cxt5051_models
[CXT5051_MODELS
] = {
1999 [CXT5051_LAPTOP
] = "laptop",
2000 [CXT5051_HP
] = "hp",
2001 [CXT5051_HP_DV6736
] = "hp-dv6736",
2002 [CXT5051_LENOVO_X200
] = "lenovo-x200",
2003 [CXT5051_F700
] = "hp-700",
2004 [CXT5051_TOSHIBA
] = "toshiba",
2005 [CXT5051_IDEAPAD
] = "ideapad",
2008 static struct snd_pci_quirk cxt5051_cfg_tbl
[] = {
2009 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736
),
2010 SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP
),
2011 SND_PCI_QUIRK(0x103c, 0x30ea, "Compaq Presario F700", CXT5051_F700
),
2012 SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba M30x", CXT5051_TOSHIBA
),
2013 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
2015 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP
),
2016 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT5051_LENOVO_X200
),
2017 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo IdeaPad", CXT5051_IDEAPAD
),
2021 static int patch_cxt5051(struct hda_codec
*codec
)
2023 struct conexant_spec
*spec
;
2026 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
2030 codec
->pin_amp_workaround
= 1;
2032 codec
->patch_ops
= conexant_patch_ops
;
2033 codec
->patch_ops
.init
= cxt5051_init
;
2035 spec
->multiout
.max_channels
= 2;
2036 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5051_dac_nids
);
2037 spec
->multiout
.dac_nids
= cxt5051_dac_nids
;
2038 spec
->multiout
.dig_out_nid
= CXT5051_SPDIF_OUT
;
2039 spec
->num_adc_nids
= 1; /* not 2; via auto-mic switch */
2040 spec
->adc_nids
= cxt5051_adc_nids
;
2041 spec
->num_mixers
= 2;
2042 spec
->mixers
[0] = cxt5051_capture_mixers
;
2043 spec
->mixers
[1] = cxt5051_playback_mixers
;
2044 spec
->num_init_verbs
= 1;
2045 spec
->init_verbs
[0] = cxt5051_init_verbs
;
2046 spec
->spdif_route
= 0;
2047 spec
->num_channel_mode
= ARRAY_SIZE(cxt5051_modes
);
2048 spec
->channel_mode
= cxt5051_modes
;
2050 spec
->cur_adc_idx
= 0;
2052 set_beep_amp(spec
, 0x13, 0, HDA_OUTPUT
);
2054 codec
->patch_ops
.unsol_event
= cxt5051_hp_unsol_event
;
2056 board_config
= snd_hda_check_board_config(codec
, CXT5051_MODELS
,
2059 spec
->auto_mic
= AUTO_MIC_PORTB
| AUTO_MIC_PORTC
;
2060 switch (board_config
) {
2062 spec
->mixers
[0] = cxt5051_hp_mixers
;
2064 case CXT5051_HP_DV6736
:
2065 spec
->init_verbs
[0] = cxt5051_hp_dv6736_init_verbs
;
2066 spec
->mixers
[0] = cxt5051_hp_dv6736_mixers
;
2069 case CXT5051_LENOVO_X200
:
2070 spec
->init_verbs
[0] = cxt5051_lenovo_x200_init_verbs
;
2071 /* Thinkpad X301 does not have S/PDIF wired and no ability
2072 to use a docking station. */
2073 if (codec
->subsystem_id
== 0x17aa211f)
2074 spec
->multiout
.dig_out_nid
= 0;
2077 spec
->init_verbs
[0] = cxt5051_f700_init_verbs
;
2078 spec
->mixers
[0] = cxt5051_f700_mixers
;
2081 case CXT5051_TOSHIBA
:
2082 spec
->mixers
[0] = cxt5051_toshiba_mixers
;
2083 spec
->auto_mic
= AUTO_MIC_PORTB
;
2085 case CXT5051_IDEAPAD
:
2086 spec
->init_verbs
[spec
->num_init_verbs
++] =
2087 cxt5051_ideapad_init_verbs
;
2093 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
2098 /* Conexant 5066 specific */
2100 static hda_nid_t cxt5066_dac_nids
[1] = { 0x10 };
2101 static hda_nid_t cxt5066_adc_nids
[3] = { 0x14, 0x15, 0x16 };
2102 static hda_nid_t cxt5066_capsrc_nids
[1] = { 0x17 };
2103 #define CXT5066_SPDIF_OUT 0x21
2105 /* OLPC's microphone port is DC coupled for use with external sensors,
2106 * therefore we use a 50% mic bias in order to center the input signal with
2107 * the DC input range of the codec. */
2108 #define CXT5066_OLPC_EXT_MIC_BIAS PIN_VREF50
2110 static struct hda_channel_mode cxt5066_modes
[1] = {
2114 #define HP_PRESENT_PORT_A (1 << 0)
2115 #define HP_PRESENT_PORT_D (1 << 1)
2116 #define hp_port_a_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_A)
2117 #define hp_port_d_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_D)
2119 static void cxt5066_update_speaker(struct hda_codec
*codec
)
2121 struct conexant_spec
*spec
= codec
->spec
;
2122 unsigned int pinctl
;
2124 snd_printdd("CXT5066: update speaker, hp_present=%d, cur_eapd=%d\n",
2125 spec
->hp_present
, spec
->cur_eapd
);
2128 pinctl
= (hp_port_a_present(spec
) && spec
->cur_eapd
) ? PIN_HP
: 0;
2129 snd_hda_codec_write(codec
, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2132 /* Port D (HP/LO) */
2133 pinctl
= spec
->cur_eapd
? spec
->port_d_mode
: 0;
2134 if (spec
->dell_automute
|| spec
->thinkpad
) {
2135 /* Mute if Port A is connected */
2136 if (hp_port_a_present(spec
))
2139 /* Thinkpad/Dell doesn't give pin-D status */
2140 if (!hp_port_d_present(spec
))
2143 snd_hda_codec_write(codec
, 0x1c, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2147 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
2148 snd_hda_codec_write(codec
, 0x1f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2152 /* turn on/off EAPD (+ mute HP) as a master switch */
2153 static int cxt5066_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
2154 struct snd_ctl_elem_value
*ucontrol
)
2156 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2158 if (!cxt_eapd_put(kcontrol
, ucontrol
))
2161 cxt5066_update_speaker(codec
);
2165 static const struct hda_input_mux cxt5066_olpc_dc_bias
= {
2169 { "50%", PIN_VREF50
},
2170 { "80%", PIN_VREF80
},
2174 static int cxt5066_set_olpc_dc_bias(struct hda_codec
*codec
)
2176 struct conexant_spec
*spec
= codec
->spec
;
2177 /* Even though port F is the DC input, the bias is controlled on port B.
2178 * we also leave that port as an active input (but unselected) in DC mode
2179 * just in case that is necessary to make the bias setting take effect. */
2180 return snd_hda_codec_write_cache(codec
, 0x1a, 0,
2181 AC_VERB_SET_PIN_WIDGET_CONTROL
,
2182 cxt5066_olpc_dc_bias
.items
[spec
->dc_input_bias
].index
);
2185 /* OLPC defers mic widget control until when capture is started because the
2186 * microphone LED comes on as soon as these settings are put in place. if we
2187 * did this before recording, it would give the false indication that recording
2188 * is happening when it is not. */
2189 static void cxt5066_olpc_select_mic(struct hda_codec
*codec
)
2191 struct conexant_spec
*spec
= codec
->spec
;
2192 if (!spec
->recording
)
2195 if (spec
->dc_enable
) {
2196 /* in DC mode we ignore presence detection and just use the jack
2197 * through our special DC port */
2198 const struct hda_verb enable_dc_mode
[] = {
2199 /* disble internal mic, port C */
2200 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2202 /* enable DC capture, port F */
2203 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2207 snd_hda_sequence_write(codec
, enable_dc_mode
);
2208 /* port B input disabled (and bias set) through the following call */
2209 cxt5066_set_olpc_dc_bias(codec
);
2213 /* disable DC (port F) */
2214 snd_hda_codec_write(codec
, 0x1e, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0);
2216 /* external mic, port B */
2217 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2218 spec
->ext_mic_present
? CXT5066_OLPC_EXT_MIC_BIAS
: 0);
2220 /* internal mic, port C */
2221 snd_hda_codec_write(codec
, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2222 spec
->ext_mic_present
? 0 : PIN_VREF80
);
2225 /* toggle input of built-in and mic jack appropriately */
2226 static void cxt5066_olpc_automic(struct hda_codec
*codec
)
2228 struct conexant_spec
*spec
= codec
->spec
;
2229 unsigned int present
;
2231 if (spec
->dc_enable
) /* don't do presence detection in DC mode */
2234 present
= snd_hda_codec_read(codec
, 0x1a, 0,
2235 AC_VERB_GET_PIN_SENSE
, 0) & 0x80000000;
2237 snd_printdd("CXT5066: external microphone detected\n");
2239 snd_printdd("CXT5066: external microphone absent\n");
2241 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_CONNECT_SEL
,
2243 spec
->ext_mic_present
= !!present
;
2245 cxt5066_olpc_select_mic(codec
);
2248 /* toggle input of built-in digital mic and mic jack appropriately */
2249 static void cxt5066_vostro_automic(struct hda_codec
*codec
)
2251 unsigned int present
;
2253 struct hda_verb ext_mic_present
[] = {
2254 /* enable external mic, port B */
2255 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2257 /* switch to external mic input */
2258 {0x17, AC_VERB_SET_CONNECT_SEL
, 0},
2259 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2261 /* disable internal digital mic */
2262 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2265 static struct hda_verb ext_mic_absent
[] = {
2266 /* enable internal mic, port C */
2267 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2269 /* switch to internal mic input */
2270 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2272 /* disable external mic, port B */
2273 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2277 present
= snd_hda_jack_detect(codec
, 0x1a);
2279 snd_printdd("CXT5066: external microphone detected\n");
2280 snd_hda_sequence_write(codec
, ext_mic_present
);
2282 snd_printdd("CXT5066: external microphone absent\n");
2283 snd_hda_sequence_write(codec
, ext_mic_absent
);
2287 /* toggle input of built-in digital mic and mic jack appropriately */
2288 static void cxt5066_ideapad_automic(struct hda_codec
*codec
)
2290 unsigned int present
;
2292 struct hda_verb ext_mic_present
[] = {
2293 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2294 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2295 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2298 static struct hda_verb ext_mic_absent
[] = {
2299 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2300 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2301 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2305 present
= snd_hda_jack_detect(codec
, 0x1b);
2307 snd_printdd("CXT5066: external microphone detected\n");
2308 snd_hda_sequence_write(codec
, ext_mic_present
);
2310 snd_printdd("CXT5066: external microphone absent\n");
2311 snd_hda_sequence_write(codec
, ext_mic_absent
);
2315 /* toggle input of built-in digital mic and mic jack appropriately */
2316 static void cxt5066_hp_laptop_automic(struct hda_codec
*codec
)
2318 unsigned int present
;
2320 present
= snd_hda_jack_detect(codec
, 0x1b);
2321 snd_printdd("CXT5066: external microphone present=%d\n", present
);
2322 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_CONNECT_SEL
,
2327 /* toggle input of built-in digital mic and mic jack appropriately
2328 order is: external mic -> dock mic -> interal mic */
2329 static void cxt5066_thinkpad_automic(struct hda_codec
*codec
)
2331 unsigned int ext_present
, dock_present
;
2333 static struct hda_verb ext_mic_present
[] = {
2334 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2335 {0x17, AC_VERB_SET_CONNECT_SEL
, 1},
2336 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2337 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2338 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2341 static struct hda_verb dock_mic_present
[] = {
2342 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2343 {0x17, AC_VERB_SET_CONNECT_SEL
, 0},
2344 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2345 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2346 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2349 static struct hda_verb ext_mic_absent
[] = {
2350 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2351 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2352 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2353 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2357 ext_present
= snd_hda_jack_detect(codec
, 0x1b);
2358 dock_present
= snd_hda_jack_detect(codec
, 0x1a);
2360 snd_printdd("CXT5066: external microphone detected\n");
2361 snd_hda_sequence_write(codec
, ext_mic_present
);
2362 } else if (dock_present
) {
2363 snd_printdd("CXT5066: dock microphone detected\n");
2364 snd_hda_sequence_write(codec
, dock_mic_present
);
2366 snd_printdd("CXT5066: external microphone absent\n");
2367 snd_hda_sequence_write(codec
, ext_mic_absent
);
2371 /* mute internal speaker if HP is plugged */
2372 static void cxt5066_hp_automute(struct hda_codec
*codec
)
2374 struct conexant_spec
*spec
= codec
->spec
;
2375 unsigned int portA
, portD
;
2378 portA
= snd_hda_jack_detect(codec
, 0x19);
2381 portD
= snd_hda_jack_detect(codec
, 0x1c);
2383 spec
->hp_present
= portA
? HP_PRESENT_PORT_A
: 0;
2384 spec
->hp_present
|= portD
? HP_PRESENT_PORT_D
: 0;
2385 snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n",
2386 portA
, portD
, spec
->hp_present
);
2387 cxt5066_update_speaker(codec
);
2390 /* Dispatch the right mic autoswitch function */
2391 static void cxt5066_automic(struct hda_codec
*codec
)
2393 struct conexant_spec
*spec
= codec
->spec
;
2395 if (spec
->dell_vostro
)
2396 cxt5066_vostro_automic(codec
);
2397 else if (spec
->ideapad
)
2398 cxt5066_ideapad_automic(codec
);
2399 else if (spec
->thinkpad
)
2400 cxt5066_thinkpad_automic(codec
);
2401 else if (spec
->hp_laptop
)
2402 cxt5066_hp_laptop_automic(codec
);
2405 /* unsolicited event for jack sensing */
2406 static void cxt5066_olpc_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2408 struct conexant_spec
*spec
= codec
->spec
;
2409 snd_printdd("CXT5066: unsol event %x (%x)\n", res
, res
>> 26);
2410 switch (res
>> 26) {
2411 case CONEXANT_HP_EVENT
:
2412 cxt5066_hp_automute(codec
);
2414 case CONEXANT_MIC_EVENT
:
2415 /* ignore mic events in DC mode; we're always using the jack */
2416 if (!spec
->dc_enable
)
2417 cxt5066_olpc_automic(codec
);
2422 /* unsolicited event for jack sensing */
2423 static void cxt5066_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2425 snd_printdd("CXT5066: unsol event %x (%x)\n", res
, res
>> 26);
2426 switch (res
>> 26) {
2427 case CONEXANT_HP_EVENT
:
2428 cxt5066_hp_automute(codec
);
2430 case CONEXANT_MIC_EVENT
:
2431 cxt5066_automic(codec
);
2437 static const struct hda_input_mux cxt5066_analog_mic_boost
= {
2448 static void cxt5066_set_mic_boost(struct hda_codec
*codec
)
2450 struct conexant_spec
*spec
= codec
->spec
;
2451 snd_hda_codec_write_cache(codec
, 0x17, 0,
2452 AC_VERB_SET_AMP_GAIN_MUTE
,
2453 AC_AMP_SET_RIGHT
| AC_AMP_SET_LEFT
| AC_AMP_SET_OUTPUT
|
2454 cxt5066_analog_mic_boost
.items
[spec
->mic_boost
].index
);
2455 if (spec
->ideapad
|| spec
->thinkpad
) {
2456 /* adjust the internal mic as well...it is not through 0x17 */
2457 snd_hda_codec_write_cache(codec
, 0x23, 0,
2458 AC_VERB_SET_AMP_GAIN_MUTE
,
2459 AC_AMP_SET_RIGHT
| AC_AMP_SET_LEFT
| AC_AMP_SET_INPUT
|
2460 cxt5066_analog_mic_boost
.
2461 items
[spec
->mic_boost
].index
);
2465 static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol
*kcontrol
,
2466 struct snd_ctl_elem_info
*uinfo
)
2468 return snd_hda_input_mux_info(&cxt5066_analog_mic_boost
, uinfo
);
2471 static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol
*kcontrol
,
2472 struct snd_ctl_elem_value
*ucontrol
)
2474 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2475 struct conexant_spec
*spec
= codec
->spec
;
2476 ucontrol
->value
.enumerated
.item
[0] = spec
->mic_boost
;
2480 static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol
*kcontrol
,
2481 struct snd_ctl_elem_value
*ucontrol
)
2483 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2484 struct conexant_spec
*spec
= codec
->spec
;
2485 const struct hda_input_mux
*imux
= &cxt5066_analog_mic_boost
;
2487 idx
= ucontrol
->value
.enumerated
.item
[0];
2488 if (idx
>= imux
->num_items
)
2489 idx
= imux
->num_items
- 1;
2491 spec
->mic_boost
= idx
;
2492 if (!spec
->dc_enable
)
2493 cxt5066_set_mic_boost(codec
);
2497 static void cxt5066_enable_dc(struct hda_codec
*codec
)
2499 const struct hda_verb enable_dc_mode
[] = {
2501 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2503 /* switch to DC input */
2504 {0x17, AC_VERB_SET_CONNECT_SEL
, 3},
2508 /* configure as input source */
2509 snd_hda_sequence_write(codec
, enable_dc_mode
);
2510 cxt5066_olpc_select_mic(codec
); /* also sets configured bias */
2513 static void cxt5066_disable_dc(struct hda_codec
*codec
)
2515 /* reconfigure input source */
2516 cxt5066_set_mic_boost(codec
);
2517 /* automic also selects the right mic if we're recording */
2518 cxt5066_olpc_automic(codec
);
2521 static int cxt5066_olpc_dc_get(struct snd_kcontrol
*kcontrol
,
2522 struct snd_ctl_elem_value
*ucontrol
)
2524 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2525 struct conexant_spec
*spec
= codec
->spec
;
2526 ucontrol
->value
.integer
.value
[0] = spec
->dc_enable
;
2530 static int cxt5066_olpc_dc_put(struct snd_kcontrol
*kcontrol
,
2531 struct snd_ctl_elem_value
*ucontrol
)
2533 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2534 struct conexant_spec
*spec
= codec
->spec
;
2535 int dc_enable
= !!ucontrol
->value
.integer
.value
[0];
2537 if (dc_enable
== spec
->dc_enable
)
2540 spec
->dc_enable
= dc_enable
;
2542 cxt5066_enable_dc(codec
);
2544 cxt5066_disable_dc(codec
);
2549 static int cxt5066_olpc_dc_bias_enum_info(struct snd_kcontrol
*kcontrol
,
2550 struct snd_ctl_elem_info
*uinfo
)
2552 return snd_hda_input_mux_info(&cxt5066_olpc_dc_bias
, uinfo
);
2555 static int cxt5066_olpc_dc_bias_enum_get(struct snd_kcontrol
*kcontrol
,
2556 struct snd_ctl_elem_value
*ucontrol
)
2558 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2559 struct conexant_spec
*spec
= codec
->spec
;
2560 ucontrol
->value
.enumerated
.item
[0] = spec
->dc_input_bias
;
2564 static int cxt5066_olpc_dc_bias_enum_put(struct snd_kcontrol
*kcontrol
,
2565 struct snd_ctl_elem_value
*ucontrol
)
2567 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2568 struct conexant_spec
*spec
= codec
->spec
;
2569 const struct hda_input_mux
*imux
= &cxt5066_analog_mic_boost
;
2572 idx
= ucontrol
->value
.enumerated
.item
[0];
2573 if (idx
>= imux
->num_items
)
2574 idx
= imux
->num_items
- 1;
2576 spec
->dc_input_bias
= idx
;
2577 if (spec
->dc_enable
)
2578 cxt5066_set_olpc_dc_bias(codec
);
2582 static void cxt5066_olpc_capture_prepare(struct hda_codec
*codec
)
2584 struct conexant_spec
*spec
= codec
->spec
;
2585 /* mark as recording and configure the microphone widget so that the
2586 * recording LED comes on. */
2587 spec
->recording
= 1;
2588 cxt5066_olpc_select_mic(codec
);
2591 static void cxt5066_olpc_capture_cleanup(struct hda_codec
*codec
)
2593 struct conexant_spec
*spec
= codec
->spec
;
2594 const struct hda_verb disable_mics
[] = {
2595 /* disable external mic, port B */
2596 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2598 /* disble internal mic, port C */
2599 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2601 /* disable DC capture, port F */
2602 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2606 snd_hda_sequence_write(codec
, disable_mics
);
2607 spec
->recording
= 0;
2610 static struct hda_input_mux cxt5066_capture_source
= {
2620 static struct hda_bind_ctls cxt5066_bind_capture_vol_others
= {
2621 .ops
= &snd_hda_bind_vol
,
2623 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT
),
2624 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT
),
2629 static struct hda_bind_ctls cxt5066_bind_capture_sw_others
= {
2630 .ops
= &snd_hda_bind_sw
,
2632 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT
),
2633 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT
),
2638 static struct snd_kcontrol_new cxt5066_mixer_master
[] = {
2639 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
2643 static struct snd_kcontrol_new cxt5066_mixer_master_olpc
[] = {
2645 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2646 .name
= "Master Playback Volume",
2647 .access
= SNDRV_CTL_ELEM_ACCESS_READWRITE
|
2648 SNDRV_CTL_ELEM_ACCESS_TLV_READ
|
2649 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK
,
2650 .subdevice
= HDA_SUBDEV_AMP_FLAG
,
2651 .info
= snd_hda_mixer_amp_volume_info
,
2652 .get
= snd_hda_mixer_amp_volume_get
,
2653 .put
= snd_hda_mixer_amp_volume_put
,
2654 .tlv
= { .c
= snd_hda_mixer_amp_tlv
},
2655 /* offset by 28 volume steps to limit minimum gain to -46dB */
2657 HDA_COMPOSE_AMP_VAL_OFS(0x10, 3, 0, HDA_OUTPUT
, 28),
2662 static struct snd_kcontrol_new cxt5066_mixer_olpc_dc
[] = {
2664 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2665 .name
= "DC Mode Enable Switch",
2666 .info
= snd_ctl_boolean_mono_info
,
2667 .get
= cxt5066_olpc_dc_get
,
2668 .put
= cxt5066_olpc_dc_put
,
2671 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2672 .name
= "DC Input Bias Enum",
2673 .info
= cxt5066_olpc_dc_bias_enum_info
,
2674 .get
= cxt5066_olpc_dc_bias_enum_get
,
2675 .put
= cxt5066_olpc_dc_bias_enum_put
,
2680 static struct snd_kcontrol_new cxt5066_mixers
[] = {
2682 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2683 .name
= "Master Playback Switch",
2684 .info
= cxt_eapd_info
,
2685 .get
= cxt_eapd_get
,
2686 .put
= cxt5066_hp_master_sw_put
,
2687 .private_value
= 0x1d,
2691 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2692 .name
= "Analog Mic Boost Capture Enum",
2693 .info
= cxt5066_mic_boost_mux_enum_info
,
2694 .get
= cxt5066_mic_boost_mux_enum_get
,
2695 .put
= cxt5066_mic_boost_mux_enum_put
,
2698 HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others
),
2699 HDA_BIND_SW("Capture Switch", &cxt5066_bind_capture_sw_others
),
2703 static struct snd_kcontrol_new cxt5066_vostro_mixers
[] = {
2705 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2706 .name
= "Internal Mic Boost Capture Enum",
2707 .info
= cxt5066_mic_boost_mux_enum_info
,
2708 .get
= cxt5066_mic_boost_mux_enum_get
,
2709 .put
= cxt5066_mic_boost_mux_enum_put
,
2710 .private_value
= 0x23 | 0x100,
2715 static struct hda_verb cxt5066_init_verbs
[] = {
2716 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port B */
2717 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port C */
2718 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2719 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2722 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2723 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2726 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2727 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2729 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2730 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2733 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2735 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2736 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2737 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2738 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2739 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2740 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2742 /* no digital microphone support yet */
2743 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2745 /* Audio input selector */
2746 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2748 /* SPDIF route: PCM */
2749 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2750 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2752 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2753 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2756 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2758 /* not handling these yet */
2759 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2760 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2761 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2762 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2763 {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2764 {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2765 {0x20, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2766 {0x22, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2770 static struct hda_verb cxt5066_init_verbs_olpc
[] = {
2771 /* Port A: headphones */
2772 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2773 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2775 /* Port B: external microphone */
2776 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2778 /* Port C: internal microphone */
2779 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2781 /* Port D: unused */
2782 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2784 /* Port E: unused, but has primary EAPD */
2785 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2786 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2788 /* Port F: external DC input through microphone port */
2789 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2791 /* Port G: internal speakers */
2792 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2793 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2796 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2799 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2801 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2802 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2803 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2804 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2805 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2806 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2807 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2808 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2809 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2810 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2811 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2812 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2814 /* Disable digital microphone port */
2815 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2817 /* Audio input selectors */
2818 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2819 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2822 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2823 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2825 /* enable unsolicited events for Port A and B */
2826 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2827 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2831 static struct hda_verb cxt5066_init_verbs_vostro
[] = {
2832 /* Port A: headphones */
2833 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2834 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2836 /* Port B: external microphone */
2837 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2839 /* Port C: unused */
2840 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2842 /* Port D: unused */
2843 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2845 /* Port E: unused, but has primary EAPD */
2846 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2847 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2849 /* Port F: unused */
2850 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2852 /* Port G: internal speakers */
2853 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2854 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2857 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2860 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2862 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2863 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2864 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2865 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2866 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2867 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2868 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2869 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2870 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2871 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2872 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2873 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2875 /* Digital microphone port */
2876 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2878 /* Audio input selectors */
2879 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2880 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2883 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2884 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2886 /* enable unsolicited events for Port A and B */
2887 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2888 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2892 static struct hda_verb cxt5066_init_verbs_ideapad
[] = {
2893 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port B */
2894 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port C */
2895 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2896 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2899 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2900 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2903 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2904 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2906 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2907 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2910 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2912 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2913 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2914 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2915 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2916 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2917 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2918 {0x14, AC_VERB_SET_CONNECT_SEL
, 2}, /* default to internal mic */
2920 /* Audio input selector */
2921 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x2},
2922 {0x17, AC_VERB_SET_CONNECT_SEL
, 1}, /* route ext mic */
2924 /* SPDIF route: PCM */
2925 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2926 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2928 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2929 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2931 /* internal microphone */
2932 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* enable internal mic */
2935 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2937 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2938 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2942 static struct hda_verb cxt5066_init_verbs_thinkpad
[] = {
2943 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2944 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2946 /* Port G: internal speakers */
2947 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2948 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2950 /* Port A: HP, Amp */
2951 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2952 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2954 /* Port B: Mic Dock */
2955 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2958 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2960 /* Port D: HP Dock, Amp */
2961 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2962 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2965 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2967 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2968 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2969 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2970 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2971 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2972 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2973 {0x14, AC_VERB_SET_CONNECT_SEL
, 2}, /* default to internal mic */
2975 /* Audio input selector */
2976 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x2},
2977 {0x17, AC_VERB_SET_CONNECT_SEL
, 1}, /* route ext mic */
2979 /* SPDIF route: PCM */
2980 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2981 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2983 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2984 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2986 /* internal microphone */
2987 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* enable internal mic */
2990 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2992 /* enable unsolicited events for Port A, B, C and D */
2993 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2994 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2995 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2996 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
3000 static struct hda_verb cxt5066_init_verbs_portd_lo
[] = {
3001 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
3006 static struct hda_verb cxt5066_init_verbs_hp_laptop
[] = {
3007 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x0},
3008 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
3009 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
3013 /* initialize jack-sensing, too */
3014 static int cxt5066_init(struct hda_codec
*codec
)
3016 snd_printdd("CXT5066: init\n");
3017 conexant_init(codec
);
3018 if (codec
->patch_ops
.unsol_event
) {
3019 cxt5066_hp_automute(codec
);
3020 cxt5066_automic(codec
);
3022 cxt5066_set_mic_boost(codec
);
3026 static int cxt5066_olpc_init(struct hda_codec
*codec
)
3028 struct conexant_spec
*spec
= codec
->spec
;
3029 snd_printdd("CXT5066: init\n");
3030 conexant_init(codec
);
3031 cxt5066_hp_automute(codec
);
3032 if (!spec
->dc_enable
) {
3033 cxt5066_set_mic_boost(codec
);
3034 cxt5066_olpc_automic(codec
);
3036 cxt5066_enable_dc(codec
);
3042 CXT5066_LAPTOP
, /* Laptops w/ EAPD support */
3043 CXT5066_DELL_LAPTOP
, /* Dell Laptop */
3044 CXT5066_OLPC_XO_1_5
, /* OLPC XO 1.5 */
3045 CXT5066_DELL_VOSTRO
, /* Dell Vostro 1015i */
3046 CXT5066_IDEAPAD
, /* Lenovo IdeaPad U150 */
3047 CXT5066_THINKPAD
, /* Lenovo ThinkPad T410s, others? */
3048 CXT5066_HP_LAPTOP
, /* HP Laptop */
3052 static const char * const cxt5066_models
[CXT5066_MODELS
] = {
3053 [CXT5066_LAPTOP
] = "laptop",
3054 [CXT5066_DELL_LAPTOP
] = "dell-laptop",
3055 [CXT5066_OLPC_XO_1_5
] = "olpc-xo-1_5",
3056 [CXT5066_DELL_VOSTRO
] = "dell-vostro",
3057 [CXT5066_IDEAPAD
] = "ideapad",
3058 [CXT5066_THINKPAD
] = "thinkpad",
3059 [CXT5066_HP_LAPTOP
] = "hp-laptop",
3062 static struct snd_pci_quirk cxt5066_cfg_tbl
[] = {
3063 SND_PCI_QUIRK_MASK(0x1025, 0xff00, 0x0400, "Acer", CXT5066_IDEAPAD
),
3064 SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTRO
),
3065 SND_PCI_QUIRK(0x1028, 0x02f5, "Dell Vostro 320", CXT5066_IDEAPAD
),
3066 SND_PCI_QUIRK(0x1028, 0x0401, "Dell Vostro 1014", CXT5066_DELL_VOSTRO
),
3067 SND_PCI_QUIRK(0x1028, 0x0402, "Dell Vostro", CXT5066_DELL_VOSTRO
),
3068 SND_PCI_QUIRK(0x1028, 0x0408, "Dell Inspiron One 19T", CXT5066_IDEAPAD
),
3069 SND_PCI_QUIRK(0x103c, 0x360b, "HP G60", CXT5066_HP_LAPTOP
),
3070 SND_PCI_QUIRK(0x1043, 0x13f3, "Asus A52J", CXT5066_HP_LAPTOP
),
3071 SND_PCI_QUIRK(0x1179, 0xff1e, "Toshiba Satellite C650D", CXT5066_IDEAPAD
),
3072 SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba Satellite P500-PSPGSC-01800T", CXT5066_OLPC_XO_1_5
),
3073 SND_PCI_QUIRK(0x1179, 0xffe0, "Toshiba Satellite Pro T130-15F", CXT5066_OLPC_XO_1_5
),
3074 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
3076 SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5
),
3077 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400s", CXT5066_THINKPAD
),
3078 SND_PCI_QUIRK(0x17aa, 0x21c5, "Thinkpad Edge 13", CXT5066_THINKPAD
),
3079 SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo Thinkpad", CXT5066_THINKPAD
),
3080 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", CXT5066_IDEAPAD
), /* Fallback for Lenovos without dock mic */
3084 static int patch_cxt5066(struct hda_codec
*codec
)
3086 struct conexant_spec
*spec
;
3089 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
3094 codec
->patch_ops
= conexant_patch_ops
;
3095 codec
->patch_ops
.init
= conexant_init
;
3097 spec
->dell_automute
= 0;
3098 spec
->multiout
.max_channels
= 2;
3099 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5066_dac_nids
);
3100 spec
->multiout
.dac_nids
= cxt5066_dac_nids
;
3101 spec
->multiout
.dig_out_nid
= CXT5066_SPDIF_OUT
;
3102 spec
->num_adc_nids
= 1;
3103 spec
->adc_nids
= cxt5066_adc_nids
;
3104 spec
->capsrc_nids
= cxt5066_capsrc_nids
;
3105 spec
->input_mux
= &cxt5066_capture_source
;
3107 spec
->port_d_mode
= PIN_HP
;
3109 spec
->num_init_verbs
= 1;
3110 spec
->init_verbs
[0] = cxt5066_init_verbs
;
3111 spec
->num_channel_mode
= ARRAY_SIZE(cxt5066_modes
);
3112 spec
->channel_mode
= cxt5066_modes
;
3114 spec
->cur_adc_idx
= 0;
3116 set_beep_amp(spec
, 0x13, 0, HDA_OUTPUT
);
3118 board_config
= snd_hda_check_board_config(codec
, CXT5066_MODELS
,
3119 cxt5066_models
, cxt5066_cfg_tbl
);
3120 switch (board_config
) {
3122 case CXT5066_LAPTOP
:
3123 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3124 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3126 case CXT5066_DELL_LAPTOP
:
3127 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3128 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3130 spec
->port_d_mode
= PIN_OUT
;
3131 spec
->init_verbs
[spec
->num_init_verbs
] = cxt5066_init_verbs_portd_lo
;
3132 spec
->num_init_verbs
++;
3133 spec
->dell_automute
= 1;
3135 case CXT5066_HP_LAPTOP
:
3136 codec
->patch_ops
.init
= cxt5066_init
;
3137 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
3138 spec
->init_verbs
[spec
->num_init_verbs
] =
3139 cxt5066_init_verbs_hp_laptop
;
3140 spec
->num_init_verbs
++;
3141 spec
->hp_laptop
= 1;
3142 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3143 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3145 spec
->multiout
.dig_out_nid
= 0;
3146 /* input source automatically selected */
3147 spec
->input_mux
= NULL
;
3148 spec
->port_d_mode
= 0;
3149 spec
->mic_boost
= 3; /* default 30dB gain */
3152 case CXT5066_OLPC_XO_1_5
:
3153 codec
->patch_ops
.init
= cxt5066_olpc_init
;
3154 codec
->patch_ops
.unsol_event
= cxt5066_olpc_unsol_event
;
3155 spec
->init_verbs
[0] = cxt5066_init_verbs_olpc
;
3156 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master_olpc
;
3157 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_olpc_dc
;
3158 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3159 spec
->port_d_mode
= 0;
3160 spec
->mic_boost
= 3; /* default 30dB gain */
3163 spec
->multiout
.dig_out_nid
= 0;
3165 /* input source automatically selected */
3166 spec
->input_mux
= NULL
;
3168 /* our capture hooks which allow us to turn on the microphone LED
3169 * at the right time */
3170 spec
->capture_prepare
= cxt5066_olpc_capture_prepare
;
3171 spec
->capture_cleanup
= cxt5066_olpc_capture_cleanup
;
3173 case CXT5066_DELL_VOSTRO
:
3174 codec
->patch_ops
.init
= cxt5066_init
;
3175 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
3176 spec
->init_verbs
[0] = cxt5066_init_verbs_vostro
;
3177 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master_olpc
;
3178 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3179 spec
->mixers
[spec
->num_mixers
++] = cxt5066_vostro_mixers
;
3180 spec
->port_d_mode
= 0;
3181 spec
->dell_vostro
= 1;
3182 spec
->mic_boost
= 3; /* default 30dB gain */
3185 spec
->multiout
.dig_out_nid
= 0;
3187 /* input source automatically selected */
3188 spec
->input_mux
= NULL
;
3190 case CXT5066_IDEAPAD
:
3191 codec
->patch_ops
.init
= cxt5066_init
;
3192 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
3193 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3194 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3195 spec
->init_verbs
[0] = cxt5066_init_verbs_ideapad
;
3196 spec
->port_d_mode
= 0;
3198 spec
->mic_boost
= 2; /* default 20dB gain */
3201 spec
->multiout
.dig_out_nid
= 0;
3203 /* input source automatically selected */
3204 spec
->input_mux
= NULL
;
3206 case CXT5066_THINKPAD
:
3207 codec
->patch_ops
.init
= cxt5066_init
;
3208 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
3209 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3210 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3211 spec
->init_verbs
[0] = cxt5066_init_verbs_thinkpad
;
3213 spec
->port_d_mode
= PIN_OUT
;
3214 spec
->mic_boost
= 2; /* default 20dB gain */
3217 spec
->multiout
.dig_out_nid
= 0;
3219 /* input source automatically selected */
3220 spec
->input_mux
= NULL
;
3225 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
3231 * Automatic parser for CX20641 & co
3234 static hda_nid_t cx_auto_adc_nids
[] = { 0x14 };
3236 /* get the connection index of @nid in the widget @mux */
3237 static int get_connection_index(struct hda_codec
*codec
, hda_nid_t mux
,
3240 hda_nid_t conn
[HDA_MAX_NUM_INPUTS
];
3243 nums
= snd_hda_get_connections(codec
, mux
, conn
, ARRAY_SIZE(conn
));
3244 for (i
= 0; i
< nums
; i
++)
3250 /* get an unassigned DAC from the given list.
3251 * Return the nid if found and reduce the DAC list, or return zero if
3254 static hda_nid_t
get_unassigned_dac(struct hda_codec
*codec
, hda_nid_t pin
,
3255 hda_nid_t
*dacs
, int *num_dacs
)
3257 int i
, nums
= *num_dacs
;
3260 for (i
= 0; i
< nums
; i
++) {
3261 if (get_connection_index(codec
, pin
, dacs
[i
]) >= 0) {
3269 memmove(dacs
, dacs
+ 1, nums
* sizeof(hda_nid_t
));
3274 #define MAX_AUTO_DACS 5
3276 /* fill analog DAC list from the widget tree */
3277 static int fill_cx_auto_dacs(struct hda_codec
*codec
, hda_nid_t
*dacs
)
3279 hda_nid_t nid
, end_nid
;
3282 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
3283 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++) {
3284 unsigned int wcaps
= get_wcaps(codec
, nid
);
3285 unsigned int type
= get_wcaps_type(wcaps
);
3286 if (type
== AC_WID_AUD_OUT
&& !(wcaps
& AC_WCAP_DIGITAL
)) {
3288 if (nums
>= MAX_AUTO_DACS
)
3295 /* fill pin_dac_pair list from the pin and dac list */
3296 static int fill_dacs_for_pins(struct hda_codec
*codec
, hda_nid_t
*pins
,
3297 int num_pins
, hda_nid_t
*dacs
, int *rest
,
3298 struct pin_dac_pair
*filled
, int type
)
3303 for (i
= 0; i
< num_pins
; i
++) {
3304 filled
[nums
].pin
= pins
[i
];
3305 filled
[nums
].type
= type
;
3306 filled
[nums
].dac
= get_unassigned_dac(codec
, pins
[i
], dacs
, rest
);
3312 /* parse analog output paths */
3313 static void cx_auto_parse_output(struct hda_codec
*codec
)
3315 struct conexant_spec
*spec
= codec
->spec
;
3316 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3317 hda_nid_t dacs
[MAX_AUTO_DACS
];
3318 int i
, j
, nums
, rest
;
3320 rest
= fill_cx_auto_dacs(codec
, dacs
);
3321 /* parse all analog output pins */
3322 nums
= fill_dacs_for_pins(codec
, cfg
->line_out_pins
, cfg
->line_outs
,
3323 dacs
, &rest
, spec
->dac_info
,
3325 nums
+= fill_dacs_for_pins(codec
, cfg
->hp_pins
, cfg
->hp_outs
,
3326 dacs
, &rest
, spec
->dac_info
+ nums
,
3328 nums
+= fill_dacs_for_pins(codec
, cfg
->speaker_pins
, cfg
->speaker_outs
,
3329 dacs
, &rest
, spec
->dac_info
+ nums
,
3330 AUTO_PIN_SPEAKER_OUT
);
3331 spec
->dac_info_filled
= nums
;
3332 /* fill multiout struct */
3333 for (i
= 0; i
< nums
; i
++) {
3334 hda_nid_t dac
= spec
->dac_info
[i
].dac
;
3337 switch (spec
->dac_info
[i
].type
) {
3338 case AUTO_PIN_LINE_OUT
:
3339 spec
->private_dac_nids
[spec
->multiout
.num_dacs
] = dac
;
3340 spec
->multiout
.num_dacs
++;
3342 case AUTO_PIN_HP_OUT
:
3343 case AUTO_PIN_SPEAKER_OUT
:
3344 if (!spec
->multiout
.hp_nid
) {
3345 spec
->multiout
.hp_nid
= dac
;
3348 for (j
= 0; j
< ARRAY_SIZE(spec
->multiout
.extra_out_nid
); j
++)
3349 if (!spec
->multiout
.extra_out_nid
[j
]) {
3350 spec
->multiout
.extra_out_nid
[j
] = dac
;
3356 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
3357 spec
->multiout
.max_channels
= nums
* 2;
3359 if (cfg
->hp_outs
> 0)
3360 spec
->auto_mute
= 1;
3361 spec
->vmaster_nid
= spec
->private_dac_nids
[0];
3364 /* auto-mute/unmute speaker and line outs according to headphone jack */
3365 static void cx_auto_hp_automute(struct hda_codec
*codec
)
3367 struct conexant_spec
*spec
= codec
->spec
;
3368 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3371 if (!spec
->auto_mute
)
3374 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
3375 if (snd_hda_jack_detect(codec
, cfg
->hp_pins
[i
])) {
3380 for (i
= 0; i
< cfg
->line_outs
; i
++) {
3381 snd_hda_codec_write(codec
, cfg
->line_out_pins
[i
], 0,
3382 AC_VERB_SET_PIN_WIDGET_CONTROL
,
3383 present
? 0 : PIN_OUT
);
3385 for (i
= 0; !present
&& i
< cfg
->line_outs
; i
++)
3386 if (snd_hda_jack_detect(codec
, cfg
->line_out_pins
[i
]))
3388 for (i
= 0; i
< cfg
->speaker_outs
; i
++) {
3389 snd_hda_codec_write(codec
, cfg
->speaker_pins
[i
], 0,
3390 AC_VERB_SET_PIN_WIDGET_CONTROL
,
3391 present
? 0 : PIN_OUT
);
3395 /* automatic switch internal and external mic */
3396 static void cx_auto_automic(struct hda_codec
*codec
)
3398 struct conexant_spec
*spec
= codec
->spec
;
3399 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3400 struct hda_input_mux
*imux
= &spec
->private_imux
;
3401 int ext_idx
= spec
->auto_mic_ext
;
3403 if (!spec
->auto_mic
)
3405 if (snd_hda_jack_detect(codec
, cfg
->inputs
[ext_idx
].pin
)) {
3406 snd_hda_codec_write(codec
, spec
->adc_nids
[0], 0,
3407 AC_VERB_SET_CONNECT_SEL
,
3408 imux
->items
[ext_idx
].index
);
3410 snd_hda_codec_write(codec
, spec
->adc_nids
[0], 0,
3411 AC_VERB_SET_CONNECT_SEL
,
3412 imux
->items
[!ext_idx
].index
);
3416 static void cx_auto_unsol_event(struct hda_codec
*codec
, unsigned int res
)
3418 int nid
= (res
& AC_UNSOL_RES_SUBTAG
) >> 20;
3419 switch (res
>> 26) {
3420 case CONEXANT_HP_EVENT
:
3421 cx_auto_hp_automute(codec
);
3422 conexant_report_jack(codec
, nid
);
3424 case CONEXANT_MIC_EVENT
:
3425 cx_auto_automic(codec
);
3426 conexant_report_jack(codec
, nid
);
3431 /* return true if it's an internal-mic pin */
3432 static int is_int_mic(struct hda_codec
*codec
, hda_nid_t pin
)
3434 unsigned int def_conf
= snd_hda_codec_get_pincfg(codec
, pin
);
3435 return get_defcfg_device(def_conf
) == AC_JACK_MIC_IN
&&
3436 snd_hda_get_input_pin_attr(def_conf
) == INPUT_PIN_ATTR_INT
;
3439 /* return true if it's an external-mic pin */
3440 static int is_ext_mic(struct hda_codec
*codec
, hda_nid_t pin
)
3442 unsigned int def_conf
= snd_hda_codec_get_pincfg(codec
, pin
);
3443 return get_defcfg_device(def_conf
) == AC_JACK_MIC_IN
&&
3444 snd_hda_get_input_pin_attr(def_conf
) >= INPUT_PIN_ATTR_NORMAL
&&
3445 (snd_hda_query_pin_caps(codec
, pin
) & AC_PINCAP_PRES_DETECT
);
3448 /* check whether the pin config is suitable for auto-mic switching;
3449 * auto-mic is enabled only when one int-mic and one-ext mic exist
3451 static void cx_auto_check_auto_mic(struct hda_codec
*codec
)
3453 struct conexant_spec
*spec
= codec
->spec
;
3454 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3456 if (is_ext_mic(codec
, cfg
->inputs
[0].pin
) &&
3457 is_int_mic(codec
, cfg
->inputs
[1].pin
)) {
3459 spec
->auto_mic_ext
= 1;
3462 if (is_int_mic(codec
, cfg
->inputs
[1].pin
) &&
3463 is_ext_mic(codec
, cfg
->inputs
[0].pin
)) {
3465 spec
->auto_mic_ext
= 0;
3470 static void cx_auto_parse_input(struct hda_codec
*codec
)
3472 struct conexant_spec
*spec
= codec
->spec
;
3473 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3474 struct hda_input_mux
*imux
;
3477 imux
= &spec
->private_imux
;
3478 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3479 int idx
= get_connection_index(codec
, spec
->adc_nids
[0],
3480 cfg
->inputs
[i
].pin
);
3483 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
3484 snd_hda_add_imux_item(imux
, label
, idx
, NULL
);
3487 if (imux
->num_items
== 2 && cfg
->num_inputs
== 2)
3488 cx_auto_check_auto_mic(codec
);
3489 if (imux
->num_items
> 1 && !spec
->auto_mic
)
3490 spec
->input_mux
= imux
;
3493 /* get digital-input audio widget corresponding to the given pin */
3494 static hda_nid_t
cx_auto_get_dig_in(struct hda_codec
*codec
, hda_nid_t pin
)
3496 hda_nid_t nid
, end_nid
;
3498 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
3499 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++) {
3500 unsigned int wcaps
= get_wcaps(codec
, nid
);
3501 unsigned int type
= get_wcaps_type(wcaps
);
3502 if (type
== AC_WID_AUD_IN
&& (wcaps
& AC_WCAP_DIGITAL
)) {
3503 if (get_connection_index(codec
, nid
, pin
) >= 0)
3510 static void cx_auto_parse_digital(struct hda_codec
*codec
)
3512 struct conexant_spec
*spec
= codec
->spec
;
3513 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3516 if (cfg
->dig_outs
&&
3517 snd_hda_get_connections(codec
, cfg
->dig_out_pins
[0], &nid
, 1) == 1)
3518 spec
->multiout
.dig_out_nid
= nid
;
3519 if (cfg
->dig_in_pin
)
3520 spec
->dig_in_nid
= cx_auto_get_dig_in(codec
, cfg
->dig_in_pin
);
3523 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3524 static void cx_auto_parse_beep(struct hda_codec
*codec
)
3526 struct conexant_spec
*spec
= codec
->spec
;
3527 hda_nid_t nid
, end_nid
;
3529 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
3530 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++)
3531 if (get_wcaps_type(get_wcaps(codec
, nid
)) == AC_WID_BEEP
) {
3532 set_beep_amp(spec
, nid
, 0, HDA_OUTPUT
);
3537 #define cx_auto_parse_beep(codec)
3540 static int cx_auto_parse_auto_config(struct hda_codec
*codec
)
3542 struct conexant_spec
*spec
= codec
->spec
;
3545 err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
);
3549 cx_auto_parse_output(codec
);
3550 cx_auto_parse_input(codec
);
3551 cx_auto_parse_digital(codec
);
3552 cx_auto_parse_beep(codec
);
3556 static void cx_auto_turn_on_eapd(struct hda_codec
*codec
, int num_pins
,
3560 for (i
= 0; i
< num_pins
; i
++) {
3561 if (snd_hda_query_pin_caps(codec
, pins
[i
]) & AC_PINCAP_EAPD
)
3562 snd_hda_codec_write(codec
, pins
[i
], 0,
3563 AC_VERB_SET_EAPD_BTLENABLE
, 0x02);
3567 static void select_connection(struct hda_codec
*codec
, hda_nid_t pin
,
3570 int idx
= get_connection_index(codec
, pin
, src
);
3572 snd_hda_codec_write(codec
, pin
, 0,
3573 AC_VERB_SET_CONNECT_SEL
, idx
);
3576 static void cx_auto_init_output(struct hda_codec
*codec
)
3578 struct conexant_spec
*spec
= codec
->spec
;
3579 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3583 for (i
= 0; i
< spec
->multiout
.num_dacs
; i
++)
3584 snd_hda_codec_write(codec
, spec
->multiout
.dac_nids
[i
], 0,
3585 AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
);
3587 for (i
= 0; i
< cfg
->hp_outs
; i
++)
3588 snd_hda_codec_write(codec
, cfg
->hp_pins
[i
], 0,
3589 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
);
3590 if (spec
->auto_mute
) {
3591 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
3592 snd_hda_codec_write(codec
, cfg
->hp_pins
[i
], 0,
3593 AC_VERB_SET_UNSOLICITED_ENABLE
,
3594 AC_USRSP_EN
| CONEXANT_HP_EVENT
);
3596 cx_auto_hp_automute(codec
);
3598 for (i
= 0; i
< cfg
->line_outs
; i
++)
3599 snd_hda_codec_write(codec
, cfg
->line_out_pins
[i
], 0,
3600 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
);
3601 for (i
= 0; i
< cfg
->speaker_outs
; i
++)
3602 snd_hda_codec_write(codec
, cfg
->speaker_pins
[i
], 0,
3603 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
);
3606 for (i
= 0; i
< spec
->dac_info_filled
; i
++) {
3607 nid
= spec
->dac_info
[i
].dac
;
3609 nid
= spec
->multiout
.dac_nids
[0];
3610 select_connection(codec
, spec
->dac_info
[i
].pin
, nid
);
3614 cx_auto_turn_on_eapd(codec
, cfg
->line_outs
, cfg
->line_out_pins
);
3615 cx_auto_turn_on_eapd(codec
, cfg
->hp_outs
, cfg
->hp_pins
);
3616 cx_auto_turn_on_eapd(codec
, cfg
->speaker_outs
, cfg
->speaker_pins
);
3619 static void cx_auto_init_input(struct hda_codec
*codec
)
3621 struct conexant_spec
*spec
= codec
->spec
;
3622 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3625 for (i
= 0; i
< spec
->num_adc_nids
; i
++)
3626 snd_hda_codec_write(codec
, spec
->adc_nids
[i
], 0,
3627 AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0));
3629 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3631 if (cfg
->inputs
[i
].type
== AUTO_PIN_MIC
)
3635 snd_hda_codec_write(codec
, cfg
->inputs
[i
].pin
, 0,
3636 AC_VERB_SET_PIN_WIDGET_CONTROL
, type
);
3639 if (spec
->auto_mic
) {
3640 int ext_idx
= spec
->auto_mic_ext
;
3641 snd_hda_codec_write(codec
, cfg
->inputs
[ext_idx
].pin
, 0,
3642 AC_VERB_SET_UNSOLICITED_ENABLE
,
3643 AC_USRSP_EN
| CONEXANT_MIC_EVENT
);
3644 cx_auto_automic(codec
);
3646 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
3647 snd_hda_codec_write(codec
, spec
->adc_nids
[i
], 0,
3648 AC_VERB_SET_CONNECT_SEL
,
3649 spec
->private_imux
.items
[0].index
);
3654 static void cx_auto_init_digital(struct hda_codec
*codec
)
3656 struct conexant_spec
*spec
= codec
->spec
;
3657 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3659 if (spec
->multiout
.dig_out_nid
)
3660 snd_hda_codec_write(codec
, cfg
->dig_out_pins
[0], 0,
3661 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
);
3662 if (spec
->dig_in_nid
)
3663 snd_hda_codec_write(codec
, cfg
->dig_in_pin
, 0,
3664 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
);
3667 static int cx_auto_init(struct hda_codec
*codec
)
3669 /*snd_hda_sequence_write(codec, cx_auto_init_verbs);*/
3670 cx_auto_init_output(codec
);
3671 cx_auto_init_input(codec
);
3672 cx_auto_init_digital(codec
);
3676 static int cx_auto_add_volume(struct hda_codec
*codec
, const char *basename
,
3677 const char *dir
, int cidx
,
3678 hda_nid_t nid
, int hda_dir
)
3680 static char name
[32];
3681 static struct snd_kcontrol_new knew
[] = {
3682 HDA_CODEC_VOLUME(name
, 0, 0, 0),
3683 HDA_CODEC_MUTE(name
, 0, 0, 0),
3685 static char *sfx
[2] = { "Volume", "Switch" };
3688 for (i
= 0; i
< 2; i
++) {
3689 struct snd_kcontrol
*kctl
;
3690 knew
[i
].private_value
= HDA_COMPOSE_AMP_VAL(nid
, 3, 0, hda_dir
);
3691 knew
[i
].subdevice
= HDA_SUBDEV_AMP_FLAG
;
3692 knew
[i
].index
= cidx
;
3693 snprintf(name
, sizeof(name
), "%s%s %s", basename
, dir
, sfx
[i
]);
3694 kctl
= snd_ctl_new1(&knew
[i
], codec
);
3697 err
= snd_hda_ctl_add(codec
, nid
, kctl
);
3700 if (!(query_amp_caps(codec
, nid
, hda_dir
) & AC_AMPCAP_MUTE
))
3706 #define cx_auto_add_pb_volume(codec, nid, str, idx) \
3707 cx_auto_add_volume(codec, str, " Playback", idx, nid, HDA_OUTPUT)
3709 static int cx_auto_build_output_controls(struct hda_codec
*codec
)
3711 struct conexant_spec
*spec
= codec
->spec
;
3713 int num_line
= 0, num_hp
= 0, num_spk
= 0;
3714 static const char * const texts
[3] = { "Front", "Surround", "CLFE" };
3716 if (spec
->dac_info_filled
== 1)
3717 return cx_auto_add_pb_volume(codec
, spec
->dac_info
[0].dac
,
3719 for (i
= 0; i
< spec
->dac_info_filled
; i
++) {
3722 if (!spec
->dac_info
[i
].dac
)
3724 type
= spec
->dac_info
[i
].type
;
3725 if (type
== AUTO_PIN_LINE_OUT
)
3726 type
= spec
->autocfg
.line_out_type
;
3728 case AUTO_PIN_LINE_OUT
:
3730 label
= texts
[num_line
++];
3733 case AUTO_PIN_HP_OUT
:
3734 label
= "Headphone";
3737 case AUTO_PIN_SPEAKER_OUT
:
3742 err
= cx_auto_add_pb_volume(codec
, spec
->dac_info
[i
].dac
,
3750 static int cx_auto_build_input_controls(struct hda_codec
*codec
)
3752 struct conexant_spec
*spec
= codec
->spec
;
3753 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3754 static const char *prev_label
;
3757 err
= cx_auto_add_volume(codec
, "Capture", "", 0, spec
->adc_nids
[0],
3763 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3764 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
3766 if (!(get_wcaps(codec
, nid
) & AC_WCAP_IN_AMP
))
3768 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
3769 if (label
== prev_label
)
3774 err
= cx_auto_add_volume(codec
, label
, " Capture", cidx
,
3782 static int cx_auto_build_controls(struct hda_codec
*codec
)
3786 err
= cx_auto_build_output_controls(codec
);
3789 err
= cx_auto_build_input_controls(codec
);
3792 return conexant_build_controls(codec
);
3795 static struct hda_codec_ops cx_auto_patch_ops
= {
3796 .build_controls
= cx_auto_build_controls
,
3797 .build_pcms
= conexant_build_pcms
,
3798 .init
= cx_auto_init
,
3799 .free
= conexant_free
,
3800 .unsol_event
= cx_auto_unsol_event
,
3801 #ifdef CONFIG_SND_HDA_POWER_SAVE
3802 .suspend
= conexant_suspend
,
3804 .reboot_notify
= snd_hda_shutup_pins
,
3807 static int patch_conexant_auto(struct hda_codec
*codec
)
3809 struct conexant_spec
*spec
;
3812 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
3816 spec
->adc_nids
= cx_auto_adc_nids
;
3817 spec
->num_adc_nids
= ARRAY_SIZE(cx_auto_adc_nids
);
3818 spec
->capsrc_nids
= spec
->adc_nids
;
3819 err
= cx_auto_parse_auto_config(codec
);
3825 codec
->patch_ops
= cx_auto_patch_ops
;
3827 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
3834 static struct hda_codec_preset snd_hda_preset_conexant
[] = {
3835 { .id
= 0x14f15045, .name
= "CX20549 (Venice)",
3836 .patch
= patch_cxt5045
},
3837 { .id
= 0x14f15047, .name
= "CX20551 (Waikiki)",
3838 .patch
= patch_cxt5047
},
3839 { .id
= 0x14f15051, .name
= "CX20561 (Hermosa)",
3840 .patch
= patch_cxt5051
},
3841 { .id
= 0x14f15066, .name
= "CX20582 (Pebble)",
3842 .patch
= patch_cxt5066
},
3843 { .id
= 0x14f15067, .name
= "CX20583 (Pebble HSF)",
3844 .patch
= patch_cxt5066
},
3845 { .id
= 0x14f15068, .name
= "CX20584",
3846 .patch
= patch_cxt5066
},
3847 { .id
= 0x14f15069, .name
= "CX20585",
3848 .patch
= patch_cxt5066
},
3849 { .id
= 0x14f15097, .name
= "CX20631",
3850 .patch
= patch_conexant_auto
},
3851 { .id
= 0x14f15098, .name
= "CX20632",
3852 .patch
= patch_conexant_auto
},
3853 { .id
= 0x14f150a1, .name
= "CX20641",
3854 .patch
= patch_conexant_auto
},
3855 { .id
= 0x14f150a2, .name
= "CX20642",
3856 .patch
= patch_conexant_auto
},
3857 { .id
= 0x14f150ab, .name
= "CX20651",
3858 .patch
= patch_conexant_auto
},
3859 { .id
= 0x14f150ac, .name
= "CX20652",
3860 .patch
= patch_conexant_auto
},
3861 { .id
= 0x14f150b8, .name
= "CX20664",
3862 .patch
= patch_conexant_auto
},
3863 { .id
= 0x14f150b9, .name
= "CX20665",
3864 .patch
= patch_conexant_auto
},
3868 MODULE_ALIAS("snd-hda-codec-id:14f15045");
3869 MODULE_ALIAS("snd-hda-codec-id:14f15047");
3870 MODULE_ALIAS("snd-hda-codec-id:14f15051");
3871 MODULE_ALIAS("snd-hda-codec-id:14f15066");
3872 MODULE_ALIAS("snd-hda-codec-id:14f15067");
3873 MODULE_ALIAS("snd-hda-codec-id:14f15068");
3874 MODULE_ALIAS("snd-hda-codec-id:14f15069");
3875 MODULE_ALIAS("snd-hda-codec-id:14f15097");
3876 MODULE_ALIAS("snd-hda-codec-id:14f15098");
3877 MODULE_ALIAS("snd-hda-codec-id:14f150a1");
3878 MODULE_ALIAS("snd-hda-codec-id:14f150a2");
3879 MODULE_ALIAS("snd-hda-codec-id:14f150ab");
3880 MODULE_ALIAS("snd-hda-codec-id:14f150ac");
3881 MODULE_ALIAS("snd-hda-codec-id:14f150b8");
3882 MODULE_ALIAS("snd-hda-codec-id:14f150b9");
3884 MODULE_LICENSE("GPL");
3885 MODULE_DESCRIPTION("Conexant HD-audio codec");
3887 static struct hda_codec_preset_list conexant_list
= {
3888 .preset
= snd_hda_preset_conexant
,
3889 .owner
= THIS_MODULE
,
3892 static int __init
patch_conexant_init(void)
3894 return snd_hda_add_codec_preset(&conexant_list
);
3897 static void __exit
patch_conexant_exit(void)
3899 snd_hda_delete_codec_preset(&conexant_list
);
3902 module_init(patch_conexant_init
)
3903 module_exit(patch_conexant_exit
)