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
;
88 hda_nid_t slave_dig_outs
[2];
91 unsigned int num_adc_nids
;
93 hda_nid_t dig_in_nid
; /* digital-in NID; optional */
95 unsigned int cur_adc_idx
;
97 unsigned int cur_adc_stream_tag
;
98 unsigned int cur_adc_format
;
101 const struct hda_input_mux
*input_mux
;
102 hda_nid_t
*capsrc_nids
;
103 unsigned int cur_mux
[3];
106 const struct hda_channel_mode
*channel_mode
;
107 int num_channel_mode
;
109 /* PCM information */
110 struct hda_pcm pcm_rec
[2]; /* used in build_pcms() */
112 unsigned int spdif_route
;
115 struct snd_array jacks
;
117 /* dynamic controls, init_verbs and input_mux */
118 struct auto_pin_cfg autocfg
;
119 struct hda_input_mux private_imux
;
120 hda_nid_t private_dac_nids
[AUTO_CFG_MAX_OUTS
];
121 struct pin_dac_pair dac_info
[8];
124 unsigned int port_d_mode
;
125 unsigned int auto_mute
:1; /* used in auto-parser */
126 unsigned int dell_automute
:1;
127 unsigned int dell_vostro
:1;
128 unsigned int ideapad
:1;
129 unsigned int thinkpad
:1;
130 unsigned int hp_laptop
:1;
133 unsigned int ext_mic_present
;
134 unsigned int recording
;
135 void (*capture_prepare
)(struct hda_codec
*codec
);
136 void (*capture_cleanup
)(struct hda_codec
*codec
);
138 /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors)
139 * through the microphone jack.
140 * When the user enables this through a mixer switch, both internal and
141 * external microphones are disabled. Gain is fixed at 0dB. In this mode,
142 * we also allow the bias to be configured through a separate mixer
144 unsigned int dc_enable
;
145 unsigned int dc_input_bias
; /* offset into cxt5066_olpc_dc_bias */
146 unsigned int mic_boost
; /* offset into cxt5066_analog_mic_boost */
148 unsigned int beep_amp
;
151 static int conexant_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
152 struct hda_codec
*codec
,
153 struct snd_pcm_substream
*substream
)
155 struct conexant_spec
*spec
= codec
->spec
;
156 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
160 static int conexant_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
161 struct hda_codec
*codec
,
162 unsigned int stream_tag
,
164 struct snd_pcm_substream
*substream
)
166 struct conexant_spec
*spec
= codec
->spec
;
167 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
,
172 static int conexant_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
173 struct hda_codec
*codec
,
174 struct snd_pcm_substream
*substream
)
176 struct conexant_spec
*spec
= codec
->spec
;
177 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
183 static int conexant_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
184 struct hda_codec
*codec
,
185 struct snd_pcm_substream
*substream
)
187 struct conexant_spec
*spec
= codec
->spec
;
188 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
191 static int conexant_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
192 struct hda_codec
*codec
,
193 struct snd_pcm_substream
*substream
)
195 struct conexant_spec
*spec
= codec
->spec
;
196 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
199 static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
200 struct hda_codec
*codec
,
201 unsigned int stream_tag
,
203 struct snd_pcm_substream
*substream
)
205 struct conexant_spec
*spec
= codec
->spec
;
206 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
214 static int conexant_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
215 struct hda_codec
*codec
,
216 unsigned int stream_tag
,
218 struct snd_pcm_substream
*substream
)
220 struct conexant_spec
*spec
= codec
->spec
;
221 if (spec
->capture_prepare
)
222 spec
->capture_prepare(codec
);
223 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
],
224 stream_tag
, 0, format
);
228 static int conexant_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
229 struct hda_codec
*codec
,
230 struct snd_pcm_substream
*substream
)
232 struct conexant_spec
*spec
= codec
->spec
;
233 snd_hda_codec_cleanup_stream(codec
, spec
->adc_nids
[substream
->number
]);
234 if (spec
->capture_cleanup
)
235 spec
->capture_cleanup(codec
);
241 static struct hda_pcm_stream conexant_pcm_analog_playback
= {
245 .nid
= 0, /* fill later */
247 .open
= conexant_playback_pcm_open
,
248 .prepare
= conexant_playback_pcm_prepare
,
249 .cleanup
= conexant_playback_pcm_cleanup
253 static struct hda_pcm_stream conexant_pcm_analog_capture
= {
257 .nid
= 0, /* fill later */
259 .prepare
= conexant_capture_pcm_prepare
,
260 .cleanup
= conexant_capture_pcm_cleanup
265 static struct hda_pcm_stream conexant_pcm_digital_playback
= {
269 .nid
= 0, /* fill later */
271 .open
= conexant_dig_playback_pcm_open
,
272 .close
= conexant_dig_playback_pcm_close
,
273 .prepare
= conexant_dig_playback_pcm_prepare
277 static struct hda_pcm_stream conexant_pcm_digital_capture
= {
281 /* NID is set in alc_build_pcms */
284 static int cx5051_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
285 struct hda_codec
*codec
,
286 unsigned int stream_tag
,
288 struct snd_pcm_substream
*substream
)
290 struct conexant_spec
*spec
= codec
->spec
;
291 spec
->cur_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
292 spec
->cur_adc_stream_tag
= stream_tag
;
293 spec
->cur_adc_format
= format
;
294 snd_hda_codec_setup_stream(codec
, spec
->cur_adc
, stream_tag
, 0, format
);
298 static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
299 struct hda_codec
*codec
,
300 struct snd_pcm_substream
*substream
)
302 struct conexant_spec
*spec
= codec
->spec
;
303 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
308 static struct hda_pcm_stream cx5051_pcm_analog_capture
= {
312 .nid
= 0, /* fill later */
314 .prepare
= cx5051_capture_pcm_prepare
,
315 .cleanup
= cx5051_capture_pcm_cleanup
319 static int conexant_build_pcms(struct hda_codec
*codec
)
321 struct conexant_spec
*spec
= codec
->spec
;
322 struct hda_pcm
*info
= spec
->pcm_rec
;
325 codec
->pcm_info
= info
;
327 info
->name
= "CONEXANT Analog";
328 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = conexant_pcm_analog_playback
;
329 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
=
330 spec
->multiout
.max_channels
;
331 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
332 spec
->multiout
.dac_nids
[0];
333 if (codec
->vendor_id
== 0x14f15051)
334 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
335 cx5051_pcm_analog_capture
;
337 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
338 conexant_pcm_analog_capture
;
339 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
= spec
->num_adc_nids
;
340 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
342 if (spec
->multiout
.dig_out_nid
) {
345 info
->name
= "Conexant Digital";
346 info
->pcm_type
= HDA_PCM_TYPE_SPDIF
;
347 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] =
348 conexant_pcm_digital_playback
;
349 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
350 spec
->multiout
.dig_out_nid
;
351 if (spec
->dig_in_nid
) {
352 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
353 conexant_pcm_digital_capture
;
354 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
=
357 if (spec
->slave_dig_outs
[0])
358 codec
->slave_dig_outs
= spec
->slave_dig_outs
;
364 static int conexant_mux_enum_info(struct snd_kcontrol
*kcontrol
,
365 struct snd_ctl_elem_info
*uinfo
)
367 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
368 struct conexant_spec
*spec
= codec
->spec
;
370 return snd_hda_input_mux_info(spec
->input_mux
, uinfo
);
373 static int conexant_mux_enum_get(struct snd_kcontrol
*kcontrol
,
374 struct snd_ctl_elem_value
*ucontrol
)
376 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
377 struct conexant_spec
*spec
= codec
->spec
;
378 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
380 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
384 static int conexant_mux_enum_put(struct snd_kcontrol
*kcontrol
,
385 struct snd_ctl_elem_value
*ucontrol
)
387 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
388 struct conexant_spec
*spec
= codec
->spec
;
389 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
391 return snd_hda_input_mux_put(codec
, spec
->input_mux
, ucontrol
,
392 spec
->capsrc_nids
[adc_idx
],
393 &spec
->cur_mux
[adc_idx
]);
396 #ifdef CONFIG_SND_HDA_INPUT_JACK
397 static void conexant_free_jack_priv(struct snd_jack
*jack
)
399 struct conexant_jack
*jacks
= jack
->private_data
;
404 static int conexant_add_jack(struct hda_codec
*codec
,
405 hda_nid_t nid
, int type
)
407 struct conexant_spec
*spec
;
408 struct conexant_jack
*jack
;
413 snd_array_init(&spec
->jacks
, sizeof(*jack
), 32);
415 jack
= spec
->jacks
.list
;
416 for (i
= 0; i
< spec
->jacks
.used
; i
++, jack
++)
417 if (jack
->nid
== nid
)
418 return 0 ; /* already present */
420 jack
= snd_array_new(&spec
->jacks
);
421 name
= (type
== SND_JACK_HEADPHONE
) ? "Headphone" : "Mic" ;
429 err
= snd_jack_new(codec
->bus
->card
, name
, type
, &jack
->jack
);
432 jack
->jack
->private_data
= jack
;
433 jack
->jack
->private_free
= conexant_free_jack_priv
;
437 static void conexant_report_jack(struct hda_codec
*codec
, hda_nid_t nid
)
439 struct conexant_spec
*spec
= codec
->spec
;
440 struct conexant_jack
*jacks
= spec
->jacks
.list
;
444 for (i
= 0; i
< spec
->jacks
.used
; i
++) {
445 if (jacks
->nid
== nid
) {
446 unsigned int present
;
447 present
= snd_hda_jack_detect(codec
, nid
);
449 present
= (present
) ? jacks
->type
: 0 ;
451 snd_jack_report(jacks
->jack
,
459 static int conexant_init_jacks(struct hda_codec
*codec
)
461 struct conexant_spec
*spec
= codec
->spec
;
464 for (i
= 0; i
< spec
->num_init_verbs
; i
++) {
465 const struct hda_verb
*hv
;
467 hv
= spec
->init_verbs
[i
];
470 switch (hv
->param
^ AC_USRSP_EN
) {
471 case CONEXANT_HP_EVENT
:
472 err
= conexant_add_jack(codec
, hv
->nid
,
474 conexant_report_jack(codec
, hv
->nid
);
476 case CXT5051_PORTC_EVENT
:
477 case CONEXANT_MIC_EVENT
:
478 err
= conexant_add_jack(codec
, hv
->nid
,
479 SND_JACK_MICROPHONE
);
480 conexant_report_jack(codec
, hv
->nid
);
492 static inline void conexant_report_jack(struct hda_codec
*codec
, hda_nid_t nid
)
496 static inline int conexant_init_jacks(struct hda_codec
*codec
)
502 static int conexant_init(struct hda_codec
*codec
)
504 struct conexant_spec
*spec
= codec
->spec
;
507 for (i
= 0; i
< spec
->num_init_verbs
; i
++)
508 snd_hda_sequence_write(codec
, spec
->init_verbs
[i
]);
512 static void conexant_free(struct hda_codec
*codec
)
514 #ifdef CONFIG_SND_HDA_INPUT_JACK
515 struct conexant_spec
*spec
= codec
->spec
;
516 if (spec
->jacks
.list
) {
517 struct conexant_jack
*jacks
= spec
->jacks
.list
;
519 for (i
= 0; i
< spec
->jacks
.used
; i
++, jacks
++) {
521 snd_device_free(codec
->bus
->card
, jacks
->jack
);
523 snd_array_free(&spec
->jacks
);
526 snd_hda_detach_beep_device(codec
);
530 static struct snd_kcontrol_new cxt_capture_mixers
[] = {
532 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
533 .name
= "Capture Source",
534 .info
= conexant_mux_enum_info
,
535 .get
= conexant_mux_enum_get
,
536 .put
= conexant_mux_enum_put
541 #ifdef CONFIG_SND_HDA_INPUT_BEEP
542 /* additional beep mixers; the actual parameters are overwritten at build */
543 static struct snd_kcontrol_new cxt_beep_mixer
[] = {
544 HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT
),
545 HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT
),
550 static const char * const slave_vols
[] = {
551 "Headphone Playback Volume",
552 "Speaker Playback Volume",
556 static const char * const slave_sws
[] = {
557 "Headphone Playback Switch",
558 "Speaker Playback Switch",
562 static int conexant_build_controls(struct hda_codec
*codec
)
564 struct conexant_spec
*spec
= codec
->spec
;
568 for (i
= 0; i
< spec
->num_mixers
; i
++) {
569 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
573 if (spec
->multiout
.dig_out_nid
) {
574 err
= snd_hda_create_spdif_out_ctls(codec
,
575 spec
->multiout
.dig_out_nid
);
578 err
= snd_hda_create_spdif_share_sw(codec
,
582 spec
->multiout
.share_spdif
= 1;
584 if (spec
->dig_in_nid
) {
585 err
= snd_hda_create_spdif_in_ctls(codec
,spec
->dig_in_nid
);
590 /* if we have no master control, let's create it */
591 if (spec
->vmaster_nid
&&
592 !snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
593 unsigned int vmaster_tlv
[4];
594 snd_hda_set_vmaster_tlv(codec
, spec
->vmaster_nid
,
595 HDA_OUTPUT
, vmaster_tlv
);
596 err
= snd_hda_add_vmaster(codec
, "Master Playback Volume",
597 vmaster_tlv
, slave_vols
);
601 if (spec
->vmaster_nid
&&
602 !snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
603 err
= snd_hda_add_vmaster(codec
, "Master Playback Switch",
609 if (spec
->input_mux
) {
610 err
= snd_hda_add_new_ctls(codec
, cxt_capture_mixers
);
615 #ifdef CONFIG_SND_HDA_INPUT_BEEP
616 /* create beep controls if needed */
617 if (spec
->beep_amp
) {
618 struct snd_kcontrol_new
*knew
;
619 for (knew
= cxt_beep_mixer
; knew
->name
; knew
++) {
620 struct snd_kcontrol
*kctl
;
621 kctl
= snd_ctl_new1(knew
, codec
);
624 kctl
->private_value
= spec
->beep_amp
;
625 err
= snd_hda_ctl_add(codec
, 0, kctl
);
635 #ifdef CONFIG_SND_HDA_POWER_SAVE
636 static int conexant_suspend(struct hda_codec
*codec
, pm_message_t state
)
638 snd_hda_shutup_pins(codec
);
643 static struct hda_codec_ops conexant_patch_ops
= {
644 .build_controls
= conexant_build_controls
,
645 .build_pcms
= conexant_build_pcms
,
646 .init
= conexant_init
,
647 .free
= conexant_free
,
648 #ifdef CONFIG_SND_HDA_POWER_SAVE
649 .suspend
= conexant_suspend
,
651 .reboot_notify
= snd_hda_shutup_pins
,
654 #ifdef CONFIG_SND_HDA_INPUT_BEEP
655 #define set_beep_amp(spec, nid, idx, dir) \
656 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir))
658 #define set_beep_amp(spec, nid, idx, dir) /* NOP */
663 * the private value = nid | (invert << 8)
666 #define cxt_eapd_info snd_ctl_boolean_mono_info
668 static int cxt_eapd_get(struct snd_kcontrol
*kcontrol
,
669 struct snd_ctl_elem_value
*ucontrol
)
671 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
672 struct conexant_spec
*spec
= codec
->spec
;
673 int invert
= (kcontrol
->private_value
>> 8) & 1;
675 ucontrol
->value
.integer
.value
[0] = !spec
->cur_eapd
;
677 ucontrol
->value
.integer
.value
[0] = spec
->cur_eapd
;
682 static int cxt_eapd_put(struct snd_kcontrol
*kcontrol
,
683 struct snd_ctl_elem_value
*ucontrol
)
685 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
686 struct conexant_spec
*spec
= codec
->spec
;
687 int invert
= (kcontrol
->private_value
>> 8) & 1;
688 hda_nid_t nid
= kcontrol
->private_value
& 0xff;
691 eapd
= !!ucontrol
->value
.integer
.value
[0];
694 if (eapd
== spec
->cur_eapd
)
697 spec
->cur_eapd
= eapd
;
698 snd_hda_codec_write_cache(codec
, nid
,
699 0, AC_VERB_SET_EAPD_BTLENABLE
,
704 /* controls for test mode */
705 #ifdef CONFIG_SND_DEBUG
707 #define CXT_EAPD_SWITCH(xname, nid, mask) \
708 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
709 .info = cxt_eapd_info, \
710 .get = cxt_eapd_get, \
711 .put = cxt_eapd_put, \
712 .private_value = nid | (mask<<16) }
716 static int conexant_ch_mode_info(struct snd_kcontrol
*kcontrol
,
717 struct snd_ctl_elem_info
*uinfo
)
719 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
720 struct conexant_spec
*spec
= codec
->spec
;
721 return snd_hda_ch_mode_info(codec
, uinfo
, spec
->channel_mode
,
722 spec
->num_channel_mode
);
725 static int conexant_ch_mode_get(struct snd_kcontrol
*kcontrol
,
726 struct snd_ctl_elem_value
*ucontrol
)
728 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
729 struct conexant_spec
*spec
= codec
->spec
;
730 return snd_hda_ch_mode_get(codec
, ucontrol
, spec
->channel_mode
,
731 spec
->num_channel_mode
,
732 spec
->multiout
.max_channels
);
735 static int conexant_ch_mode_put(struct snd_kcontrol
*kcontrol
,
736 struct snd_ctl_elem_value
*ucontrol
)
738 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
739 struct conexant_spec
*spec
= codec
->spec
;
740 int err
= snd_hda_ch_mode_put(codec
, ucontrol
, spec
->channel_mode
,
741 spec
->num_channel_mode
,
742 &spec
->multiout
.max_channels
);
743 if (err
>= 0 && spec
->need_dac_fix
)
744 spec
->multiout
.num_dacs
= spec
->multiout
.max_channels
/ 2;
748 #define CXT_PIN_MODE(xname, nid, dir) \
749 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
750 .info = conexant_ch_mode_info, \
751 .get = conexant_ch_mode_get, \
752 .put = conexant_ch_mode_put, \
753 .private_value = nid | (dir<<16) }
755 #endif /* CONFIG_SND_DEBUG */
757 /* Conexant 5045 specific */
759 static hda_nid_t cxt5045_dac_nids
[1] = { 0x19 };
760 static hda_nid_t cxt5045_adc_nids
[1] = { 0x1a };
761 static hda_nid_t cxt5045_capsrc_nids
[1] = { 0x1a };
762 #define CXT5045_SPDIF_OUT 0x18
764 static struct hda_channel_mode cxt5045_modes
[1] = {
768 static struct hda_input_mux cxt5045_capture_source
= {
776 static struct hda_input_mux cxt5045_capture_source_benq
= {
787 static struct hda_input_mux cxt5045_capture_source_hp530
= {
795 /* turn on/off EAPD (+ mute HP) as a master switch */
796 static int cxt5045_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
797 struct snd_ctl_elem_value
*ucontrol
)
799 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
800 struct conexant_spec
*spec
= codec
->spec
;
803 if (!cxt_eapd_put(kcontrol
, ucontrol
))
806 /* toggle internal speakers mute depending of presence of
809 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
810 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
813 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
814 snd_hda_codec_amp_stereo(codec
, 0x11, HDA_OUTPUT
, 0,
819 /* bind volumes of both NID 0x10 and 0x11 */
820 static struct hda_bind_ctls cxt5045_hp_bind_master_vol
= {
821 .ops
= &snd_hda_bind_vol
,
823 HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT
),
824 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT
),
829 /* toggle input of built-in and mic jack appropriately */
830 static void cxt5045_hp_automic(struct hda_codec
*codec
)
832 static struct hda_verb mic_jack_on
[] = {
833 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
834 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
837 static struct hda_verb mic_jack_off
[] = {
838 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
839 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
842 unsigned int present
;
844 present
= snd_hda_jack_detect(codec
, 0x12);
846 snd_hda_sequence_write(codec
, mic_jack_on
);
848 snd_hda_sequence_write(codec
, mic_jack_off
);
852 /* mute internal speaker if HP is plugged */
853 static void cxt5045_hp_automute(struct hda_codec
*codec
)
855 struct conexant_spec
*spec
= codec
->spec
;
858 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x11);
860 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
861 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
865 /* unsolicited event for HP jack sensing */
866 static void cxt5045_hp_unsol_event(struct hda_codec
*codec
,
871 case CONEXANT_HP_EVENT
:
872 cxt5045_hp_automute(codec
);
874 case CONEXANT_MIC_EVENT
:
875 cxt5045_hp_automic(codec
);
881 static struct snd_kcontrol_new cxt5045_mixers
[] = {
882 HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x1a, 0x01, HDA_INPUT
),
883 HDA_CODEC_MUTE("Internal Mic Capture Switch", 0x1a, 0x01, HDA_INPUT
),
884 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1a, 0x02, HDA_INPUT
),
885 HDA_CODEC_MUTE("Mic Capture Switch", 0x1a, 0x02, HDA_INPUT
),
886 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT
),
887 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT
),
888 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
889 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x1, HDA_INPUT
),
890 HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
891 HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
892 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol
),
894 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
895 .name
= "Master Playback Switch",
896 .info
= cxt_eapd_info
,
898 .put
= cxt5045_hp_master_sw_put
,
899 .private_value
= 0x10,
905 static struct snd_kcontrol_new cxt5045_benq_mixers
[] = {
906 HDA_CODEC_VOLUME("CD Capture Volume", 0x1a, 0x04, HDA_INPUT
),
907 HDA_CODEC_MUTE("CD Capture Switch", 0x1a, 0x04, HDA_INPUT
),
908 HDA_CODEC_VOLUME("CD Playback Volume", 0x17, 0x4, HDA_INPUT
),
909 HDA_CODEC_MUTE("CD Playback Switch", 0x17, 0x4, HDA_INPUT
),
911 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1a, 0x03, HDA_INPUT
),
912 HDA_CODEC_MUTE("Line In Capture Switch", 0x1a, 0x03, HDA_INPUT
),
913 HDA_CODEC_VOLUME("Line In Playback Volume", 0x17, 0x3, HDA_INPUT
),
914 HDA_CODEC_MUTE("Line In Playback Switch", 0x17, 0x3, HDA_INPUT
),
916 HDA_CODEC_VOLUME("Mixer Capture Volume", 0x1a, 0x0, HDA_INPUT
),
917 HDA_CODEC_MUTE("Mixer Capture Switch", 0x1a, 0x0, HDA_INPUT
),
922 static struct snd_kcontrol_new cxt5045_mixers_hp530
[] = {
923 HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x1a, 0x02, HDA_INPUT
),
924 HDA_CODEC_MUTE("Internal Mic Capture Switch", 0x1a, 0x02, HDA_INPUT
),
925 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1a, 0x01, HDA_INPUT
),
926 HDA_CODEC_MUTE("Mic Capture Switch", 0x1a, 0x01, HDA_INPUT
),
927 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT
),
928 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT
),
929 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
930 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
931 HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
932 HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x1, HDA_INPUT
),
933 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol
),
935 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
936 .name
= "Master Playback Switch",
937 .info
= cxt_eapd_info
,
939 .put
= cxt5045_hp_master_sw_put
,
940 .private_value
= 0x10,
946 static struct hda_verb cxt5045_init_verbs
[] = {
948 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
949 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
951 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
952 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
953 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
954 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
955 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
956 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
957 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
958 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
959 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
960 /* Record selector: Internal mic */
961 {0x1a, AC_VERB_SET_CONNECT_SEL
,0x1},
962 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
963 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
964 /* SPDIF route: PCM */
965 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
966 { 0x13, AC_VERB_SET_CONNECT_SEL
, 0x0 },
968 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2 }, /* default on */
972 static struct hda_verb cxt5045_benq_init_verbs
[] = {
973 /* Internal Mic, Mic */
974 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
975 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
976 /* Line In,HP, Amp */
977 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
978 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
979 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
980 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
981 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
982 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
983 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
984 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
985 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
986 /* Record selector: Internal mic */
987 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x1},
988 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
989 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
990 /* SPDIF route: PCM */
991 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
992 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0},
994 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
998 static struct hda_verb cxt5045_hp_sense_init_verbs
[] = {
999 /* pin sensing on HP jack */
1000 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
1004 static struct hda_verb cxt5045_mic_sense_init_verbs
[] = {
1005 /* pin sensing on HP jack */
1006 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
1010 #ifdef CONFIG_SND_DEBUG
1011 /* Test configuration for debugging, modelled after the ALC260 test
1014 static struct hda_input_mux cxt5045_test_capture_source
= {
1018 { "MIC1 pin", 0x1 },
1019 { "LINE1 pin", 0x2 },
1020 { "HP-OUT pin", 0x3 },
1025 static struct snd_kcontrol_new cxt5045_test_mixer
[] = {
1027 /* Output controls */
1028 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT
),
1029 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT
),
1030 HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
1031 HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
1032 HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
1033 HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
1035 /* Modes for retasking pin widgets */
1036 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT
),
1037 CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT
),
1039 /* EAPD Switch Control */
1040 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
1042 /* Loopback mixer controls */
1044 HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT
),
1045 HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT
),
1046 HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT
),
1047 HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT
),
1048 HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT
),
1049 HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT
),
1050 HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT
),
1051 HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT
),
1052 HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT
),
1053 HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT
),
1055 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1056 .name
= "Input Source",
1057 .info
= conexant_mux_enum_info
,
1058 .get
= conexant_mux_enum_get
,
1059 .put
= conexant_mux_enum_put
,
1061 /* Audio input controls */
1062 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT
),
1063 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT
),
1064 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT
),
1065 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT
),
1066 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT
),
1067 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT
),
1068 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT
),
1069 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT
),
1070 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT
),
1071 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT
),
1075 static struct hda_verb cxt5045_test_init_verbs
[] = {
1076 /* Set connections */
1077 { 0x10, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1078 { 0x11, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1079 { 0x12, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1080 /* Enable retasking pins as output, initially without power amp */
1081 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1082 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1084 /* Disable digital (SPDIF) pins initially, but users can enable
1085 * them via a mixer switch. In the case of SPDIF-out, this initverb
1086 * payload also sets the generation to 0, output to be in "consumer"
1087 * PCM format, copyright asserted, no pre-emphasis and no validity
1090 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1091 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
1093 /* Start with output sum widgets muted and their output gains at min */
1094 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1095 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1097 /* Unmute retasking pin widget output buffers since the default
1098 * state appears to be output. As the pin mode is changed by the
1099 * user the pin mode control will take care of enabling the pin's
1100 * input/output buffers as needed.
1102 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1103 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1105 /* Mute capture amp left and right */
1106 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1108 /* Set ADC connection select to match default mixer setting (mic1
1111 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1112 {0x17, AC_VERB_SET_CONNECT_SEL
, 0x00},
1114 /* Mute all inputs to mixer widget (even unconnected ones) */
1115 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* Mixer pin */
1116 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* Mic1 pin */
1117 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* Line pin */
1118 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* HP pin */
1119 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
1126 /* initialize jack-sensing, too */
1127 static int cxt5045_init(struct hda_codec
*codec
)
1129 conexant_init(codec
);
1130 cxt5045_hp_automute(codec
);
1136 CXT5045_LAPTOP_HPSENSE
,
1137 CXT5045_LAPTOP_MICSENSE
,
1138 CXT5045_LAPTOP_HPMICSENSE
,
1140 CXT5045_LAPTOP_HP530
,
1141 #ifdef CONFIG_SND_DEBUG
1147 static const char * const cxt5045_models
[CXT5045_MODELS
] = {
1148 [CXT5045_LAPTOP_HPSENSE
] = "laptop-hpsense",
1149 [CXT5045_LAPTOP_MICSENSE
] = "laptop-micsense",
1150 [CXT5045_LAPTOP_HPMICSENSE
] = "laptop-hpmicsense",
1151 [CXT5045_BENQ
] = "benq",
1152 [CXT5045_LAPTOP_HP530
] = "laptop-hp530",
1153 #ifdef CONFIG_SND_DEBUG
1154 [CXT5045_TEST
] = "test",
1158 static struct snd_pci_quirk cxt5045_cfg_tbl
[] = {
1159 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530
),
1160 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1161 CXT5045_LAPTOP_HPSENSE
),
1162 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE
),
1163 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ
),
1164 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE
),
1165 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE
),
1166 SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505",
1167 CXT5045_LAPTOP_HPMICSENSE
),
1168 SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1169 SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1170 SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1171 SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell",
1172 CXT5045_LAPTOP_HPMICSENSE
),
1173 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE
),
1177 static int patch_cxt5045(struct hda_codec
*codec
)
1179 struct conexant_spec
*spec
;
1182 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1186 codec
->pin_amp_workaround
= 1;
1188 spec
->multiout
.max_channels
= 2;
1189 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5045_dac_nids
);
1190 spec
->multiout
.dac_nids
= cxt5045_dac_nids
;
1191 spec
->multiout
.dig_out_nid
= CXT5045_SPDIF_OUT
;
1192 spec
->num_adc_nids
= 1;
1193 spec
->adc_nids
= cxt5045_adc_nids
;
1194 spec
->capsrc_nids
= cxt5045_capsrc_nids
;
1195 spec
->input_mux
= &cxt5045_capture_source
;
1196 spec
->num_mixers
= 1;
1197 spec
->mixers
[0] = cxt5045_mixers
;
1198 spec
->num_init_verbs
= 1;
1199 spec
->init_verbs
[0] = cxt5045_init_verbs
;
1200 spec
->spdif_route
= 0;
1201 spec
->num_channel_mode
= ARRAY_SIZE(cxt5045_modes
);
1202 spec
->channel_mode
= cxt5045_modes
;
1204 set_beep_amp(spec
, 0x16, 0, 1);
1206 codec
->patch_ops
= conexant_patch_ops
;
1208 board_config
= snd_hda_check_board_config(codec
, CXT5045_MODELS
,
1211 switch (board_config
) {
1212 case CXT5045_LAPTOP_HPSENSE
:
1213 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1214 spec
->input_mux
= &cxt5045_capture_source
;
1215 spec
->num_init_verbs
= 2;
1216 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1217 spec
->mixers
[0] = cxt5045_mixers
;
1218 codec
->patch_ops
.init
= cxt5045_init
;
1220 case CXT5045_LAPTOP_MICSENSE
:
1221 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1222 spec
->input_mux
= &cxt5045_capture_source
;
1223 spec
->num_init_verbs
= 2;
1224 spec
->init_verbs
[1] = cxt5045_mic_sense_init_verbs
;
1225 spec
->mixers
[0] = cxt5045_mixers
;
1226 codec
->patch_ops
.init
= cxt5045_init
;
1229 case CXT5045_LAPTOP_HPMICSENSE
:
1230 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1231 spec
->input_mux
= &cxt5045_capture_source
;
1232 spec
->num_init_verbs
= 3;
1233 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1234 spec
->init_verbs
[2] = cxt5045_mic_sense_init_verbs
;
1235 spec
->mixers
[0] = cxt5045_mixers
;
1236 codec
->patch_ops
.init
= cxt5045_init
;
1239 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1240 spec
->input_mux
= &cxt5045_capture_source_benq
;
1241 spec
->num_init_verbs
= 1;
1242 spec
->init_verbs
[0] = cxt5045_benq_init_verbs
;
1243 spec
->mixers
[0] = cxt5045_mixers
;
1244 spec
->mixers
[1] = cxt5045_benq_mixers
;
1245 spec
->num_mixers
= 2;
1246 codec
->patch_ops
.init
= cxt5045_init
;
1248 case CXT5045_LAPTOP_HP530
:
1249 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1250 spec
->input_mux
= &cxt5045_capture_source_hp530
;
1251 spec
->num_init_verbs
= 2;
1252 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1253 spec
->mixers
[0] = cxt5045_mixers_hp530
;
1254 codec
->patch_ops
.init
= cxt5045_init
;
1256 #ifdef CONFIG_SND_DEBUG
1258 spec
->input_mux
= &cxt5045_test_capture_source
;
1259 spec
->mixers
[0] = cxt5045_test_mixer
;
1260 spec
->init_verbs
[0] = cxt5045_test_init_verbs
;
1266 switch (codec
->subsystem_id
>> 16) {
1271 /* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have
1272 * really bad sound over 0dB on NID 0x17. Fix max PCM level to
1273 * 0 dB (originally it has 0x2b steps with 0dB offset 0x14)
1275 snd_hda_override_amp_caps(codec
, 0x17, HDA_INPUT
,
1276 (0x14 << AC_AMPCAP_OFFSET_SHIFT
) |
1277 (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
1278 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
1279 (1 << AC_AMPCAP_MUTE_SHIFT
));
1284 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
1290 /* Conexant 5047 specific */
1291 #define CXT5047_SPDIF_OUT 0x11
1293 static hda_nid_t cxt5047_dac_nids
[1] = { 0x10 }; /* 0x1c */
1294 static hda_nid_t cxt5047_adc_nids
[1] = { 0x12 };
1295 static hda_nid_t cxt5047_capsrc_nids
[1] = { 0x1a };
1297 static struct hda_channel_mode cxt5047_modes
[1] = {
1301 static struct hda_input_mux cxt5047_toshiba_capture_source
= {
1309 /* turn on/off EAPD (+ mute HP) as a master switch */
1310 static int cxt5047_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1311 struct snd_ctl_elem_value
*ucontrol
)
1313 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1314 struct conexant_spec
*spec
= codec
->spec
;
1317 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1320 /* toggle internal speakers mute depending of presence of
1321 * the headphone jack
1323 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
1324 /* NOTE: Conexat codec needs the index for *OUTPUT* amp of
1325 * pin widgets unlike other codecs. In this case, we need to
1326 * set index 0x01 for the volume from the mixer amp 0x19.
1328 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0x01,
1329 HDA_AMP_MUTE
, bits
);
1330 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
1331 snd_hda_codec_amp_stereo(codec
, 0x13, HDA_OUTPUT
, 0,
1332 HDA_AMP_MUTE
, bits
);
1336 /* mute internal speaker if HP is plugged */
1337 static void cxt5047_hp_automute(struct hda_codec
*codec
)
1339 struct conexant_spec
*spec
= codec
->spec
;
1342 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x13);
1344 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
1345 /* See the note in cxt5047_hp_master_sw_put */
1346 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0x01,
1347 HDA_AMP_MUTE
, bits
);
1350 /* toggle input of built-in and mic jack appropriately */
1351 static void cxt5047_hp_automic(struct hda_codec
*codec
)
1353 static struct hda_verb mic_jack_on
[] = {
1354 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1355 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1358 static struct hda_verb mic_jack_off
[] = {
1359 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1360 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1363 unsigned int present
;
1365 present
= snd_hda_jack_detect(codec
, 0x15);
1367 snd_hda_sequence_write(codec
, mic_jack_on
);
1369 snd_hda_sequence_write(codec
, mic_jack_off
);
1372 /* unsolicited event for HP jack sensing */
1373 static void cxt5047_hp_unsol_event(struct hda_codec
*codec
,
1376 switch (res
>> 26) {
1377 case CONEXANT_HP_EVENT
:
1378 cxt5047_hp_automute(codec
);
1380 case CONEXANT_MIC_EVENT
:
1381 cxt5047_hp_automic(codec
);
1386 static struct snd_kcontrol_new cxt5047_base_mixers
[] = {
1387 HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT
),
1388 HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT
),
1389 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT
),
1390 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT
),
1391 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT
),
1392 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT
),
1393 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT
),
1395 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1396 .name
= "Master Playback Switch",
1397 .info
= cxt_eapd_info
,
1398 .get
= cxt_eapd_get
,
1399 .put
= cxt5047_hp_master_sw_put
,
1400 .private_value
= 0x13,
1406 static struct snd_kcontrol_new cxt5047_hp_spk_mixers
[] = {
1407 /* See the note in cxt5047_hp_master_sw_put */
1408 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT
),
1409 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1413 static struct snd_kcontrol_new cxt5047_hp_only_mixers
[] = {
1414 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1418 static struct hda_verb cxt5047_init_verbs
[] = {
1419 /* Line in, Mic, Built-in Mic */
1420 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1421 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1422 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1424 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1425 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* mixer(0x19) */
1426 {0x1d, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* mixer(0x19) */
1427 /* Record selector: Mic */
1428 {0x12, AC_VERB_SET_CONNECT_SEL
,0x03},
1429 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
,
1430 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
1431 {0x1A, AC_VERB_SET_CONNECT_SEL
,0x02},
1432 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1433 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x00},
1434 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1435 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x03},
1436 /* SPDIF route: PCM */
1437 { 0x18, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1438 /* Enable unsolicited events */
1439 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
1440 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
1444 /* configuration for Toshiba Laptops */
1445 static struct hda_verb cxt5047_toshiba_init_verbs
[] = {
1446 {0x13, AC_VERB_SET_EAPD_BTLENABLE
, 0x0}, /* default off */
1450 /* Test configuration for debugging, modelled after the ALC260 test
1453 #ifdef CONFIG_SND_DEBUG
1454 static struct hda_input_mux cxt5047_test_capture_source
= {
1457 { "LINE1 pin", 0x0 },
1458 { "MIC1 pin", 0x1 },
1459 { "MIC2 pin", 0x2 },
1464 static struct snd_kcontrol_new cxt5047_test_mixer
[] = {
1466 /* Output only controls */
1467 HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT
),
1468 HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT
),
1469 HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT
),
1470 HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT
),
1471 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
1472 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT
),
1473 HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
1474 HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
1475 HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT
),
1476 HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT
),
1477 HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT
),
1478 HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT
),
1480 /* Modes for retasking pin widgets */
1481 CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT
),
1482 CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT
),
1484 /* EAPD Switch Control */
1485 CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0),
1487 /* Loopback mixer controls */
1488 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT
),
1489 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT
),
1490 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT
),
1491 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT
),
1492 HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT
),
1493 HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT
),
1494 HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT
),
1495 HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT
),
1497 HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT
),
1498 HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT
),
1499 HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT
),
1500 HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT
),
1501 HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT
),
1502 HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT
),
1503 HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT
),
1504 HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT
),
1506 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1507 .name
= "Input Source",
1508 .info
= conexant_mux_enum_info
,
1509 .get
= conexant_mux_enum_get
,
1510 .put
= conexant_mux_enum_put
,
1512 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT
),
1517 static struct hda_verb cxt5047_test_init_verbs
[] = {
1518 /* Enable retasking pins as output, initially without power amp */
1519 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1520 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1521 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1523 /* Disable digital (SPDIF) pins initially, but users can enable
1524 * them via a mixer switch. In the case of SPDIF-out, this initverb
1525 * payload also sets the generation to 0, output to be in "consumer"
1526 * PCM format, copyright asserted, no pre-emphasis and no validity
1529 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
1531 /* Ensure mic1, mic2, line1 pin widgets take input from the
1532 * OUT1 sum bus when acting as an output.
1534 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0},
1535 {0x1b, AC_VERB_SET_CONNECT_SEL
, 0},
1537 /* Start with output sum widgets muted and their output gains at min */
1538 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1539 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1541 /* Unmute retasking pin widget output buffers since the default
1542 * state appears to be output. As the pin mode is changed by the
1543 * user the pin mode control will take care of enabling the pin's
1544 * input/output buffers as needed.
1546 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1547 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1548 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1550 /* Mute capture amp left and right */
1551 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1553 /* Set ADC connection select to match default mixer setting (mic1
1556 {0x12, AC_VERB_SET_CONNECT_SEL
, 0x00},
1558 /* Mute all inputs to mixer widget (even unconnected ones) */
1559 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* mic1 pin */
1560 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* mic2 pin */
1561 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* line1 pin */
1562 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* line2 pin */
1563 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
1564 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)}, /* Beep-gen pin */
1565 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)}, /* Line-out pin */
1566 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)}, /* HP-pin pin */
1573 /* initialize jack-sensing, too */
1574 static int cxt5047_hp_init(struct hda_codec
*codec
)
1576 conexant_init(codec
);
1577 cxt5047_hp_automute(codec
);
1583 CXT5047_LAPTOP
, /* Laptops w/o EAPD support */
1584 CXT5047_LAPTOP_HP
, /* Some HP laptops */
1585 CXT5047_LAPTOP_EAPD
, /* Laptops with EAPD support */
1586 #ifdef CONFIG_SND_DEBUG
1592 static const char * const cxt5047_models
[CXT5047_MODELS
] = {
1593 [CXT5047_LAPTOP
] = "laptop",
1594 [CXT5047_LAPTOP_HP
] = "laptop-hp",
1595 [CXT5047_LAPTOP_EAPD
] = "laptop-eapd",
1596 #ifdef CONFIG_SND_DEBUG
1597 [CXT5047_TEST
] = "test",
1601 static struct snd_pci_quirk cxt5047_cfg_tbl
[] = {
1602 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP
),
1603 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1605 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD
),
1609 static int patch_cxt5047(struct hda_codec
*codec
)
1611 struct conexant_spec
*spec
;
1614 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1618 codec
->pin_amp_workaround
= 1;
1620 spec
->multiout
.max_channels
= 2;
1621 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5047_dac_nids
);
1622 spec
->multiout
.dac_nids
= cxt5047_dac_nids
;
1623 spec
->multiout
.dig_out_nid
= CXT5047_SPDIF_OUT
;
1624 spec
->num_adc_nids
= 1;
1625 spec
->adc_nids
= cxt5047_adc_nids
;
1626 spec
->capsrc_nids
= cxt5047_capsrc_nids
;
1627 spec
->num_mixers
= 1;
1628 spec
->mixers
[0] = cxt5047_base_mixers
;
1629 spec
->num_init_verbs
= 1;
1630 spec
->init_verbs
[0] = cxt5047_init_verbs
;
1631 spec
->spdif_route
= 0;
1632 spec
->num_channel_mode
= ARRAY_SIZE(cxt5047_modes
),
1633 spec
->channel_mode
= cxt5047_modes
,
1635 codec
->patch_ops
= conexant_patch_ops
;
1637 board_config
= snd_hda_check_board_config(codec
, CXT5047_MODELS
,
1640 switch (board_config
) {
1641 case CXT5047_LAPTOP
:
1642 spec
->num_mixers
= 2;
1643 spec
->mixers
[1] = cxt5047_hp_spk_mixers
;
1644 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1646 case CXT5047_LAPTOP_HP
:
1647 spec
->num_mixers
= 2;
1648 spec
->mixers
[1] = cxt5047_hp_only_mixers
;
1649 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1650 codec
->patch_ops
.init
= cxt5047_hp_init
;
1652 case CXT5047_LAPTOP_EAPD
:
1653 spec
->input_mux
= &cxt5047_toshiba_capture_source
;
1654 spec
->num_mixers
= 2;
1655 spec
->mixers
[1] = cxt5047_hp_spk_mixers
;
1656 spec
->num_init_verbs
= 2;
1657 spec
->init_verbs
[1] = cxt5047_toshiba_init_verbs
;
1658 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1660 #ifdef CONFIG_SND_DEBUG
1662 spec
->input_mux
= &cxt5047_test_capture_source
;
1663 spec
->mixers
[0] = cxt5047_test_mixer
;
1664 spec
->init_verbs
[0] = cxt5047_test_init_verbs
;
1665 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1668 spec
->vmaster_nid
= 0x13;
1670 switch (codec
->subsystem_id
>> 16) {
1672 /* HP laptops have really bad sound over 0 dB on NID 0x10.
1673 * Fix max PCM level to 0 dB (originally it has 0x1e steps
1674 * with 0 dB offset 0x17)
1676 snd_hda_override_amp_caps(codec
, 0x10, HDA_INPUT
,
1677 (0x17 << AC_AMPCAP_OFFSET_SHIFT
) |
1678 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
1679 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
1680 (1 << AC_AMPCAP_MUTE_SHIFT
));
1687 /* Conexant 5051 specific */
1688 static hda_nid_t cxt5051_dac_nids
[1] = { 0x10 };
1689 static hda_nid_t cxt5051_adc_nids
[2] = { 0x14, 0x15 };
1691 static struct hda_channel_mode cxt5051_modes
[1] = {
1695 static void cxt5051_update_speaker(struct hda_codec
*codec
)
1697 struct conexant_spec
*spec
= codec
->spec
;
1698 unsigned int pinctl
;
1700 pinctl
= (spec
->hp_present
&& spec
->cur_eapd
) ? PIN_HP
: 0;
1701 snd_hda_codec_write(codec
, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1704 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
1705 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1707 /* on ideapad there is an aditional speaker (subwoofer) to mute */
1709 snd_hda_codec_write(codec
, 0x1b, 0,
1710 AC_VERB_SET_PIN_WIDGET_CONTROL
,
1714 /* turn on/off EAPD (+ mute HP) as a master switch */
1715 static int cxt5051_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1716 struct snd_ctl_elem_value
*ucontrol
)
1718 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1720 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1722 cxt5051_update_speaker(codec
);
1726 /* toggle input of built-in and mic jack appropriately */
1727 static void cxt5051_portb_automic(struct hda_codec
*codec
)
1729 struct conexant_spec
*spec
= codec
->spec
;
1730 unsigned int present
;
1732 if (!(spec
->auto_mic
& AUTO_MIC_PORTB
))
1734 present
= snd_hda_jack_detect(codec
, 0x17);
1735 snd_hda_codec_write(codec
, 0x14, 0,
1736 AC_VERB_SET_CONNECT_SEL
,
1737 present
? 0x01 : 0x00);
1740 /* switch the current ADC according to the jack state */
1741 static void cxt5051_portc_automic(struct hda_codec
*codec
)
1743 struct conexant_spec
*spec
= codec
->spec
;
1744 unsigned int present
;
1747 if (!(spec
->auto_mic
& AUTO_MIC_PORTC
))
1749 present
= snd_hda_jack_detect(codec
, 0x18);
1751 spec
->cur_adc_idx
= 1;
1753 spec
->cur_adc_idx
= 0;
1754 new_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
1755 if (spec
->cur_adc
&& spec
->cur_adc
!= new_adc
) {
1756 /* stream is running, let's swap the current ADC */
1757 __snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
, 1);
1758 spec
->cur_adc
= new_adc
;
1759 snd_hda_codec_setup_stream(codec
, new_adc
,
1760 spec
->cur_adc_stream_tag
, 0,
1761 spec
->cur_adc_format
);
1765 /* mute internal speaker if HP is plugged */
1766 static void cxt5051_hp_automute(struct hda_codec
*codec
)
1768 struct conexant_spec
*spec
= codec
->spec
;
1770 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x16);
1771 cxt5051_update_speaker(codec
);
1774 /* unsolicited event for HP jack sensing */
1775 static void cxt5051_hp_unsol_event(struct hda_codec
*codec
,
1778 int nid
= (res
& AC_UNSOL_RES_SUBTAG
) >> 20;
1779 switch (res
>> 26) {
1780 case CONEXANT_HP_EVENT
:
1781 cxt5051_hp_automute(codec
);
1783 case CXT5051_PORTB_EVENT
:
1784 cxt5051_portb_automic(codec
);
1786 case CXT5051_PORTC_EVENT
:
1787 cxt5051_portc_automic(codec
);
1790 conexant_report_jack(codec
, nid
);
1793 static struct snd_kcontrol_new cxt5051_playback_mixers
[] = {
1794 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
1796 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1797 .name
= "Master Playback Switch",
1798 .info
= cxt_eapd_info
,
1799 .get
= cxt_eapd_get
,
1800 .put
= cxt5051_hp_master_sw_put
,
1801 .private_value
= 0x1a,
1806 static struct snd_kcontrol_new cxt5051_capture_mixers
[] = {
1807 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1808 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1809 HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT
),
1810 HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT
),
1811 HDA_CODEC_VOLUME("Docking Mic Volume", 0x15, 0x00, HDA_INPUT
),
1812 HDA_CODEC_MUTE("Docking Mic Switch", 0x15, 0x00, HDA_INPUT
),
1816 static struct snd_kcontrol_new cxt5051_hp_mixers
[] = {
1817 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1818 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1819 HDA_CODEC_VOLUME("Mic Volume", 0x15, 0x00, HDA_INPUT
),
1820 HDA_CODEC_MUTE("Mic Switch", 0x15, 0x00, HDA_INPUT
),
1824 static struct snd_kcontrol_new cxt5051_hp_dv6736_mixers
[] = {
1825 HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x00, HDA_INPUT
),
1826 HDA_CODEC_MUTE("Capture Switch", 0x14, 0x00, HDA_INPUT
),
1830 static struct snd_kcontrol_new cxt5051_f700_mixers
[] = {
1831 HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x01, HDA_INPUT
),
1832 HDA_CODEC_MUTE("Capture Switch", 0x14, 0x01, HDA_INPUT
),
1836 static struct snd_kcontrol_new cxt5051_toshiba_mixers
[] = {
1837 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1838 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1839 HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT
),
1840 HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT
),
1844 static struct hda_verb cxt5051_init_verbs
[] = {
1846 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1847 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1848 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1849 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1850 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1851 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1853 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1854 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1856 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1857 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1859 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1860 /* Record selector: Internal mic */
1861 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1862 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1863 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1864 /* SPDIF route: PCM */
1865 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1866 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1868 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1869 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1873 static struct hda_verb cxt5051_hp_dv6736_init_verbs
[] = {
1875 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1876 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1877 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1878 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1880 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1881 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1883 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1884 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1886 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1887 /* Record selector: Internal mic */
1888 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1889 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x1},
1890 /* SPDIF route: PCM */
1891 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1893 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1894 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1898 static struct hda_verb cxt5051_lenovo_x200_init_verbs
[] = {
1900 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1901 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1902 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1903 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1904 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1905 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1907 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1908 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1910 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1911 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1913 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1914 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00},
1916 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1917 /* Record selector: Internal mic */
1918 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1919 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1920 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1921 /* SPDIF route: PCM */
1922 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
}, /* needed for W500 Advanced Mini Dock 250410 */
1923 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1925 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1926 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1927 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1931 static struct hda_verb cxt5051_f700_init_verbs
[] = {
1933 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1934 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1935 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1936 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1938 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1939 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1941 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1942 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1944 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1945 /* Record selector: Internal mic */
1946 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1947 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x1},
1948 /* SPDIF route: PCM */
1949 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1951 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1952 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1956 static void cxt5051_init_mic_port(struct hda_codec
*codec
, hda_nid_t nid
,
1959 snd_hda_codec_write(codec
, nid
, 0,
1960 AC_VERB_SET_UNSOLICITED_ENABLE
,
1961 AC_USRSP_EN
| event
);
1962 #ifdef CONFIG_SND_HDA_INPUT_JACK
1963 conexant_add_jack(codec
, nid
, SND_JACK_MICROPHONE
);
1964 conexant_report_jack(codec
, nid
);
1968 static struct hda_verb cxt5051_ideapad_init_verbs
[] = {
1970 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1971 {0x1b, AC_VERB_SET_CONNECT_SEL
, 0x00},
1975 /* initialize jack-sensing, too */
1976 static int cxt5051_init(struct hda_codec
*codec
)
1978 struct conexant_spec
*spec
= codec
->spec
;
1980 conexant_init(codec
);
1981 conexant_init_jacks(codec
);
1983 if (spec
->auto_mic
& AUTO_MIC_PORTB
)
1984 cxt5051_init_mic_port(codec
, 0x17, CXT5051_PORTB_EVENT
);
1985 if (spec
->auto_mic
& AUTO_MIC_PORTC
)
1986 cxt5051_init_mic_port(codec
, 0x18, CXT5051_PORTC_EVENT
);
1988 if (codec
->patch_ops
.unsol_event
) {
1989 cxt5051_hp_automute(codec
);
1990 cxt5051_portb_automic(codec
);
1991 cxt5051_portc_automic(codec
);
1998 CXT5051_LAPTOP
, /* Laptops w/ EAPD support */
1999 CXT5051_HP
, /* no docking */
2000 CXT5051_HP_DV6736
, /* HP without mic switch */
2001 CXT5051_LENOVO_X200
, /* Lenovo X200 laptop, also used for Advanced Mini Dock 250410 */
2002 CXT5051_F700
, /* HP Compaq Presario F700 */
2003 CXT5051_TOSHIBA
, /* Toshiba M300 & co */
2004 CXT5051_IDEAPAD
, /* Lenovo IdeaPad Y430 */
2008 static const char *const cxt5051_models
[CXT5051_MODELS
] = {
2009 [CXT5051_LAPTOP
] = "laptop",
2010 [CXT5051_HP
] = "hp",
2011 [CXT5051_HP_DV6736
] = "hp-dv6736",
2012 [CXT5051_LENOVO_X200
] = "lenovo-x200",
2013 [CXT5051_F700
] = "hp-700",
2014 [CXT5051_TOSHIBA
] = "toshiba",
2015 [CXT5051_IDEAPAD
] = "ideapad",
2018 static struct snd_pci_quirk cxt5051_cfg_tbl
[] = {
2019 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736
),
2020 SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP
),
2021 SND_PCI_QUIRK(0x103c, 0x30ea, "Compaq Presario F700", CXT5051_F700
),
2022 SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba M30x", CXT5051_TOSHIBA
),
2023 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
2025 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP
),
2026 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT5051_LENOVO_X200
),
2027 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo IdeaPad", CXT5051_IDEAPAD
),
2031 static int patch_cxt5051(struct hda_codec
*codec
)
2033 struct conexant_spec
*spec
;
2036 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
2040 codec
->pin_amp_workaround
= 1;
2042 codec
->patch_ops
= conexant_patch_ops
;
2043 codec
->patch_ops
.init
= cxt5051_init
;
2045 spec
->multiout
.max_channels
= 2;
2046 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5051_dac_nids
);
2047 spec
->multiout
.dac_nids
= cxt5051_dac_nids
;
2048 spec
->multiout
.dig_out_nid
= CXT5051_SPDIF_OUT
;
2049 spec
->num_adc_nids
= 1; /* not 2; via auto-mic switch */
2050 spec
->adc_nids
= cxt5051_adc_nids
;
2051 spec
->num_mixers
= 2;
2052 spec
->mixers
[0] = cxt5051_capture_mixers
;
2053 spec
->mixers
[1] = cxt5051_playback_mixers
;
2054 spec
->num_init_verbs
= 1;
2055 spec
->init_verbs
[0] = cxt5051_init_verbs
;
2056 spec
->spdif_route
= 0;
2057 spec
->num_channel_mode
= ARRAY_SIZE(cxt5051_modes
);
2058 spec
->channel_mode
= cxt5051_modes
;
2060 spec
->cur_adc_idx
= 0;
2062 set_beep_amp(spec
, 0x13, 0, HDA_OUTPUT
);
2064 codec
->patch_ops
.unsol_event
= cxt5051_hp_unsol_event
;
2066 board_config
= snd_hda_check_board_config(codec
, CXT5051_MODELS
,
2069 spec
->auto_mic
= AUTO_MIC_PORTB
| AUTO_MIC_PORTC
;
2070 switch (board_config
) {
2072 spec
->mixers
[0] = cxt5051_hp_mixers
;
2074 case CXT5051_HP_DV6736
:
2075 spec
->init_verbs
[0] = cxt5051_hp_dv6736_init_verbs
;
2076 spec
->mixers
[0] = cxt5051_hp_dv6736_mixers
;
2079 case CXT5051_LENOVO_X200
:
2080 spec
->init_verbs
[0] = cxt5051_lenovo_x200_init_verbs
;
2081 /* Thinkpad X301 does not have S/PDIF wired and no ability
2082 to use a docking station. */
2083 if (codec
->subsystem_id
== 0x17aa211f)
2084 spec
->multiout
.dig_out_nid
= 0;
2087 spec
->init_verbs
[0] = cxt5051_f700_init_verbs
;
2088 spec
->mixers
[0] = cxt5051_f700_mixers
;
2091 case CXT5051_TOSHIBA
:
2092 spec
->mixers
[0] = cxt5051_toshiba_mixers
;
2093 spec
->auto_mic
= AUTO_MIC_PORTB
;
2095 case CXT5051_IDEAPAD
:
2096 spec
->init_verbs
[spec
->num_init_verbs
++] =
2097 cxt5051_ideapad_init_verbs
;
2103 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
2108 /* Conexant 5066 specific */
2110 static hda_nid_t cxt5066_dac_nids
[1] = { 0x10 };
2111 static hda_nid_t cxt5066_adc_nids
[3] = { 0x14, 0x15, 0x16 };
2112 static hda_nid_t cxt5066_capsrc_nids
[1] = { 0x17 };
2113 static hda_nid_t cxt5066_digout_pin_nids
[2] = { 0x20, 0x22 };
2115 /* OLPC's microphone port is DC coupled for use with external sensors,
2116 * therefore we use a 50% mic bias in order to center the input signal with
2117 * the DC input range of the codec. */
2118 #define CXT5066_OLPC_EXT_MIC_BIAS PIN_VREF50
2120 static struct hda_channel_mode cxt5066_modes
[1] = {
2124 #define HP_PRESENT_PORT_A (1 << 0)
2125 #define HP_PRESENT_PORT_D (1 << 1)
2126 #define hp_port_a_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_A)
2127 #define hp_port_d_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_D)
2129 static void cxt5066_update_speaker(struct hda_codec
*codec
)
2131 struct conexant_spec
*spec
= codec
->spec
;
2132 unsigned int pinctl
;
2134 snd_printdd("CXT5066: update speaker, hp_present=%d, cur_eapd=%d\n",
2135 spec
->hp_present
, spec
->cur_eapd
);
2138 pinctl
= (hp_port_a_present(spec
) && spec
->cur_eapd
) ? PIN_HP
: 0;
2139 snd_hda_codec_write(codec
, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2142 /* Port D (HP/LO) */
2143 pinctl
= spec
->cur_eapd
? spec
->port_d_mode
: 0;
2144 if (spec
->dell_automute
|| spec
->thinkpad
) {
2145 /* Mute if Port A is connected */
2146 if (hp_port_a_present(spec
))
2149 /* Thinkpad/Dell doesn't give pin-D status */
2150 if (!hp_port_d_present(spec
))
2153 snd_hda_codec_write(codec
, 0x1c, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2157 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
2158 snd_hda_codec_write(codec
, 0x1f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2162 /* turn on/off EAPD (+ mute HP) as a master switch */
2163 static int cxt5066_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
2164 struct snd_ctl_elem_value
*ucontrol
)
2166 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2168 if (!cxt_eapd_put(kcontrol
, ucontrol
))
2171 cxt5066_update_speaker(codec
);
2175 static const struct hda_input_mux cxt5066_olpc_dc_bias
= {
2179 { "50%", PIN_VREF50
},
2180 { "80%", PIN_VREF80
},
2184 static int cxt5066_set_olpc_dc_bias(struct hda_codec
*codec
)
2186 struct conexant_spec
*spec
= codec
->spec
;
2187 /* Even though port F is the DC input, the bias is controlled on port B.
2188 * we also leave that port as an active input (but unselected) in DC mode
2189 * just in case that is necessary to make the bias setting take effect. */
2190 return snd_hda_codec_write_cache(codec
, 0x1a, 0,
2191 AC_VERB_SET_PIN_WIDGET_CONTROL
,
2192 cxt5066_olpc_dc_bias
.items
[spec
->dc_input_bias
].index
);
2195 /* OLPC defers mic widget control until when capture is started because the
2196 * microphone LED comes on as soon as these settings are put in place. if we
2197 * did this before recording, it would give the false indication that recording
2198 * is happening when it is not. */
2199 static void cxt5066_olpc_select_mic(struct hda_codec
*codec
)
2201 struct conexant_spec
*spec
= codec
->spec
;
2202 if (!spec
->recording
)
2205 if (spec
->dc_enable
) {
2206 /* in DC mode we ignore presence detection and just use the jack
2207 * through our special DC port */
2208 const struct hda_verb enable_dc_mode
[] = {
2209 /* disble internal mic, port C */
2210 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2212 /* enable DC capture, port F */
2213 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2217 snd_hda_sequence_write(codec
, enable_dc_mode
);
2218 /* port B input disabled (and bias set) through the following call */
2219 cxt5066_set_olpc_dc_bias(codec
);
2223 /* disable DC (port F) */
2224 snd_hda_codec_write(codec
, 0x1e, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0);
2226 /* external mic, port B */
2227 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2228 spec
->ext_mic_present
? CXT5066_OLPC_EXT_MIC_BIAS
: 0);
2230 /* internal mic, port C */
2231 snd_hda_codec_write(codec
, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2232 spec
->ext_mic_present
? 0 : PIN_VREF80
);
2235 /* toggle input of built-in and mic jack appropriately */
2236 static void cxt5066_olpc_automic(struct hda_codec
*codec
)
2238 struct conexant_spec
*spec
= codec
->spec
;
2239 unsigned int present
;
2241 if (spec
->dc_enable
) /* don't do presence detection in DC mode */
2244 present
= snd_hda_codec_read(codec
, 0x1a, 0,
2245 AC_VERB_GET_PIN_SENSE
, 0) & 0x80000000;
2247 snd_printdd("CXT5066: external microphone detected\n");
2249 snd_printdd("CXT5066: external microphone absent\n");
2251 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_CONNECT_SEL
,
2253 spec
->ext_mic_present
= !!present
;
2255 cxt5066_olpc_select_mic(codec
);
2258 /* toggle input of built-in digital mic and mic jack appropriately */
2259 static void cxt5066_vostro_automic(struct hda_codec
*codec
)
2261 unsigned int present
;
2263 struct hda_verb ext_mic_present
[] = {
2264 /* enable external mic, port B */
2265 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2267 /* switch to external mic input */
2268 {0x17, AC_VERB_SET_CONNECT_SEL
, 0},
2269 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2271 /* disable internal digital mic */
2272 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2275 static struct hda_verb ext_mic_absent
[] = {
2276 /* enable internal mic, port C */
2277 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2279 /* switch to internal mic input */
2280 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2282 /* disable external mic, port B */
2283 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2287 present
= snd_hda_jack_detect(codec
, 0x1a);
2289 snd_printdd("CXT5066: external microphone detected\n");
2290 snd_hda_sequence_write(codec
, ext_mic_present
);
2292 snd_printdd("CXT5066: external microphone absent\n");
2293 snd_hda_sequence_write(codec
, ext_mic_absent
);
2297 /* toggle input of built-in digital mic and mic jack appropriately */
2298 static void cxt5066_ideapad_automic(struct hda_codec
*codec
)
2300 unsigned int present
;
2302 struct hda_verb ext_mic_present
[] = {
2303 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2304 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2305 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2308 static struct hda_verb ext_mic_absent
[] = {
2309 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2310 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2311 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2315 present
= snd_hda_jack_detect(codec
, 0x1b);
2317 snd_printdd("CXT5066: external microphone detected\n");
2318 snd_hda_sequence_write(codec
, ext_mic_present
);
2320 snd_printdd("CXT5066: external microphone absent\n");
2321 snd_hda_sequence_write(codec
, ext_mic_absent
);
2326 /* toggle input of built-in digital mic and mic jack appropriately */
2327 static void cxt5066_asus_automic(struct hda_codec
*codec
)
2329 unsigned int present
;
2331 present
= snd_hda_jack_detect(codec
, 0x1b);
2332 snd_printdd("CXT5066: external microphone present=%d\n", present
);
2333 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_CONNECT_SEL
,
2338 /* toggle input of built-in digital mic and mic jack appropriately */
2339 static void cxt5066_hp_laptop_automic(struct hda_codec
*codec
)
2341 unsigned int present
;
2343 present
= snd_hda_jack_detect(codec
, 0x1b);
2344 snd_printdd("CXT5066: external microphone present=%d\n", present
);
2345 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_CONNECT_SEL
,
2350 /* toggle input of built-in digital mic and mic jack appropriately
2351 order is: external mic -> dock mic -> interal mic */
2352 static void cxt5066_thinkpad_automic(struct hda_codec
*codec
)
2354 unsigned int ext_present
, dock_present
;
2356 static struct hda_verb ext_mic_present
[] = {
2357 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2358 {0x17, AC_VERB_SET_CONNECT_SEL
, 1},
2359 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2360 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2361 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2364 static struct hda_verb dock_mic_present
[] = {
2365 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2366 {0x17, AC_VERB_SET_CONNECT_SEL
, 0},
2367 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2368 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2369 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2372 static struct hda_verb ext_mic_absent
[] = {
2373 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2374 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2375 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2376 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2380 ext_present
= snd_hda_jack_detect(codec
, 0x1b);
2381 dock_present
= snd_hda_jack_detect(codec
, 0x1a);
2383 snd_printdd("CXT5066: external microphone detected\n");
2384 snd_hda_sequence_write(codec
, ext_mic_present
);
2385 } else if (dock_present
) {
2386 snd_printdd("CXT5066: dock microphone detected\n");
2387 snd_hda_sequence_write(codec
, dock_mic_present
);
2389 snd_printdd("CXT5066: external microphone absent\n");
2390 snd_hda_sequence_write(codec
, ext_mic_absent
);
2394 /* mute internal speaker if HP is plugged */
2395 static void cxt5066_hp_automute(struct hda_codec
*codec
)
2397 struct conexant_spec
*spec
= codec
->spec
;
2398 unsigned int portA
, portD
;
2401 portA
= snd_hda_jack_detect(codec
, 0x19);
2404 portD
= snd_hda_jack_detect(codec
, 0x1c);
2406 spec
->hp_present
= portA
? HP_PRESENT_PORT_A
: 0;
2407 spec
->hp_present
|= portD
? HP_PRESENT_PORT_D
: 0;
2408 snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n",
2409 portA
, portD
, spec
->hp_present
);
2410 cxt5066_update_speaker(codec
);
2413 /* Dispatch the right mic autoswitch function */
2414 static void cxt5066_automic(struct hda_codec
*codec
)
2416 struct conexant_spec
*spec
= codec
->spec
;
2418 if (spec
->dell_vostro
)
2419 cxt5066_vostro_automic(codec
);
2420 else if (spec
->ideapad
)
2421 cxt5066_ideapad_automic(codec
);
2422 else if (spec
->thinkpad
)
2423 cxt5066_thinkpad_automic(codec
);
2424 else if (spec
->hp_laptop
)
2425 cxt5066_hp_laptop_automic(codec
);
2426 else if (spec
->asus
)
2427 cxt5066_asus_automic(codec
);
2430 /* unsolicited event for jack sensing */
2431 static void cxt5066_olpc_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2433 struct conexant_spec
*spec
= codec
->spec
;
2434 snd_printdd("CXT5066: unsol event %x (%x)\n", res
, res
>> 26);
2435 switch (res
>> 26) {
2436 case CONEXANT_HP_EVENT
:
2437 cxt5066_hp_automute(codec
);
2439 case CONEXANT_MIC_EVENT
:
2440 /* ignore mic events in DC mode; we're always using the jack */
2441 if (!spec
->dc_enable
)
2442 cxt5066_olpc_automic(codec
);
2447 /* unsolicited event for jack sensing */
2448 static void cxt5066_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2450 snd_printdd("CXT5066: unsol event %x (%x)\n", res
, res
>> 26);
2451 switch (res
>> 26) {
2452 case CONEXANT_HP_EVENT
:
2453 cxt5066_hp_automute(codec
);
2455 case CONEXANT_MIC_EVENT
:
2456 cxt5066_automic(codec
);
2462 static const struct hda_input_mux cxt5066_analog_mic_boost
= {
2473 static void cxt5066_set_mic_boost(struct hda_codec
*codec
)
2475 struct conexant_spec
*spec
= codec
->spec
;
2476 snd_hda_codec_write_cache(codec
, 0x17, 0,
2477 AC_VERB_SET_AMP_GAIN_MUTE
,
2478 AC_AMP_SET_RIGHT
| AC_AMP_SET_LEFT
| AC_AMP_SET_OUTPUT
|
2479 cxt5066_analog_mic_boost
.items
[spec
->mic_boost
].index
);
2480 if (spec
->ideapad
|| spec
->thinkpad
) {
2481 /* adjust the internal mic as well...it is not through 0x17 */
2482 snd_hda_codec_write_cache(codec
, 0x23, 0,
2483 AC_VERB_SET_AMP_GAIN_MUTE
,
2484 AC_AMP_SET_RIGHT
| AC_AMP_SET_LEFT
| AC_AMP_SET_INPUT
|
2485 cxt5066_analog_mic_boost
.
2486 items
[spec
->mic_boost
].index
);
2490 static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol
*kcontrol
,
2491 struct snd_ctl_elem_info
*uinfo
)
2493 return snd_hda_input_mux_info(&cxt5066_analog_mic_boost
, uinfo
);
2496 static int cxt5066_mic_boost_mux_enum_get(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 ucontrol
->value
.enumerated
.item
[0] = spec
->mic_boost
;
2505 static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol
*kcontrol
,
2506 struct snd_ctl_elem_value
*ucontrol
)
2508 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2509 struct conexant_spec
*spec
= codec
->spec
;
2510 const struct hda_input_mux
*imux
= &cxt5066_analog_mic_boost
;
2512 idx
= ucontrol
->value
.enumerated
.item
[0];
2513 if (idx
>= imux
->num_items
)
2514 idx
= imux
->num_items
- 1;
2516 spec
->mic_boost
= idx
;
2517 if (!spec
->dc_enable
)
2518 cxt5066_set_mic_boost(codec
);
2522 static void cxt5066_enable_dc(struct hda_codec
*codec
)
2524 const struct hda_verb enable_dc_mode
[] = {
2526 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2528 /* switch to DC input */
2529 {0x17, AC_VERB_SET_CONNECT_SEL
, 3},
2533 /* configure as input source */
2534 snd_hda_sequence_write(codec
, enable_dc_mode
);
2535 cxt5066_olpc_select_mic(codec
); /* also sets configured bias */
2538 static void cxt5066_disable_dc(struct hda_codec
*codec
)
2540 /* reconfigure input source */
2541 cxt5066_set_mic_boost(codec
);
2542 /* automic also selects the right mic if we're recording */
2543 cxt5066_olpc_automic(codec
);
2546 static int cxt5066_olpc_dc_get(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 ucontrol
->value
.integer
.value
[0] = spec
->dc_enable
;
2555 static int cxt5066_olpc_dc_put(struct snd_kcontrol
*kcontrol
,
2556 struct snd_ctl_elem_value
*ucontrol
)
2558 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2559 struct conexant_spec
*spec
= codec
->spec
;
2560 int dc_enable
= !!ucontrol
->value
.integer
.value
[0];
2562 if (dc_enable
== spec
->dc_enable
)
2565 spec
->dc_enable
= dc_enable
;
2567 cxt5066_enable_dc(codec
);
2569 cxt5066_disable_dc(codec
);
2574 static int cxt5066_olpc_dc_bias_enum_info(struct snd_kcontrol
*kcontrol
,
2575 struct snd_ctl_elem_info
*uinfo
)
2577 return snd_hda_input_mux_info(&cxt5066_olpc_dc_bias
, uinfo
);
2580 static int cxt5066_olpc_dc_bias_enum_get(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 ucontrol
->value
.enumerated
.item
[0] = spec
->dc_input_bias
;
2589 static int cxt5066_olpc_dc_bias_enum_put(struct snd_kcontrol
*kcontrol
,
2590 struct snd_ctl_elem_value
*ucontrol
)
2592 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2593 struct conexant_spec
*spec
= codec
->spec
;
2594 const struct hda_input_mux
*imux
= &cxt5066_analog_mic_boost
;
2597 idx
= ucontrol
->value
.enumerated
.item
[0];
2598 if (idx
>= imux
->num_items
)
2599 idx
= imux
->num_items
- 1;
2601 spec
->dc_input_bias
= idx
;
2602 if (spec
->dc_enable
)
2603 cxt5066_set_olpc_dc_bias(codec
);
2607 static void cxt5066_olpc_capture_prepare(struct hda_codec
*codec
)
2609 struct conexant_spec
*spec
= codec
->spec
;
2610 /* mark as recording and configure the microphone widget so that the
2611 * recording LED comes on. */
2612 spec
->recording
= 1;
2613 cxt5066_olpc_select_mic(codec
);
2616 static void cxt5066_olpc_capture_cleanup(struct hda_codec
*codec
)
2618 struct conexant_spec
*spec
= codec
->spec
;
2619 const struct hda_verb disable_mics
[] = {
2620 /* disable external mic, port B */
2621 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2623 /* disble internal mic, port C */
2624 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2626 /* disable DC capture, port F */
2627 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2631 snd_hda_sequence_write(codec
, disable_mics
);
2632 spec
->recording
= 0;
2635 static void conexant_check_dig_outs(struct hda_codec
*codec
,
2636 hda_nid_t
*dig_pins
,
2639 struct conexant_spec
*spec
= codec
->spec
;
2640 hda_nid_t
*nid_loc
= &spec
->multiout
.dig_out_nid
;
2643 for (i
= 0; i
< num_pins
; i
++, dig_pins
++) {
2644 unsigned int cfg
= snd_hda_codec_get_pincfg(codec
, *dig_pins
);
2645 if (get_defcfg_connect(cfg
) == AC_JACK_PORT_NONE
)
2647 if (snd_hda_get_connections(codec
, *dig_pins
, nid_loc
, 1) != 1)
2649 if (spec
->slave_dig_outs
[0])
2652 nid_loc
= spec
->slave_dig_outs
;
2656 static struct hda_input_mux cxt5066_capture_source
= {
2666 static struct hda_bind_ctls cxt5066_bind_capture_vol_others
= {
2667 .ops
= &snd_hda_bind_vol
,
2669 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT
),
2670 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT
),
2675 static struct hda_bind_ctls cxt5066_bind_capture_sw_others
= {
2676 .ops
= &snd_hda_bind_sw
,
2678 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT
),
2679 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT
),
2684 static struct snd_kcontrol_new cxt5066_mixer_master
[] = {
2685 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
2689 static struct snd_kcontrol_new cxt5066_mixer_master_olpc
[] = {
2691 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2692 .name
= "Master Playback Volume",
2693 .access
= SNDRV_CTL_ELEM_ACCESS_READWRITE
|
2694 SNDRV_CTL_ELEM_ACCESS_TLV_READ
|
2695 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK
,
2696 .subdevice
= HDA_SUBDEV_AMP_FLAG
,
2697 .info
= snd_hda_mixer_amp_volume_info
,
2698 .get
= snd_hda_mixer_amp_volume_get
,
2699 .put
= snd_hda_mixer_amp_volume_put
,
2700 .tlv
= { .c
= snd_hda_mixer_amp_tlv
},
2701 /* offset by 28 volume steps to limit minimum gain to -46dB */
2703 HDA_COMPOSE_AMP_VAL_OFS(0x10, 3, 0, HDA_OUTPUT
, 28),
2708 static struct snd_kcontrol_new cxt5066_mixer_olpc_dc
[] = {
2710 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2711 .name
= "DC Mode Enable Switch",
2712 .info
= snd_ctl_boolean_mono_info
,
2713 .get
= cxt5066_olpc_dc_get
,
2714 .put
= cxt5066_olpc_dc_put
,
2717 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2718 .name
= "DC Input Bias Enum",
2719 .info
= cxt5066_olpc_dc_bias_enum_info
,
2720 .get
= cxt5066_olpc_dc_bias_enum_get
,
2721 .put
= cxt5066_olpc_dc_bias_enum_put
,
2726 static struct snd_kcontrol_new cxt5066_mixers
[] = {
2728 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2729 .name
= "Master Playback Switch",
2730 .info
= cxt_eapd_info
,
2731 .get
= cxt_eapd_get
,
2732 .put
= cxt5066_hp_master_sw_put
,
2733 .private_value
= 0x1d,
2737 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2738 .name
= "Analog Mic Boost Capture Enum",
2739 .info
= cxt5066_mic_boost_mux_enum_info
,
2740 .get
= cxt5066_mic_boost_mux_enum_get
,
2741 .put
= cxt5066_mic_boost_mux_enum_put
,
2744 HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others
),
2745 HDA_BIND_SW("Capture Switch", &cxt5066_bind_capture_sw_others
),
2749 static struct snd_kcontrol_new cxt5066_vostro_mixers
[] = {
2751 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2752 .name
= "Internal Mic Boost Capture Enum",
2753 .info
= cxt5066_mic_boost_mux_enum_info
,
2754 .get
= cxt5066_mic_boost_mux_enum_get
,
2755 .put
= cxt5066_mic_boost_mux_enum_put
,
2756 .private_value
= 0x23 | 0x100,
2761 static struct hda_verb cxt5066_init_verbs
[] = {
2762 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port B */
2763 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port C */
2764 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2765 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2768 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2769 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2772 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2773 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2775 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2776 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2779 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2781 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2782 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2783 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2784 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2785 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2786 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2788 /* no digital microphone support yet */
2789 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2791 /* Audio input selector */
2792 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2794 /* SPDIF route: PCM */
2795 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2796 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2798 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2799 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2802 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2804 /* not handling these yet */
2805 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2806 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2807 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2808 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2809 {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2810 {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2811 {0x20, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2812 {0x22, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2816 static struct hda_verb cxt5066_init_verbs_olpc
[] = {
2817 /* Port A: headphones */
2818 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2819 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2821 /* Port B: external microphone */
2822 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2824 /* Port C: internal microphone */
2825 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2827 /* Port D: unused */
2828 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2830 /* Port E: unused, but has primary EAPD */
2831 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2832 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2834 /* Port F: external DC input through microphone port */
2835 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2837 /* Port G: internal speakers */
2838 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2839 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2842 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2845 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2847 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2848 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2849 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2850 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2851 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2852 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2853 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2854 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2855 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2856 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2857 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2858 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2860 /* Disable digital microphone port */
2861 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2863 /* Audio input selectors */
2864 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2865 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2868 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2869 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2871 /* enable unsolicited events for Port A and B */
2872 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2873 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2877 static struct hda_verb cxt5066_init_verbs_vostro
[] = {
2878 /* Port A: headphones */
2879 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2880 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2882 /* Port B: external microphone */
2883 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2885 /* Port C: unused */
2886 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2888 /* Port D: unused */
2889 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2891 /* Port E: unused, but has primary EAPD */
2892 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2893 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2895 /* Port F: unused */
2896 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2898 /* Port G: internal speakers */
2899 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2900 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2903 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2906 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2908 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2909 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2910 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2911 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2912 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2913 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2914 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2915 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2916 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2917 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2918 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2919 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2921 /* Digital microphone port */
2922 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2924 /* Audio input selectors */
2925 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2926 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2929 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2930 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2932 /* enable unsolicited events for Port A and B */
2933 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2934 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2938 static struct hda_verb cxt5066_init_verbs_ideapad
[] = {
2939 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port B */
2940 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port C */
2941 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2942 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2945 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2946 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2949 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2950 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2952 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2953 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2956 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2958 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2959 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2960 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2961 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2962 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2963 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2964 {0x14, AC_VERB_SET_CONNECT_SEL
, 2}, /* default to internal mic */
2966 /* Audio input selector */
2967 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x2},
2968 {0x17, AC_VERB_SET_CONNECT_SEL
, 1}, /* route ext mic */
2970 /* SPDIF route: PCM */
2971 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2972 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2974 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2975 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2977 /* internal microphone */
2978 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* enable internal mic */
2981 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2983 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2984 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2988 static struct hda_verb cxt5066_init_verbs_thinkpad
[] = {
2989 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2990 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2992 /* Port G: internal speakers */
2993 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2994 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2996 /* Port A: HP, Amp */
2997 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2998 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
3000 /* Port B: Mic Dock */
3001 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
3004 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
3006 /* Port D: HP Dock, Amp */
3007 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
3008 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
3011 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
3013 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
3014 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
3015 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
3016 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
3017 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
3018 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
3019 {0x14, AC_VERB_SET_CONNECT_SEL
, 2}, /* default to internal mic */
3021 /* Audio input selector */
3022 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x2},
3023 {0x17, AC_VERB_SET_CONNECT_SEL
, 1}, /* route ext mic */
3025 /* SPDIF route: PCM */
3026 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
3027 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
3029 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
3030 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
3032 /* internal microphone */
3033 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* enable internal mic */
3036 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
3038 /* enable unsolicited events for Port A, B, C and D */
3039 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
3040 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
3041 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
3042 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
3046 static struct hda_verb cxt5066_init_verbs_portd_lo
[] = {
3047 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
3052 static struct hda_verb cxt5066_init_verbs_hp_laptop
[] = {
3053 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x0},
3054 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
3055 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
3059 /* initialize jack-sensing, too */
3060 static int cxt5066_init(struct hda_codec
*codec
)
3062 snd_printdd("CXT5066: init\n");
3063 conexant_init(codec
);
3064 if (codec
->patch_ops
.unsol_event
) {
3065 cxt5066_hp_automute(codec
);
3066 cxt5066_automic(codec
);
3068 cxt5066_set_mic_boost(codec
);
3072 static int cxt5066_olpc_init(struct hda_codec
*codec
)
3074 struct conexant_spec
*spec
= codec
->spec
;
3075 snd_printdd("CXT5066: init\n");
3076 conexant_init(codec
);
3077 cxt5066_hp_automute(codec
);
3078 if (!spec
->dc_enable
) {
3079 cxt5066_set_mic_boost(codec
);
3080 cxt5066_olpc_automic(codec
);
3082 cxt5066_enable_dc(codec
);
3088 CXT5066_LAPTOP
, /* Laptops w/ EAPD support */
3089 CXT5066_DELL_LAPTOP
, /* Dell Laptop */
3090 CXT5066_OLPC_XO_1_5
, /* OLPC XO 1.5 */
3091 CXT5066_DELL_VOSTRO
, /* Dell Vostro 1015i */
3092 CXT5066_IDEAPAD
, /* Lenovo IdeaPad U150 */
3093 CXT5066_THINKPAD
, /* Lenovo ThinkPad T410s, others? */
3094 CXT5066_ASUS
, /* Asus K52JU, Lenovo G560 - Int mic at 0x1a and Ext mic at 0x1b */
3095 CXT5066_HP_LAPTOP
, /* HP Laptop */
3099 static const char * const cxt5066_models
[CXT5066_MODELS
] = {
3100 [CXT5066_LAPTOP
] = "laptop",
3101 [CXT5066_DELL_LAPTOP
] = "dell-laptop",
3102 [CXT5066_OLPC_XO_1_5
] = "olpc-xo-1_5",
3103 [CXT5066_DELL_VOSTRO
] = "dell-vostro",
3104 [CXT5066_IDEAPAD
] = "ideapad",
3105 [CXT5066_THINKPAD
] = "thinkpad",
3106 [CXT5066_ASUS
] = "asus",
3107 [CXT5066_HP_LAPTOP
] = "hp-laptop",
3110 static struct snd_pci_quirk cxt5066_cfg_tbl
[] = {
3111 SND_PCI_QUIRK_MASK(0x1025, 0xff00, 0x0400, "Acer", CXT5066_IDEAPAD
),
3112 SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTRO
),
3113 SND_PCI_QUIRK(0x1028, 0x02f5, "Dell Vostro 320", CXT5066_IDEAPAD
),
3114 SND_PCI_QUIRK(0x1028, 0x0401, "Dell Vostro 1014", CXT5066_DELL_VOSTRO
),
3115 SND_PCI_QUIRK(0x1028, 0x0402, "Dell Vostro", CXT5066_DELL_VOSTRO
),
3116 SND_PCI_QUIRK(0x1028, 0x0408, "Dell Inspiron One 19T", CXT5066_IDEAPAD
),
3117 SND_PCI_QUIRK(0x1028, 0x050f, "Dell Inspiron", CXT5066_IDEAPAD
),
3118 SND_PCI_QUIRK(0x1028, 0x0510, "Dell Vostro", CXT5066_IDEAPAD
),
3119 SND_PCI_QUIRK(0x103c, 0x360b, "HP G60", CXT5066_HP_LAPTOP
),
3120 SND_PCI_QUIRK(0x1043, 0x13f3, "Asus A52J", CXT5066_ASUS
),
3121 SND_PCI_QUIRK(0x1043, 0x1643, "Asus K52JU", CXT5066_ASUS
),
3122 SND_PCI_QUIRK(0x1043, 0x1993, "Asus U50F", CXT5066_ASUS
),
3123 SND_PCI_QUIRK(0x1179, 0xff1e, "Toshiba Satellite C650D", CXT5066_IDEAPAD
),
3124 SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba Satellite P500-PSPGSC-01800T", CXT5066_OLPC_XO_1_5
),
3125 SND_PCI_QUIRK(0x1179, 0xffe0, "Toshiba Satellite Pro T130-15F", CXT5066_OLPC_XO_1_5
),
3126 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
3128 SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5
),
3129 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400s", CXT5066_THINKPAD
),
3130 SND_PCI_QUIRK(0x17aa, 0x21c5, "Thinkpad Edge 13", CXT5066_THINKPAD
),
3131 SND_PCI_QUIRK(0x17aa, 0x21c6, "Thinkpad Edge 13", CXT5066_ASUS
),
3132 SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo Thinkpad", CXT5066_THINKPAD
),
3133 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo G560", CXT5066_ASUS
),
3134 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", CXT5066_IDEAPAD
), /* Fallback for Lenovos without dock mic */
3138 static int patch_cxt5066(struct hda_codec
*codec
)
3140 struct conexant_spec
*spec
;
3143 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
3148 codec
->patch_ops
= conexant_patch_ops
;
3149 codec
->patch_ops
.init
= conexant_init
;
3151 spec
->dell_automute
= 0;
3152 spec
->multiout
.max_channels
= 2;
3153 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5066_dac_nids
);
3154 spec
->multiout
.dac_nids
= cxt5066_dac_nids
;
3155 conexant_check_dig_outs(codec
, cxt5066_digout_pin_nids
,
3156 ARRAY_SIZE(cxt5066_digout_pin_nids
));
3157 spec
->num_adc_nids
= 1;
3158 spec
->adc_nids
= cxt5066_adc_nids
;
3159 spec
->capsrc_nids
= cxt5066_capsrc_nids
;
3160 spec
->input_mux
= &cxt5066_capture_source
;
3162 spec
->port_d_mode
= PIN_HP
;
3164 spec
->num_init_verbs
= 1;
3165 spec
->init_verbs
[0] = cxt5066_init_verbs
;
3166 spec
->num_channel_mode
= ARRAY_SIZE(cxt5066_modes
);
3167 spec
->channel_mode
= cxt5066_modes
;
3169 spec
->cur_adc_idx
= 0;
3171 set_beep_amp(spec
, 0x13, 0, HDA_OUTPUT
);
3173 board_config
= snd_hda_check_board_config(codec
, CXT5066_MODELS
,
3174 cxt5066_models
, cxt5066_cfg_tbl
);
3175 switch (board_config
) {
3177 case CXT5066_LAPTOP
:
3178 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3179 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3181 case CXT5066_DELL_LAPTOP
:
3182 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3183 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3185 spec
->port_d_mode
= PIN_OUT
;
3186 spec
->init_verbs
[spec
->num_init_verbs
] = cxt5066_init_verbs_portd_lo
;
3187 spec
->num_init_verbs
++;
3188 spec
->dell_automute
= 1;
3191 case CXT5066_HP_LAPTOP
:
3192 codec
->patch_ops
.init
= cxt5066_init
;
3193 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
3194 spec
->init_verbs
[spec
->num_init_verbs
] =
3195 cxt5066_init_verbs_hp_laptop
;
3196 spec
->num_init_verbs
++;
3197 spec
->hp_laptop
= board_config
== CXT5066_HP_LAPTOP
;
3198 spec
->asus
= board_config
== CXT5066_ASUS
;
3199 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3200 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3202 if (board_config
== CXT5066_HP_LAPTOP
)
3203 spec
->multiout
.dig_out_nid
= 0;
3204 /* input source automatically selected */
3205 spec
->input_mux
= NULL
;
3206 spec
->port_d_mode
= 0;
3207 spec
->mic_boost
= 3; /* default 30dB gain */
3210 case CXT5066_OLPC_XO_1_5
:
3211 codec
->patch_ops
.init
= cxt5066_olpc_init
;
3212 codec
->patch_ops
.unsol_event
= cxt5066_olpc_unsol_event
;
3213 spec
->init_verbs
[0] = cxt5066_init_verbs_olpc
;
3214 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master_olpc
;
3215 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_olpc_dc
;
3216 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3217 spec
->port_d_mode
= 0;
3218 spec
->mic_boost
= 3; /* default 30dB gain */
3221 spec
->multiout
.dig_out_nid
= 0;
3223 /* input source automatically selected */
3224 spec
->input_mux
= NULL
;
3226 /* our capture hooks which allow us to turn on the microphone LED
3227 * at the right time */
3228 spec
->capture_prepare
= cxt5066_olpc_capture_prepare
;
3229 spec
->capture_cleanup
= cxt5066_olpc_capture_cleanup
;
3231 case CXT5066_DELL_VOSTRO
:
3232 codec
->patch_ops
.init
= cxt5066_init
;
3233 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
3234 spec
->init_verbs
[0] = cxt5066_init_verbs_vostro
;
3235 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master_olpc
;
3236 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3237 spec
->mixers
[spec
->num_mixers
++] = cxt5066_vostro_mixers
;
3238 spec
->port_d_mode
= 0;
3239 spec
->dell_vostro
= 1;
3240 spec
->mic_boost
= 3; /* default 30dB gain */
3243 spec
->multiout
.dig_out_nid
= 0;
3245 /* input source automatically selected */
3246 spec
->input_mux
= NULL
;
3248 case CXT5066_IDEAPAD
:
3249 codec
->patch_ops
.init
= cxt5066_init
;
3250 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
3251 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3252 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3253 spec
->init_verbs
[0] = cxt5066_init_verbs_ideapad
;
3254 spec
->port_d_mode
= 0;
3256 spec
->mic_boost
= 2; /* default 20dB gain */
3259 spec
->multiout
.dig_out_nid
= 0;
3261 /* input source automatically selected */
3262 spec
->input_mux
= NULL
;
3264 case CXT5066_THINKPAD
:
3265 codec
->patch_ops
.init
= cxt5066_init
;
3266 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
3267 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
3268 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
3269 spec
->init_verbs
[0] = cxt5066_init_verbs_thinkpad
;
3271 spec
->port_d_mode
= PIN_OUT
;
3272 spec
->mic_boost
= 2; /* default 20dB gain */
3275 spec
->multiout
.dig_out_nid
= 0;
3277 /* input source automatically selected */
3278 spec
->input_mux
= NULL
;
3283 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
3289 * Automatic parser for CX20641 & co
3292 static hda_nid_t cx_auto_adc_nids
[] = { 0x14 };
3294 /* get the connection index of @nid in the widget @mux */
3295 static int get_connection_index(struct hda_codec
*codec
, hda_nid_t mux
,
3298 hda_nid_t conn
[HDA_MAX_NUM_INPUTS
];
3301 nums
= snd_hda_get_connections(codec
, mux
, conn
, ARRAY_SIZE(conn
));
3302 for (i
= 0; i
< nums
; i
++)
3308 /* get an unassigned DAC from the given list.
3309 * Return the nid if found and reduce the DAC list, or return zero if
3312 static hda_nid_t
get_unassigned_dac(struct hda_codec
*codec
, hda_nid_t pin
,
3313 hda_nid_t
*dacs
, int *num_dacs
)
3315 int i
, nums
= *num_dacs
;
3318 for (i
= 0; i
< nums
; i
++) {
3319 if (get_connection_index(codec
, pin
, dacs
[i
]) >= 0) {
3327 memmove(dacs
, dacs
+ 1, nums
* sizeof(hda_nid_t
));
3332 #define MAX_AUTO_DACS 5
3334 /* fill analog DAC list from the widget tree */
3335 static int fill_cx_auto_dacs(struct hda_codec
*codec
, hda_nid_t
*dacs
)
3337 hda_nid_t nid
, end_nid
;
3340 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
3341 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++) {
3342 unsigned int wcaps
= get_wcaps(codec
, nid
);
3343 unsigned int type
= get_wcaps_type(wcaps
);
3344 if (type
== AC_WID_AUD_OUT
&& !(wcaps
& AC_WCAP_DIGITAL
)) {
3346 if (nums
>= MAX_AUTO_DACS
)
3353 /* fill pin_dac_pair list from the pin and dac list */
3354 static int fill_dacs_for_pins(struct hda_codec
*codec
, hda_nid_t
*pins
,
3355 int num_pins
, hda_nid_t
*dacs
, int *rest
,
3356 struct pin_dac_pair
*filled
, int type
)
3361 for (i
= 0; i
< num_pins
; i
++) {
3362 filled
[nums
].pin
= pins
[i
];
3363 filled
[nums
].type
= type
;
3364 filled
[nums
].dac
= get_unassigned_dac(codec
, pins
[i
], dacs
, rest
);
3370 /* parse analog output paths */
3371 static void cx_auto_parse_output(struct hda_codec
*codec
)
3373 struct conexant_spec
*spec
= codec
->spec
;
3374 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3375 hda_nid_t dacs
[MAX_AUTO_DACS
];
3376 int i
, j
, nums
, rest
;
3378 rest
= fill_cx_auto_dacs(codec
, dacs
);
3379 /* parse all analog output pins */
3380 nums
= fill_dacs_for_pins(codec
, cfg
->line_out_pins
, cfg
->line_outs
,
3381 dacs
, &rest
, spec
->dac_info
,
3383 nums
+= fill_dacs_for_pins(codec
, cfg
->hp_pins
, cfg
->hp_outs
,
3384 dacs
, &rest
, spec
->dac_info
+ nums
,
3386 nums
+= fill_dacs_for_pins(codec
, cfg
->speaker_pins
, cfg
->speaker_outs
,
3387 dacs
, &rest
, spec
->dac_info
+ nums
,
3388 AUTO_PIN_SPEAKER_OUT
);
3389 spec
->dac_info_filled
= nums
;
3390 /* fill multiout struct */
3391 for (i
= 0; i
< nums
; i
++) {
3392 hda_nid_t dac
= spec
->dac_info
[i
].dac
;
3395 switch (spec
->dac_info
[i
].type
) {
3396 case AUTO_PIN_LINE_OUT
:
3397 spec
->private_dac_nids
[spec
->multiout
.num_dacs
] = dac
;
3398 spec
->multiout
.num_dacs
++;
3400 case AUTO_PIN_HP_OUT
:
3401 case AUTO_PIN_SPEAKER_OUT
:
3402 if (!spec
->multiout
.hp_nid
) {
3403 spec
->multiout
.hp_nid
= dac
;
3406 for (j
= 0; j
< ARRAY_SIZE(spec
->multiout
.extra_out_nid
); j
++)
3407 if (!spec
->multiout
.extra_out_nid
[j
]) {
3408 spec
->multiout
.extra_out_nid
[j
] = dac
;
3414 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
3415 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
3417 if (cfg
->hp_outs
> 0)
3418 spec
->auto_mute
= 1;
3419 spec
->vmaster_nid
= spec
->private_dac_nids
[0];
3422 /* auto-mute/unmute speaker and line outs according to headphone jack */
3423 static void cx_auto_hp_automute(struct hda_codec
*codec
)
3425 struct conexant_spec
*spec
= codec
->spec
;
3426 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3429 if (!spec
->auto_mute
)
3432 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
3433 if (snd_hda_jack_detect(codec
, cfg
->hp_pins
[i
])) {
3438 for (i
= 0; i
< cfg
->line_outs
; i
++) {
3439 snd_hda_codec_write(codec
, cfg
->line_out_pins
[i
], 0,
3440 AC_VERB_SET_PIN_WIDGET_CONTROL
,
3441 present
? 0 : PIN_OUT
);
3443 for (i
= 0; !present
&& i
< cfg
->line_outs
; i
++)
3444 if (snd_hda_jack_detect(codec
, cfg
->line_out_pins
[i
]))
3446 for (i
= 0; i
< cfg
->speaker_outs
; i
++) {
3447 snd_hda_codec_write(codec
, cfg
->speaker_pins
[i
], 0,
3448 AC_VERB_SET_PIN_WIDGET_CONTROL
,
3449 present
? 0 : PIN_OUT
);
3453 /* automatic switch internal and external mic */
3454 static void cx_auto_automic(struct hda_codec
*codec
)
3456 struct conexant_spec
*spec
= codec
->spec
;
3457 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3458 struct hda_input_mux
*imux
= &spec
->private_imux
;
3459 int ext_idx
= spec
->auto_mic_ext
;
3461 if (!spec
->auto_mic
)
3463 if (snd_hda_jack_detect(codec
, cfg
->inputs
[ext_idx
].pin
)) {
3464 snd_hda_codec_write(codec
, spec
->adc_nids
[0], 0,
3465 AC_VERB_SET_CONNECT_SEL
,
3466 imux
->items
[ext_idx
].index
);
3468 snd_hda_codec_write(codec
, spec
->adc_nids
[0], 0,
3469 AC_VERB_SET_CONNECT_SEL
,
3470 imux
->items
[!ext_idx
].index
);
3474 static void cx_auto_unsol_event(struct hda_codec
*codec
, unsigned int res
)
3476 int nid
= (res
& AC_UNSOL_RES_SUBTAG
) >> 20;
3477 switch (res
>> 26) {
3478 case CONEXANT_HP_EVENT
:
3479 cx_auto_hp_automute(codec
);
3480 conexant_report_jack(codec
, nid
);
3482 case CONEXANT_MIC_EVENT
:
3483 cx_auto_automic(codec
);
3484 conexant_report_jack(codec
, nid
);
3489 /* return true if it's an internal-mic pin */
3490 static int is_int_mic(struct hda_codec
*codec
, hda_nid_t pin
)
3492 unsigned int def_conf
= snd_hda_codec_get_pincfg(codec
, pin
);
3493 return get_defcfg_device(def_conf
) == AC_JACK_MIC_IN
&&
3494 snd_hda_get_input_pin_attr(def_conf
) == INPUT_PIN_ATTR_INT
;
3497 /* return true if it's an external-mic pin */
3498 static int is_ext_mic(struct hda_codec
*codec
, hda_nid_t pin
)
3500 unsigned int def_conf
= snd_hda_codec_get_pincfg(codec
, pin
);
3501 return get_defcfg_device(def_conf
) == AC_JACK_MIC_IN
&&
3502 snd_hda_get_input_pin_attr(def_conf
) >= INPUT_PIN_ATTR_NORMAL
&&
3503 (snd_hda_query_pin_caps(codec
, pin
) & AC_PINCAP_PRES_DETECT
);
3506 /* check whether the pin config is suitable for auto-mic switching;
3507 * auto-mic is enabled only when one int-mic and one-ext mic exist
3509 static void cx_auto_check_auto_mic(struct hda_codec
*codec
)
3511 struct conexant_spec
*spec
= codec
->spec
;
3512 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3514 if (is_ext_mic(codec
, cfg
->inputs
[0].pin
) &&
3515 is_int_mic(codec
, cfg
->inputs
[1].pin
)) {
3517 spec
->auto_mic_ext
= 1;
3520 if (is_int_mic(codec
, cfg
->inputs
[1].pin
) &&
3521 is_ext_mic(codec
, cfg
->inputs
[0].pin
)) {
3523 spec
->auto_mic_ext
= 0;
3528 static void cx_auto_parse_input(struct hda_codec
*codec
)
3530 struct conexant_spec
*spec
= codec
->spec
;
3531 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3532 struct hda_input_mux
*imux
;
3535 imux
= &spec
->private_imux
;
3536 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3537 int idx
= get_connection_index(codec
, spec
->adc_nids
[0],
3538 cfg
->inputs
[i
].pin
);
3541 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
3542 snd_hda_add_imux_item(imux
, label
, idx
, NULL
);
3545 if (imux
->num_items
== 2 && cfg
->num_inputs
== 2)
3546 cx_auto_check_auto_mic(codec
);
3547 if (imux
->num_items
> 1 && !spec
->auto_mic
)
3548 spec
->input_mux
= imux
;
3551 /* get digital-input audio widget corresponding to the given pin */
3552 static hda_nid_t
cx_auto_get_dig_in(struct hda_codec
*codec
, hda_nid_t pin
)
3554 hda_nid_t nid
, end_nid
;
3556 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
3557 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++) {
3558 unsigned int wcaps
= get_wcaps(codec
, nid
);
3559 unsigned int type
= get_wcaps_type(wcaps
);
3560 if (type
== AC_WID_AUD_IN
&& (wcaps
& AC_WCAP_DIGITAL
)) {
3561 if (get_connection_index(codec
, nid
, pin
) >= 0)
3568 static void cx_auto_parse_digital(struct hda_codec
*codec
)
3570 struct conexant_spec
*spec
= codec
->spec
;
3571 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3574 if (cfg
->dig_outs
&&
3575 snd_hda_get_connections(codec
, cfg
->dig_out_pins
[0], &nid
, 1) == 1)
3576 spec
->multiout
.dig_out_nid
= nid
;
3577 if (cfg
->dig_in_pin
)
3578 spec
->dig_in_nid
= cx_auto_get_dig_in(codec
, cfg
->dig_in_pin
);
3581 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3582 static void cx_auto_parse_beep(struct hda_codec
*codec
)
3584 struct conexant_spec
*spec
= codec
->spec
;
3585 hda_nid_t nid
, end_nid
;
3587 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
3588 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++)
3589 if (get_wcaps_type(get_wcaps(codec
, nid
)) == AC_WID_BEEP
) {
3590 set_beep_amp(spec
, nid
, 0, HDA_OUTPUT
);
3595 #define cx_auto_parse_beep(codec)
3598 static int cx_auto_parse_auto_config(struct hda_codec
*codec
)
3600 struct conexant_spec
*spec
= codec
->spec
;
3603 err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
);
3607 cx_auto_parse_output(codec
);
3608 cx_auto_parse_input(codec
);
3609 cx_auto_parse_digital(codec
);
3610 cx_auto_parse_beep(codec
);
3614 static void cx_auto_turn_on_eapd(struct hda_codec
*codec
, int num_pins
,
3618 for (i
= 0; i
< num_pins
; i
++) {
3619 if (snd_hda_query_pin_caps(codec
, pins
[i
]) & AC_PINCAP_EAPD
)
3620 snd_hda_codec_write(codec
, pins
[i
], 0,
3621 AC_VERB_SET_EAPD_BTLENABLE
, 0x02);
3625 static void select_connection(struct hda_codec
*codec
, hda_nid_t pin
,
3628 int idx
= get_connection_index(codec
, pin
, src
);
3630 snd_hda_codec_write(codec
, pin
, 0,
3631 AC_VERB_SET_CONNECT_SEL
, idx
);
3634 static void cx_auto_init_output(struct hda_codec
*codec
)
3636 struct conexant_spec
*spec
= codec
->spec
;
3637 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3641 for (i
= 0; i
< spec
->multiout
.num_dacs
; i
++)
3642 snd_hda_codec_write(codec
, spec
->multiout
.dac_nids
[i
], 0,
3643 AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
);
3645 for (i
= 0; i
< cfg
->hp_outs
; i
++)
3646 snd_hda_codec_write(codec
, cfg
->hp_pins
[i
], 0,
3647 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
);
3648 if (spec
->auto_mute
) {
3649 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
3650 snd_hda_codec_write(codec
, cfg
->hp_pins
[i
], 0,
3651 AC_VERB_SET_UNSOLICITED_ENABLE
,
3652 AC_USRSP_EN
| CONEXANT_HP_EVENT
);
3654 cx_auto_hp_automute(codec
);
3656 for (i
= 0; i
< cfg
->line_outs
; i
++)
3657 snd_hda_codec_write(codec
, cfg
->line_out_pins
[i
], 0,
3658 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
);
3659 for (i
= 0; i
< cfg
->speaker_outs
; i
++)
3660 snd_hda_codec_write(codec
, cfg
->speaker_pins
[i
], 0,
3661 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
);
3664 for (i
= 0; i
< spec
->dac_info_filled
; i
++) {
3665 nid
= spec
->dac_info
[i
].dac
;
3667 nid
= spec
->multiout
.dac_nids
[0];
3668 select_connection(codec
, spec
->dac_info
[i
].pin
, nid
);
3672 cx_auto_turn_on_eapd(codec
, cfg
->line_outs
, cfg
->line_out_pins
);
3673 cx_auto_turn_on_eapd(codec
, cfg
->hp_outs
, cfg
->hp_pins
);
3674 cx_auto_turn_on_eapd(codec
, cfg
->speaker_outs
, cfg
->speaker_pins
);
3677 static void cx_auto_init_input(struct hda_codec
*codec
)
3679 struct conexant_spec
*spec
= codec
->spec
;
3680 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3683 for (i
= 0; i
< spec
->num_adc_nids
; i
++)
3684 snd_hda_codec_write(codec
, spec
->adc_nids
[i
], 0,
3685 AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0));
3687 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3689 if (cfg
->inputs
[i
].type
== AUTO_PIN_MIC
)
3693 snd_hda_codec_write(codec
, cfg
->inputs
[i
].pin
, 0,
3694 AC_VERB_SET_PIN_WIDGET_CONTROL
, type
);
3697 if (spec
->auto_mic
) {
3698 int ext_idx
= spec
->auto_mic_ext
;
3699 snd_hda_codec_write(codec
, cfg
->inputs
[ext_idx
].pin
, 0,
3700 AC_VERB_SET_UNSOLICITED_ENABLE
,
3701 AC_USRSP_EN
| CONEXANT_MIC_EVENT
);
3702 cx_auto_automic(codec
);
3704 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
3705 snd_hda_codec_write(codec
, spec
->adc_nids
[i
], 0,
3706 AC_VERB_SET_CONNECT_SEL
,
3707 spec
->private_imux
.items
[0].index
);
3712 static void cx_auto_init_digital(struct hda_codec
*codec
)
3714 struct conexant_spec
*spec
= codec
->spec
;
3715 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3717 if (spec
->multiout
.dig_out_nid
)
3718 snd_hda_codec_write(codec
, cfg
->dig_out_pins
[0], 0,
3719 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
);
3720 if (spec
->dig_in_nid
)
3721 snd_hda_codec_write(codec
, cfg
->dig_in_pin
, 0,
3722 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
);
3725 static int cx_auto_init(struct hda_codec
*codec
)
3727 /*snd_hda_sequence_write(codec, cx_auto_init_verbs);*/
3728 cx_auto_init_output(codec
);
3729 cx_auto_init_input(codec
);
3730 cx_auto_init_digital(codec
);
3734 static int cx_auto_add_volume_idx(struct hda_codec
*codec
, const char *basename
,
3735 const char *dir
, int cidx
,
3736 hda_nid_t nid
, int hda_dir
, int amp_idx
)
3738 static char name
[32];
3739 static struct snd_kcontrol_new knew
[] = {
3740 HDA_CODEC_VOLUME(name
, 0, 0, 0),
3741 HDA_CODEC_MUTE(name
, 0, 0, 0),
3743 static char *sfx
[2] = { "Volume", "Switch" };
3746 for (i
= 0; i
< 2; i
++) {
3747 struct snd_kcontrol
*kctl
;
3748 knew
[i
].private_value
= HDA_COMPOSE_AMP_VAL(nid
, 3, amp_idx
,
3750 knew
[i
].subdevice
= HDA_SUBDEV_AMP_FLAG
;
3751 knew
[i
].index
= cidx
;
3752 snprintf(name
, sizeof(name
), "%s%s %s", basename
, dir
, sfx
[i
]);
3753 kctl
= snd_ctl_new1(&knew
[i
], codec
);
3756 err
= snd_hda_ctl_add(codec
, nid
, kctl
);
3759 if (!(query_amp_caps(codec
, nid
, hda_dir
) & AC_AMPCAP_MUTE
))
3765 #define cx_auto_add_volume(codec, str, dir, cidx, nid, hda_dir) \
3766 cx_auto_add_volume_idx(codec, str, dir, cidx, nid, hda_dir, 0)
3768 #define cx_auto_add_pb_volume(codec, nid, str, idx) \
3769 cx_auto_add_volume(codec, str, " Playback", idx, nid, HDA_OUTPUT)
3771 static int cx_auto_build_output_controls(struct hda_codec
*codec
)
3773 struct conexant_spec
*spec
= codec
->spec
;
3775 int num_line
= 0, num_hp
= 0, num_spk
= 0;
3776 static const char * const texts
[3] = { "Front", "Surround", "CLFE" };
3778 if (spec
->dac_info_filled
== 1)
3779 return cx_auto_add_pb_volume(codec
, spec
->dac_info
[0].dac
,
3781 for (i
= 0; i
< spec
->dac_info_filled
; i
++) {
3784 if (!spec
->dac_info
[i
].dac
)
3786 type
= spec
->dac_info
[i
].type
;
3787 if (type
== AUTO_PIN_LINE_OUT
)
3788 type
= spec
->autocfg
.line_out_type
;
3790 case AUTO_PIN_LINE_OUT
:
3792 label
= texts
[num_line
++];
3795 case AUTO_PIN_HP_OUT
:
3796 label
= "Headphone";
3799 case AUTO_PIN_SPEAKER_OUT
:
3804 err
= cx_auto_add_pb_volume(codec
, spec
->dac_info
[i
].dac
,
3812 static int cx_auto_build_input_controls(struct hda_codec
*codec
)
3814 struct conexant_spec
*spec
= codec
->spec
;
3815 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3816 static const char *prev_label
;
3817 int i
, err
, cidx
, conn_len
;
3818 hda_nid_t conn
[HDA_MAX_CONNECTIONS
];
3820 int multi_adc_volume
= 0; /* If the ADC nid has several input volumes */
3821 int adc_nid
= spec
->adc_nids
[0];
3823 conn_len
= snd_hda_get_connections(codec
, adc_nid
, conn
,
3824 HDA_MAX_CONNECTIONS
);
3828 multi_adc_volume
= cfg
->num_inputs
> 1 && conn_len
> 1;
3829 if (!multi_adc_volume
) {
3830 err
= cx_auto_add_volume(codec
, "Capture", "", 0, adc_nid
,
3838 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3839 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
3842 int pin_amp
= get_wcaps(codec
, nid
) & AC_WCAP_IN_AMP
;
3843 if (!pin_amp
&& !multi_adc_volume
)
3846 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
3847 if (label
== prev_label
)
3854 err
= cx_auto_add_volume(codec
, label
, " Boost", cidx
,
3860 if (!multi_adc_volume
)
3862 for (j
= 0; j
< conn_len
; j
++) {
3863 if (conn
[j
] == nid
) {
3864 err
= cx_auto_add_volume_idx(codec
, label
,
3865 " Capture", cidx
, adc_nid
, HDA_INPUT
, j
);
3875 static int cx_auto_build_controls(struct hda_codec
*codec
)
3879 err
= cx_auto_build_output_controls(codec
);
3882 err
= cx_auto_build_input_controls(codec
);
3885 return conexant_build_controls(codec
);
3888 static struct hda_codec_ops cx_auto_patch_ops
= {
3889 .build_controls
= cx_auto_build_controls
,
3890 .build_pcms
= conexant_build_pcms
,
3891 .init
= cx_auto_init
,
3892 .free
= conexant_free
,
3893 .unsol_event
= cx_auto_unsol_event
,
3894 #ifdef CONFIG_SND_HDA_POWER_SAVE
3895 .suspend
= conexant_suspend
,
3897 .reboot_notify
= snd_hda_shutup_pins
,
3900 static int patch_conexant_auto(struct hda_codec
*codec
)
3902 struct conexant_spec
*spec
;
3905 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
3909 spec
->adc_nids
= cx_auto_adc_nids
;
3910 spec
->num_adc_nids
= ARRAY_SIZE(cx_auto_adc_nids
);
3911 spec
->capsrc_nids
= spec
->adc_nids
;
3912 err
= cx_auto_parse_auto_config(codec
);
3918 codec
->patch_ops
= cx_auto_patch_ops
;
3920 snd_hda_attach_beep_device(codec
, spec
->beep_amp
);
3927 static struct hda_codec_preset snd_hda_preset_conexant
[] = {
3928 { .id
= 0x14f15045, .name
= "CX20549 (Venice)",
3929 .patch
= patch_cxt5045
},
3930 { .id
= 0x14f15047, .name
= "CX20551 (Waikiki)",
3931 .patch
= patch_cxt5047
},
3932 { .id
= 0x14f15051, .name
= "CX20561 (Hermosa)",
3933 .patch
= patch_cxt5051
},
3934 { .id
= 0x14f15066, .name
= "CX20582 (Pebble)",
3935 .patch
= patch_cxt5066
},
3936 { .id
= 0x14f15067, .name
= "CX20583 (Pebble HSF)",
3937 .patch
= patch_cxt5066
},
3938 { .id
= 0x14f15068, .name
= "CX20584",
3939 .patch
= patch_cxt5066
},
3940 { .id
= 0x14f15069, .name
= "CX20585",
3941 .patch
= patch_cxt5066
},
3942 { .id
= 0x14f1506e, .name
= "CX20590",
3943 .patch
= patch_cxt5066
},
3944 { .id
= 0x14f15097, .name
= "CX20631",
3945 .patch
= patch_conexant_auto
},
3946 { .id
= 0x14f15098, .name
= "CX20632",
3947 .patch
= patch_conexant_auto
},
3948 { .id
= 0x14f150a1, .name
= "CX20641",
3949 .patch
= patch_conexant_auto
},
3950 { .id
= 0x14f150a2, .name
= "CX20642",
3951 .patch
= patch_conexant_auto
},
3952 { .id
= 0x14f150ab, .name
= "CX20651",
3953 .patch
= patch_conexant_auto
},
3954 { .id
= 0x14f150ac, .name
= "CX20652",
3955 .patch
= patch_conexant_auto
},
3956 { .id
= 0x14f150b8, .name
= "CX20664",
3957 .patch
= patch_conexant_auto
},
3958 { .id
= 0x14f150b9, .name
= "CX20665",
3959 .patch
= patch_conexant_auto
},
3963 MODULE_ALIAS("snd-hda-codec-id:14f15045");
3964 MODULE_ALIAS("snd-hda-codec-id:14f15047");
3965 MODULE_ALIAS("snd-hda-codec-id:14f15051");
3966 MODULE_ALIAS("snd-hda-codec-id:14f15066");
3967 MODULE_ALIAS("snd-hda-codec-id:14f15067");
3968 MODULE_ALIAS("snd-hda-codec-id:14f15068");
3969 MODULE_ALIAS("snd-hda-codec-id:14f15069");
3970 MODULE_ALIAS("snd-hda-codec-id:14f1506e");
3971 MODULE_ALIAS("snd-hda-codec-id:14f15097");
3972 MODULE_ALIAS("snd-hda-codec-id:14f15098");
3973 MODULE_ALIAS("snd-hda-codec-id:14f150a1");
3974 MODULE_ALIAS("snd-hda-codec-id:14f150a2");
3975 MODULE_ALIAS("snd-hda-codec-id:14f150ab");
3976 MODULE_ALIAS("snd-hda-codec-id:14f150ac");
3977 MODULE_ALIAS("snd-hda-codec-id:14f150b8");
3978 MODULE_ALIAS("snd-hda-codec-id:14f150b9");
3980 MODULE_LICENSE("GPL");
3981 MODULE_DESCRIPTION("Conexant HD-audio codec");
3983 static struct hda_codec_preset_list conexant_list
= {
3984 .preset
= snd_hda_preset_conexant
,
3985 .owner
= THIS_MODULE
,
3988 static int __init
patch_conexant_init(void)
3990 return snd_hda_add_codec_preset(&conexant_list
);
3993 static void __exit
patch_conexant_exit(void)
3995 snd_hda_delete_codec_preset(&conexant_list
);
3998 module_init(patch_conexant_init
)
3999 module_exit(patch_conexant_exit
)