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;
132 unsigned int ext_mic_present
;
133 unsigned int recording
;
134 void (*capture_prepare
)(struct hda_codec
*codec
);
135 void (*capture_cleanup
)(struct hda_codec
*codec
);
137 /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors)
138 * through the microphone jack.
139 * When the user enables this through a mixer switch, both internal and
140 * external microphones are disabled. Gain is fixed at 0dB. In this mode,
141 * we also allow the bias to be configured through a separate mixer
143 unsigned int dc_enable
;
144 unsigned int dc_input_bias
; /* offset into cxt5066_olpc_dc_bias */
145 unsigned int mic_boost
; /* offset into cxt5066_analog_mic_boost */
147 unsigned int beep_amp
;
150 static int conexant_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
151 struct hda_codec
*codec
,
152 struct snd_pcm_substream
*substream
)
154 struct conexant_spec
*spec
= codec
->spec
;
155 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
159 static int conexant_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
160 struct hda_codec
*codec
,
161 unsigned int stream_tag
,
163 struct snd_pcm_substream
*substream
)
165 struct conexant_spec
*spec
= codec
->spec
;
166 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
,
171 static int conexant_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
172 struct hda_codec
*codec
,
173 struct snd_pcm_substream
*substream
)
175 struct conexant_spec
*spec
= codec
->spec
;
176 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
182 static int conexant_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
183 struct hda_codec
*codec
,
184 struct snd_pcm_substream
*substream
)
186 struct conexant_spec
*spec
= codec
->spec
;
187 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
190 static int conexant_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
191 struct hda_codec
*codec
,
192 struct snd_pcm_substream
*substream
)
194 struct conexant_spec
*spec
= codec
->spec
;
195 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
198 static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
199 struct hda_codec
*codec
,
200 unsigned int stream_tag
,
202 struct snd_pcm_substream
*substream
)
204 struct conexant_spec
*spec
= codec
->spec
;
205 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
213 static int conexant_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
214 struct hda_codec
*codec
,
215 unsigned int stream_tag
,
217 struct snd_pcm_substream
*substream
)
219 struct conexant_spec
*spec
= codec
->spec
;
220 if (spec
->capture_prepare
)
221 spec
->capture_prepare(codec
);
222 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
],
223 stream_tag
, 0, format
);
227 static int conexant_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
228 struct hda_codec
*codec
,
229 struct snd_pcm_substream
*substream
)
231 struct conexant_spec
*spec
= codec
->spec
;
232 snd_hda_codec_cleanup_stream(codec
, spec
->adc_nids
[substream
->number
]);
233 if (spec
->capture_cleanup
)
234 spec
->capture_cleanup(codec
);
240 static struct hda_pcm_stream conexant_pcm_analog_playback
= {
244 .nid
= 0, /* fill later */
246 .open
= conexant_playback_pcm_open
,
247 .prepare
= conexant_playback_pcm_prepare
,
248 .cleanup
= conexant_playback_pcm_cleanup
252 static struct hda_pcm_stream conexant_pcm_analog_capture
= {
256 .nid
= 0, /* fill later */
258 .prepare
= conexant_capture_pcm_prepare
,
259 .cleanup
= conexant_capture_pcm_cleanup
264 static struct hda_pcm_stream conexant_pcm_digital_playback
= {
268 .nid
= 0, /* fill later */
270 .open
= conexant_dig_playback_pcm_open
,
271 .close
= conexant_dig_playback_pcm_close
,
272 .prepare
= conexant_dig_playback_pcm_prepare
276 static struct hda_pcm_stream conexant_pcm_digital_capture
= {
280 /* NID is set in alc_build_pcms */
283 static int cx5051_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
284 struct hda_codec
*codec
,
285 unsigned int stream_tag
,
287 struct snd_pcm_substream
*substream
)
289 struct conexant_spec
*spec
= codec
->spec
;
290 spec
->cur_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
291 spec
->cur_adc_stream_tag
= stream_tag
;
292 spec
->cur_adc_format
= format
;
293 snd_hda_codec_setup_stream(codec
, spec
->cur_adc
, stream_tag
, 0, format
);
297 static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
298 struct hda_codec
*codec
,
299 struct snd_pcm_substream
*substream
)
301 struct conexant_spec
*spec
= codec
->spec
;
302 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
307 static struct hda_pcm_stream cx5051_pcm_analog_capture
= {
311 .nid
= 0, /* fill later */
313 .prepare
= cx5051_capture_pcm_prepare
,
314 .cleanup
= cx5051_capture_pcm_cleanup
318 static int conexant_build_pcms(struct hda_codec
*codec
)
320 struct conexant_spec
*spec
= codec
->spec
;
321 struct hda_pcm
*info
= spec
->pcm_rec
;
324 codec
->pcm_info
= info
;
326 info
->name
= "CONEXANT Analog";
327 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = conexant_pcm_analog_playback
;
328 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
=
329 spec
->multiout
.max_channels
;
330 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
331 spec
->multiout
.dac_nids
[0];
332 if (codec
->vendor_id
== 0x14f15051)
333 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
334 cx5051_pcm_analog_capture
;
336 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
337 conexant_pcm_analog_capture
;
338 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
= spec
->num_adc_nids
;
339 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
341 if (spec
->multiout
.dig_out_nid
) {
344 info
->name
= "Conexant Digital";
345 info
->pcm_type
= HDA_PCM_TYPE_SPDIF
;
346 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] =
347 conexant_pcm_digital_playback
;
348 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
349 spec
->multiout
.dig_out_nid
;
350 if (spec
->dig_in_nid
) {
351 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
352 conexant_pcm_digital_capture
;
353 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
=
361 static int conexant_mux_enum_info(struct snd_kcontrol
*kcontrol
,
362 struct snd_ctl_elem_info
*uinfo
)
364 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
365 struct conexant_spec
*spec
= codec
->spec
;
367 return snd_hda_input_mux_info(spec
->input_mux
, uinfo
);
370 static int conexant_mux_enum_get(struct snd_kcontrol
*kcontrol
,
371 struct snd_ctl_elem_value
*ucontrol
)
373 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
374 struct conexant_spec
*spec
= codec
->spec
;
375 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
377 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
381 static int conexant_mux_enum_put(struct snd_kcontrol
*kcontrol
,
382 struct snd_ctl_elem_value
*ucontrol
)
384 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
385 struct conexant_spec
*spec
= codec
->spec
;
386 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
388 return snd_hda_input_mux_put(codec
, spec
->input_mux
, ucontrol
,
389 spec
->capsrc_nids
[adc_idx
],
390 &spec
->cur_mux
[adc_idx
]);
393 #ifdef CONFIG_SND_HDA_INPUT_JACK
394 static void conexant_free_jack_priv(struct snd_jack
*jack
)
396 struct conexant_jack
*jacks
= jack
->private_data
;
401 static int conexant_add_jack(struct hda_codec
*codec
,
402 hda_nid_t nid
, int type
)
404 struct conexant_spec
*spec
;
405 struct conexant_jack
*jack
;
410 snd_array_init(&spec
->jacks
, sizeof(*jack
), 32);
411 jack
= snd_array_new(&spec
->jacks
);
412 name
= (type
== SND_JACK_HEADPHONE
) ? "Headphone" : "Mic" ;
420 err
= snd_jack_new(codec
->bus
->card
, name
, type
, &jack
->jack
);
423 jack
->jack
->private_data
= jack
;
424 jack
->jack
->private_free
= conexant_free_jack_priv
;
428 static void conexant_report_jack(struct hda_codec
*codec
, hda_nid_t nid
)
430 struct conexant_spec
*spec
= codec
->spec
;
431 struct conexant_jack
*jacks
= spec
->jacks
.list
;
435 for (i
= 0; i
< spec
->jacks
.used
; i
++) {
436 if (jacks
->nid
== nid
) {
437 unsigned int present
;
438 present
= snd_hda_jack_detect(codec
, nid
);
440 present
= (present
) ? jacks
->type
: 0 ;
442 snd_jack_report(jacks
->jack
,
450 static int conexant_init_jacks(struct hda_codec
*codec
)
452 struct conexant_spec
*spec
= codec
->spec
;
455 for (i
= 0; i
< spec
->num_init_verbs
; i
++) {
456 const struct hda_verb
*hv
;
458 hv
= spec
->init_verbs
[i
];
461 switch (hv
->param
^ AC_USRSP_EN
) {
462 case CONEXANT_HP_EVENT
:
463 err
= conexant_add_jack(codec
, hv
->nid
,
465 conexant_report_jack(codec
, hv
->nid
);
467 case CXT5051_PORTC_EVENT
:
468 case CONEXANT_MIC_EVENT
:
469 err
= conexant_add_jack(codec
, hv
->nid
,
470 SND_JACK_MICROPHONE
);
471 conexant_report_jack(codec
, hv
->nid
);
483 static inline void conexant_report_jack(struct hda_codec
*codec
, hda_nid_t nid
)
487 static inline int conexant_init_jacks(struct hda_codec
*codec
)
493 static int conexant_init(struct hda_codec
*codec
)
495 struct conexant_spec
*spec
= codec
->spec
;
498 for (i
= 0; i
< spec
->num_init_verbs
; i
++)
499 snd_hda_sequence_write(codec
, spec
->init_verbs
[i
]);
503 static void conexant_free(struct hda_codec
*codec
)
505 #ifdef CONFIG_SND_HDA_INPUT_JACK
506 struct conexant_spec
*spec
= codec
->spec
;
507 if (spec
->jacks
.list
) {
508 struct conexant_jack
*jacks
= spec
->jacks
.list
;
510 for (i
= 0; i
< spec
->jacks
.used
; i
++, jacks
++) {
512 snd_device_free(codec
->bus
->card
, jacks
->jack
);
514 snd_array_free(&spec
->jacks
);
517 snd_hda_detach_beep_device(codec
);
521 static struct snd_kcontrol_new cxt_capture_mixers
[] = {
523 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
524 .name
= "Capture Source",
525 .info
= conexant_mux_enum_info
,
526 .get
= conexant_mux_enum_get
,
527 .put
= conexant_mux_enum_put
532 #ifdef CONFIG_SND_HDA_INPUT_BEEP
533 /* additional beep mixers; the actual parameters are overwritten at build */
534 static struct snd_kcontrol_new cxt_beep_mixer
[] = {
535 HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT
),
536 HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT
),
541 static const char * const slave_vols
[] = {
542 "Headphone Playback Volume",
543 "Speaker Playback Volume",
547 static const char * const slave_sws
[] = {
548 "Headphone Playback Switch",
549 "Speaker Playback Switch",
553 static int conexant_build_controls(struct hda_codec
*codec
)
555 struct conexant_spec
*spec
= codec
->spec
;
559 for (i
= 0; i
< spec
->num_mixers
; i
++) {
560 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
564 if (spec
->multiout
.dig_out_nid
) {
565 err
= snd_hda_create_spdif_out_ctls(codec
,
566 spec
->multiout
.dig_out_nid
);
569 err
= snd_hda_create_spdif_share_sw(codec
,
573 spec
->multiout
.share_spdif
= 1;
575 if (spec
->dig_in_nid
) {
576 err
= snd_hda_create_spdif_in_ctls(codec
,spec
->dig_in_nid
);
581 /* if we have no master control, let's create it */
582 if (spec
->vmaster_nid
&&
583 !snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
584 unsigned int vmaster_tlv
[4];
585 snd_hda_set_vmaster_tlv(codec
, spec
->vmaster_nid
,
586 HDA_OUTPUT
, vmaster_tlv
);
587 err
= snd_hda_add_vmaster(codec
, "Master Playback Volume",
588 vmaster_tlv
, slave_vols
);
592 if (spec
->vmaster_nid
&&
593 !snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
594 err
= snd_hda_add_vmaster(codec
, "Master Playback Switch",
600 if (spec
->input_mux
) {
601 err
= snd_hda_add_new_ctls(codec
, cxt_capture_mixers
);
606 #ifdef CONFIG_SND_HDA_INPUT_BEEP
607 /* create beep controls if needed */
608 if (spec
->beep_amp
) {
609 struct snd_kcontrol_new
*knew
;
610 for (knew
= cxt_beep_mixer
; knew
->name
; knew
++) {
611 struct snd_kcontrol
*kctl
;
612 kctl
= snd_ctl_new1(knew
, codec
);
615 kctl
->private_value
= spec
->beep_amp
;
616 err
= snd_hda_ctl_add(codec
, 0, kctl
);
626 #ifdef CONFIG_SND_HDA_POWER_SAVE
627 static int conexant_suspend(struct hda_codec
*codec
, pm_message_t state
)
629 snd_hda_shutup_pins(codec
);
634 static struct hda_codec_ops conexant_patch_ops
= {
635 .build_controls
= conexant_build_controls
,
636 .build_pcms
= conexant_build_pcms
,
637 .init
= conexant_init
,
638 .free
= conexant_free
,
639 #ifdef CONFIG_SND_HDA_POWER_SAVE
640 .suspend
= conexant_suspend
,
642 .reboot_notify
= snd_hda_shutup_pins
,
645 #ifdef CONFIG_SND_HDA_INPUT_BEEP
646 #define set_beep_amp(spec, nid, idx, dir) \
647 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir))
649 #define set_beep_amp(spec, nid, idx, dir) /* NOP */
654 * the private value = nid | (invert << 8)
657 #define cxt_eapd_info snd_ctl_boolean_mono_info
659 static int cxt_eapd_get(struct snd_kcontrol
*kcontrol
,
660 struct snd_ctl_elem_value
*ucontrol
)
662 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
663 struct conexant_spec
*spec
= codec
->spec
;
664 int invert
= (kcontrol
->private_value
>> 8) & 1;
666 ucontrol
->value
.integer
.value
[0] = !spec
->cur_eapd
;
668 ucontrol
->value
.integer
.value
[0] = spec
->cur_eapd
;
673 static int cxt_eapd_put(struct snd_kcontrol
*kcontrol
,
674 struct snd_ctl_elem_value
*ucontrol
)
676 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
677 struct conexant_spec
*spec
= codec
->spec
;
678 int invert
= (kcontrol
->private_value
>> 8) & 1;
679 hda_nid_t nid
= kcontrol
->private_value
& 0xff;
682 eapd
= !!ucontrol
->value
.integer
.value
[0];
685 if (eapd
== spec
->cur_eapd
)
688 spec
->cur_eapd
= eapd
;
689 snd_hda_codec_write_cache(codec
, nid
,
690 0, AC_VERB_SET_EAPD_BTLENABLE
,
695 /* controls for test mode */
696 #ifdef CONFIG_SND_DEBUG
698 #define CXT_EAPD_SWITCH(xname, nid, mask) \
699 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
700 .info = cxt_eapd_info, \
701 .get = cxt_eapd_get, \
702 .put = cxt_eapd_put, \
703 .private_value = nid | (mask<<16) }
707 static int conexant_ch_mode_info(struct snd_kcontrol
*kcontrol
,
708 struct snd_ctl_elem_info
*uinfo
)
710 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
711 struct conexant_spec
*spec
= codec
->spec
;
712 return snd_hda_ch_mode_info(codec
, uinfo
, spec
->channel_mode
,
713 spec
->num_channel_mode
);
716 static int conexant_ch_mode_get(struct snd_kcontrol
*kcontrol
,
717 struct snd_ctl_elem_value
*ucontrol
)
719 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
720 struct conexant_spec
*spec
= codec
->spec
;
721 return snd_hda_ch_mode_get(codec
, ucontrol
, spec
->channel_mode
,
722 spec
->num_channel_mode
,
723 spec
->multiout
.max_channels
);
726 static int conexant_ch_mode_put(struct snd_kcontrol
*kcontrol
,
727 struct snd_ctl_elem_value
*ucontrol
)
729 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
730 struct conexant_spec
*spec
= codec
->spec
;
731 int err
= snd_hda_ch_mode_put(codec
, ucontrol
, spec
->channel_mode
,
732 spec
->num_channel_mode
,
733 &spec
->multiout
.max_channels
);
734 if (err
>= 0 && spec
->need_dac_fix
)
735 spec
->multiout
.num_dacs
= spec
->multiout
.max_channels
/ 2;
739 #define CXT_PIN_MODE(xname, nid, dir) \
740 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
741 .info = conexant_ch_mode_info, \
742 .get = conexant_ch_mode_get, \
743 .put = conexant_ch_mode_put, \
744 .private_value = nid | (dir<<16) }
746 #endif /* CONFIG_SND_DEBUG */
748 /* Conexant 5045 specific */
750 static hda_nid_t cxt5045_dac_nids
[1] = { 0x19 };
751 static hda_nid_t cxt5045_adc_nids
[1] = { 0x1a };
752 static hda_nid_t cxt5045_capsrc_nids
[1] = { 0x1a };
753 #define CXT5045_SPDIF_OUT 0x18
755 static struct hda_channel_mode cxt5045_modes
[1] = {
759 static struct hda_input_mux cxt5045_capture_source
= {
767 static struct hda_input_mux cxt5045_capture_source_benq
= {
778 static struct hda_input_mux cxt5045_capture_source_hp530
= {
786 /* turn on/off EAPD (+ mute HP) as a master switch */
787 static int cxt5045_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
788 struct snd_ctl_elem_value
*ucontrol
)
790 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
791 struct conexant_spec
*spec
= codec
->spec
;
794 if (!cxt_eapd_put(kcontrol
, ucontrol
))
797 /* toggle internal speakers mute depending of presence of
800 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
801 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
804 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
805 snd_hda_codec_amp_stereo(codec
, 0x11, HDA_OUTPUT
, 0,
810 /* bind volumes of both NID 0x10 and 0x11 */
811 static struct hda_bind_ctls cxt5045_hp_bind_master_vol
= {
812 .ops
= &snd_hda_bind_vol
,
814 HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT
),
815 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT
),
820 /* toggle input of built-in and mic jack appropriately */
821 static void cxt5045_hp_automic(struct hda_codec
*codec
)
823 static struct hda_verb mic_jack_on
[] = {
824 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
825 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
828 static struct hda_verb mic_jack_off
[] = {
829 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
830 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
833 unsigned int present
;
835 present
= snd_hda_jack_detect(codec
, 0x12);
837 snd_hda_sequence_write(codec
, mic_jack_on
);
839 snd_hda_sequence_write(codec
, mic_jack_off
);
843 /* mute internal speaker if HP is plugged */
844 static void cxt5045_hp_automute(struct hda_codec
*codec
)
846 struct conexant_spec
*spec
= codec
->spec
;
849 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x11);
851 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
852 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
856 /* unsolicited event for HP jack sensing */
857 static void cxt5045_hp_unsol_event(struct hda_codec
*codec
,
862 case CONEXANT_HP_EVENT
:
863 cxt5045_hp_automute(codec
);
865 case CONEXANT_MIC_EVENT
:
866 cxt5045_hp_automic(codec
);
872 static struct snd_kcontrol_new cxt5045_mixers
[] = {
873 HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x1a, 0x01, HDA_INPUT
),
874 HDA_CODEC_MUTE("Internal Mic Capture Switch", 0x1a, 0x01, HDA_INPUT
),
875 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1a, 0x02, HDA_INPUT
),
876 HDA_CODEC_MUTE("Mic Capture Switch", 0x1a, 0x02, HDA_INPUT
),
877 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT
),
878 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT
),
879 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
880 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x1, HDA_INPUT
),
881 HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
882 HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
883 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol
),
885 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
886 .name
= "Master Playback Switch",
887 .info
= cxt_eapd_info
,
889 .put
= cxt5045_hp_master_sw_put
,
890 .private_value
= 0x10,
896 static struct snd_kcontrol_new cxt5045_benq_mixers
[] = {
897 HDA_CODEC_VOLUME("CD Capture Volume", 0x1a, 0x04, HDA_INPUT
),
898 HDA_CODEC_MUTE("CD Capture Switch", 0x1a, 0x04, HDA_INPUT
),
899 HDA_CODEC_VOLUME("CD Playback Volume", 0x17, 0x4, HDA_INPUT
),
900 HDA_CODEC_MUTE("CD Playback Switch", 0x17, 0x4, HDA_INPUT
),
902 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1a, 0x03, HDA_INPUT
),
903 HDA_CODEC_MUTE("Line In Capture Switch", 0x1a, 0x03, HDA_INPUT
),
904 HDA_CODEC_VOLUME("Line In Playback Volume", 0x17, 0x3, HDA_INPUT
),
905 HDA_CODEC_MUTE("Line In Playback Switch", 0x17, 0x3, HDA_INPUT
),
907 HDA_CODEC_VOLUME("Mixer Capture Volume", 0x1a, 0x0, HDA_INPUT
),
908 HDA_CODEC_MUTE("Mixer Capture Switch", 0x1a, 0x0, HDA_INPUT
),
913 static struct snd_kcontrol_new cxt5045_mixers_hp530
[] = {
914 HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x1a, 0x02, HDA_INPUT
),
915 HDA_CODEC_MUTE("Internal Mic Capture Switch", 0x1a, 0x02, HDA_INPUT
),
916 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1a, 0x01, HDA_INPUT
),
917 HDA_CODEC_MUTE("Mic Capture Switch", 0x1a, 0x01, HDA_INPUT
),
918 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT
),
919 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT
),
920 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
921 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
922 HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
923 HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x1, HDA_INPUT
),
924 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol
),
926 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
927 .name
= "Master Playback Switch",
928 .info
= cxt_eapd_info
,
930 .put
= cxt5045_hp_master_sw_put
,
931 .private_value
= 0x10,
937 static struct hda_verb cxt5045_init_verbs
[] = {
939 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
940 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
942 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
943 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
944 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
945 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
946 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
947 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
948 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
949 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
950 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
951 /* Record selector: Internal mic */
952 {0x1a, AC_VERB_SET_CONNECT_SEL
,0x1},
953 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
954 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
955 /* SPDIF route: PCM */
956 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
957 { 0x13, AC_VERB_SET_CONNECT_SEL
, 0x0 },
959 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2 }, /* default on */
963 static struct hda_verb cxt5045_benq_init_verbs
[] = {
964 /* Internal Mic, Mic */
965 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
966 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
967 /* Line In,HP, Amp */
968 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
969 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
970 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
971 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
972 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
973 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
974 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
975 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
976 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
977 /* Record selector: Internal mic */
978 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x1},
979 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
980 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
981 /* SPDIF route: PCM */
982 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
983 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0},
985 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
989 static struct hda_verb cxt5045_hp_sense_init_verbs
[] = {
990 /* pin sensing on HP jack */
991 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
995 static struct hda_verb cxt5045_mic_sense_init_verbs
[] = {
996 /* pin sensing on HP jack */
997 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
1001 #ifdef CONFIG_SND_DEBUG
1002 /* Test configuration for debugging, modelled after the ALC260 test
1005 static struct hda_input_mux cxt5045_test_capture_source
= {
1009 { "MIC1 pin", 0x1 },
1010 { "LINE1 pin", 0x2 },
1011 { "HP-OUT pin", 0x3 },
1016 static struct snd_kcontrol_new cxt5045_test_mixer
[] = {
1018 /* Output controls */
1019 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT
),
1020 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT
),
1021 HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
1022 HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
1023 HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
1024 HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
1026 /* Modes for retasking pin widgets */
1027 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT
),
1028 CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT
),
1030 /* EAPD Switch Control */
1031 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
1033 /* Loopback mixer controls */
1035 HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT
),
1036 HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT
),
1037 HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT
),
1038 HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT
),
1039 HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT
),
1040 HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT
),
1041 HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT
),
1042 HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT
),
1043 HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT
),
1044 HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT
),
1046 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1047 .name
= "Input Source",
1048 .info
= conexant_mux_enum_info
,
1049 .get
= conexant_mux_enum_get
,
1050 .put
= conexant_mux_enum_put
,
1052 /* Audio input controls */
1053 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT
),
1054 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT
),
1055 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT
),
1056 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT
),
1057 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT
),
1058 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT
),
1059 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT
),
1060 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT
),
1061 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT
),
1062 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT
),
1066 static struct hda_verb cxt5045_test_init_verbs
[] = {
1067 /* Set connections */
1068 { 0x10, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1069 { 0x11, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1070 { 0x12, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1071 /* Enable retasking pins as output, initially without power amp */
1072 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1073 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1075 /* Disable digital (SPDIF) pins initially, but users can enable
1076 * them via a mixer switch. In the case of SPDIF-out, this initverb
1077 * payload also sets the generation to 0, output to be in "consumer"
1078 * PCM format, copyright asserted, no pre-emphasis and no validity
1081 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1082 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
1084 /* Start with output sum widgets muted and their output gains at min */
1085 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1086 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1088 /* Unmute retasking pin widget output buffers since the default
1089 * state appears to be output. As the pin mode is changed by the
1090 * user the pin mode control will take care of enabling the pin's
1091 * input/output buffers as needed.
1093 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1094 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1096 /* Mute capture amp left and right */
1097 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1099 /* Set ADC connection select to match default mixer setting (mic1
1102 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1103 {0x17, AC_VERB_SET_CONNECT_SEL
, 0x00},
1105 /* Mute all inputs to mixer widget (even unconnected ones) */
1106 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* Mixer pin */
1107 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* Mic1 pin */
1108 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* Line pin */
1109 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* HP pin */
1110 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
1117 /* initialize jack-sensing, too */
1118 static int cxt5045_init(struct hda_codec
*codec
)
1120 conexant_init(codec
);
1121 cxt5045_hp_automute(codec
);
1127 CXT5045_LAPTOP_HPSENSE
,
1128 CXT5045_LAPTOP_MICSENSE
,
1129 CXT5045_LAPTOP_HPMICSENSE
,
1131 CXT5045_LAPTOP_HP530
,
1132 #ifdef CONFIG_SND_DEBUG
1138 static const char * const cxt5045_models
[CXT5045_MODELS
] = {
1139 [CXT5045_LAPTOP_HPSENSE
] = "laptop-hpsense",
1140 [CXT5045_LAPTOP_MICSENSE
] = "laptop-micsense",
1141 [CXT5045_LAPTOP_HPMICSENSE
] = "laptop-hpmicsense",
1142 [CXT5045_BENQ
] = "benq",
1143 [CXT5045_LAPTOP_HP530
] = "laptop-hp530",
1144 #ifdef CONFIG_SND_DEBUG
1145 [CXT5045_TEST
] = "test",
1149 static struct snd_pci_quirk cxt5045_cfg_tbl
[] = {
1150 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530
),
1151 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1152 CXT5045_LAPTOP_HPSENSE
),
1153 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE
),
1154 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ
),
1155 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE
),
1156 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE
),
1157 SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505",
1158 CXT5045_LAPTOP_HPMICSENSE
),
1159 SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1160 SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1161 SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1162 SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell",
1163 CXT5045_LAPTOP_HPMICSENSE
),
1164 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE
),
1168 static int patch_cxt5045(struct hda_codec
*codec
)
1170 struct conexant_spec
*spec
;
1173 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1177 codec
->pin_amp_workaround
= 1;
1179 spec
->multiout
.max_channels
= 2;
1180 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5045_dac_nids
);
1181 spec
->multiout
.dac_nids
= cxt5045_dac_nids
;
1182 spec
->multiout
.dig_out_nid
= CXT5045_SPDIF_OUT
;
1183 spec
->num_adc_nids
= 1;
1184 spec
->adc_nids
= cxt5045_adc_nids
;
1185 spec
->capsrc_nids
= cxt5045_capsrc_nids
;
1186 spec
->input_mux
= &cxt5045_capture_source
;
1187 spec
->num_mixers
= 1;
1188 spec
->mixers
[0] = cxt5045_mixers
;
1189 spec
->num_init_verbs
= 1;
1190 spec
->init_verbs
[0] = cxt5045_init_verbs
;
1191 spec
->spdif_route
= 0;
1192 spec
->num_channel_mode
= ARRAY_SIZE(cxt5045_modes
);
1193 spec
->channel_mode
= cxt5045_modes
;
1195 set_beep_amp(spec
, 0x16, 0, 1);
1197 codec
->patch_ops
= conexant_patch_ops
;
1199 board_config
= snd_hda_check_board_config(codec
, CXT5045_MODELS
,
1202 switch (board_config
) {
1203 case CXT5045_LAPTOP_HPSENSE
:
1204 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1205 spec
->input_mux
= &cxt5045_capture_source
;
1206 spec
->num_init_verbs
= 2;
1207 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1208 spec
->mixers
[0] = cxt5045_mixers
;
1209 codec
->patch_ops
.init
= cxt5045_init
;
1211 case CXT5045_LAPTOP_MICSENSE
:
1212 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1213 spec
->input_mux
= &cxt5045_capture_source
;
1214 spec
->num_init_verbs
= 2;
1215 spec
->init_verbs
[1] = cxt5045_mic_sense_init_verbs
;
1216 spec
->mixers
[0] = cxt5045_mixers
;
1217 codec
->patch_ops
.init
= cxt5045_init
;
1220 case CXT5045_LAPTOP_HPMICSENSE
:
1221 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1222 spec
->input_mux
= &cxt5045_capture_source
;
1223 spec
->num_init_verbs
= 3;
1224 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1225 spec
->init_verbs
[2] = cxt5045_mic_sense_init_verbs
;
1226 spec
->mixers
[0] = cxt5045_mixers
;
1227 codec
->patch_ops
.init
= cxt5045_init
;
1230 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1231 spec
->input_mux
= &cxt5045_capture_source_benq
;
1232 spec
->num_init_verbs
= 1;
1233 spec
->init_verbs
[0] = cxt5045_benq_init_verbs
;
1234 spec
->mixers
[0] = cxt5045_mixers
;
1235 spec
->mixers
[1] = cxt5045_benq_mixers
;
1236 spec
->num_mixers
= 2;
1237 codec
->patch_ops
.init
= cxt5045_init
;
1239 case CXT5045_LAPTOP_HP530
:
1240 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1241 spec
->input_mux
= &cxt5045_capture_source_hp530
;
1242 spec
->num_init_verbs
= 2;
1243 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1244 spec
->mixers
[0] = cxt5045_mixers_hp530
;
1245 codec
->patch_ops
.init
= cxt5045_init
;
1247 #ifdef CONFIG_SND_DEBUG
1249 spec
->input_mux
= &cxt5045_test_capture_source
;
1250 spec
->mixers
[0] = cxt5045_test_mixer
;
1251 spec
->init_verbs
[0] = cxt5045_test_init_verbs
;
1257 switch (codec
->subsystem_id
>> 16) {
1262 /* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have
1263 * really bad sound over 0dB on NID 0x17. Fix max PCM level to
1264 * 0 dB (originally it has 0x2b steps with 0dB offset 0x14)
1266 snd_hda_override_amp_caps(codec
, 0x17, HDA_INPUT
,
1267 (0x14 << AC_AMPCAP_OFFSET_SHIFT
) |
1268 (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
1269 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
1270 (1 << AC_AMPCAP_MUTE_SHIFT
));
1275 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
1281 /* Conexant 5047 specific */
1282 #define CXT5047_SPDIF_OUT 0x11
1284 static hda_nid_t cxt5047_dac_nids
[1] = { 0x10 }; /* 0x1c */
1285 static hda_nid_t cxt5047_adc_nids
[1] = { 0x12 };
1286 static hda_nid_t cxt5047_capsrc_nids
[1] = { 0x1a };
1288 static struct hda_channel_mode cxt5047_modes
[1] = {
1292 static struct hda_input_mux cxt5047_toshiba_capture_source
= {
1300 /* turn on/off EAPD (+ mute HP) as a master switch */
1301 static int cxt5047_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1302 struct snd_ctl_elem_value
*ucontrol
)
1304 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1305 struct conexant_spec
*spec
= codec
->spec
;
1308 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1311 /* toggle internal speakers mute depending of presence of
1312 * the headphone jack
1314 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
1315 /* NOTE: Conexat codec needs the index for *OUTPUT* amp of
1316 * pin widgets unlike other codecs. In this case, we need to
1317 * set index 0x01 for the volume from the mixer amp 0x19.
1319 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0x01,
1320 HDA_AMP_MUTE
, bits
);
1321 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
1322 snd_hda_codec_amp_stereo(codec
, 0x13, HDA_OUTPUT
, 0,
1323 HDA_AMP_MUTE
, bits
);
1327 /* mute internal speaker if HP is plugged */
1328 static void cxt5047_hp_automute(struct hda_codec
*codec
)
1330 struct conexant_spec
*spec
= codec
->spec
;
1333 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x13);
1335 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
1336 /* See the note in cxt5047_hp_master_sw_put */
1337 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0x01,
1338 HDA_AMP_MUTE
, bits
);
1341 /* toggle input of built-in and mic jack appropriately */
1342 static void cxt5047_hp_automic(struct hda_codec
*codec
)
1344 static struct hda_verb mic_jack_on
[] = {
1345 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1346 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1349 static struct hda_verb mic_jack_off
[] = {
1350 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1351 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1354 unsigned int present
;
1356 present
= snd_hda_jack_detect(codec
, 0x15);
1358 snd_hda_sequence_write(codec
, mic_jack_on
);
1360 snd_hda_sequence_write(codec
, mic_jack_off
);
1363 /* unsolicited event for HP jack sensing */
1364 static void cxt5047_hp_unsol_event(struct hda_codec
*codec
,
1367 switch (res
>> 26) {
1368 case CONEXANT_HP_EVENT
:
1369 cxt5047_hp_automute(codec
);
1371 case CONEXANT_MIC_EVENT
:
1372 cxt5047_hp_automic(codec
);
1377 static struct snd_kcontrol_new cxt5047_base_mixers
[] = {
1378 HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT
),
1379 HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT
),
1380 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT
),
1381 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT
),
1382 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT
),
1383 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT
),
1384 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT
),
1386 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1387 .name
= "Master Playback Switch",
1388 .info
= cxt_eapd_info
,
1389 .get
= cxt_eapd_get
,
1390 .put
= cxt5047_hp_master_sw_put
,
1391 .private_value
= 0x13,
1397 static struct snd_kcontrol_new cxt5047_hp_spk_mixers
[] = {
1398 /* See the note in cxt5047_hp_master_sw_put */
1399 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT
),
1400 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1404 static struct snd_kcontrol_new cxt5047_hp_only_mixers
[] = {
1405 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1409 static struct hda_verb cxt5047_init_verbs
[] = {
1410 /* Line in, Mic, Built-in Mic */
1411 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1412 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1413 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1415 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1416 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* mixer(0x19) */
1417 {0x1d, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* mixer(0x19) */
1418 /* Record selector: Mic */
1419 {0x12, AC_VERB_SET_CONNECT_SEL
,0x03},
1420 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
,
1421 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
1422 {0x1A, AC_VERB_SET_CONNECT_SEL
,0x02},
1423 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1424 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x00},
1425 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1426 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x03},
1427 /* SPDIF route: PCM */
1428 { 0x18, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1429 /* Enable unsolicited events */
1430 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
1431 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
1435 /* configuration for Toshiba Laptops */
1436 static struct hda_verb cxt5047_toshiba_init_verbs
[] = {
1437 {0x13, AC_VERB_SET_EAPD_BTLENABLE
, 0x0}, /* default off */
1441 /* Test configuration for debugging, modelled after the ALC260 test
1444 #ifdef CONFIG_SND_DEBUG
1445 static struct hda_input_mux cxt5047_test_capture_source
= {
1448 { "LINE1 pin", 0x0 },
1449 { "MIC1 pin", 0x1 },
1450 { "MIC2 pin", 0x2 },
1455 static struct snd_kcontrol_new cxt5047_test_mixer
[] = {
1457 /* Output only controls */
1458 HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT
),
1459 HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT
),
1460 HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT
),
1461 HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT
),
1462 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
1463 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT
),
1464 HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
1465 HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
1466 HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT
),
1467 HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT
),
1468 HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT
),
1469 HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT
),
1471 /* Modes for retasking pin widgets */
1472 CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT
),
1473 CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT
),
1475 /* EAPD Switch Control */
1476 CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0),
1478 /* Loopback mixer controls */
1479 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT
),
1480 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT
),
1481 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT
),
1482 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT
),
1483 HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT
),
1484 HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT
),
1485 HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT
),
1486 HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT
),
1488 HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT
),
1489 HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT
),
1490 HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT
),
1491 HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT
),
1492 HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT
),
1493 HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT
),
1494 HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT
),
1495 HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT
),
1497 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1498 .name
= "Input Source",
1499 .info
= conexant_mux_enum_info
,
1500 .get
= conexant_mux_enum_get
,
1501 .put
= conexant_mux_enum_put
,
1503 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT
),
1508 static struct hda_verb cxt5047_test_init_verbs
[] = {
1509 /* Enable retasking pins as output, initially without power amp */
1510 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1511 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1512 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1514 /* Disable digital (SPDIF) pins initially, but users can enable
1515 * them via a mixer switch. In the case of SPDIF-out, this initverb
1516 * payload also sets the generation to 0, output to be in "consumer"
1517 * PCM format, copyright asserted, no pre-emphasis and no validity
1520 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
1522 /* Ensure mic1, mic2, line1 pin widgets take input from the
1523 * OUT1 sum bus when acting as an output.
1525 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0},
1526 {0x1b, AC_VERB_SET_CONNECT_SEL
, 0},
1528 /* Start with output sum widgets muted and their output gains at min */
1529 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1530 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1532 /* Unmute retasking pin widget output buffers since the default
1533 * state appears to be output. As the pin mode is changed by the
1534 * user the pin mode control will take care of enabling the pin's
1535 * input/output buffers as needed.
1537 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1538 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1539 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1541 /* Mute capture amp left and right */
1542 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1544 /* Set ADC connection select to match default mixer setting (mic1
1547 {0x12, AC_VERB_SET_CONNECT_SEL
, 0x00},
1549 /* Mute all inputs to mixer widget (even unconnected ones) */
1550 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* mic1 pin */
1551 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* mic2 pin */
1552 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* line1 pin */
1553 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* line2 pin */
1554 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
1555 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)}, /* Beep-gen pin */
1556 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)}, /* Line-out pin */
1557 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)}, /* HP-pin pin */
1564 /* initialize jack-sensing, too */
1565 static int cxt5047_hp_init(struct hda_codec
*codec
)
1567 conexant_init(codec
);
1568 cxt5047_hp_automute(codec
);
1574 CXT5047_LAPTOP
, /* Laptops w/o EAPD support */
1575 CXT5047_LAPTOP_HP
, /* Some HP laptops */
1576 CXT5047_LAPTOP_EAPD
, /* Laptops with EAPD support */
1577 #ifdef CONFIG_SND_DEBUG
1583 static const char * const cxt5047_models
[CXT5047_MODELS
] = {
1584 [CXT5047_LAPTOP
] = "laptop",
1585 [CXT5047_LAPTOP_HP
] = "laptop-hp",
1586 [CXT5047_LAPTOP_EAPD
] = "laptop-eapd",
1587 #ifdef CONFIG_SND_DEBUG
1588 [CXT5047_TEST
] = "test",
1592 static struct snd_pci_quirk cxt5047_cfg_tbl
[] = {
1593 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP
),
1594 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1596 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD
),
1600 static int patch_cxt5047(struct hda_codec
*codec
)
1602 struct conexant_spec
*spec
;
1605 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1609 codec
->pin_amp_workaround
= 1;
1611 spec
->multiout
.max_channels
= 2;
1612 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5047_dac_nids
);
1613 spec
->multiout
.dac_nids
= cxt5047_dac_nids
;
1614 spec
->multiout
.dig_out_nid
= CXT5047_SPDIF_OUT
;
1615 spec
->num_adc_nids
= 1;
1616 spec
->adc_nids
= cxt5047_adc_nids
;
1617 spec
->capsrc_nids
= cxt5047_capsrc_nids
;
1618 spec
->num_mixers
= 1;
1619 spec
->mixers
[0] = cxt5047_base_mixers
;
1620 spec
->num_init_verbs
= 1;
1621 spec
->init_verbs
[0] = cxt5047_init_verbs
;
1622 spec
->spdif_route
= 0;
1623 spec
->num_channel_mode
= ARRAY_SIZE(cxt5047_modes
),
1624 spec
->channel_mode
= cxt5047_modes
,
1626 codec
->patch_ops
= conexant_patch_ops
;
1628 board_config
= snd_hda_check_board_config(codec
, CXT5047_MODELS
,
1631 switch (board_config
) {
1632 case CXT5047_LAPTOP
:
1633 spec
->num_mixers
= 2;
1634 spec
->mixers
[1] = cxt5047_hp_spk_mixers
;
1635 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1637 case CXT5047_LAPTOP_HP
:
1638 spec
->num_mixers
= 2;
1639 spec
->mixers
[1] = cxt5047_hp_only_mixers
;
1640 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1641 codec
->patch_ops
.init
= cxt5047_hp_init
;
1643 case CXT5047_LAPTOP_EAPD
:
1644 spec
->input_mux
= &cxt5047_toshiba_capture_source
;
1645 spec
->num_mixers
= 2;
1646 spec
->mixers
[1] = cxt5047_hp_spk_mixers
;
1647 spec
->num_init_verbs
= 2;
1648 spec
->init_verbs
[1] = cxt5047_toshiba_init_verbs
;
1649 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1651 #ifdef CONFIG_SND_DEBUG
1653 spec
->input_mux
= &cxt5047_test_capture_source
;
1654 spec
->mixers
[0] = cxt5047_test_mixer
;
1655 spec
->init_verbs
[0] = cxt5047_test_init_verbs
;
1656 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1659 spec
->vmaster_nid
= 0x13;
1661 switch (codec
->subsystem_id
>> 16) {
1663 /* HP laptops have really bad sound over 0 dB on NID 0x10.
1664 * Fix max PCM level to 0 dB (originally it has 0x1e steps
1665 * with 0 dB offset 0x17)
1667 snd_hda_override_amp_caps(codec
, 0x10, HDA_INPUT
,
1668 (0x17 << AC_AMPCAP_OFFSET_SHIFT
) |
1669 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
1670 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
1671 (1 << AC_AMPCAP_MUTE_SHIFT
));
1678 /* Conexant 5051 specific */
1679 static hda_nid_t cxt5051_dac_nids
[1] = { 0x10 };
1680 static hda_nid_t cxt5051_adc_nids
[2] = { 0x14, 0x15 };
1682 static struct hda_channel_mode cxt5051_modes
[1] = {
1686 static void cxt5051_update_speaker(struct hda_codec
*codec
)
1688 struct conexant_spec
*spec
= codec
->spec
;
1689 unsigned int pinctl
;
1691 pinctl
= (spec
->hp_present
&& spec
->cur_eapd
) ? PIN_HP
: 0;
1692 snd_hda_codec_write(codec
, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1695 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
1696 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1698 /* on ideapad there is an aditional speaker (subwoofer) to mute */
1700 snd_hda_codec_write(codec
, 0x1b, 0,
1701 AC_VERB_SET_PIN_WIDGET_CONTROL
,
1705 /* turn on/off EAPD (+ mute HP) as a master switch */
1706 static int cxt5051_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1707 struct snd_ctl_elem_value
*ucontrol
)
1709 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1711 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1713 cxt5051_update_speaker(codec
);
1717 /* toggle input of built-in and mic jack appropriately */
1718 static void cxt5051_portb_automic(struct hda_codec
*codec
)
1720 struct conexant_spec
*spec
= codec
->spec
;
1721 unsigned int present
;
1723 if (!(spec
->auto_mic
& AUTO_MIC_PORTB
))
1725 present
= snd_hda_jack_detect(codec
, 0x17);
1726 snd_hda_codec_write(codec
, 0x14, 0,
1727 AC_VERB_SET_CONNECT_SEL
,
1728 present
? 0x01 : 0x00);
1731 /* switch the current ADC according to the jack state */
1732 static void cxt5051_portc_automic(struct hda_codec
*codec
)
1734 struct conexant_spec
*spec
= codec
->spec
;
1735 unsigned int present
;
1738 if (!(spec
->auto_mic
& AUTO_MIC_PORTC
))
1740 present
= snd_hda_jack_detect(codec
, 0x18);
1742 spec
->cur_adc_idx
= 1;
1744 spec
->cur_adc_idx
= 0;
1745 new_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
1746 if (spec
->cur_adc
&& spec
->cur_adc
!= new_adc
) {
1747 /* stream is running, let's swap the current ADC */
1748 __snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
, 1);
1749 spec
->cur_adc
= new_adc
;
1750 snd_hda_codec_setup_stream(codec
, new_adc
,
1751 spec
->cur_adc_stream_tag
, 0,
1752 spec
->cur_adc_format
);
1756 /* mute internal speaker if HP is plugged */
1757 static void cxt5051_hp_automute(struct hda_codec
*codec
)
1759 struct conexant_spec
*spec
= codec
->spec
;
1761 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x16);
1762 cxt5051_update_speaker(codec
);
1765 /* unsolicited event for HP jack sensing */
1766 static void cxt5051_hp_unsol_event(struct hda_codec
*codec
,
1769 int nid
= (res
& AC_UNSOL_RES_SUBTAG
) >> 20;
1770 switch (res
>> 26) {
1771 case CONEXANT_HP_EVENT
:
1772 cxt5051_hp_automute(codec
);
1774 case CXT5051_PORTB_EVENT
:
1775 cxt5051_portb_automic(codec
);
1777 case CXT5051_PORTC_EVENT
:
1778 cxt5051_portc_automic(codec
);
1781 conexant_report_jack(codec
, nid
);
1784 static struct snd_kcontrol_new cxt5051_playback_mixers
[] = {
1785 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
1787 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1788 .name
= "Master Playback Switch",
1789 .info
= cxt_eapd_info
,
1790 .get
= cxt_eapd_get
,
1791 .put
= cxt5051_hp_master_sw_put
,
1792 .private_value
= 0x1a,
1797 static struct snd_kcontrol_new cxt5051_capture_mixers
[] = {
1798 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1799 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1800 HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT
),
1801 HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT
),
1802 HDA_CODEC_VOLUME("Docking Mic Volume", 0x15, 0x00, HDA_INPUT
),
1803 HDA_CODEC_MUTE("Docking Mic Switch", 0x15, 0x00, HDA_INPUT
),
1807 static struct snd_kcontrol_new cxt5051_hp_mixers
[] = {
1808 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1809 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1810 HDA_CODEC_VOLUME("Mic Volume", 0x15, 0x00, HDA_INPUT
),
1811 HDA_CODEC_MUTE("Mic Switch", 0x15, 0x00, HDA_INPUT
),
1815 static struct snd_kcontrol_new cxt5051_hp_dv6736_mixers
[] = {
1816 HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x00, HDA_INPUT
),
1817 HDA_CODEC_MUTE("Capture Switch", 0x14, 0x00, HDA_INPUT
),
1821 static struct snd_kcontrol_new cxt5051_f700_mixers
[] = {
1822 HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x01, HDA_INPUT
),
1823 HDA_CODEC_MUTE("Capture Switch", 0x14, 0x01, HDA_INPUT
),
1827 static struct snd_kcontrol_new cxt5051_toshiba_mixers
[] = {
1828 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1829 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1830 HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT
),
1831 HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT
),
1835 static struct hda_verb cxt5051_init_verbs
[] = {
1837 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1838 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1839 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1840 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1841 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1842 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1844 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1845 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1847 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1848 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1850 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1851 /* Record selector: Internal mic */
1852 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1853 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1854 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1855 /* SPDIF route: PCM */
1856 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1857 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1859 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1860 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1864 static struct hda_verb cxt5051_hp_dv6736_init_verbs
[] = {
1866 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1867 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1868 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1869 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1871 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1872 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1874 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1875 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1877 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1878 /* Record selector: Internal mic */
1879 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1880 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x1},
1881 /* SPDIF route: PCM */
1882 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1884 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1885 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1889 static struct hda_verb cxt5051_lenovo_x200_init_verbs
[] = {
1891 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1892 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1893 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1894 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1895 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1896 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1898 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1899 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1901 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1902 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1904 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1905 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00},
1907 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1908 /* Record selector: Internal mic */
1909 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1910 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1911 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1912 /* SPDIF route: PCM */
1913 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
}, /* needed for W500 Advanced Mini Dock 250410 */
1914 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1916 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1917 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1918 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1922 static struct hda_verb cxt5051_f700_init_verbs
[] = {
1924 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1925 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1926 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1927 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1929 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1930 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1932 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1933 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1935 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1936 /* Record selector: Internal mic */
1937 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1938 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x1},
1939 /* SPDIF route: PCM */
1940 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1942 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1943 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1947 static void cxt5051_init_mic_port(struct hda_codec
*codec
, hda_nid_t nid
,
1950 snd_hda_codec_write(codec
, nid
, 0,
1951 AC_VERB_SET_UNSOLICITED_ENABLE
,
1952 AC_USRSP_EN
| event
);
1953 #ifdef CONFIG_SND_HDA_INPUT_JACK
1954 conexant_add_jack(codec
, nid
, SND_JACK_MICROPHONE
);
1955 conexant_report_jack(codec
, nid
);
1959 static struct hda_verb cxt5051_ideapad_init_verbs
[] = {
1961 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1962 {0x1b, AC_VERB_SET_CONNECT_SEL
, 0x00},
1966 /* initialize jack-sensing, too */
1967 static int cxt5051_init(struct hda_codec
*codec
)
1969 struct conexant_spec
*spec
= codec
->spec
;
1971 conexant_init(codec
);
1972 conexant_init_jacks(codec
);
1974 if (spec
->auto_mic
& AUTO_MIC_PORTB
)
1975 cxt5051_init_mic_port(codec
, 0x17, CXT5051_PORTB_EVENT
);
1976 if (spec
->auto_mic
& AUTO_MIC_PORTC
)
1977 cxt5051_init_mic_port(codec
, 0x18, CXT5051_PORTC_EVENT
);
1979 if (codec
->patch_ops
.unsol_event
) {
1980 cxt5051_hp_automute(codec
);
1981 cxt5051_portb_automic(codec
);
1982 cxt5051_portc_automic(codec
);
1989 CXT5051_LAPTOP
, /* Laptops w/ EAPD support */
1990 CXT5051_HP
, /* no docking */
1991 CXT5051_HP_DV6736
, /* HP without mic switch */
1992 CXT5051_LENOVO_X200
, /* Lenovo X200 laptop, also used for Advanced Mini Dock 250410 */
1993 CXT5051_F700
, /* HP Compaq Presario F700 */
1994 CXT5051_TOSHIBA
, /* Toshiba M300 & co */
1995 CXT5051_IDEAPAD
, /* Lenovo IdeaPad Y430 */
1999 static const char *const cxt5051_models
[CXT5051_MODELS
] = {
2000 [CXT5051_LAPTOP
] = "laptop",
2001 [CXT5051_HP
] = "hp",
2002 [CXT5051_HP_DV6736
] = "hp-dv6736",
2003 [CXT5051_LENOVO_X200
] = "lenovo-x200",
2004 [CXT5051_F700
] = "hp-700",
2005 [CXT5051_TOSHIBA
] = "toshiba",
2006 [CXT5051_IDEAPAD
] = "ideapad",
2009 static struct snd_pci_quirk cxt5051_cfg_tbl
[] = {
2010 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736
),
2011 SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP
),
2012 SND_PCI_QUIRK(0x103c, 0x30ea, "Compaq Presario F700", CXT5051_F700
),
2013 SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba M30x", CXT5051_TOSHIBA
),
2014 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
2016 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP
),
2017 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT5051_LENOVO_X200
),
2018 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo IdeaPad", CXT5051_IDEAPAD
),
2022 static int patch_cxt5051(struct hda_codec
*codec
)
2024 struct conexant_spec
*spec
;
2027 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
2031 codec
->pin_amp_workaround
= 1;
2033 codec
->patch_ops
= conexant_patch_ops
;
2034 codec
->patch_ops
.init
= cxt5051_init
;
2036 spec
->multiout
.max_channels
= 2;
2037 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5051_dac_nids
);
2038 spec
->multiout
.dac_nids
= cxt5051_dac_nids
;
2039 spec
->multiout
.dig_out_nid
= CXT5051_SPDIF_OUT
;
2040 spec
->num_adc_nids
= 1; /* not 2; via auto-mic switch */
2041 spec
->adc_nids
= cxt5051_adc_nids
;
2042 spec
->num_mixers
= 2;
2043 spec
->mixers
[0] = cxt5051_capture_mixers
;
2044 spec
->mixers
[1] = cxt5051_playback_mixers
;
2045 spec
->num_init_verbs
= 1;
2046 spec
->init_verbs
[0] = cxt5051_init_verbs
;
2047 spec
->spdif_route
= 0;
2048 spec
->num_channel_mode
= ARRAY_SIZE(cxt5051_modes
);
2049 spec
->channel_mode
= cxt5051_modes
;
2051 spec
->cur_adc_idx
= 0;
2053 set_beep_amp(spec
, 0x13, 0, HDA_OUTPUT
);
2055 codec
->patch_ops
.unsol_event
= cxt5051_hp_unsol_event
;
2057 board_config
= snd_hda_check_board_config(codec
, CXT5051_MODELS
,
2060 spec
->auto_mic
= AUTO_MIC_PORTB
| AUTO_MIC_PORTC
;
2061 switch (board_config
) {
2063 spec
->mixers
[0] = cxt5051_hp_mixers
;
2065 case CXT5051_HP_DV6736
:
2066 spec
->init_verbs
[0] = cxt5051_hp_dv6736_init_verbs
;
2067 spec
->mixers
[0] = cxt5051_hp_dv6736_mixers
;
2070 case CXT5051_LENOVO_X200
:
2071 spec
->init_verbs
[0] = cxt5051_lenovo_x200_init_verbs
;
2072 /* Thinkpad X301 does not have S/PDIF wired and no ability
2073 to use a docking station. */
2074 if (codec
->subsystem_id
== 0x17aa211f)
2075 spec
->multiout
.dig_out_nid
= 0;
2078 spec
->init_verbs
[0] = cxt5051_f700_init_verbs
;
2079 spec
->mixers
[0] = cxt5051_f700_mixers
;
2082 case CXT5051_TOSHIBA
:
2083 spec
->mixers
[0] = cxt5051_toshiba_mixers
;
2084 spec
->auto_mic
= AUTO_MIC_PORTB
;
2086 case CXT5051_IDEAPAD
:
2087 spec
->init_verbs
[spec
->num_init_verbs
++] =
2088 cxt5051_ideapad_init_verbs
;
2094 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
2099 /* Conexant 5066 specific */
2101 static hda_nid_t cxt5066_dac_nids
[1] = { 0x10 };
2102 static hda_nid_t cxt5066_adc_nids
[3] = { 0x14, 0x15, 0x16 };
2103 static hda_nid_t cxt5066_capsrc_nids
[1] = { 0x17 };
2104 #define CXT5066_SPDIF_OUT 0x21
2106 /* OLPC's microphone port is DC coupled for use with external sensors,
2107 * therefore we use a 50% mic bias in order to center the input signal with
2108 * the DC input range of the codec. */
2109 #define CXT5066_OLPC_EXT_MIC_BIAS PIN_VREF50
2111 static struct hda_channel_mode cxt5066_modes
[1] = {
2115 #define HP_PRESENT_PORT_A (1 << 0)
2116 #define HP_PRESENT_PORT_D (1 << 1)
2117 #define hp_port_a_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_A)
2118 #define hp_port_d_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_D)
2120 static void cxt5066_update_speaker(struct hda_codec
*codec
)
2122 struct conexant_spec
*spec
= codec
->spec
;
2123 unsigned int pinctl
;
2125 snd_printdd("CXT5066: update speaker, hp_present=%d, cur_eapd=%d\n",
2126 spec
->hp_present
, spec
->cur_eapd
);
2129 pinctl
= (hp_port_a_present(spec
) && spec
->cur_eapd
) ? PIN_HP
: 0;
2130 snd_hda_codec_write(codec
, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2133 /* Port D (HP/LO) */
2134 pinctl
= spec
->cur_eapd
? spec
->port_d_mode
: 0;
2135 if (spec
->dell_automute
|| spec
->thinkpad
) {
2136 /* Mute if Port A is connected */
2137 if (hp_port_a_present(spec
))
2140 /* Thinkpad/Dell doesn't give pin-D status */
2141 if (!hp_port_d_present(spec
))
2144 snd_hda_codec_write(codec
, 0x1c, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2148 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
2149 snd_hda_codec_write(codec
, 0x1f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2153 /* turn on/off EAPD (+ mute HP) as a master switch */
2154 static int cxt5066_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
2155 struct snd_ctl_elem_value
*ucontrol
)
2157 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2159 if (!cxt_eapd_put(kcontrol
, ucontrol
))
2162 cxt5066_update_speaker(codec
);
2166 static const struct hda_input_mux cxt5066_olpc_dc_bias
= {
2170 { "50%", PIN_VREF50
},
2171 { "80%", PIN_VREF80
},
2175 static int cxt5066_set_olpc_dc_bias(struct hda_codec
*codec
)
2177 struct conexant_spec
*spec
= codec
->spec
;
2178 /* Even though port F is the DC input, the bias is controlled on port B.
2179 * we also leave that port as an active input (but unselected) in DC mode
2180 * just in case that is necessary to make the bias setting take effect. */
2181 return snd_hda_codec_write_cache(codec
, 0x1a, 0,
2182 AC_VERB_SET_PIN_WIDGET_CONTROL
,
2183 cxt5066_olpc_dc_bias
.items
[spec
->dc_input_bias
].index
);
2186 /* OLPC defers mic widget control until when capture is started because the
2187 * microphone LED comes on as soon as these settings are put in place. if we
2188 * did this before recording, it would give the false indication that recording
2189 * is happening when it is not. */
2190 static void cxt5066_olpc_select_mic(struct hda_codec
*codec
)
2192 struct conexant_spec
*spec
= codec
->spec
;
2193 if (!spec
->recording
)
2196 if (spec
->dc_enable
) {
2197 /* in DC mode we ignore presence detection and just use the jack
2198 * through our special DC port */
2199 const struct hda_verb enable_dc_mode
[] = {
2200 /* disble internal mic, port C */
2201 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2203 /* enable DC capture, port F */
2204 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2208 snd_hda_sequence_write(codec
, enable_dc_mode
);
2209 /* port B input disabled (and bias set) through the following call */
2210 cxt5066_set_olpc_dc_bias(codec
);
2214 /* disable DC (port F) */
2215 snd_hda_codec_write(codec
, 0x1e, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0);
2217 /* external mic, port B */
2218 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2219 spec
->ext_mic_present
? CXT5066_OLPC_EXT_MIC_BIAS
: 0);
2221 /* internal mic, port C */
2222 snd_hda_codec_write(codec
, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2223 spec
->ext_mic_present
? 0 : PIN_VREF80
);
2226 /* toggle input of built-in and mic jack appropriately */
2227 static void cxt5066_olpc_automic(struct hda_codec
*codec
)
2229 struct conexant_spec
*spec
= codec
->spec
;
2230 unsigned int present
;
2232 if (spec
->dc_enable
) /* don't do presence detection in DC mode */
2235 present
= snd_hda_codec_read(codec
, 0x1a, 0,
2236 AC_VERB_GET_PIN_SENSE
, 0) & 0x80000000;
2238 snd_printdd("CXT5066: external microphone detected\n");
2240 snd_printdd("CXT5066: external microphone absent\n");
2242 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_CONNECT_SEL
,
2244 spec
->ext_mic_present
= !!present
;
2246 cxt5066_olpc_select_mic(codec
);
2249 /* toggle input of built-in digital mic and mic jack appropriately */
2250 static void cxt5066_vostro_automic(struct hda_codec
*codec
)
2252 unsigned int present
;
2254 struct hda_verb ext_mic_present
[] = {
2255 /* enable external mic, port B */
2256 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2258 /* switch to external mic input */
2259 {0x17, AC_VERB_SET_CONNECT_SEL
, 0},
2260 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2262 /* disable internal digital mic */
2263 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2266 static struct hda_verb ext_mic_absent
[] = {
2267 /* enable internal mic, port C */
2268 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2270 /* switch to internal mic input */
2271 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2273 /* disable external mic, port B */
2274 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2278 present
= snd_hda_jack_detect(codec
, 0x1a);
2280 snd_printdd("CXT5066: external microphone detected\n");
2281 snd_hda_sequence_write(codec
, ext_mic_present
);
2283 snd_printdd("CXT5066: external microphone absent\n");
2284 snd_hda_sequence_write(codec
, ext_mic_absent
);
2288 /* toggle input of built-in digital mic and mic jack appropriately */
2289 static void cxt5066_ideapad_automic(struct hda_codec
*codec
)
2291 unsigned int present
;
2293 struct hda_verb ext_mic_present
[] = {
2294 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2295 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2296 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2299 static struct hda_verb ext_mic_absent
[] = {
2300 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2301 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2302 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2306 present
= snd_hda_jack_detect(codec
, 0x1b);
2308 snd_printdd("CXT5066: external microphone detected\n");
2309 snd_hda_sequence_write(codec
, ext_mic_present
);
2311 snd_printdd("CXT5066: external microphone absent\n");
2312 snd_hda_sequence_write(codec
, ext_mic_absent
);
2317 /* toggle input of built-in digital mic and mic jack appropriately */
2318 static void cxt5066_asus_automic(struct hda_codec
*codec
)
2320 unsigned int present
;
2322 present
= snd_hda_jack_detect(codec
, 0x1b);
2323 snd_printdd("CXT5066: external microphone present=%d\n", present
);
2324 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_CONNECT_SEL
,
2329 /* toggle input of built-in digital mic and mic jack appropriately */
2330 static void cxt5066_hp_laptop_automic(struct hda_codec
*codec
)
2332 unsigned int present
;
2334 present
= snd_hda_jack_detect(codec
, 0x1b);
2335 snd_printdd("CXT5066: external microphone present=%d\n", present
);
2336 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_CONNECT_SEL
,
2341 /* toggle input of built-in digital mic and mic jack appropriately
2342 order is: external mic -> dock mic -> interal mic */
2343 static void cxt5066_thinkpad_automic(struct hda_codec
*codec
)
2345 unsigned int ext_present
, dock_present
;
2347 static struct hda_verb ext_mic_present
[] = {
2348 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2349 {0x17, AC_VERB_SET_CONNECT_SEL
, 1},
2350 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2351 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2352 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2355 static struct hda_verb dock_mic_present
[] = {
2356 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2357 {0x17, AC_VERB_SET_CONNECT_SEL
, 0},
2358 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2359 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2360 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2363 static struct hda_verb ext_mic_absent
[] = {
2364 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2365 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2366 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2367 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2371 ext_present
= snd_hda_jack_detect(codec
, 0x1b);
2372 dock_present
= snd_hda_jack_detect(codec
, 0x1a);
2374 snd_printdd("CXT5066: external microphone detected\n");
2375 snd_hda_sequence_write(codec
, ext_mic_present
);
2376 } else if (dock_present
) {
2377 snd_printdd("CXT5066: dock microphone detected\n");
2378 snd_hda_sequence_write(codec
, dock_mic_present
);
2380 snd_printdd("CXT5066: external microphone absent\n");
2381 snd_hda_sequence_write(codec
, ext_mic_absent
);
2385 /* mute internal speaker if HP is plugged */
2386 static void cxt5066_hp_automute(struct hda_codec
*codec
)
2388 struct conexant_spec
*spec
= codec
->spec
;
2389 unsigned int portA
, portD
;
2392 portA
= snd_hda_jack_detect(codec
, 0x19);
2395 portD
= snd_hda_jack_detect(codec
, 0x1c);
2397 spec
->hp_present
= portA
? HP_PRESENT_PORT_A
: 0;
2398 spec
->hp_present
|= portD
? HP_PRESENT_PORT_D
: 0;
2399 snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n",
2400 portA
, portD
, spec
->hp_present
);
2401 cxt5066_update_speaker(codec
);
2404 /* Dispatch the right mic autoswitch function */
2405 static void cxt5066_automic(struct hda_codec
*codec
)
2407 struct conexant_spec
*spec
= codec
->spec
;
2409 if (spec
->dell_vostro
)
2410 cxt5066_vostro_automic(codec
);
2411 else if (spec
->ideapad
)
2412 cxt5066_ideapad_automic(codec
);
2413 else if (spec
->thinkpad
)
2414 cxt5066_thinkpad_automic(codec
);
2415 else if (spec
->hp_laptop
)
2416 cxt5066_hp_laptop_automic(codec
);
2417 else if (spec
->asus
)
2418 cxt5066_asus_automic(codec
);
2421 /* unsolicited event for jack sensing */
2422 static void cxt5066_olpc_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2424 struct conexant_spec
*spec
= codec
->spec
;
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 /* ignore mic events in DC mode; we're always using the jack */
2432 if (!spec
->dc_enable
)
2433 cxt5066_olpc_automic(codec
);
2438 /* unsolicited event for jack sensing */
2439 static void cxt5066_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2441 snd_printdd("CXT5066: unsol event %x (%x)\n", res
, res
>> 26);
2442 switch (res
>> 26) {
2443 case CONEXANT_HP_EVENT
:
2444 cxt5066_hp_automute(codec
);
2446 case CONEXANT_MIC_EVENT
:
2447 cxt5066_automic(codec
);
2453 static const struct hda_input_mux cxt5066_analog_mic_boost
= {
2464 static void cxt5066_set_mic_boost(struct hda_codec
*codec
)
2466 struct conexant_spec
*spec
= codec
->spec
;
2467 snd_hda_codec_write_cache(codec
, 0x17, 0,
2468 AC_VERB_SET_AMP_GAIN_MUTE
,
2469 AC_AMP_SET_RIGHT
| AC_AMP_SET_LEFT
| AC_AMP_SET_OUTPUT
|
2470 cxt5066_analog_mic_boost
.items
[spec
->mic_boost
].index
);
2471 if (spec
->ideapad
|| spec
->thinkpad
) {
2472 /* adjust the internal mic as well...it is not through 0x17 */
2473 snd_hda_codec_write_cache(codec
, 0x23, 0,
2474 AC_VERB_SET_AMP_GAIN_MUTE
,
2475 AC_AMP_SET_RIGHT
| AC_AMP_SET_LEFT
| AC_AMP_SET_INPUT
|
2476 cxt5066_analog_mic_boost
.
2477 items
[spec
->mic_boost
].index
);
2481 static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol
*kcontrol
,
2482 struct snd_ctl_elem_info
*uinfo
)
2484 return snd_hda_input_mux_info(&cxt5066_analog_mic_boost
, uinfo
);
2487 static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol
*kcontrol
,
2488 struct snd_ctl_elem_value
*ucontrol
)
2490 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2491 struct conexant_spec
*spec
= codec
->spec
;
2492 ucontrol
->value
.enumerated
.item
[0] = spec
->mic_boost
;
2496 static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol
*kcontrol
,
2497 struct snd_ctl_elem_value
*ucontrol
)
2499 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2500 struct conexant_spec
*spec
= codec
->spec
;
2501 const struct hda_input_mux
*imux
= &cxt5066_analog_mic_boost
;
2503 idx
= ucontrol
->value
.enumerated
.item
[0];
2504 if (idx
>= imux
->num_items
)
2505 idx
= imux
->num_items
- 1;
2507 spec
->mic_boost
= idx
;
2508 if (!spec
->dc_enable
)
2509 cxt5066_set_mic_boost(codec
);
2513 static void cxt5066_enable_dc(struct hda_codec
*codec
)
2515 const struct hda_verb enable_dc_mode
[] = {
2517 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2519 /* switch to DC input */
2520 {0x17, AC_VERB_SET_CONNECT_SEL
, 3},
2524 /* configure as input source */
2525 snd_hda_sequence_write(codec
, enable_dc_mode
);
2526 cxt5066_olpc_select_mic(codec
); /* also sets configured bias */
2529 static void cxt5066_disable_dc(struct hda_codec
*codec
)
2531 /* reconfigure input source */
2532 cxt5066_set_mic_boost(codec
);
2533 /* automic also selects the right mic if we're recording */
2534 cxt5066_olpc_automic(codec
);
2537 static int cxt5066_olpc_dc_get(struct snd_kcontrol
*kcontrol
,
2538 struct snd_ctl_elem_value
*ucontrol
)
2540 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2541 struct conexant_spec
*spec
= codec
->spec
;
2542 ucontrol
->value
.integer
.value
[0] = spec
->dc_enable
;
2546 static int cxt5066_olpc_dc_put(struct snd_kcontrol
*kcontrol
,
2547 struct snd_ctl_elem_value
*ucontrol
)
2549 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2550 struct conexant_spec
*spec
= codec
->spec
;
2551 int dc_enable
= !!ucontrol
->value
.integer
.value
[0];
2553 if (dc_enable
== spec
->dc_enable
)
2556 spec
->dc_enable
= dc_enable
;
2558 cxt5066_enable_dc(codec
);
2560 cxt5066_disable_dc(codec
);
2565 static int cxt5066_olpc_dc_bias_enum_info(struct snd_kcontrol
*kcontrol
,
2566 struct snd_ctl_elem_info
*uinfo
)
2568 return snd_hda_input_mux_info(&cxt5066_olpc_dc_bias
, uinfo
);
2571 static int cxt5066_olpc_dc_bias_enum_get(struct snd_kcontrol
*kcontrol
,
2572 struct snd_ctl_elem_value
*ucontrol
)
2574 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2575 struct conexant_spec
*spec
= codec
->spec
;
2576 ucontrol
->value
.enumerated
.item
[0] = spec
->dc_input_bias
;
2580 static int cxt5066_olpc_dc_bias_enum_put(struct snd_kcontrol
*kcontrol
,
2581 struct snd_ctl_elem_value
*ucontrol
)
2583 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2584 struct conexant_spec
*spec
= codec
->spec
;
2585 const struct hda_input_mux
*imux
= &cxt5066_analog_mic_boost
;
2588 idx
= ucontrol
->value
.enumerated
.item
[0];
2589 if (idx
>= imux
->num_items
)
2590 idx
= imux
->num_items
- 1;
2592 spec
->dc_input_bias
= idx
;
2593 if (spec
->dc_enable
)
2594 cxt5066_set_olpc_dc_bias(codec
);
2598 static void cxt5066_olpc_capture_prepare(struct hda_codec
*codec
)
2600 struct conexant_spec
*spec
= codec
->spec
;
2601 /* mark as recording and configure the microphone widget so that the
2602 * recording LED comes on. */
2603 spec
->recording
= 1;
2604 cxt5066_olpc_select_mic(codec
);
2607 static void cxt5066_olpc_capture_cleanup(struct hda_codec
*codec
)
2609 struct conexant_spec
*spec
= codec
->spec
;
2610 const struct hda_verb disable_mics
[] = {
2611 /* disable external mic, port B */
2612 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2614 /* disble internal mic, port C */
2615 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2617 /* disable DC capture, port F */
2618 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2622 snd_hda_sequence_write(codec
, disable_mics
);
2623 spec
->recording
= 0;
2626 static struct hda_input_mux cxt5066_capture_source
= {
2636 static struct hda_bind_ctls cxt5066_bind_capture_vol_others
= {
2637 .ops
= &snd_hda_bind_vol
,
2639 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT
),
2640 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT
),
2645 static struct hda_bind_ctls cxt5066_bind_capture_sw_others
= {
2646 .ops
= &snd_hda_bind_sw
,
2648 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT
),
2649 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT
),
2654 static struct snd_kcontrol_new cxt5066_mixer_master
[] = {
2655 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
2659 static struct snd_kcontrol_new cxt5066_mixer_master_olpc
[] = {
2661 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2662 .name
= "Master Playback Volume",
2663 .access
= SNDRV_CTL_ELEM_ACCESS_READWRITE
|
2664 SNDRV_CTL_ELEM_ACCESS_TLV_READ
|
2665 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK
,
2666 .subdevice
= HDA_SUBDEV_AMP_FLAG
,
2667 .info
= snd_hda_mixer_amp_volume_info
,
2668 .get
= snd_hda_mixer_amp_volume_get
,
2669 .put
= snd_hda_mixer_amp_volume_put
,
2670 .tlv
= { .c
= snd_hda_mixer_amp_tlv
},
2671 /* offset by 28 volume steps to limit minimum gain to -46dB */
2673 HDA_COMPOSE_AMP_VAL_OFS(0x10, 3, 0, HDA_OUTPUT
, 28),
2678 static struct snd_kcontrol_new cxt5066_mixer_olpc_dc
[] = {
2680 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2681 .name
= "DC Mode Enable Switch",
2682 .info
= snd_ctl_boolean_mono_info
,
2683 .get
= cxt5066_olpc_dc_get
,
2684 .put
= cxt5066_olpc_dc_put
,
2687 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2688 .name
= "DC Input Bias Enum",
2689 .info
= cxt5066_olpc_dc_bias_enum_info
,
2690 .get
= cxt5066_olpc_dc_bias_enum_get
,
2691 .put
= cxt5066_olpc_dc_bias_enum_put
,
2696 static struct snd_kcontrol_new cxt5066_mixers
[] = {
2698 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2699 .name
= "Master Playback Switch",
2700 .info
= cxt_eapd_info
,
2701 .get
= cxt_eapd_get
,
2702 .put
= cxt5066_hp_master_sw_put
,
2703 .private_value
= 0x1d,
2707 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2708 .name
= "Analog Mic Boost Capture Enum",
2709 .info
= cxt5066_mic_boost_mux_enum_info
,
2710 .get
= cxt5066_mic_boost_mux_enum_get
,
2711 .put
= cxt5066_mic_boost_mux_enum_put
,
2714 HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others
),
2715 HDA_BIND_SW("Capture Switch", &cxt5066_bind_capture_sw_others
),
2719 static struct snd_kcontrol_new cxt5066_vostro_mixers
[] = {
2721 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2722 .name
= "Internal Mic Boost Capture Enum",
2723 .info
= cxt5066_mic_boost_mux_enum_info
,
2724 .get
= cxt5066_mic_boost_mux_enum_get
,
2725 .put
= cxt5066_mic_boost_mux_enum_put
,
2726 .private_value
= 0x23 | 0x100,
2731 static struct hda_verb cxt5066_init_verbs
[] = {
2732 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port B */
2733 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port C */
2734 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2735 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2738 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2739 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2742 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2743 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2745 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2746 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2749 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2751 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2752 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2753 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2754 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2755 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2756 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2758 /* no digital microphone support yet */
2759 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2761 /* Audio input selector */
2762 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2764 /* SPDIF route: PCM */
2765 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2766 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2768 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2769 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2772 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2774 /* not handling these yet */
2775 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2776 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2777 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2778 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2779 {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2780 {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2781 {0x20, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2782 {0x22, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2786 static struct hda_verb cxt5066_init_verbs_olpc
[] = {
2787 /* Port A: headphones */
2788 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2789 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2791 /* Port B: external microphone */
2792 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2794 /* Port C: internal microphone */
2795 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2797 /* Port D: unused */
2798 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2800 /* Port E: unused, but has primary EAPD */
2801 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2802 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2804 /* Port F: external DC input through microphone port */
2805 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2807 /* Port G: internal speakers */
2808 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2809 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2812 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2815 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2817 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2818 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2819 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2820 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2821 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2822 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2823 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2824 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2825 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2826 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2827 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2828 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2830 /* Disable digital microphone port */
2831 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2833 /* Audio input selectors */
2834 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2835 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2838 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2839 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2841 /* enable unsolicited events for Port A and B */
2842 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2843 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2847 static struct hda_verb cxt5066_init_verbs_vostro
[] = {
2848 /* Port A: headphones */
2849 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2850 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2852 /* Port B: external microphone */
2853 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2855 /* Port C: unused */
2856 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2858 /* Port D: unused */
2859 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2861 /* Port E: unused, but has primary EAPD */
2862 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2863 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2865 /* Port F: unused */
2866 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2868 /* Port G: internal speakers */
2869 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2870 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2873 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2876 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2878 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2879 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2880 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2881 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2882 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2883 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2884 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2885 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2886 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2887 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2888 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2889 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2891 /* Digital microphone port */
2892 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2894 /* Audio input selectors */
2895 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2896 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2899 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2900 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2902 /* enable unsolicited events for Port A and B */
2903 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2904 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2908 static struct hda_verb cxt5066_init_verbs_ideapad
[] = {
2909 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port B */
2910 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port C */
2911 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2912 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2915 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2916 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2919 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2920 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2922 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2923 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2926 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2928 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2929 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2930 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2931 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2932 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2933 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2934 {0x14, AC_VERB_SET_CONNECT_SEL
, 2}, /* default to internal mic */
2936 /* Audio input selector */
2937 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x2},
2938 {0x17, AC_VERB_SET_CONNECT_SEL
, 1}, /* route ext mic */
2940 /* SPDIF route: PCM */
2941 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2942 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2944 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2945 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2947 /* internal microphone */
2948 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* enable internal mic */
2951 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2953 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2954 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2958 static struct hda_verb cxt5066_init_verbs_thinkpad
[] = {
2959 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2960 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2962 /* Port G: internal speakers */
2963 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2964 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2966 /* Port A: HP, Amp */
2967 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2968 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2970 /* Port B: Mic Dock */
2971 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2974 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2976 /* Port D: HP Dock, Amp */
2977 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2978 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2981 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2983 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2984 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2985 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2986 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2987 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2988 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2989 {0x14, AC_VERB_SET_CONNECT_SEL
, 2}, /* default to internal mic */
2991 /* Audio input selector */
2992 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x2},
2993 {0x17, AC_VERB_SET_CONNECT_SEL
, 1}, /* route ext mic */
2995 /* SPDIF route: PCM */
2996 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2997 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2999 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
3000 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
3002 /* internal microphone */
3003 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* enable internal mic */
3006 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
3008 /* enable unsolicited events for Port A, B, C and D */
3009 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
3010 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
3011 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
3012 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
3016 static struct hda_verb cxt5066_init_verbs_portd_lo
[] = {
3017 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
3022 static struct hda_verb cxt5066_init_verbs_hp_laptop
[] = {
3023 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x0},
3024 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
3025 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
3029 /* initialize jack-sensing, too */
3030 static int cxt5066_init(struct hda_codec
*codec
)
3032 snd_printdd("CXT5066: init\n");
3033 conexant_init(codec
);
3034 if (codec
->patch_ops
.unsol_event
) {
3035 cxt5066_hp_automute(codec
);
3036 cxt5066_automic(codec
);
3038 cxt5066_set_mic_boost(codec
);
3042 static int cxt5066_olpc_init(struct hda_codec
*codec
)
3044 struct conexant_spec
*spec
= codec
->spec
;
3045 snd_printdd("CXT5066: init\n");
3046 conexant_init(codec
);
3047 cxt5066_hp_automute(codec
);
3048 if (!spec
->dc_enable
) {
3049 cxt5066_set_mic_boost(codec
);
3050 cxt5066_olpc_automic(codec
);
3052 cxt5066_enable_dc(codec
);
3058 CXT5066_LAPTOP
, /* Laptops w/ EAPD support */
3059 CXT5066_DELL_LAPTOP
, /* Dell Laptop */
3060 CXT5066_OLPC_XO_1_5
, /* OLPC XO 1.5 */
3061 CXT5066_DELL_VOSTRO
, /* Dell Vostro 1015i */
3062 CXT5066_IDEAPAD
, /* Lenovo IdeaPad U150 */
3063 CXT5066_THINKPAD
, /* Lenovo ThinkPad T410s, others? */
3064 CXT5066_ASUS
, /* Asus K52JU, Lenovo G560 - Int mic at 0x1a and Ext mic at 0x1b */
3065 CXT5066_HP_LAPTOP
, /* HP Laptop */
3069 static const char * const cxt5066_models
[CXT5066_MODELS
] = {
3070 [CXT5066_LAPTOP
] = "laptop",
3071 [CXT5066_DELL_LAPTOP
] = "dell-laptop",
3072 [CXT5066_OLPC_XO_1_5
] = "olpc-xo-1_5",
3073 [CXT5066_DELL_VOSTRO
] = "dell-vostro",
3074 [CXT5066_IDEAPAD
] = "ideapad",
3075 [CXT5066_THINKPAD
] = "thinkpad",
3076 [CXT5066_ASUS
] = "asus",
3077 [CXT5066_HP_LAPTOP
] = "hp-laptop",
3080 static struct snd_pci_quirk cxt5066_cfg_tbl
[] = {
3081 SND_PCI_QUIRK_MASK(0x1025, 0xff00, 0x0400, "Acer", CXT5066_IDEAPAD
),
3082 SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTRO
),
3083 SND_PCI_QUIRK(0x1028, 0x02f5, "Dell Vostro 320", CXT5066_IDEAPAD
),
3084 SND_PCI_QUIRK(0x1028, 0x0401, "Dell Vostro 1014", CXT5066_DELL_VOSTRO
),
3085 SND_PCI_QUIRK(0x1028, 0x0402, "Dell Vostro", CXT5066_DELL_VOSTRO
),
3086 SND_PCI_QUIRK(0x1028, 0x0408, "Dell Inspiron One 19T", CXT5066_IDEAPAD
),
3087 SND_PCI_QUIRK(0x103c, 0x360b, "HP G60", CXT5066_HP_LAPTOP
),
3088 SND_PCI_QUIRK(0x1043, 0x13f3, "Asus A52J", CXT5066_HP_LAPTOP
),
3089 SND_PCI_QUIRK(0x1043, 0x1643, "Asus K52JU", CXT5066_ASUS
),
3090 SND_PCI_QUIRK(0x1179, 0xff1e, "Toshiba Satellite C650D", CXT5066_IDEAPAD
),
3091 SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba Satellite P500-PSPGSC-01800T", CXT5066_OLPC_XO_1_5
),
3092 SND_PCI_QUIRK(0x1179, 0xffe0, "Toshiba Satellite Pro T130-15F", CXT5066_OLPC_XO_1_5
),
3093 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
3095 SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5
),
3096 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400s", CXT5066_THINKPAD
),
3097 SND_PCI_QUIRK(0x17aa, 0x21c5, "Thinkpad Edge 13", CXT5066_THINKPAD
),
3098 SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo Thinkpad", CXT5066_THINKPAD
),
3099 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo G560", CXT5066_ASUS
),
3100 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", CXT5066_IDEAPAD
), /* Fallback for Lenovos without dock mic */
3104 static int patch_cxt5066(struct hda_codec
*codec
)
3106 struct conexant_spec
*spec
;
3109 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
3114 codec
->patch_ops
= conexant_patch_ops
;
3115 codec
->patch_ops
.init
= conexant_init
;
3117 spec
->dell_automute
= 0;
3118 spec
->multiout
.max_channels
= 2;
3119 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5066_dac_nids
);
3120 spec
->multiout
.dac_nids
= cxt5066_dac_nids
;
3121 spec
->multiout
.dig_out_nid
= CXT5066_SPDIF_OUT
;
3122 spec
->num_adc_nids
= 1;
3123 spec
->adc_nids
= cxt5066_adc_nids
;
3124 spec
->capsrc_nids
= cxt5066_capsrc_nids
;
3125 spec
->input_mux
= &cxt5066_capture_source
;
3127 spec
->port_d_mode
= PIN_HP
;
3129 spec
->num_init_verbs
= 1;
3130 spec
->init_verbs
[0] = cxt5066_init_verbs
;
3131 spec
->num_channel_mode
= ARRAY_SIZE(cxt5066_modes
);
3132 spec
->channel_mode
= cxt5066_modes
;
3134 spec
->cur_adc_idx
= 0;
3136 set_beep_amp(spec
, 0x13, 0, HDA_OUTPUT
);
3138 board_config
= snd_hda_check_board_config(codec
, CXT5066_MODELS
,
3139 cxt5066_models
, cxt5066_cfg_tbl
);
3140 switch (board_config
) {
3142 case CXT5066_LAPTOP
:
3143 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3144 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3146 case CXT5066_DELL_LAPTOP
:
3147 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3148 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3150 spec
->port_d_mode
= PIN_OUT
;
3151 spec
->init_verbs
[spec
->num_init_verbs
] = cxt5066_init_verbs_portd_lo
;
3152 spec
->num_init_verbs
++;
3153 spec
->dell_automute
= 1;
3156 case CXT5066_HP_LAPTOP
:
3157 codec
->patch_ops
.init
= cxt5066_init
;
3158 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
3159 spec
->init_verbs
[spec
->num_init_verbs
] =
3160 cxt5066_init_verbs_hp_laptop
;
3161 spec
->num_init_verbs
++;
3162 spec
->hp_laptop
= board_config
== CXT5066_HP_LAPTOP
;
3163 spec
->asus
= board_config
== CXT5066_ASUS
;
3164 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3165 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3167 spec
->multiout
.dig_out_nid
= 0;
3168 /* input source automatically selected */
3169 spec
->input_mux
= NULL
;
3170 spec
->port_d_mode
= 0;
3171 spec
->mic_boost
= 3; /* default 30dB gain */
3174 case CXT5066_OLPC_XO_1_5
:
3175 codec
->patch_ops
.init
= cxt5066_olpc_init
;
3176 codec
->patch_ops
.unsol_event
= cxt5066_olpc_unsol_event
;
3177 spec
->init_verbs
[0] = cxt5066_init_verbs_olpc
;
3178 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master_olpc
;
3179 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_olpc_dc
;
3180 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3181 spec
->port_d_mode
= 0;
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 /* our capture hooks which allow us to turn on the microphone LED
3191 * at the right time */
3192 spec
->capture_prepare
= cxt5066_olpc_capture_prepare
;
3193 spec
->capture_cleanup
= cxt5066_olpc_capture_cleanup
;
3195 case CXT5066_DELL_VOSTRO
:
3196 codec
->patch_ops
.init
= cxt5066_init
;
3197 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
3198 spec
->init_verbs
[0] = cxt5066_init_verbs_vostro
;
3199 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master_olpc
;
3200 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3201 spec
->mixers
[spec
->num_mixers
++] = cxt5066_vostro_mixers
;
3202 spec
->port_d_mode
= 0;
3203 spec
->dell_vostro
= 1;
3204 spec
->mic_boost
= 3; /* default 30dB gain */
3207 spec
->multiout
.dig_out_nid
= 0;
3209 /* input source automatically selected */
3210 spec
->input_mux
= NULL
;
3212 case CXT5066_IDEAPAD
:
3213 codec
->patch_ops
.init
= cxt5066_init
;
3214 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
3215 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3216 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3217 spec
->init_verbs
[0] = cxt5066_init_verbs_ideapad
;
3218 spec
->port_d_mode
= 0;
3220 spec
->mic_boost
= 2; /* default 20dB gain */
3223 spec
->multiout
.dig_out_nid
= 0;
3225 /* input source automatically selected */
3226 spec
->input_mux
= NULL
;
3228 case CXT5066_THINKPAD
:
3229 codec
->patch_ops
.init
= cxt5066_init
;
3230 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
3231 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3232 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3233 spec
->init_verbs
[0] = cxt5066_init_verbs_thinkpad
;
3235 spec
->port_d_mode
= PIN_OUT
;
3236 spec
->mic_boost
= 2; /* default 20dB gain */
3239 spec
->multiout
.dig_out_nid
= 0;
3241 /* input source automatically selected */
3242 spec
->input_mux
= NULL
;
3247 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
3253 * Automatic parser for CX20641 & co
3256 static hda_nid_t cx_auto_adc_nids
[] = { 0x14 };
3258 /* get the connection index of @nid in the widget @mux */
3259 static int get_connection_index(struct hda_codec
*codec
, hda_nid_t mux
,
3262 hda_nid_t conn
[HDA_MAX_NUM_INPUTS
];
3265 nums
= snd_hda_get_connections(codec
, mux
, conn
, ARRAY_SIZE(conn
));
3266 for (i
= 0; i
< nums
; i
++)
3272 /* get an unassigned DAC from the given list.
3273 * Return the nid if found and reduce the DAC list, or return zero if
3276 static hda_nid_t
get_unassigned_dac(struct hda_codec
*codec
, hda_nid_t pin
,
3277 hda_nid_t
*dacs
, int *num_dacs
)
3279 int i
, nums
= *num_dacs
;
3282 for (i
= 0; i
< nums
; i
++) {
3283 if (get_connection_index(codec
, pin
, dacs
[i
]) >= 0) {
3291 memmove(dacs
, dacs
+ 1, nums
* sizeof(hda_nid_t
));
3296 #define MAX_AUTO_DACS 5
3298 /* fill analog DAC list from the widget tree */
3299 static int fill_cx_auto_dacs(struct hda_codec
*codec
, hda_nid_t
*dacs
)
3301 hda_nid_t nid
, end_nid
;
3304 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
3305 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++) {
3306 unsigned int wcaps
= get_wcaps(codec
, nid
);
3307 unsigned int type
= get_wcaps_type(wcaps
);
3308 if (type
== AC_WID_AUD_OUT
&& !(wcaps
& AC_WCAP_DIGITAL
)) {
3310 if (nums
>= MAX_AUTO_DACS
)
3317 /* fill pin_dac_pair list from the pin and dac list */
3318 static int fill_dacs_for_pins(struct hda_codec
*codec
, hda_nid_t
*pins
,
3319 int num_pins
, hda_nid_t
*dacs
, int *rest
,
3320 struct pin_dac_pair
*filled
, int type
)
3325 for (i
= 0; i
< num_pins
; i
++) {
3326 filled
[nums
].pin
= pins
[i
];
3327 filled
[nums
].type
= type
;
3328 filled
[nums
].dac
= get_unassigned_dac(codec
, pins
[i
], dacs
, rest
);
3334 /* parse analog output paths */
3335 static void cx_auto_parse_output(struct hda_codec
*codec
)
3337 struct conexant_spec
*spec
= codec
->spec
;
3338 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3339 hda_nid_t dacs
[MAX_AUTO_DACS
];
3340 int i
, j
, nums
, rest
;
3342 rest
= fill_cx_auto_dacs(codec
, dacs
);
3343 /* parse all analog output pins */
3344 nums
= fill_dacs_for_pins(codec
, cfg
->line_out_pins
, cfg
->line_outs
,
3345 dacs
, &rest
, spec
->dac_info
,
3347 nums
+= fill_dacs_for_pins(codec
, cfg
->hp_pins
, cfg
->hp_outs
,
3348 dacs
, &rest
, spec
->dac_info
+ nums
,
3350 nums
+= fill_dacs_for_pins(codec
, cfg
->speaker_pins
, cfg
->speaker_outs
,
3351 dacs
, &rest
, spec
->dac_info
+ nums
,
3352 AUTO_PIN_SPEAKER_OUT
);
3353 spec
->dac_info_filled
= nums
;
3354 /* fill multiout struct */
3355 for (i
= 0; i
< nums
; i
++) {
3356 hda_nid_t dac
= spec
->dac_info
[i
].dac
;
3359 switch (spec
->dac_info
[i
].type
) {
3360 case AUTO_PIN_LINE_OUT
:
3361 spec
->private_dac_nids
[spec
->multiout
.num_dacs
] = dac
;
3362 spec
->multiout
.num_dacs
++;
3364 case AUTO_PIN_HP_OUT
:
3365 case AUTO_PIN_SPEAKER_OUT
:
3366 if (!spec
->multiout
.hp_nid
) {
3367 spec
->multiout
.hp_nid
= dac
;
3370 for (j
= 0; j
< ARRAY_SIZE(spec
->multiout
.extra_out_nid
); j
++)
3371 if (!spec
->multiout
.extra_out_nid
[j
]) {
3372 spec
->multiout
.extra_out_nid
[j
] = dac
;
3378 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
3379 spec
->multiout
.max_channels
= nums
* 2;
3381 if (cfg
->hp_outs
> 0)
3382 spec
->auto_mute
= 1;
3383 spec
->vmaster_nid
= spec
->private_dac_nids
[0];
3386 /* auto-mute/unmute speaker and line outs according to headphone jack */
3387 static void cx_auto_hp_automute(struct hda_codec
*codec
)
3389 struct conexant_spec
*spec
= codec
->spec
;
3390 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3393 if (!spec
->auto_mute
)
3396 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
3397 if (snd_hda_jack_detect(codec
, cfg
->hp_pins
[i
])) {
3402 for (i
= 0; i
< cfg
->line_outs
; i
++) {
3403 snd_hda_codec_write(codec
, cfg
->line_out_pins
[i
], 0,
3404 AC_VERB_SET_PIN_WIDGET_CONTROL
,
3405 present
? 0 : PIN_OUT
);
3407 for (i
= 0; !present
&& i
< cfg
->line_outs
; i
++)
3408 if (snd_hda_jack_detect(codec
, cfg
->line_out_pins
[i
]))
3410 for (i
= 0; i
< cfg
->speaker_outs
; i
++) {
3411 snd_hda_codec_write(codec
, cfg
->speaker_pins
[i
], 0,
3412 AC_VERB_SET_PIN_WIDGET_CONTROL
,
3413 present
? 0 : PIN_OUT
);
3417 /* automatic switch internal and external mic */
3418 static void cx_auto_automic(struct hda_codec
*codec
)
3420 struct conexant_spec
*spec
= codec
->spec
;
3421 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3422 struct hda_input_mux
*imux
= &spec
->private_imux
;
3423 int ext_idx
= spec
->auto_mic_ext
;
3425 if (!spec
->auto_mic
)
3427 if (snd_hda_jack_detect(codec
, cfg
->inputs
[ext_idx
].pin
)) {
3428 snd_hda_codec_write(codec
, spec
->adc_nids
[0], 0,
3429 AC_VERB_SET_CONNECT_SEL
,
3430 imux
->items
[ext_idx
].index
);
3432 snd_hda_codec_write(codec
, spec
->adc_nids
[0], 0,
3433 AC_VERB_SET_CONNECT_SEL
,
3434 imux
->items
[!ext_idx
].index
);
3438 static void cx_auto_unsol_event(struct hda_codec
*codec
, unsigned int res
)
3440 int nid
= (res
& AC_UNSOL_RES_SUBTAG
) >> 20;
3441 switch (res
>> 26) {
3442 case CONEXANT_HP_EVENT
:
3443 cx_auto_hp_automute(codec
);
3444 conexant_report_jack(codec
, nid
);
3446 case CONEXANT_MIC_EVENT
:
3447 cx_auto_automic(codec
);
3448 conexant_report_jack(codec
, nid
);
3453 /* return true if it's an internal-mic pin */
3454 static int is_int_mic(struct hda_codec
*codec
, hda_nid_t pin
)
3456 unsigned int def_conf
= snd_hda_codec_get_pincfg(codec
, pin
);
3457 return get_defcfg_device(def_conf
) == AC_JACK_MIC_IN
&&
3458 snd_hda_get_input_pin_attr(def_conf
) == INPUT_PIN_ATTR_INT
;
3461 /* return true if it's an external-mic pin */
3462 static int is_ext_mic(struct hda_codec
*codec
, hda_nid_t pin
)
3464 unsigned int def_conf
= snd_hda_codec_get_pincfg(codec
, pin
);
3465 return get_defcfg_device(def_conf
) == AC_JACK_MIC_IN
&&
3466 snd_hda_get_input_pin_attr(def_conf
) >= INPUT_PIN_ATTR_NORMAL
&&
3467 (snd_hda_query_pin_caps(codec
, pin
) & AC_PINCAP_PRES_DETECT
);
3470 /* check whether the pin config is suitable for auto-mic switching;
3471 * auto-mic is enabled only when one int-mic and one-ext mic exist
3473 static void cx_auto_check_auto_mic(struct hda_codec
*codec
)
3475 struct conexant_spec
*spec
= codec
->spec
;
3476 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3478 if (is_ext_mic(codec
, cfg
->inputs
[0].pin
) &&
3479 is_int_mic(codec
, cfg
->inputs
[1].pin
)) {
3481 spec
->auto_mic_ext
= 1;
3484 if (is_int_mic(codec
, cfg
->inputs
[1].pin
) &&
3485 is_ext_mic(codec
, cfg
->inputs
[0].pin
)) {
3487 spec
->auto_mic_ext
= 0;
3492 static void cx_auto_parse_input(struct hda_codec
*codec
)
3494 struct conexant_spec
*spec
= codec
->spec
;
3495 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3496 struct hda_input_mux
*imux
;
3499 imux
= &spec
->private_imux
;
3500 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3501 int idx
= get_connection_index(codec
, spec
->adc_nids
[0],
3502 cfg
->inputs
[i
].pin
);
3505 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
3506 snd_hda_add_imux_item(imux
, label
, idx
, NULL
);
3509 if (imux
->num_items
== 2 && cfg
->num_inputs
== 2)
3510 cx_auto_check_auto_mic(codec
);
3511 if (imux
->num_items
> 1 && !spec
->auto_mic
)
3512 spec
->input_mux
= imux
;
3515 /* get digital-input audio widget corresponding to the given pin */
3516 static hda_nid_t
cx_auto_get_dig_in(struct hda_codec
*codec
, hda_nid_t pin
)
3518 hda_nid_t nid
, end_nid
;
3520 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
3521 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++) {
3522 unsigned int wcaps
= get_wcaps(codec
, nid
);
3523 unsigned int type
= get_wcaps_type(wcaps
);
3524 if (type
== AC_WID_AUD_IN
&& (wcaps
& AC_WCAP_DIGITAL
)) {
3525 if (get_connection_index(codec
, nid
, pin
) >= 0)
3532 static void cx_auto_parse_digital(struct hda_codec
*codec
)
3534 struct conexant_spec
*spec
= codec
->spec
;
3535 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3538 if (cfg
->dig_outs
&&
3539 snd_hda_get_connections(codec
, cfg
->dig_out_pins
[0], &nid
, 1) == 1)
3540 spec
->multiout
.dig_out_nid
= nid
;
3541 if (cfg
->dig_in_pin
)
3542 spec
->dig_in_nid
= cx_auto_get_dig_in(codec
, cfg
->dig_in_pin
);
3545 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3546 static void cx_auto_parse_beep(struct hda_codec
*codec
)
3548 struct conexant_spec
*spec
= codec
->spec
;
3549 hda_nid_t nid
, end_nid
;
3551 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
3552 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++)
3553 if (get_wcaps_type(get_wcaps(codec
, nid
)) == AC_WID_BEEP
) {
3554 set_beep_amp(spec
, nid
, 0, HDA_OUTPUT
);
3559 #define cx_auto_parse_beep(codec)
3562 static int cx_auto_parse_auto_config(struct hda_codec
*codec
)
3564 struct conexant_spec
*spec
= codec
->spec
;
3567 err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
);
3571 cx_auto_parse_output(codec
);
3572 cx_auto_parse_input(codec
);
3573 cx_auto_parse_digital(codec
);
3574 cx_auto_parse_beep(codec
);
3578 static void cx_auto_turn_on_eapd(struct hda_codec
*codec
, int num_pins
,
3582 for (i
= 0; i
< num_pins
; i
++) {
3583 if (snd_hda_query_pin_caps(codec
, pins
[i
]) & AC_PINCAP_EAPD
)
3584 snd_hda_codec_write(codec
, pins
[i
], 0,
3585 AC_VERB_SET_EAPD_BTLENABLE
, 0x02);
3589 static void select_connection(struct hda_codec
*codec
, hda_nid_t pin
,
3592 int idx
= get_connection_index(codec
, pin
, src
);
3594 snd_hda_codec_write(codec
, pin
, 0,
3595 AC_VERB_SET_CONNECT_SEL
, idx
);
3598 static void cx_auto_init_output(struct hda_codec
*codec
)
3600 struct conexant_spec
*spec
= codec
->spec
;
3601 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3605 for (i
= 0; i
< spec
->multiout
.num_dacs
; i
++)
3606 snd_hda_codec_write(codec
, spec
->multiout
.dac_nids
[i
], 0,
3607 AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
);
3609 for (i
= 0; i
< cfg
->hp_outs
; i
++)
3610 snd_hda_codec_write(codec
, cfg
->hp_pins
[i
], 0,
3611 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
);
3612 if (spec
->auto_mute
) {
3613 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
3614 snd_hda_codec_write(codec
, cfg
->hp_pins
[i
], 0,
3615 AC_VERB_SET_UNSOLICITED_ENABLE
,
3616 AC_USRSP_EN
| CONEXANT_HP_EVENT
);
3618 cx_auto_hp_automute(codec
);
3620 for (i
= 0; i
< cfg
->line_outs
; i
++)
3621 snd_hda_codec_write(codec
, cfg
->line_out_pins
[i
], 0,
3622 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
);
3623 for (i
= 0; i
< cfg
->speaker_outs
; i
++)
3624 snd_hda_codec_write(codec
, cfg
->speaker_pins
[i
], 0,
3625 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
);
3628 for (i
= 0; i
< spec
->dac_info_filled
; i
++) {
3629 nid
= spec
->dac_info
[i
].dac
;
3631 nid
= spec
->multiout
.dac_nids
[0];
3632 select_connection(codec
, spec
->dac_info
[i
].pin
, nid
);
3636 cx_auto_turn_on_eapd(codec
, cfg
->line_outs
, cfg
->line_out_pins
);
3637 cx_auto_turn_on_eapd(codec
, cfg
->hp_outs
, cfg
->hp_pins
);
3638 cx_auto_turn_on_eapd(codec
, cfg
->speaker_outs
, cfg
->speaker_pins
);
3641 static void cx_auto_init_input(struct hda_codec
*codec
)
3643 struct conexant_spec
*spec
= codec
->spec
;
3644 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3647 for (i
= 0; i
< spec
->num_adc_nids
; i
++)
3648 snd_hda_codec_write(codec
, spec
->adc_nids
[i
], 0,
3649 AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0));
3651 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3653 if (cfg
->inputs
[i
].type
== AUTO_PIN_MIC
)
3657 snd_hda_codec_write(codec
, cfg
->inputs
[i
].pin
, 0,
3658 AC_VERB_SET_PIN_WIDGET_CONTROL
, type
);
3661 if (spec
->auto_mic
) {
3662 int ext_idx
= spec
->auto_mic_ext
;
3663 snd_hda_codec_write(codec
, cfg
->inputs
[ext_idx
].pin
, 0,
3664 AC_VERB_SET_UNSOLICITED_ENABLE
,
3665 AC_USRSP_EN
| CONEXANT_MIC_EVENT
);
3666 cx_auto_automic(codec
);
3668 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
3669 snd_hda_codec_write(codec
, spec
->adc_nids
[i
], 0,
3670 AC_VERB_SET_CONNECT_SEL
,
3671 spec
->private_imux
.items
[0].index
);
3676 static void cx_auto_init_digital(struct hda_codec
*codec
)
3678 struct conexant_spec
*spec
= codec
->spec
;
3679 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3681 if (spec
->multiout
.dig_out_nid
)
3682 snd_hda_codec_write(codec
, cfg
->dig_out_pins
[0], 0,
3683 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
);
3684 if (spec
->dig_in_nid
)
3685 snd_hda_codec_write(codec
, cfg
->dig_in_pin
, 0,
3686 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
);
3689 static int cx_auto_init(struct hda_codec
*codec
)
3691 /*snd_hda_sequence_write(codec, cx_auto_init_verbs);*/
3692 cx_auto_init_output(codec
);
3693 cx_auto_init_input(codec
);
3694 cx_auto_init_digital(codec
);
3698 static int cx_auto_add_volume(struct hda_codec
*codec
, const char *basename
,
3699 const char *dir
, int cidx
,
3700 hda_nid_t nid
, int hda_dir
)
3702 static char name
[32];
3703 static struct snd_kcontrol_new knew
[] = {
3704 HDA_CODEC_VOLUME(name
, 0, 0, 0),
3705 HDA_CODEC_MUTE(name
, 0, 0, 0),
3707 static char *sfx
[2] = { "Volume", "Switch" };
3710 for (i
= 0; i
< 2; i
++) {
3711 struct snd_kcontrol
*kctl
;
3712 knew
[i
].private_value
= HDA_COMPOSE_AMP_VAL(nid
, 3, 0, hda_dir
);
3713 knew
[i
].subdevice
= HDA_SUBDEV_AMP_FLAG
;
3714 knew
[i
].index
= cidx
;
3715 snprintf(name
, sizeof(name
), "%s%s %s", basename
, dir
, sfx
[i
]);
3716 kctl
= snd_ctl_new1(&knew
[i
], codec
);
3719 err
= snd_hda_ctl_add(codec
, nid
, kctl
);
3722 if (!(query_amp_caps(codec
, nid
, hda_dir
) & AC_AMPCAP_MUTE
))
3728 #define cx_auto_add_pb_volume(codec, nid, str, idx) \
3729 cx_auto_add_volume(codec, str, " Playback", idx, nid, HDA_OUTPUT)
3731 static int cx_auto_build_output_controls(struct hda_codec
*codec
)
3733 struct conexant_spec
*spec
= codec
->spec
;
3735 int num_line
= 0, num_hp
= 0, num_spk
= 0;
3736 static const char * const texts
[3] = { "Front", "Surround", "CLFE" };
3738 if (spec
->dac_info_filled
== 1)
3739 return cx_auto_add_pb_volume(codec
, spec
->dac_info
[0].dac
,
3741 for (i
= 0; i
< spec
->dac_info_filled
; i
++) {
3744 if (!spec
->dac_info
[i
].dac
)
3746 type
= spec
->dac_info
[i
].type
;
3747 if (type
== AUTO_PIN_LINE_OUT
)
3748 type
= spec
->autocfg
.line_out_type
;
3750 case AUTO_PIN_LINE_OUT
:
3752 label
= texts
[num_line
++];
3755 case AUTO_PIN_HP_OUT
:
3756 label
= "Headphone";
3759 case AUTO_PIN_SPEAKER_OUT
:
3764 err
= cx_auto_add_pb_volume(codec
, spec
->dac_info
[i
].dac
,
3772 static int cx_auto_build_input_controls(struct hda_codec
*codec
)
3774 struct conexant_spec
*spec
= codec
->spec
;
3775 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3776 static const char *prev_label
;
3779 err
= cx_auto_add_volume(codec
, "Capture", "", 0, spec
->adc_nids
[0],
3785 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3786 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
3788 if (!(get_wcaps(codec
, nid
) & AC_WCAP_IN_AMP
))
3790 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
3791 if (label
== prev_label
)
3796 err
= cx_auto_add_volume(codec
, label
, " Capture", cidx
,
3804 static int cx_auto_build_controls(struct hda_codec
*codec
)
3808 err
= cx_auto_build_output_controls(codec
);
3811 err
= cx_auto_build_input_controls(codec
);
3814 return conexant_build_controls(codec
);
3817 static struct hda_codec_ops cx_auto_patch_ops
= {
3818 .build_controls
= cx_auto_build_controls
,
3819 .build_pcms
= conexant_build_pcms
,
3820 .init
= cx_auto_init
,
3821 .free
= conexant_free
,
3822 .unsol_event
= cx_auto_unsol_event
,
3823 #ifdef CONFIG_SND_HDA_POWER_SAVE
3824 .suspend
= conexant_suspend
,
3826 .reboot_notify
= snd_hda_shutup_pins
,
3829 static int patch_conexant_auto(struct hda_codec
*codec
)
3831 struct conexant_spec
*spec
;
3834 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
3838 spec
->adc_nids
= cx_auto_adc_nids
;
3839 spec
->num_adc_nids
= ARRAY_SIZE(cx_auto_adc_nids
);
3840 spec
->capsrc_nids
= spec
->adc_nids
;
3841 err
= cx_auto_parse_auto_config(codec
);
3847 codec
->patch_ops
= cx_auto_patch_ops
;
3849 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
3856 static struct hda_codec_preset snd_hda_preset_conexant
[] = {
3857 { .id
= 0x14f15045, .name
= "CX20549 (Venice)",
3858 .patch
= patch_cxt5045
},
3859 { .id
= 0x14f15047, .name
= "CX20551 (Waikiki)",
3860 .patch
= patch_cxt5047
},
3861 { .id
= 0x14f15051, .name
= "CX20561 (Hermosa)",
3862 .patch
= patch_cxt5051
},
3863 { .id
= 0x14f15066, .name
= "CX20582 (Pebble)",
3864 .patch
= patch_cxt5066
},
3865 { .id
= 0x14f15067, .name
= "CX20583 (Pebble HSF)",
3866 .patch
= patch_cxt5066
},
3867 { .id
= 0x14f15068, .name
= "CX20584",
3868 .patch
= patch_cxt5066
},
3869 { .id
= 0x14f15069, .name
= "CX20585",
3870 .patch
= patch_cxt5066
},
3871 { .id
= 0x14f15097, .name
= "CX20631",
3872 .patch
= patch_conexant_auto
},
3873 { .id
= 0x14f15098, .name
= "CX20632",
3874 .patch
= patch_conexant_auto
},
3875 { .id
= 0x14f150a1, .name
= "CX20641",
3876 .patch
= patch_conexant_auto
},
3877 { .id
= 0x14f150a2, .name
= "CX20642",
3878 .patch
= patch_conexant_auto
},
3879 { .id
= 0x14f150ab, .name
= "CX20651",
3880 .patch
= patch_conexant_auto
},
3881 { .id
= 0x14f150ac, .name
= "CX20652",
3882 .patch
= patch_conexant_auto
},
3883 { .id
= 0x14f150b8, .name
= "CX20664",
3884 .patch
= patch_conexant_auto
},
3885 { .id
= 0x14f150b9, .name
= "CX20665",
3886 .patch
= patch_conexant_auto
},
3890 MODULE_ALIAS("snd-hda-codec-id:14f15045");
3891 MODULE_ALIAS("snd-hda-codec-id:14f15047");
3892 MODULE_ALIAS("snd-hda-codec-id:14f15051");
3893 MODULE_ALIAS("snd-hda-codec-id:14f15066");
3894 MODULE_ALIAS("snd-hda-codec-id:14f15067");
3895 MODULE_ALIAS("snd-hda-codec-id:14f15068");
3896 MODULE_ALIAS("snd-hda-codec-id:14f15069");
3897 MODULE_ALIAS("snd-hda-codec-id:14f15097");
3898 MODULE_ALIAS("snd-hda-codec-id:14f15098");
3899 MODULE_ALIAS("snd-hda-codec-id:14f150a1");
3900 MODULE_ALIAS("snd-hda-codec-id:14f150a2");
3901 MODULE_ALIAS("snd-hda-codec-id:14f150ab");
3902 MODULE_ALIAS("snd-hda-codec-id:14f150ac");
3903 MODULE_ALIAS("snd-hda-codec-id:14f150b8");
3904 MODULE_ALIAS("snd-hda-codec-id:14f150b9");
3906 MODULE_LICENSE("GPL");
3907 MODULE_DESCRIPTION("Conexant HD-audio codec");
3909 static struct hda_codec_preset_list conexant_list
= {
3910 .preset
= snd_hda_preset_conexant
,
3911 .owner
= THIS_MODULE
,
3914 static int __init
patch_conexant_init(void)
3916 return snd_hda_add_codec_preset(&conexant_list
);
3919 static void __exit
patch_conexant_exit(void)
3921 snd_hda_delete_codec_preset(&conexant_list
);
3924 module_init(patch_conexant_init
)
3925 module_exit(patch_conexant_exit
)