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 0x1C
46 #define CXT5051_PORTB_EVENT 0x38
47 #define CXT5051_PORTC_EVENT 0x39
50 struct conexant_jack
{
54 struct snd_jack
*jack
;
58 struct conexant_spec
{
60 struct snd_kcontrol_new
*mixers
[5];
62 hda_nid_t vmaster_nid
;
64 const struct hda_verb
*init_verbs
[5]; /* initialization verbs
68 unsigned int num_init_verbs
;
71 struct hda_multi_out multiout
; /* playback set-up
72 * max_channels, dacs must be set
73 * dig_out_nid and hp_nid are optional
75 unsigned int cur_eapd
;
76 unsigned int hp_present
;
77 unsigned int no_auto_mic
;
78 unsigned int need_dac_fix
;
81 unsigned int num_adc_nids
;
83 hda_nid_t dig_in_nid
; /* digital-in NID; optional */
85 unsigned int cur_adc_idx
;
87 unsigned int cur_adc_stream_tag
;
88 unsigned int cur_adc_format
;
91 const struct hda_input_mux
*input_mux
;
92 hda_nid_t
*capsrc_nids
;
93 unsigned int cur_mux
[3];
96 const struct hda_channel_mode
*channel_mode
;
100 struct hda_pcm pcm_rec
[2]; /* used in build_pcms() */
102 unsigned int spdif_route
;
105 struct snd_array jacks
;
107 /* dynamic controls, init_verbs and input_mux */
108 struct auto_pin_cfg autocfg
;
109 struct hda_input_mux private_imux
;
110 hda_nid_t private_dac_nids
[AUTO_CFG_MAX_OUTS
];
112 unsigned int dell_automute
;
113 unsigned int port_d_mode
;
114 unsigned int dell_vostro
;
116 unsigned int ext_mic_present
;
117 unsigned int recording
;
118 void (*capture_prepare
)(struct hda_codec
*codec
);
119 void (*capture_cleanup
)(struct hda_codec
*codec
);
121 /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors)
122 * through the microphone jack.
123 * When the user enables this through a mixer switch, both internal and
124 * external microphones are disabled. Gain is fixed at 0dB. In this mode,
125 * we also allow the bias to be configured through a separate mixer
127 unsigned int dc_enable
;
128 unsigned int dc_input_bias
; /* offset into cxt5066_olpc_dc_bias */
129 unsigned int mic_boost
; /* offset into cxt5066_analog_mic_boost */
132 static int conexant_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
133 struct hda_codec
*codec
,
134 struct snd_pcm_substream
*substream
)
136 struct conexant_spec
*spec
= codec
->spec
;
137 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
141 static int conexant_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
142 struct hda_codec
*codec
,
143 unsigned int stream_tag
,
145 struct snd_pcm_substream
*substream
)
147 struct conexant_spec
*spec
= codec
->spec
;
148 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
,
153 static int conexant_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
154 struct hda_codec
*codec
,
155 struct snd_pcm_substream
*substream
)
157 struct conexant_spec
*spec
= codec
->spec
;
158 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
164 static int conexant_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
165 struct hda_codec
*codec
,
166 struct snd_pcm_substream
*substream
)
168 struct conexant_spec
*spec
= codec
->spec
;
169 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
172 static int conexant_dig_playback_pcm_close(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_dig_close(codec
, &spec
->multiout
);
180 static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
181 struct hda_codec
*codec
,
182 unsigned int stream_tag
,
184 struct snd_pcm_substream
*substream
)
186 struct conexant_spec
*spec
= codec
->spec
;
187 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
195 static int conexant_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
196 struct hda_codec
*codec
,
197 unsigned int stream_tag
,
199 struct snd_pcm_substream
*substream
)
201 struct conexant_spec
*spec
= codec
->spec
;
202 if (spec
->capture_prepare
)
203 spec
->capture_prepare(codec
);
204 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
],
205 stream_tag
, 0, format
);
209 static int conexant_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
210 struct hda_codec
*codec
,
211 struct snd_pcm_substream
*substream
)
213 struct conexant_spec
*spec
= codec
->spec
;
214 snd_hda_codec_cleanup_stream(codec
, spec
->adc_nids
[substream
->number
]);
215 if (spec
->capture_cleanup
)
216 spec
->capture_cleanup(codec
);
222 static struct hda_pcm_stream conexant_pcm_analog_playback
= {
226 .nid
= 0, /* fill later */
228 .open
= conexant_playback_pcm_open
,
229 .prepare
= conexant_playback_pcm_prepare
,
230 .cleanup
= conexant_playback_pcm_cleanup
234 static struct hda_pcm_stream conexant_pcm_analog_capture
= {
238 .nid
= 0, /* fill later */
240 .prepare
= conexant_capture_pcm_prepare
,
241 .cleanup
= conexant_capture_pcm_cleanup
246 static struct hda_pcm_stream conexant_pcm_digital_playback
= {
250 .nid
= 0, /* fill later */
252 .open
= conexant_dig_playback_pcm_open
,
253 .close
= conexant_dig_playback_pcm_close
,
254 .prepare
= conexant_dig_playback_pcm_prepare
258 static struct hda_pcm_stream conexant_pcm_digital_capture
= {
262 /* NID is set in alc_build_pcms */
265 static int cx5051_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
266 struct hda_codec
*codec
,
267 unsigned int stream_tag
,
269 struct snd_pcm_substream
*substream
)
271 struct conexant_spec
*spec
= codec
->spec
;
272 spec
->cur_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
273 spec
->cur_adc_stream_tag
= stream_tag
;
274 spec
->cur_adc_format
= format
;
275 snd_hda_codec_setup_stream(codec
, spec
->cur_adc
, stream_tag
, 0, format
);
279 static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
280 struct hda_codec
*codec
,
281 struct snd_pcm_substream
*substream
)
283 struct conexant_spec
*spec
= codec
->spec
;
284 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
289 static struct hda_pcm_stream cx5051_pcm_analog_capture
= {
293 .nid
= 0, /* fill later */
295 .prepare
= cx5051_capture_pcm_prepare
,
296 .cleanup
= cx5051_capture_pcm_cleanup
300 static int conexant_build_pcms(struct hda_codec
*codec
)
302 struct conexant_spec
*spec
= codec
->spec
;
303 struct hda_pcm
*info
= spec
->pcm_rec
;
306 codec
->pcm_info
= info
;
308 info
->name
= "CONEXANT Analog";
309 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = conexant_pcm_analog_playback
;
310 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
=
311 spec
->multiout
.max_channels
;
312 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
313 spec
->multiout
.dac_nids
[0];
314 if (codec
->vendor_id
== 0x14f15051)
315 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
316 cx5051_pcm_analog_capture
;
318 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
319 conexant_pcm_analog_capture
;
320 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
= spec
->num_adc_nids
;
321 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
323 if (spec
->multiout
.dig_out_nid
) {
326 info
->name
= "Conexant Digital";
327 info
->pcm_type
= HDA_PCM_TYPE_SPDIF
;
328 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] =
329 conexant_pcm_digital_playback
;
330 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
331 spec
->multiout
.dig_out_nid
;
332 if (spec
->dig_in_nid
) {
333 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
334 conexant_pcm_digital_capture
;
335 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
=
343 static int conexant_mux_enum_info(struct snd_kcontrol
*kcontrol
,
344 struct snd_ctl_elem_info
*uinfo
)
346 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
347 struct conexant_spec
*spec
= codec
->spec
;
349 return snd_hda_input_mux_info(spec
->input_mux
, uinfo
);
352 static int conexant_mux_enum_get(struct snd_kcontrol
*kcontrol
,
353 struct snd_ctl_elem_value
*ucontrol
)
355 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
356 struct conexant_spec
*spec
= codec
->spec
;
357 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
359 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
363 static int conexant_mux_enum_put(struct snd_kcontrol
*kcontrol
,
364 struct snd_ctl_elem_value
*ucontrol
)
366 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
367 struct conexant_spec
*spec
= codec
->spec
;
368 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
370 return snd_hda_input_mux_put(codec
, spec
->input_mux
, ucontrol
,
371 spec
->capsrc_nids
[adc_idx
],
372 &spec
->cur_mux
[adc_idx
]);
375 #ifdef CONFIG_SND_HDA_INPUT_JACK
376 static void conexant_free_jack_priv(struct snd_jack
*jack
)
378 struct conexant_jack
*jacks
= jack
->private_data
;
383 static int conexant_add_jack(struct hda_codec
*codec
,
384 hda_nid_t nid
, int type
)
386 struct conexant_spec
*spec
;
387 struct conexant_jack
*jack
;
392 snd_array_init(&spec
->jacks
, sizeof(*jack
), 32);
393 jack
= snd_array_new(&spec
->jacks
);
394 name
= (type
== SND_JACK_HEADPHONE
) ? "Headphone" : "Mic" ;
402 err
= snd_jack_new(codec
->bus
->card
, name
, type
, &jack
->jack
);
405 jack
->jack
->private_data
= jack
;
406 jack
->jack
->private_free
= conexant_free_jack_priv
;
410 static void conexant_report_jack(struct hda_codec
*codec
, hda_nid_t nid
)
412 struct conexant_spec
*spec
= codec
->spec
;
413 struct conexant_jack
*jacks
= spec
->jacks
.list
;
417 for (i
= 0; i
< spec
->jacks
.used
; i
++) {
418 if (jacks
->nid
== nid
) {
419 unsigned int present
;
420 present
= snd_hda_jack_detect(codec
, nid
);
422 present
= (present
) ? jacks
->type
: 0 ;
424 snd_jack_report(jacks
->jack
,
432 static int conexant_init_jacks(struct hda_codec
*codec
)
434 struct conexant_spec
*spec
= codec
->spec
;
437 for (i
= 0; i
< spec
->num_init_verbs
; i
++) {
438 const struct hda_verb
*hv
;
440 hv
= spec
->init_verbs
[i
];
443 switch (hv
->param
^ AC_USRSP_EN
) {
444 case CONEXANT_HP_EVENT
:
445 err
= conexant_add_jack(codec
, hv
->nid
,
447 conexant_report_jack(codec
, hv
->nid
);
449 case CXT5051_PORTC_EVENT
:
450 case CONEXANT_MIC_EVENT
:
451 err
= conexant_add_jack(codec
, hv
->nid
,
452 SND_JACK_MICROPHONE
);
453 conexant_report_jack(codec
, hv
->nid
);
465 static inline void conexant_report_jack(struct hda_codec
*codec
, hda_nid_t nid
)
469 static inline int conexant_init_jacks(struct hda_codec
*codec
)
475 static int conexant_init(struct hda_codec
*codec
)
477 struct conexant_spec
*spec
= codec
->spec
;
480 for (i
= 0; i
< spec
->num_init_verbs
; i
++)
481 snd_hda_sequence_write(codec
, spec
->init_verbs
[i
]);
485 static void conexant_free(struct hda_codec
*codec
)
487 #ifdef CONFIG_SND_HDA_INPUT_JACK
488 struct conexant_spec
*spec
= codec
->spec
;
489 if (spec
->jacks
.list
) {
490 struct conexant_jack
*jacks
= spec
->jacks
.list
;
492 for (i
= 0; i
< spec
->jacks
.used
; i
++, jacks
++) {
494 snd_device_free(codec
->bus
->card
, jacks
->jack
);
496 snd_array_free(&spec
->jacks
);
499 snd_hda_detach_beep_device(codec
);
503 static struct snd_kcontrol_new cxt_capture_mixers
[] = {
505 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
506 .name
= "Capture Source",
507 .info
= conexant_mux_enum_info
,
508 .get
= conexant_mux_enum_get
,
509 .put
= conexant_mux_enum_put
514 static const char *slave_vols
[] = {
515 "Headphone Playback Volume",
516 "Speaker Playback Volume",
520 static const char *slave_sws
[] = {
521 "Headphone Playback Switch",
522 "Speaker Playback Switch",
526 static int conexant_build_controls(struct hda_codec
*codec
)
528 struct conexant_spec
*spec
= codec
->spec
;
532 for (i
= 0; i
< spec
->num_mixers
; i
++) {
533 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
537 if (spec
->multiout
.dig_out_nid
) {
538 err
= snd_hda_create_spdif_out_ctls(codec
,
539 spec
->multiout
.dig_out_nid
);
542 err
= snd_hda_create_spdif_share_sw(codec
,
546 spec
->multiout
.share_spdif
= 1;
548 if (spec
->dig_in_nid
) {
549 err
= snd_hda_create_spdif_in_ctls(codec
,spec
->dig_in_nid
);
554 /* if we have no master control, let's create it */
555 if (spec
->vmaster_nid
&&
556 !snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
557 unsigned int vmaster_tlv
[4];
558 snd_hda_set_vmaster_tlv(codec
, spec
->vmaster_nid
,
559 HDA_OUTPUT
, vmaster_tlv
);
560 err
= snd_hda_add_vmaster(codec
, "Master Playback Volume",
561 vmaster_tlv
, slave_vols
);
565 if (spec
->vmaster_nid
&&
566 !snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
567 err
= snd_hda_add_vmaster(codec
, "Master Playback Switch",
573 if (spec
->input_mux
) {
574 err
= snd_hda_add_new_ctls(codec
, cxt_capture_mixers
);
582 static struct hda_codec_ops conexant_patch_ops
= {
583 .build_controls
= conexant_build_controls
,
584 .build_pcms
= conexant_build_pcms
,
585 .init
= conexant_init
,
586 .free
= conexant_free
,
591 * the private value = nid | (invert << 8)
594 #define cxt_eapd_info snd_ctl_boolean_mono_info
596 static int cxt_eapd_get(struct snd_kcontrol
*kcontrol
,
597 struct snd_ctl_elem_value
*ucontrol
)
599 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
600 struct conexant_spec
*spec
= codec
->spec
;
601 int invert
= (kcontrol
->private_value
>> 8) & 1;
603 ucontrol
->value
.integer
.value
[0] = !spec
->cur_eapd
;
605 ucontrol
->value
.integer
.value
[0] = spec
->cur_eapd
;
610 static int cxt_eapd_put(struct snd_kcontrol
*kcontrol
,
611 struct snd_ctl_elem_value
*ucontrol
)
613 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
614 struct conexant_spec
*spec
= codec
->spec
;
615 int invert
= (kcontrol
->private_value
>> 8) & 1;
616 hda_nid_t nid
= kcontrol
->private_value
& 0xff;
619 eapd
= !!ucontrol
->value
.integer
.value
[0];
622 if (eapd
== spec
->cur_eapd
)
625 spec
->cur_eapd
= eapd
;
626 snd_hda_codec_write_cache(codec
, nid
,
627 0, AC_VERB_SET_EAPD_BTLENABLE
,
632 /* controls for test mode */
633 #ifdef CONFIG_SND_DEBUG
635 #define CXT_EAPD_SWITCH(xname, nid, mask) \
636 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
637 .info = cxt_eapd_info, \
638 .get = cxt_eapd_get, \
639 .put = cxt_eapd_put, \
640 .private_value = nid | (mask<<16) }
644 static int conexant_ch_mode_info(struct snd_kcontrol
*kcontrol
,
645 struct snd_ctl_elem_info
*uinfo
)
647 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
648 struct conexant_spec
*spec
= codec
->spec
;
649 return snd_hda_ch_mode_info(codec
, uinfo
, spec
->channel_mode
,
650 spec
->num_channel_mode
);
653 static int conexant_ch_mode_get(struct snd_kcontrol
*kcontrol
,
654 struct snd_ctl_elem_value
*ucontrol
)
656 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
657 struct conexant_spec
*spec
= codec
->spec
;
658 return snd_hda_ch_mode_get(codec
, ucontrol
, spec
->channel_mode
,
659 spec
->num_channel_mode
,
660 spec
->multiout
.max_channels
);
663 static int conexant_ch_mode_put(struct snd_kcontrol
*kcontrol
,
664 struct snd_ctl_elem_value
*ucontrol
)
666 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
667 struct conexant_spec
*spec
= codec
->spec
;
668 int err
= snd_hda_ch_mode_put(codec
, ucontrol
, spec
->channel_mode
,
669 spec
->num_channel_mode
,
670 &spec
->multiout
.max_channels
);
671 if (err
>= 0 && spec
->need_dac_fix
)
672 spec
->multiout
.num_dacs
= spec
->multiout
.max_channels
/ 2;
676 #define CXT_PIN_MODE(xname, nid, dir) \
677 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
678 .info = conexant_ch_mode_info, \
679 .get = conexant_ch_mode_get, \
680 .put = conexant_ch_mode_put, \
681 .private_value = nid | (dir<<16) }
683 #endif /* CONFIG_SND_DEBUG */
685 /* Conexant 5045 specific */
687 static hda_nid_t cxt5045_dac_nids
[1] = { 0x19 };
688 static hda_nid_t cxt5045_adc_nids
[1] = { 0x1a };
689 static hda_nid_t cxt5045_capsrc_nids
[1] = { 0x1a };
690 #define CXT5045_SPDIF_OUT 0x18
692 static struct hda_channel_mode cxt5045_modes
[1] = {
696 static struct hda_input_mux cxt5045_capture_source
= {
704 static struct hda_input_mux cxt5045_capture_source_benq
= {
715 static struct hda_input_mux cxt5045_capture_source_hp530
= {
723 /* turn on/off EAPD (+ mute HP) as a master switch */
724 static int cxt5045_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
725 struct snd_ctl_elem_value
*ucontrol
)
727 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
728 struct conexant_spec
*spec
= codec
->spec
;
731 if (!cxt_eapd_put(kcontrol
, ucontrol
))
734 /* toggle internal speakers mute depending of presence of
737 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
738 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
741 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
742 snd_hda_codec_amp_stereo(codec
, 0x11, HDA_OUTPUT
, 0,
747 /* bind volumes of both NID 0x10 and 0x11 */
748 static struct hda_bind_ctls cxt5045_hp_bind_master_vol
= {
749 .ops
= &snd_hda_bind_vol
,
751 HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT
),
752 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT
),
757 /* toggle input of built-in and mic jack appropriately */
758 static void cxt5045_hp_automic(struct hda_codec
*codec
)
760 static struct hda_verb mic_jack_on
[] = {
761 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
762 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
765 static struct hda_verb mic_jack_off
[] = {
766 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
767 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
770 unsigned int present
;
772 present
= snd_hda_jack_detect(codec
, 0x12);
774 snd_hda_sequence_write(codec
, mic_jack_on
);
776 snd_hda_sequence_write(codec
, mic_jack_off
);
780 /* mute internal speaker if HP is plugged */
781 static void cxt5045_hp_automute(struct hda_codec
*codec
)
783 struct conexant_spec
*spec
= codec
->spec
;
786 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x11);
788 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
789 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
793 /* unsolicited event for HP jack sensing */
794 static void cxt5045_hp_unsol_event(struct hda_codec
*codec
,
799 case CONEXANT_HP_EVENT
:
800 cxt5045_hp_automute(codec
);
802 case CONEXANT_MIC_EVENT
:
803 cxt5045_hp_automic(codec
);
809 static struct snd_kcontrol_new cxt5045_mixers
[] = {
810 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x01, HDA_INPUT
),
811 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x01, HDA_INPUT
),
812 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x02, HDA_INPUT
),
813 HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x02, HDA_INPUT
),
814 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT
),
815 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT
),
816 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
817 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x1, HDA_INPUT
),
818 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
819 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
820 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol
),
822 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
823 .name
= "Master Playback Switch",
824 .info
= cxt_eapd_info
,
826 .put
= cxt5045_hp_master_sw_put
,
827 .private_value
= 0x10,
833 static struct snd_kcontrol_new cxt5045_benq_mixers
[] = {
834 HDA_CODEC_VOLUME("CD Capture Volume", 0x1a, 0x04, HDA_INPUT
),
835 HDA_CODEC_MUTE("CD Capture Switch", 0x1a, 0x04, HDA_INPUT
),
836 HDA_CODEC_VOLUME("CD Playback Volume", 0x17, 0x4, HDA_INPUT
),
837 HDA_CODEC_MUTE("CD Playback Switch", 0x17, 0x4, HDA_INPUT
),
839 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1a, 0x03, HDA_INPUT
),
840 HDA_CODEC_MUTE("Line In Capture Switch", 0x1a, 0x03, HDA_INPUT
),
841 HDA_CODEC_VOLUME("Line In Playback Volume", 0x17, 0x3, HDA_INPUT
),
842 HDA_CODEC_MUTE("Line In Playback Switch", 0x17, 0x3, HDA_INPUT
),
844 HDA_CODEC_VOLUME("Mixer Capture Volume", 0x1a, 0x0, HDA_INPUT
),
845 HDA_CODEC_MUTE("Mixer Capture Switch", 0x1a, 0x0, HDA_INPUT
),
850 static struct snd_kcontrol_new cxt5045_mixers_hp530
[] = {
851 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x02, HDA_INPUT
),
852 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x02, HDA_INPUT
),
853 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x01, HDA_INPUT
),
854 HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x01, HDA_INPUT
),
855 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT
),
856 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT
),
857 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
858 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
859 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
860 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x1, HDA_INPUT
),
861 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol
),
863 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
864 .name
= "Master Playback Switch",
865 .info
= cxt_eapd_info
,
867 .put
= cxt5045_hp_master_sw_put
,
868 .private_value
= 0x10,
874 static struct hda_verb cxt5045_init_verbs
[] = {
876 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
877 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
879 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
880 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
881 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
882 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
883 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
884 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
885 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
886 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
887 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
888 /* Record selector: Int mic */
889 {0x1a, AC_VERB_SET_CONNECT_SEL
,0x1},
890 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
891 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
892 /* SPDIF route: PCM */
893 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
894 { 0x13, AC_VERB_SET_CONNECT_SEL
, 0x0 },
896 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2 }, /* default on */
900 static struct hda_verb cxt5045_benq_init_verbs
[] = {
902 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
903 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
904 /* Line In,HP, Amp */
905 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
906 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
907 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
908 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
909 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
910 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
911 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
912 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
913 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
914 /* Record selector: Int mic */
915 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x1},
916 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
917 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
918 /* SPDIF route: PCM */
919 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
920 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0},
922 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
926 static struct hda_verb cxt5045_hp_sense_init_verbs
[] = {
927 /* pin sensing on HP jack */
928 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
932 static struct hda_verb cxt5045_mic_sense_init_verbs
[] = {
933 /* pin sensing on HP jack */
934 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
938 #ifdef CONFIG_SND_DEBUG
939 /* Test configuration for debugging, modelled after the ALC260 test
942 static struct hda_input_mux cxt5045_test_capture_source
= {
947 { "LINE1 pin", 0x2 },
948 { "HP-OUT pin", 0x3 },
953 static struct snd_kcontrol_new cxt5045_test_mixer
[] = {
955 /* Output controls */
956 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT
),
957 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT
),
958 HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
959 HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
960 HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
961 HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
963 /* Modes for retasking pin widgets */
964 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT
),
965 CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT
),
967 /* EAPD Switch Control */
968 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
970 /* Loopback mixer controls */
972 HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT
),
973 HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT
),
974 HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT
),
975 HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT
),
976 HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT
),
977 HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT
),
978 HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT
),
979 HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT
),
980 HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT
),
981 HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT
),
983 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
984 .name
= "Input Source",
985 .info
= conexant_mux_enum_info
,
986 .get
= conexant_mux_enum_get
,
987 .put
= conexant_mux_enum_put
,
989 /* Audio input controls */
990 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT
),
991 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT
),
992 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT
),
993 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT
),
994 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT
),
995 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT
),
996 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT
),
997 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT
),
998 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT
),
999 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT
),
1003 static struct hda_verb cxt5045_test_init_verbs
[] = {
1004 /* Set connections */
1005 { 0x10, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1006 { 0x11, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1007 { 0x12, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1008 /* Enable retasking pins as output, initially without power amp */
1009 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1010 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1012 /* Disable digital (SPDIF) pins initially, but users can enable
1013 * them via a mixer switch. In the case of SPDIF-out, this initverb
1014 * payload also sets the generation to 0, output to be in "consumer"
1015 * PCM format, copyright asserted, no pre-emphasis and no validity
1018 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1019 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
1021 /* Start with output sum widgets muted and their output gains at min */
1022 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1023 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1025 /* Unmute retasking pin widget output buffers since the default
1026 * state appears to be output. As the pin mode is changed by the
1027 * user the pin mode control will take care of enabling the pin's
1028 * input/output buffers as needed.
1030 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1031 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1033 /* Mute capture amp left and right */
1034 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1036 /* Set ADC connection select to match default mixer setting (mic1
1039 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1040 {0x17, AC_VERB_SET_CONNECT_SEL
, 0x00},
1042 /* Mute all inputs to mixer widget (even unconnected ones) */
1043 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* Mixer pin */
1044 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* Mic1 pin */
1045 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* Line pin */
1046 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* HP pin */
1047 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
1054 /* initialize jack-sensing, too */
1055 static int cxt5045_init(struct hda_codec
*codec
)
1057 conexant_init(codec
);
1058 cxt5045_hp_automute(codec
);
1064 CXT5045_LAPTOP_HPSENSE
,
1065 CXT5045_LAPTOP_MICSENSE
,
1066 CXT5045_LAPTOP_HPMICSENSE
,
1068 CXT5045_LAPTOP_HP530
,
1069 #ifdef CONFIG_SND_DEBUG
1075 static const char *cxt5045_models
[CXT5045_MODELS
] = {
1076 [CXT5045_LAPTOP_HPSENSE
] = "laptop-hpsense",
1077 [CXT5045_LAPTOP_MICSENSE
] = "laptop-micsense",
1078 [CXT5045_LAPTOP_HPMICSENSE
] = "laptop-hpmicsense",
1079 [CXT5045_BENQ
] = "benq",
1080 [CXT5045_LAPTOP_HP530
] = "laptop-hp530",
1081 #ifdef CONFIG_SND_DEBUG
1082 [CXT5045_TEST
] = "test",
1086 static struct snd_pci_quirk cxt5045_cfg_tbl
[] = {
1087 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530
),
1088 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1089 CXT5045_LAPTOP_HPSENSE
),
1090 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE
),
1091 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ
),
1092 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE
),
1093 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE
),
1094 SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505",
1095 CXT5045_LAPTOP_HPMICSENSE
),
1096 SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1097 SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1098 SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1099 SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell",
1100 CXT5045_LAPTOP_HPMICSENSE
),
1101 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE
),
1105 static int patch_cxt5045(struct hda_codec
*codec
)
1107 struct conexant_spec
*spec
;
1110 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1114 codec
->pin_amp_workaround
= 1;
1116 spec
->multiout
.max_channels
= 2;
1117 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5045_dac_nids
);
1118 spec
->multiout
.dac_nids
= cxt5045_dac_nids
;
1119 spec
->multiout
.dig_out_nid
= CXT5045_SPDIF_OUT
;
1120 spec
->num_adc_nids
= 1;
1121 spec
->adc_nids
= cxt5045_adc_nids
;
1122 spec
->capsrc_nids
= cxt5045_capsrc_nids
;
1123 spec
->input_mux
= &cxt5045_capture_source
;
1124 spec
->num_mixers
= 1;
1125 spec
->mixers
[0] = cxt5045_mixers
;
1126 spec
->num_init_verbs
= 1;
1127 spec
->init_verbs
[0] = cxt5045_init_verbs
;
1128 spec
->spdif_route
= 0;
1129 spec
->num_channel_mode
= ARRAY_SIZE(cxt5045_modes
),
1130 spec
->channel_mode
= cxt5045_modes
,
1133 codec
->patch_ops
= conexant_patch_ops
;
1135 board_config
= snd_hda_check_board_config(codec
, CXT5045_MODELS
,
1138 switch (board_config
) {
1139 case CXT5045_LAPTOP_HPSENSE
:
1140 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1141 spec
->input_mux
= &cxt5045_capture_source
;
1142 spec
->num_init_verbs
= 2;
1143 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1144 spec
->mixers
[0] = cxt5045_mixers
;
1145 codec
->patch_ops
.init
= cxt5045_init
;
1147 case CXT5045_LAPTOP_MICSENSE
:
1148 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1149 spec
->input_mux
= &cxt5045_capture_source
;
1150 spec
->num_init_verbs
= 2;
1151 spec
->init_verbs
[1] = cxt5045_mic_sense_init_verbs
;
1152 spec
->mixers
[0] = cxt5045_mixers
;
1153 codec
->patch_ops
.init
= cxt5045_init
;
1156 case CXT5045_LAPTOP_HPMICSENSE
:
1157 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1158 spec
->input_mux
= &cxt5045_capture_source
;
1159 spec
->num_init_verbs
= 3;
1160 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1161 spec
->init_verbs
[2] = cxt5045_mic_sense_init_verbs
;
1162 spec
->mixers
[0] = cxt5045_mixers
;
1163 codec
->patch_ops
.init
= cxt5045_init
;
1166 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1167 spec
->input_mux
= &cxt5045_capture_source_benq
;
1168 spec
->num_init_verbs
= 1;
1169 spec
->init_verbs
[0] = cxt5045_benq_init_verbs
;
1170 spec
->mixers
[0] = cxt5045_mixers
;
1171 spec
->mixers
[1] = cxt5045_benq_mixers
;
1172 spec
->num_mixers
= 2;
1173 codec
->patch_ops
.init
= cxt5045_init
;
1175 case CXT5045_LAPTOP_HP530
:
1176 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1177 spec
->input_mux
= &cxt5045_capture_source_hp530
;
1178 spec
->num_init_verbs
= 2;
1179 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1180 spec
->mixers
[0] = cxt5045_mixers_hp530
;
1181 codec
->patch_ops
.init
= cxt5045_init
;
1183 #ifdef CONFIG_SND_DEBUG
1185 spec
->input_mux
= &cxt5045_test_capture_source
;
1186 spec
->mixers
[0] = cxt5045_test_mixer
;
1187 spec
->init_verbs
[0] = cxt5045_test_init_verbs
;
1193 switch (codec
->subsystem_id
>> 16) {
1196 /* HP & Fujitsu-Siemens laptops have really bad sound over 0dB
1197 * on NID 0x17. Fix max PCM level to 0 dB
1198 * (originally it has 0x2b steps with 0dB offset 0x14)
1200 snd_hda_override_amp_caps(codec
, 0x17, HDA_INPUT
,
1201 (0x14 << AC_AMPCAP_OFFSET_SHIFT
) |
1202 (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
1203 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
1204 (1 << AC_AMPCAP_MUTE_SHIFT
));
1212 /* Conexant 5047 specific */
1213 #define CXT5047_SPDIF_OUT 0x11
1215 static hda_nid_t cxt5047_dac_nids
[1] = { 0x10 }; /* 0x1c */
1216 static hda_nid_t cxt5047_adc_nids
[1] = { 0x12 };
1217 static hda_nid_t cxt5047_capsrc_nids
[1] = { 0x1a };
1219 static struct hda_channel_mode cxt5047_modes
[1] = {
1223 static struct hda_input_mux cxt5047_toshiba_capture_source
= {
1231 /* turn on/off EAPD (+ mute HP) as a master switch */
1232 static int cxt5047_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1233 struct snd_ctl_elem_value
*ucontrol
)
1235 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1236 struct conexant_spec
*spec
= codec
->spec
;
1239 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1242 /* toggle internal speakers mute depending of presence of
1243 * the headphone jack
1245 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
1246 /* NOTE: Conexat codec needs the index for *OUTPUT* amp of
1247 * pin widgets unlike other codecs. In this case, we need to
1248 * set index 0x01 for the volume from the mixer amp 0x19.
1250 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0x01,
1251 HDA_AMP_MUTE
, bits
);
1252 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
1253 snd_hda_codec_amp_stereo(codec
, 0x13, HDA_OUTPUT
, 0,
1254 HDA_AMP_MUTE
, bits
);
1258 /* mute internal speaker if HP is plugged */
1259 static void cxt5047_hp_automute(struct hda_codec
*codec
)
1261 struct conexant_spec
*spec
= codec
->spec
;
1264 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x13);
1266 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
1267 /* See the note in cxt5047_hp_master_sw_put */
1268 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0x01,
1269 HDA_AMP_MUTE
, bits
);
1272 /* toggle input of built-in and mic jack appropriately */
1273 static void cxt5047_hp_automic(struct hda_codec
*codec
)
1275 static struct hda_verb mic_jack_on
[] = {
1276 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1277 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1280 static struct hda_verb mic_jack_off
[] = {
1281 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1282 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1285 unsigned int present
;
1287 present
= snd_hda_jack_detect(codec
, 0x15);
1289 snd_hda_sequence_write(codec
, mic_jack_on
);
1291 snd_hda_sequence_write(codec
, mic_jack_off
);
1294 /* unsolicited event for HP jack sensing */
1295 static void cxt5047_hp_unsol_event(struct hda_codec
*codec
,
1298 switch (res
>> 26) {
1299 case CONEXANT_HP_EVENT
:
1300 cxt5047_hp_automute(codec
);
1302 case CONEXANT_MIC_EVENT
:
1303 cxt5047_hp_automic(codec
);
1308 static struct snd_kcontrol_new cxt5047_base_mixers
[] = {
1309 HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT
),
1310 HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT
),
1311 HDA_CODEC_VOLUME("Mic Boost", 0x1a, 0x0, HDA_OUTPUT
),
1312 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT
),
1313 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT
),
1314 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT
),
1315 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT
),
1317 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1318 .name
= "Master Playback Switch",
1319 .info
= cxt_eapd_info
,
1320 .get
= cxt_eapd_get
,
1321 .put
= cxt5047_hp_master_sw_put
,
1322 .private_value
= 0x13,
1328 static struct snd_kcontrol_new cxt5047_hp_spk_mixers
[] = {
1329 /* See the note in cxt5047_hp_master_sw_put */
1330 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT
),
1331 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1335 static struct snd_kcontrol_new cxt5047_hp_only_mixers
[] = {
1336 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1340 static struct hda_verb cxt5047_init_verbs
[] = {
1341 /* Line in, Mic, Built-in Mic */
1342 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1343 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1344 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1346 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1347 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* mixer(0x19) */
1348 {0x1d, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* mixer(0x19) */
1349 /* Record selector: Mic */
1350 {0x12, AC_VERB_SET_CONNECT_SEL
,0x03},
1351 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
,
1352 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
1353 {0x1A, AC_VERB_SET_CONNECT_SEL
,0x02},
1354 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1355 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x00},
1356 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1357 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x03},
1358 /* SPDIF route: PCM */
1359 { 0x18, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1360 /* Enable unsolicited events */
1361 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
1362 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
1366 /* configuration for Toshiba Laptops */
1367 static struct hda_verb cxt5047_toshiba_init_verbs
[] = {
1368 {0x13, AC_VERB_SET_EAPD_BTLENABLE
, 0x0}, /* default off */
1372 /* Test configuration for debugging, modelled after the ALC260 test
1375 #ifdef CONFIG_SND_DEBUG
1376 static struct hda_input_mux cxt5047_test_capture_source
= {
1379 { "LINE1 pin", 0x0 },
1380 { "MIC1 pin", 0x1 },
1381 { "MIC2 pin", 0x2 },
1386 static struct snd_kcontrol_new cxt5047_test_mixer
[] = {
1388 /* Output only controls */
1389 HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT
),
1390 HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT
),
1391 HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT
),
1392 HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT
),
1393 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
1394 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT
),
1395 HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
1396 HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
1397 HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT
),
1398 HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT
),
1399 HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT
),
1400 HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT
),
1402 /* Modes for retasking pin widgets */
1403 CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT
),
1404 CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT
),
1406 /* EAPD Switch Control */
1407 CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0),
1409 /* Loopback mixer controls */
1410 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT
),
1411 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT
),
1412 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT
),
1413 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT
),
1414 HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT
),
1415 HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT
),
1416 HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT
),
1417 HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT
),
1419 HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT
),
1420 HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT
),
1421 HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT
),
1422 HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT
),
1423 HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT
),
1424 HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT
),
1425 HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT
),
1426 HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT
),
1428 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1429 .name
= "Input Source",
1430 .info
= conexant_mux_enum_info
,
1431 .get
= conexant_mux_enum_get
,
1432 .put
= conexant_mux_enum_put
,
1434 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT
),
1439 static struct hda_verb cxt5047_test_init_verbs
[] = {
1440 /* Enable retasking pins as output, initially without power amp */
1441 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1442 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1443 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1445 /* Disable digital (SPDIF) pins initially, but users can enable
1446 * them via a mixer switch. In the case of SPDIF-out, this initverb
1447 * payload also sets the generation to 0, output to be in "consumer"
1448 * PCM format, copyright asserted, no pre-emphasis and no validity
1451 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
1453 /* Ensure mic1, mic2, line1 pin widgets take input from the
1454 * OUT1 sum bus when acting as an output.
1456 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0},
1457 {0x1b, AC_VERB_SET_CONNECT_SEL
, 0},
1459 /* Start with output sum widgets muted and their output gains at min */
1460 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1461 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1463 /* Unmute retasking pin widget output buffers since the default
1464 * state appears to be output. As the pin mode is changed by the
1465 * user the pin mode control will take care of enabling the pin's
1466 * input/output buffers as needed.
1468 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1469 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1470 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1472 /* Mute capture amp left and right */
1473 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1475 /* Set ADC connection select to match default mixer setting (mic1
1478 {0x12, AC_VERB_SET_CONNECT_SEL
, 0x00},
1480 /* Mute all inputs to mixer widget (even unconnected ones) */
1481 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* mic1 pin */
1482 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* mic2 pin */
1483 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* line1 pin */
1484 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* line2 pin */
1485 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
1486 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)}, /* Beep-gen pin */
1487 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)}, /* Line-out pin */
1488 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)}, /* HP-pin pin */
1495 /* initialize jack-sensing, too */
1496 static int cxt5047_hp_init(struct hda_codec
*codec
)
1498 conexant_init(codec
);
1499 cxt5047_hp_automute(codec
);
1505 CXT5047_LAPTOP
, /* Laptops w/o EAPD support */
1506 CXT5047_LAPTOP_HP
, /* Some HP laptops */
1507 CXT5047_LAPTOP_EAPD
, /* Laptops with EAPD support */
1508 #ifdef CONFIG_SND_DEBUG
1514 static const char *cxt5047_models
[CXT5047_MODELS
] = {
1515 [CXT5047_LAPTOP
] = "laptop",
1516 [CXT5047_LAPTOP_HP
] = "laptop-hp",
1517 [CXT5047_LAPTOP_EAPD
] = "laptop-eapd",
1518 #ifdef CONFIG_SND_DEBUG
1519 [CXT5047_TEST
] = "test",
1523 static struct snd_pci_quirk cxt5047_cfg_tbl
[] = {
1524 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP
),
1525 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1527 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD
),
1531 static int patch_cxt5047(struct hda_codec
*codec
)
1533 struct conexant_spec
*spec
;
1536 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1540 codec
->pin_amp_workaround
= 1;
1542 spec
->multiout
.max_channels
= 2;
1543 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5047_dac_nids
);
1544 spec
->multiout
.dac_nids
= cxt5047_dac_nids
;
1545 spec
->multiout
.dig_out_nid
= CXT5047_SPDIF_OUT
;
1546 spec
->num_adc_nids
= 1;
1547 spec
->adc_nids
= cxt5047_adc_nids
;
1548 spec
->capsrc_nids
= cxt5047_capsrc_nids
;
1549 spec
->num_mixers
= 1;
1550 spec
->mixers
[0] = cxt5047_base_mixers
;
1551 spec
->num_init_verbs
= 1;
1552 spec
->init_verbs
[0] = cxt5047_init_verbs
;
1553 spec
->spdif_route
= 0;
1554 spec
->num_channel_mode
= ARRAY_SIZE(cxt5047_modes
),
1555 spec
->channel_mode
= cxt5047_modes
,
1557 codec
->patch_ops
= conexant_patch_ops
;
1559 board_config
= snd_hda_check_board_config(codec
, CXT5047_MODELS
,
1562 switch (board_config
) {
1563 case CXT5047_LAPTOP
:
1564 spec
->num_mixers
= 2;
1565 spec
->mixers
[1] = cxt5047_hp_spk_mixers
;
1566 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1568 case CXT5047_LAPTOP_HP
:
1569 spec
->num_mixers
= 2;
1570 spec
->mixers
[1] = cxt5047_hp_only_mixers
;
1571 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1572 codec
->patch_ops
.init
= cxt5047_hp_init
;
1574 case CXT5047_LAPTOP_EAPD
:
1575 spec
->input_mux
= &cxt5047_toshiba_capture_source
;
1576 spec
->num_mixers
= 2;
1577 spec
->mixers
[1] = cxt5047_hp_spk_mixers
;
1578 spec
->num_init_verbs
= 2;
1579 spec
->init_verbs
[1] = cxt5047_toshiba_init_verbs
;
1580 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1582 #ifdef CONFIG_SND_DEBUG
1584 spec
->input_mux
= &cxt5047_test_capture_source
;
1585 spec
->mixers
[0] = cxt5047_test_mixer
;
1586 spec
->init_verbs
[0] = cxt5047_test_init_verbs
;
1587 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1590 spec
->vmaster_nid
= 0x13;
1594 /* Conexant 5051 specific */
1595 static hda_nid_t cxt5051_dac_nids
[1] = { 0x10 };
1596 static hda_nid_t cxt5051_adc_nids
[2] = { 0x14, 0x15 };
1598 static struct hda_channel_mode cxt5051_modes
[1] = {
1602 static void cxt5051_update_speaker(struct hda_codec
*codec
)
1604 struct conexant_spec
*spec
= codec
->spec
;
1605 unsigned int pinctl
;
1606 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
1607 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1611 /* turn on/off EAPD (+ mute HP) as a master switch */
1612 static int cxt5051_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1613 struct snd_ctl_elem_value
*ucontrol
)
1615 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1617 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1619 cxt5051_update_speaker(codec
);
1623 /* toggle input of built-in and mic jack appropriately */
1624 static void cxt5051_portb_automic(struct hda_codec
*codec
)
1626 struct conexant_spec
*spec
= codec
->spec
;
1627 unsigned int present
;
1629 if (spec
->no_auto_mic
)
1631 present
= snd_hda_jack_detect(codec
, 0x17);
1632 snd_hda_codec_write(codec
, 0x14, 0,
1633 AC_VERB_SET_CONNECT_SEL
,
1634 present
? 0x01 : 0x00);
1637 /* switch the current ADC according to the jack state */
1638 static void cxt5051_portc_automic(struct hda_codec
*codec
)
1640 struct conexant_spec
*spec
= codec
->spec
;
1641 unsigned int present
;
1644 if (spec
->no_auto_mic
)
1646 present
= snd_hda_jack_detect(codec
, 0x18);
1648 spec
->cur_adc_idx
= 1;
1650 spec
->cur_adc_idx
= 0;
1651 new_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
1652 if (spec
->cur_adc
&& spec
->cur_adc
!= new_adc
) {
1653 /* stream is running, let's swap the current ADC */
1654 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
1655 spec
->cur_adc
= new_adc
;
1656 snd_hda_codec_setup_stream(codec
, new_adc
,
1657 spec
->cur_adc_stream_tag
, 0,
1658 spec
->cur_adc_format
);
1662 /* mute internal speaker if HP is plugged */
1663 static void cxt5051_hp_automute(struct hda_codec
*codec
)
1665 struct conexant_spec
*spec
= codec
->spec
;
1667 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x16);
1668 cxt5051_update_speaker(codec
);
1671 /* unsolicited event for HP jack sensing */
1672 static void cxt5051_hp_unsol_event(struct hda_codec
*codec
,
1675 int nid
= (res
& AC_UNSOL_RES_SUBTAG
) >> 20;
1676 switch (res
>> 26) {
1677 case CONEXANT_HP_EVENT
:
1678 cxt5051_hp_automute(codec
);
1680 case CXT5051_PORTB_EVENT
:
1681 cxt5051_portb_automic(codec
);
1683 case CXT5051_PORTC_EVENT
:
1684 cxt5051_portc_automic(codec
);
1687 conexant_report_jack(codec
, nid
);
1690 static struct snd_kcontrol_new cxt5051_mixers
[] = {
1691 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1692 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1693 HDA_CODEC_VOLUME("External Mic Volume", 0x14, 0x01, HDA_INPUT
),
1694 HDA_CODEC_MUTE("External Mic Switch", 0x14, 0x01, HDA_INPUT
),
1695 HDA_CODEC_VOLUME("Docking Mic Volume", 0x15, 0x00, HDA_INPUT
),
1696 HDA_CODEC_MUTE("Docking Mic Switch", 0x15, 0x00, HDA_INPUT
),
1697 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
1699 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1700 .name
= "Master Playback Switch",
1701 .info
= cxt_eapd_info
,
1702 .get
= cxt_eapd_get
,
1703 .put
= cxt5051_hp_master_sw_put
,
1704 .private_value
= 0x1a,
1710 static struct snd_kcontrol_new cxt5051_hp_mixers
[] = {
1711 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1712 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1713 HDA_CODEC_VOLUME("External Mic Volume", 0x15, 0x00, HDA_INPUT
),
1714 HDA_CODEC_MUTE("External Mic Switch", 0x15, 0x00, HDA_INPUT
),
1715 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
1717 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1718 .name
= "Master Playback Switch",
1719 .info
= cxt_eapd_info
,
1720 .get
= cxt_eapd_get
,
1721 .put
= cxt5051_hp_master_sw_put
,
1722 .private_value
= 0x1a,
1728 static struct snd_kcontrol_new cxt5051_hp_dv6736_mixers
[] = {
1729 HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x00, HDA_INPUT
),
1730 HDA_CODEC_MUTE("Capture Switch", 0x14, 0x00, HDA_INPUT
),
1731 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
1733 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1734 .name
= "Master Playback Switch",
1735 .info
= cxt_eapd_info
,
1736 .get
= cxt_eapd_get
,
1737 .put
= cxt5051_hp_master_sw_put
,
1738 .private_value
= 0x1a,
1744 static struct snd_kcontrol_new cxt5051_f700_mixers
[] = {
1745 HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x01, HDA_INPUT
),
1746 HDA_CODEC_MUTE("Capture Switch", 0x14, 0x01, HDA_INPUT
),
1747 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
1749 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1750 .name
= "Master Playback Switch",
1751 .info
= cxt_eapd_info
,
1752 .get
= cxt_eapd_get
,
1753 .put
= cxt5051_hp_master_sw_put
,
1754 .private_value
= 0x1a,
1760 static struct hda_verb cxt5051_init_verbs
[] = {
1762 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1763 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1764 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1765 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1766 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1767 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1769 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1770 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1772 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1773 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1775 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1776 /* Record selector: Int mic */
1777 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1778 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1779 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1780 /* SPDIF route: PCM */
1781 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1783 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1784 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1785 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CXT5051_PORTB_EVENT
},
1786 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CXT5051_PORTC_EVENT
},
1790 static struct hda_verb cxt5051_hp_dv6736_init_verbs
[] = {
1792 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1793 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1794 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1795 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1797 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1798 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1800 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1801 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1803 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1804 /* Record selector: Int mic */
1805 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1806 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x1},
1807 /* SPDIF route: PCM */
1808 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1810 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1811 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1812 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CXT5051_PORTB_EVENT
},
1816 static struct hda_verb cxt5051_lenovo_x200_init_verbs
[] = {
1818 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1819 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1820 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1821 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1822 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1823 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1825 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1826 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1828 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1829 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1831 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1832 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00},
1834 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1835 /* Record selector: Int mic */
1836 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1837 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1838 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1839 /* SPDIF route: PCM */
1840 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1842 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1843 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1844 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CXT5051_PORTB_EVENT
},
1845 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CXT5051_PORTC_EVENT
},
1846 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1850 static struct hda_verb cxt5051_f700_init_verbs
[] = {
1852 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x03},
1853 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1854 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1855 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1857 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1858 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1860 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1861 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1863 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1864 /* Record selector: Int mic */
1865 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1866 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x1},
1867 /* SPDIF route: PCM */
1868 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1870 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1871 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1872 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CXT5051_PORTB_EVENT
},
1876 /* initialize jack-sensing, too */
1877 static int cxt5051_init(struct hda_codec
*codec
)
1879 conexant_init(codec
);
1880 conexant_init_jacks(codec
);
1881 if (codec
->patch_ops
.unsol_event
) {
1882 cxt5051_hp_automute(codec
);
1883 cxt5051_portb_automic(codec
);
1884 cxt5051_portc_automic(codec
);
1891 CXT5051_LAPTOP
, /* Laptops w/ EAPD support */
1892 CXT5051_HP
, /* no docking */
1893 CXT5051_HP_DV6736
, /* HP without mic switch */
1894 CXT5051_LENOVO_X200
, /* Lenovo X200 laptop */
1895 CXT5051_F700
, /* HP Compaq Presario F700 */
1899 static const char *cxt5051_models
[CXT5051_MODELS
] = {
1900 [CXT5051_LAPTOP
] = "laptop",
1901 [CXT5051_HP
] = "hp",
1902 [CXT5051_HP_DV6736
] = "hp-dv6736",
1903 [CXT5051_LENOVO_X200
] = "lenovo-x200",
1904 [CXT5051_F700
] = "hp-700",
1907 static struct snd_pci_quirk cxt5051_cfg_tbl
[] = {
1908 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736
),
1909 SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP
),
1910 SND_PCI_QUIRK(0x103c, 0x30ea, "Compaq Presario F700", CXT5051_F700
),
1911 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
1913 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP
),
1914 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT5051_LENOVO_X200
),
1918 static int patch_cxt5051(struct hda_codec
*codec
)
1920 struct conexant_spec
*spec
;
1923 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1927 codec
->pin_amp_workaround
= 1;
1929 codec
->patch_ops
= conexant_patch_ops
;
1930 codec
->patch_ops
.init
= cxt5051_init
;
1932 spec
->multiout
.max_channels
= 2;
1933 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5051_dac_nids
);
1934 spec
->multiout
.dac_nids
= cxt5051_dac_nids
;
1935 spec
->multiout
.dig_out_nid
= CXT5051_SPDIF_OUT
;
1936 spec
->num_adc_nids
= 1; /* not 2; via auto-mic switch */
1937 spec
->adc_nids
= cxt5051_adc_nids
;
1938 spec
->num_mixers
= 1;
1939 spec
->mixers
[0] = cxt5051_mixers
;
1940 spec
->num_init_verbs
= 1;
1941 spec
->init_verbs
[0] = cxt5051_init_verbs
;
1942 spec
->spdif_route
= 0;
1943 spec
->num_channel_mode
= ARRAY_SIZE(cxt5051_modes
);
1944 spec
->channel_mode
= cxt5051_modes
;
1946 spec
->cur_adc_idx
= 0;
1948 codec
->patch_ops
.unsol_event
= cxt5051_hp_unsol_event
;
1950 board_config
= snd_hda_check_board_config(codec
, CXT5051_MODELS
,
1953 switch (board_config
) {
1955 spec
->mixers
[0] = cxt5051_hp_mixers
;
1957 case CXT5051_HP_DV6736
:
1958 spec
->init_verbs
[0] = cxt5051_hp_dv6736_init_verbs
;
1959 spec
->mixers
[0] = cxt5051_hp_dv6736_mixers
;
1960 spec
->no_auto_mic
= 1;
1962 case CXT5051_LENOVO_X200
:
1963 spec
->init_verbs
[0] = cxt5051_lenovo_x200_init_verbs
;
1966 spec
->init_verbs
[0] = cxt5051_f700_init_verbs
;
1967 spec
->mixers
[0] = cxt5051_f700_mixers
;
1968 spec
->no_auto_mic
= 1;
1975 /* Conexant 5066 specific */
1977 static hda_nid_t cxt5066_dac_nids
[1] = { 0x10 };
1978 static hda_nid_t cxt5066_adc_nids
[3] = { 0x14, 0x15, 0x16 };
1979 static hda_nid_t cxt5066_capsrc_nids
[1] = { 0x17 };
1980 #define CXT5066_SPDIF_OUT 0x21
1982 /* OLPC's microphone port is DC coupled for use with external sensors,
1983 * therefore we use a 50% mic bias in order to center the input signal with
1984 * the DC input range of the codec. */
1985 #define CXT5066_OLPC_EXT_MIC_BIAS PIN_VREF50
1987 static struct hda_channel_mode cxt5066_modes
[1] = {
1991 static void cxt5066_update_speaker(struct hda_codec
*codec
)
1993 struct conexant_spec
*spec
= codec
->spec
;
1994 unsigned int pinctl
;
1996 snd_printdd("CXT5066: update speaker, hp_present=%d\n",
2000 pinctl
= ((spec
->hp_present
& 1) && spec
->cur_eapd
) ? PIN_HP
: 0;
2001 snd_hda_codec_write(codec
, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2004 /* Port D (HP/LO) */
2005 pinctl
= ((spec
->hp_present
& 2) && spec
->cur_eapd
)
2006 ? spec
->port_d_mode
: 0;
2007 snd_hda_codec_write(codec
, 0x1c, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2011 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
2012 snd_hda_codec_write(codec
, 0x1f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2015 if (spec
->dell_automute
) {
2016 /* DELL AIO Port Rule: PortA > PortD > IntSpk */
2017 pinctl
= (!(spec
->hp_present
& 1) && spec
->cur_eapd
)
2019 snd_hda_codec_write(codec
, 0x1c, 0,
2020 AC_VERB_SET_PIN_WIDGET_CONTROL
, pinctl
);
2024 /* turn on/off EAPD (+ mute HP) as a master switch */
2025 static int cxt5066_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
2026 struct snd_ctl_elem_value
*ucontrol
)
2028 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2030 if (!cxt_eapd_put(kcontrol
, ucontrol
))
2033 cxt5066_update_speaker(codec
);
2037 static const struct hda_input_mux cxt5066_olpc_dc_bias
= {
2041 { "50%", PIN_VREF50
},
2042 { "80%", PIN_VREF80
},
2046 static int cxt5066_set_olpc_dc_bias(struct hda_codec
*codec
)
2048 struct conexant_spec
*spec
= codec
->spec
;
2049 /* Even though port F is the DC input, the bias is controlled on port B.
2050 * we also leave that port as an active input (but unselected) in DC mode
2051 * just in case that is necessary to make the bias setting take effect. */
2052 return snd_hda_codec_write_cache(codec
, 0x1a, 0,
2053 AC_VERB_SET_PIN_WIDGET_CONTROL
,
2054 cxt5066_olpc_dc_bias
.items
[spec
->dc_input_bias
].index
);
2057 /* OLPC defers mic widget control until when capture is started because the
2058 * microphone LED comes on as soon as these settings are put in place. if we
2059 * did this before recording, it would give the false indication that recording
2060 * is happening when it is not. */
2061 static void cxt5066_olpc_select_mic(struct hda_codec
*codec
)
2063 struct conexant_spec
*spec
= codec
->spec
;
2064 if (!spec
->recording
)
2067 if (spec
->dc_enable
) {
2068 /* in DC mode we ignore presence detection and just use the jack
2069 * through our special DC port */
2070 const struct hda_verb enable_dc_mode
[] = {
2071 /* disble internal mic, port C */
2072 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2074 /* enable DC capture, port F */
2075 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2079 snd_hda_sequence_write(codec
, enable_dc_mode
);
2080 /* port B input disabled (and bias set) through the following call */
2081 cxt5066_set_olpc_dc_bias(codec
);
2085 /* disable DC (port F) */
2086 snd_hda_codec_write(codec
, 0x1e, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0);
2088 /* external mic, port B */
2089 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2090 spec
->ext_mic_present
? CXT5066_OLPC_EXT_MIC_BIAS
: 0);
2092 /* internal mic, port C */
2093 snd_hda_codec_write(codec
, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2094 spec
->ext_mic_present
? 0 : PIN_VREF80
);
2097 /* toggle input of built-in and mic jack appropriately */
2098 static void cxt5066_olpc_automic(struct hda_codec
*codec
)
2100 struct conexant_spec
*spec
= codec
->spec
;
2101 unsigned int present
;
2103 if (spec
->dc_enable
) /* don't do presence detection in DC mode */
2106 present
= snd_hda_codec_read(codec
, 0x1a, 0,
2107 AC_VERB_GET_PIN_SENSE
, 0) & 0x80000000;
2109 snd_printdd("CXT5066: external microphone detected\n");
2111 snd_printdd("CXT5066: external microphone absent\n");
2113 snd_hda_codec_write(codec
, 0x17, 0, AC_VERB_SET_CONNECT_SEL
,
2115 spec
->ext_mic_present
= !!present
;
2117 cxt5066_olpc_select_mic(codec
);
2120 /* toggle input of built-in digital mic and mic jack appropriately */
2121 static void cxt5066_vostro_automic(struct hda_codec
*codec
)
2123 unsigned int present
;
2125 struct hda_verb ext_mic_present
[] = {
2126 /* enable external mic, port B */
2127 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2129 /* switch to external mic input */
2130 {0x17, AC_VERB_SET_CONNECT_SEL
, 0},
2131 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2133 /* disable internal digital mic */
2134 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2137 static struct hda_verb ext_mic_absent
[] = {
2138 /* enable internal mic, port C */
2139 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2141 /* switch to internal mic input */
2142 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2144 /* disable external mic, port B */
2145 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2149 present
= snd_hda_jack_detect(codec
, 0x1a);
2151 snd_printdd("CXT5066: external microphone detected\n");
2152 snd_hda_sequence_write(codec
, ext_mic_present
);
2154 snd_printdd("CXT5066: external microphone absent\n");
2155 snd_hda_sequence_write(codec
, ext_mic_absent
);
2159 /* mute internal speaker if HP is plugged */
2160 static void cxt5066_hp_automute(struct hda_codec
*codec
)
2162 struct conexant_spec
*spec
= codec
->spec
;
2163 unsigned int portA
, portD
;
2166 portA
= snd_hda_jack_detect(codec
, 0x19);
2169 portD
= snd_hda_jack_detect(codec
, 0x1c);
2171 spec
->hp_present
= !!(portA
| portD
);
2172 snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n",
2173 portA
, portD
, spec
->hp_present
);
2174 cxt5066_update_speaker(codec
);
2177 /* unsolicited event for jack sensing */
2178 static void cxt5066_olpc_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2180 struct conexant_spec
*spec
= codec
->spec
;
2181 snd_printdd("CXT5066: unsol event %x (%x)\n", res
, res
>> 26);
2182 switch (res
>> 26) {
2183 case CONEXANT_HP_EVENT
:
2184 cxt5066_hp_automute(codec
);
2186 case CONEXANT_MIC_EVENT
:
2187 /* ignore mic events in DC mode; we're always using the jack */
2188 if (!spec
->dc_enable
)
2189 cxt5066_olpc_automic(codec
);
2194 /* unsolicited event for jack sensing */
2195 static void cxt5066_vostro_event(struct hda_codec
*codec
, unsigned int res
)
2197 snd_printdd("CXT5066_vostro: unsol event %x (%x)\n", res
, res
>> 26);
2198 switch (res
>> 26) {
2199 case CONEXANT_HP_EVENT
:
2200 cxt5066_hp_automute(codec
);
2202 case CONEXANT_MIC_EVENT
:
2203 cxt5066_vostro_automic(codec
);
2208 static const struct hda_input_mux cxt5066_analog_mic_boost
= {
2219 static int cxt5066_set_mic_boost(struct hda_codec
*codec
)
2221 struct conexant_spec
*spec
= codec
->spec
;
2222 return snd_hda_codec_write_cache(codec
, 0x17, 0,
2223 AC_VERB_SET_AMP_GAIN_MUTE
,
2224 AC_AMP_SET_RIGHT
| AC_AMP_SET_LEFT
| AC_AMP_SET_OUTPUT
|
2225 cxt5066_analog_mic_boost
.items
[spec
->mic_boost
].index
);
2228 static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol
*kcontrol
,
2229 struct snd_ctl_elem_info
*uinfo
)
2231 return snd_hda_input_mux_info(&cxt5066_analog_mic_boost
, uinfo
);
2234 static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol
*kcontrol
,
2235 struct snd_ctl_elem_value
*ucontrol
)
2237 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2238 struct conexant_spec
*spec
= codec
->spec
;
2239 ucontrol
->value
.enumerated
.item
[0] = spec
->mic_boost
;
2243 static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol
*kcontrol
,
2244 struct snd_ctl_elem_value
*ucontrol
)
2246 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2247 struct conexant_spec
*spec
= codec
->spec
;
2248 const struct hda_input_mux
*imux
= &cxt5066_analog_mic_boost
;
2250 idx
= ucontrol
->value
.enumerated
.item
[0];
2251 if (idx
>= imux
->num_items
)
2252 idx
= imux
->num_items
- 1;
2254 spec
->mic_boost
= idx
;
2255 if (!spec
->dc_enable
)
2256 cxt5066_set_mic_boost(codec
);
2260 static void cxt5066_enable_dc(struct hda_codec
*codec
)
2262 const struct hda_verb enable_dc_mode
[] = {
2264 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2266 /* switch to DC input */
2267 {0x17, AC_VERB_SET_CONNECT_SEL
, 3},
2271 /* configure as input source */
2272 snd_hda_sequence_write(codec
, enable_dc_mode
);
2273 cxt5066_olpc_select_mic(codec
); /* also sets configured bias */
2276 static void cxt5066_disable_dc(struct hda_codec
*codec
)
2278 /* reconfigure input source */
2279 cxt5066_set_mic_boost(codec
);
2280 /* automic also selects the right mic if we're recording */
2281 cxt5066_olpc_automic(codec
);
2284 static int cxt5066_olpc_dc_get(struct snd_kcontrol
*kcontrol
,
2285 struct snd_ctl_elem_value
*ucontrol
)
2287 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2288 struct conexant_spec
*spec
= codec
->spec
;
2289 ucontrol
->value
.integer
.value
[0] = spec
->dc_enable
;
2293 static int cxt5066_olpc_dc_put(struct snd_kcontrol
*kcontrol
,
2294 struct snd_ctl_elem_value
*ucontrol
)
2296 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2297 struct conexant_spec
*spec
= codec
->spec
;
2298 int dc_enable
= !!ucontrol
->value
.integer
.value
[0];
2300 if (dc_enable
== spec
->dc_enable
)
2303 spec
->dc_enable
= dc_enable
;
2305 cxt5066_enable_dc(codec
);
2307 cxt5066_disable_dc(codec
);
2312 static int cxt5066_olpc_dc_bias_enum_info(struct snd_kcontrol
*kcontrol
,
2313 struct snd_ctl_elem_info
*uinfo
)
2315 return snd_hda_input_mux_info(&cxt5066_olpc_dc_bias
, uinfo
);
2318 static int cxt5066_olpc_dc_bias_enum_get(struct snd_kcontrol
*kcontrol
,
2319 struct snd_ctl_elem_value
*ucontrol
)
2321 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2322 struct conexant_spec
*spec
= codec
->spec
;
2323 ucontrol
->value
.enumerated
.item
[0] = spec
->dc_input_bias
;
2327 static int cxt5066_olpc_dc_bias_enum_put(struct snd_kcontrol
*kcontrol
,
2328 struct snd_ctl_elem_value
*ucontrol
)
2330 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2331 struct conexant_spec
*spec
= codec
->spec
;
2332 const struct hda_input_mux
*imux
= &cxt5066_analog_mic_boost
;
2335 idx
= ucontrol
->value
.enumerated
.item
[0];
2336 if (idx
>= imux
->num_items
)
2337 idx
= imux
->num_items
- 1;
2339 spec
->dc_input_bias
= idx
;
2340 if (spec
->dc_enable
)
2341 cxt5066_set_olpc_dc_bias(codec
);
2345 static void cxt5066_olpc_capture_prepare(struct hda_codec
*codec
)
2347 struct conexant_spec
*spec
= codec
->spec
;
2348 /* mark as recording and configure the microphone widget so that the
2349 * recording LED comes on. */
2350 spec
->recording
= 1;
2351 cxt5066_olpc_select_mic(codec
);
2354 static void cxt5066_olpc_capture_cleanup(struct hda_codec
*codec
)
2356 struct conexant_spec
*spec
= codec
->spec
;
2357 const struct hda_verb disable_mics
[] = {
2358 /* disable external mic, port B */
2359 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2361 /* disble internal mic, port C */
2362 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2364 /* disable DC capture, port F */
2365 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2369 snd_hda_sequence_write(codec
, disable_mics
);
2370 spec
->recording
= 0;
2373 static struct hda_input_mux cxt5066_capture_source
= {
2383 static struct hda_bind_ctls cxt5066_bind_capture_vol_others
= {
2384 .ops
= &snd_hda_bind_vol
,
2386 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT
),
2387 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT
),
2392 static struct hda_bind_ctls cxt5066_bind_capture_sw_others
= {
2393 .ops
= &snd_hda_bind_sw
,
2395 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT
),
2396 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT
),
2401 static struct snd_kcontrol_new cxt5066_mixer_master
[] = {
2402 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
2406 static struct snd_kcontrol_new cxt5066_mixer_master_olpc
[] = {
2408 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2409 .name
= "Master Playback Volume",
2410 .access
= SNDRV_CTL_ELEM_ACCESS_READWRITE
|
2411 SNDRV_CTL_ELEM_ACCESS_TLV_READ
|
2412 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK
,
2413 .subdevice
= HDA_SUBDEV_AMP_FLAG
,
2414 .info
= snd_hda_mixer_amp_volume_info
,
2415 .get
= snd_hda_mixer_amp_volume_get
,
2416 .put
= snd_hda_mixer_amp_volume_put
,
2417 .tlv
= { .c
= snd_hda_mixer_amp_tlv
},
2418 /* offset by 28 volume steps to limit minimum gain to -46dB */
2420 HDA_COMPOSE_AMP_VAL_OFS(0x10, 3, 0, HDA_OUTPUT
, 28),
2425 static struct snd_kcontrol_new cxt5066_mixer_olpc_dc
[] = {
2427 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2428 .name
= "DC Mode Enable Switch",
2429 .info
= snd_ctl_boolean_mono_info
,
2430 .get
= cxt5066_olpc_dc_get
,
2431 .put
= cxt5066_olpc_dc_put
,
2434 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2435 .name
= "DC Input Bias Enum",
2436 .info
= cxt5066_olpc_dc_bias_enum_info
,
2437 .get
= cxt5066_olpc_dc_bias_enum_get
,
2438 .put
= cxt5066_olpc_dc_bias_enum_put
,
2443 static struct snd_kcontrol_new cxt5066_mixers
[] = {
2445 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2446 .name
= "Master Playback Switch",
2447 .info
= cxt_eapd_info
,
2448 .get
= cxt_eapd_get
,
2449 .put
= cxt5066_hp_master_sw_put
,
2450 .private_value
= 0x1d,
2454 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2455 .name
= "Analog Mic Boost Capture Enum",
2456 .info
= cxt5066_mic_boost_mux_enum_info
,
2457 .get
= cxt5066_mic_boost_mux_enum_get
,
2458 .put
= cxt5066_mic_boost_mux_enum_put
,
2461 HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others
),
2462 HDA_BIND_SW("Capture Switch", &cxt5066_bind_capture_sw_others
),
2466 static struct snd_kcontrol_new cxt5066_vostro_mixers
[] = {
2468 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2469 .name
= "Int Mic Boost Capture Enum",
2470 .info
= cxt5066_mic_boost_mux_enum_info
,
2471 .get
= cxt5066_mic_boost_mux_enum_get
,
2472 .put
= cxt5066_mic_boost_mux_enum_put
,
2473 .private_value
= 0x23 | 0x100,
2475 HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT
),
2479 static struct hda_verb cxt5066_init_verbs
[] = {
2480 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port B */
2481 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port C */
2482 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2483 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2486 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2487 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2490 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2491 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2493 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2494 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2497 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2499 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2500 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2501 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2502 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2503 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2504 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2506 /* no digital microphone support yet */
2507 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2509 /* Audio input selector */
2510 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2512 /* SPDIF route: PCM */
2513 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2514 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2516 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2517 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2520 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2522 /* not handling these yet */
2523 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2524 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2525 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2526 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2527 {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2528 {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2529 {0x20, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2530 {0x22, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2534 static struct hda_verb cxt5066_init_verbs_olpc
[] = {
2535 /* Port A: headphones */
2536 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2537 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2539 /* Port B: external microphone */
2540 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2542 /* Port C: internal microphone */
2543 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2545 /* Port D: unused */
2546 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2548 /* Port E: unused, but has primary EAPD */
2549 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2550 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2552 /* Port F: external DC input through microphone port */
2553 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2555 /* Port G: internal speakers */
2556 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2557 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2560 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2563 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2565 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2566 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2567 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2568 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2569 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2570 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2571 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2572 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2573 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2574 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2575 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2576 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2578 /* Disable digital microphone port */
2579 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2581 /* Audio input selectors */
2582 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2583 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2586 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2587 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2589 /* enable unsolicited events for Port A and B */
2590 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2591 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2595 static struct hda_verb cxt5066_init_verbs_vostro
[] = {
2596 /* Port A: headphones */
2597 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2598 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2600 /* Port B: external microphone */
2601 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2603 /* Port C: unused */
2604 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2606 /* Port D: unused */
2607 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2609 /* Port E: unused, but has primary EAPD */
2610 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2611 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2613 /* Port F: unused */
2614 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2616 /* Port G: internal speakers */
2617 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2618 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2621 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2624 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2626 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2627 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2628 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2629 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2630 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2631 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2632 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2633 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2634 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2635 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2636 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2637 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2639 /* Digital microphone port */
2640 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2642 /* Audio input selectors */
2643 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2644 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2647 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2648 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2650 /* enable unsolicited events for Port A and B */
2651 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2652 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2656 static struct hda_verb cxt5066_init_verbs_portd_lo
[] = {
2657 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2661 /* initialize jack-sensing, too */
2662 static int cxt5066_init(struct hda_codec
*codec
)
2664 struct conexant_spec
*spec
= codec
->spec
;
2666 snd_printdd("CXT5066: init\n");
2667 conexant_init(codec
);
2668 if (codec
->patch_ops
.unsol_event
) {
2669 cxt5066_hp_automute(codec
);
2670 if (spec
->dell_vostro
)
2671 cxt5066_vostro_automic(codec
);
2673 cxt5066_set_mic_boost(codec
);
2677 static int cxt5066_olpc_init(struct hda_codec
*codec
)
2679 struct conexant_spec
*spec
= codec
->spec
;
2680 snd_printdd("CXT5066: init\n");
2681 conexant_init(codec
);
2682 cxt5066_hp_automute(codec
);
2683 if (!spec
->dc_enable
) {
2684 cxt5066_set_mic_boost(codec
);
2685 cxt5066_olpc_automic(codec
);
2687 cxt5066_enable_dc(codec
);
2693 CXT5066_LAPTOP
, /* Laptops w/ EAPD support */
2694 CXT5066_DELL_LAPTOP
, /* Dell Laptop */
2695 CXT5066_OLPC_XO_1_5
, /* OLPC XO 1.5 */
2696 CXT5066_DELL_VOSTO
, /* Dell Vostro 1015i */
2700 static const char *cxt5066_models
[CXT5066_MODELS
] = {
2701 [CXT5066_LAPTOP
] = "laptop",
2702 [CXT5066_DELL_LAPTOP
] = "dell-laptop",
2703 [CXT5066_OLPC_XO_1_5
] = "olpc-xo-1_5",
2704 [CXT5066_DELL_VOSTO
] = "dell-vostro"
2707 static struct snd_pci_quirk cxt5066_cfg_tbl
[] = {
2708 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
2710 SND_PCI_QUIRK(0x1028, 0x02f5, "Dell",
2711 CXT5066_DELL_LAPTOP
),
2712 SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5
),
2713 SND_PCI_QUIRK(0x1028, 0x0402, "Dell Vostro", CXT5066_DELL_VOSTO
),
2717 static int patch_cxt5066(struct hda_codec
*codec
)
2719 struct conexant_spec
*spec
;
2722 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
2727 codec
->patch_ops
= conexant_patch_ops
;
2728 codec
->patch_ops
.init
= conexant_init
;
2730 spec
->dell_automute
= 0;
2731 spec
->multiout
.max_channels
= 2;
2732 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5066_dac_nids
);
2733 spec
->multiout
.dac_nids
= cxt5066_dac_nids
;
2734 spec
->multiout
.dig_out_nid
= CXT5066_SPDIF_OUT
;
2735 spec
->num_adc_nids
= 1;
2736 spec
->adc_nids
= cxt5066_adc_nids
;
2737 spec
->capsrc_nids
= cxt5066_capsrc_nids
;
2738 spec
->input_mux
= &cxt5066_capture_source
;
2740 spec
->port_d_mode
= PIN_HP
;
2742 spec
->num_init_verbs
= 1;
2743 spec
->init_verbs
[0] = cxt5066_init_verbs
;
2744 spec
->num_channel_mode
= ARRAY_SIZE(cxt5066_modes
);
2745 spec
->channel_mode
= cxt5066_modes
;
2747 spec
->cur_adc_idx
= 0;
2749 board_config
= snd_hda_check_board_config(codec
, CXT5066_MODELS
,
2750 cxt5066_models
, cxt5066_cfg_tbl
);
2751 switch (board_config
) {
2753 case CXT5066_LAPTOP
:
2754 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
2755 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
2757 case CXT5066_DELL_LAPTOP
:
2758 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
2759 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
2761 spec
->port_d_mode
= PIN_OUT
;
2762 spec
->init_verbs
[spec
->num_init_verbs
] = cxt5066_init_verbs_portd_lo
;
2763 spec
->num_init_verbs
++;
2764 spec
->dell_automute
= 1;
2766 case CXT5066_OLPC_XO_1_5
:
2767 codec
->patch_ops
.init
= cxt5066_olpc_init
;
2768 codec
->patch_ops
.unsol_event
= cxt5066_olpc_unsol_event
;
2769 spec
->init_verbs
[0] = cxt5066_init_verbs_olpc
;
2770 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master_olpc
;
2771 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_olpc_dc
;
2772 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
2773 spec
->port_d_mode
= 0;
2774 spec
->mic_boost
= 3; /* default 30dB gain */
2777 spec
->multiout
.dig_out_nid
= 0;
2779 /* input source automatically selected */
2780 spec
->input_mux
= NULL
;
2782 /* our capture hooks which allow us to turn on the microphone LED
2783 * at the right time */
2784 spec
->capture_prepare
= cxt5066_olpc_capture_prepare
;
2785 spec
->capture_cleanup
= cxt5066_olpc_capture_cleanup
;
2787 case CXT5066_DELL_VOSTO
:
2788 codec
->patch_ops
.init
= cxt5066_init
;
2789 codec
->patch_ops
.unsol_event
= cxt5066_vostro_event
;
2790 spec
->init_verbs
[0] = cxt5066_init_verbs_vostro
;
2791 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master_olpc
;
2792 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
2793 spec
->mixers
[spec
->num_mixers
++] = cxt5066_vostro_mixers
;
2794 spec
->port_d_mode
= 0;
2795 spec
->dell_vostro
= 1;
2796 spec
->mic_boost
= 3; /* default 30dB gain */
2797 snd_hda_attach_beep_device(codec
, 0x13);
2800 spec
->multiout
.dig_out_nid
= 0;
2802 /* input source automatically selected */
2803 spec
->input_mux
= NULL
;
2813 static struct hda_codec_preset snd_hda_preset_conexant
[] = {
2814 { .id
= 0x14f15045, .name
= "CX20549 (Venice)",
2815 .patch
= patch_cxt5045
},
2816 { .id
= 0x14f15047, .name
= "CX20551 (Waikiki)",
2817 .patch
= patch_cxt5047
},
2818 { .id
= 0x14f15051, .name
= "CX20561 (Hermosa)",
2819 .patch
= patch_cxt5051
},
2820 { .id
= 0x14f15066, .name
= "CX20582 (Pebble)",
2821 .patch
= patch_cxt5066
},
2822 { .id
= 0x14f15067, .name
= "CX20583 (Pebble HSF)",
2823 .patch
= patch_cxt5066
},
2827 MODULE_ALIAS("snd-hda-codec-id:14f15045");
2828 MODULE_ALIAS("snd-hda-codec-id:14f15047");
2829 MODULE_ALIAS("snd-hda-codec-id:14f15051");
2830 MODULE_ALIAS("snd-hda-codec-id:14f15066");
2831 MODULE_ALIAS("snd-hda-codec-id:14f15067");
2833 MODULE_LICENSE("GPL");
2834 MODULE_DESCRIPTION("Conexant HD-audio codec");
2836 static struct hda_codec_preset_list conexant_list
= {
2837 .preset
= snd_hda_preset_conexant
,
2838 .owner
= THIS_MODULE
,
2841 static int __init
patch_conexant_init(void)
2843 return snd_hda_add_codec_preset(&conexant_list
);
2846 static void __exit
patch_conexant_exit(void)
2848 snd_hda_delete_codec_preset(&conexant_list
);
2851 module_init(patch_conexant_init
)
2852 module_exit(patch_conexant_exit
)