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"
33 #define CXT_PIN_DIR_IN 0x00
34 #define CXT_PIN_DIR_OUT 0x01
35 #define CXT_PIN_DIR_INOUT 0x02
36 #define CXT_PIN_DIR_IN_NOMICBIAS 0x03
37 #define CXT_PIN_DIR_INOUT_NOMICBIAS 0x04
39 #define CONEXANT_HP_EVENT 0x37
40 #define CONEXANT_MIC_EVENT 0x38
42 /* Conexant 5051 specific */
44 #define CXT5051_SPDIF_OUT 0x1C
45 #define CXT5051_PORTB_EVENT 0x38
46 #define CXT5051_PORTC_EVENT 0x39
49 struct conexant_jack
{
53 struct snd_jack
*jack
;
57 struct conexant_spec
{
59 struct snd_kcontrol_new
*mixers
[5];
61 hda_nid_t vmaster_nid
;
63 const struct hda_verb
*init_verbs
[5]; /* initialization verbs
67 unsigned int num_init_verbs
;
70 struct hda_multi_out multiout
; /* playback set-up
71 * max_channels, dacs must be set
72 * dig_out_nid and hp_nid are optional
74 unsigned int cur_eapd
;
75 unsigned int hp_present
;
76 unsigned int no_auto_mic
;
77 unsigned int need_dac_fix
;
80 unsigned int num_adc_nids
;
82 hda_nid_t dig_in_nid
; /* digital-in NID; optional */
84 unsigned int cur_adc_idx
;
86 unsigned int cur_adc_stream_tag
;
87 unsigned int cur_adc_format
;
90 const struct hda_input_mux
*input_mux
;
91 hda_nid_t
*capsrc_nids
;
92 unsigned int cur_mux
[3];
95 const struct hda_channel_mode
*channel_mode
;
99 struct hda_pcm pcm_rec
[2]; /* used in build_pcms() */
101 unsigned int spdif_route
;
104 struct snd_array jacks
;
106 /* dynamic controls, init_verbs and input_mux */
107 struct auto_pin_cfg autocfg
;
108 struct hda_input_mux private_imux
;
109 hda_nid_t private_dac_nids
[AUTO_CFG_MAX_OUTS
];
111 unsigned int dell_automute
;
112 unsigned int port_d_mode
;
113 unsigned char ext_mic_bias
;
116 static int conexant_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
117 struct hda_codec
*codec
,
118 struct snd_pcm_substream
*substream
)
120 struct conexant_spec
*spec
= codec
->spec
;
121 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
125 static int conexant_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
126 struct hda_codec
*codec
,
127 unsigned int stream_tag
,
129 struct snd_pcm_substream
*substream
)
131 struct conexant_spec
*spec
= codec
->spec
;
132 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
,
137 static int conexant_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
138 struct hda_codec
*codec
,
139 struct snd_pcm_substream
*substream
)
141 struct conexant_spec
*spec
= codec
->spec
;
142 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
148 static int conexant_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
149 struct hda_codec
*codec
,
150 struct snd_pcm_substream
*substream
)
152 struct conexant_spec
*spec
= codec
->spec
;
153 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
156 static int conexant_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
157 struct hda_codec
*codec
,
158 struct snd_pcm_substream
*substream
)
160 struct conexant_spec
*spec
= codec
->spec
;
161 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
164 static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
165 struct hda_codec
*codec
,
166 unsigned int stream_tag
,
168 struct snd_pcm_substream
*substream
)
170 struct conexant_spec
*spec
= codec
->spec
;
171 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
179 static int conexant_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
180 struct hda_codec
*codec
,
181 unsigned int stream_tag
,
183 struct snd_pcm_substream
*substream
)
185 struct conexant_spec
*spec
= codec
->spec
;
186 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
],
187 stream_tag
, 0, format
);
191 static int conexant_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
192 struct hda_codec
*codec
,
193 struct snd_pcm_substream
*substream
)
195 struct conexant_spec
*spec
= codec
->spec
;
196 snd_hda_codec_cleanup_stream(codec
, spec
->adc_nids
[substream
->number
]);
202 static struct hda_pcm_stream conexant_pcm_analog_playback
= {
206 .nid
= 0, /* fill later */
208 .open
= conexant_playback_pcm_open
,
209 .prepare
= conexant_playback_pcm_prepare
,
210 .cleanup
= conexant_playback_pcm_cleanup
214 static struct hda_pcm_stream conexant_pcm_analog_capture
= {
218 .nid
= 0, /* fill later */
220 .prepare
= conexant_capture_pcm_prepare
,
221 .cleanup
= conexant_capture_pcm_cleanup
226 static struct hda_pcm_stream conexant_pcm_digital_playback
= {
230 .nid
= 0, /* fill later */
232 .open
= conexant_dig_playback_pcm_open
,
233 .close
= conexant_dig_playback_pcm_close
,
234 .prepare
= conexant_dig_playback_pcm_prepare
238 static struct hda_pcm_stream conexant_pcm_digital_capture
= {
242 /* NID is set in alc_build_pcms */
245 static int cx5051_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
246 struct hda_codec
*codec
,
247 unsigned int stream_tag
,
249 struct snd_pcm_substream
*substream
)
251 struct conexant_spec
*spec
= codec
->spec
;
252 spec
->cur_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
253 spec
->cur_adc_stream_tag
= stream_tag
;
254 spec
->cur_adc_format
= format
;
255 snd_hda_codec_setup_stream(codec
, spec
->cur_adc
, stream_tag
, 0, format
);
259 static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
260 struct hda_codec
*codec
,
261 struct snd_pcm_substream
*substream
)
263 struct conexant_spec
*spec
= codec
->spec
;
264 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
269 static struct hda_pcm_stream cx5051_pcm_analog_capture
= {
273 .nid
= 0, /* fill later */
275 .prepare
= cx5051_capture_pcm_prepare
,
276 .cleanup
= cx5051_capture_pcm_cleanup
280 static int conexant_build_pcms(struct hda_codec
*codec
)
282 struct conexant_spec
*spec
= codec
->spec
;
283 struct hda_pcm
*info
= spec
->pcm_rec
;
286 codec
->pcm_info
= info
;
288 info
->name
= "CONEXANT Analog";
289 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = conexant_pcm_analog_playback
;
290 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
=
291 spec
->multiout
.max_channels
;
292 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
293 spec
->multiout
.dac_nids
[0];
294 if (codec
->vendor_id
== 0x14f15051)
295 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
296 cx5051_pcm_analog_capture
;
298 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
299 conexant_pcm_analog_capture
;
300 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
= spec
->num_adc_nids
;
301 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
303 if (spec
->multiout
.dig_out_nid
) {
306 info
->name
= "Conexant Digital";
307 info
->pcm_type
= HDA_PCM_TYPE_SPDIF
;
308 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] =
309 conexant_pcm_digital_playback
;
310 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
311 spec
->multiout
.dig_out_nid
;
312 if (spec
->dig_in_nid
) {
313 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
314 conexant_pcm_digital_capture
;
315 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
=
323 static int conexant_mux_enum_info(struct snd_kcontrol
*kcontrol
,
324 struct snd_ctl_elem_info
*uinfo
)
326 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
327 struct conexant_spec
*spec
= codec
->spec
;
329 return snd_hda_input_mux_info(spec
->input_mux
, uinfo
);
332 static int conexant_mux_enum_get(struct snd_kcontrol
*kcontrol
,
333 struct snd_ctl_elem_value
*ucontrol
)
335 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
336 struct conexant_spec
*spec
= codec
->spec
;
337 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
339 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
343 static int conexant_mux_enum_put(struct snd_kcontrol
*kcontrol
,
344 struct snd_ctl_elem_value
*ucontrol
)
346 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
347 struct conexant_spec
*spec
= codec
->spec
;
348 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
350 return snd_hda_input_mux_put(codec
, spec
->input_mux
, ucontrol
,
351 spec
->capsrc_nids
[adc_idx
],
352 &spec
->cur_mux
[adc_idx
]);
355 #ifdef CONFIG_SND_HDA_INPUT_JACK
356 static void conexant_free_jack_priv(struct snd_jack
*jack
)
358 struct conexant_jack
*jacks
= jack
->private_data
;
363 static int conexant_add_jack(struct hda_codec
*codec
,
364 hda_nid_t nid
, int type
)
366 struct conexant_spec
*spec
;
367 struct conexant_jack
*jack
;
372 snd_array_init(&spec
->jacks
, sizeof(*jack
), 32);
373 jack
= snd_array_new(&spec
->jacks
);
374 name
= (type
== SND_JACK_HEADPHONE
) ? "Headphone" : "Mic" ;
382 err
= snd_jack_new(codec
->bus
->card
, name
, type
, &jack
->jack
);
385 jack
->jack
->private_data
= jack
;
386 jack
->jack
->private_free
= conexant_free_jack_priv
;
390 static void conexant_report_jack(struct hda_codec
*codec
, hda_nid_t nid
)
392 struct conexant_spec
*spec
= codec
->spec
;
393 struct conexant_jack
*jacks
= spec
->jacks
.list
;
397 for (i
= 0; i
< spec
->jacks
.used
; i
++) {
398 if (jacks
->nid
== nid
) {
399 unsigned int present
;
400 present
= snd_hda_jack_detect(codec
, nid
);
402 present
= (present
) ? jacks
->type
: 0 ;
404 snd_jack_report(jacks
->jack
,
412 static int conexant_init_jacks(struct hda_codec
*codec
)
414 struct conexant_spec
*spec
= codec
->spec
;
417 for (i
= 0; i
< spec
->num_init_verbs
; i
++) {
418 const struct hda_verb
*hv
;
420 hv
= spec
->init_verbs
[i
];
423 switch (hv
->param
^ AC_USRSP_EN
) {
424 case CONEXANT_HP_EVENT
:
425 err
= conexant_add_jack(codec
, hv
->nid
,
427 conexant_report_jack(codec
, hv
->nid
);
429 case CXT5051_PORTC_EVENT
:
430 case CONEXANT_MIC_EVENT
:
431 err
= conexant_add_jack(codec
, hv
->nid
,
432 SND_JACK_MICROPHONE
);
433 conexant_report_jack(codec
, hv
->nid
);
445 static inline void conexant_report_jack(struct hda_codec
*codec
, hda_nid_t nid
)
449 static inline int conexant_init_jacks(struct hda_codec
*codec
)
455 static int conexant_init(struct hda_codec
*codec
)
457 struct conexant_spec
*spec
= codec
->spec
;
460 for (i
= 0; i
< spec
->num_init_verbs
; i
++)
461 snd_hda_sequence_write(codec
, spec
->init_verbs
[i
]);
465 static void conexant_free(struct hda_codec
*codec
)
467 #ifdef CONFIG_SND_HDA_INPUT_JACK
468 struct conexant_spec
*spec
= codec
->spec
;
469 if (spec
->jacks
.list
) {
470 struct conexant_jack
*jacks
= spec
->jacks
.list
;
472 for (i
= 0; i
< spec
->jacks
.used
; i
++, jacks
++) {
474 snd_device_free(codec
->bus
->card
, jacks
->jack
);
476 snd_array_free(&spec
->jacks
);
482 static struct snd_kcontrol_new cxt_capture_mixers
[] = {
484 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
485 .name
= "Capture Source",
486 .info
= conexant_mux_enum_info
,
487 .get
= conexant_mux_enum_get
,
488 .put
= conexant_mux_enum_put
493 static const char *slave_vols
[] = {
494 "Headphone Playback Volume",
495 "Speaker Playback Volume",
499 static const char *slave_sws
[] = {
500 "Headphone Playback Switch",
501 "Speaker Playback Switch",
505 static int conexant_build_controls(struct hda_codec
*codec
)
507 struct conexant_spec
*spec
= codec
->spec
;
511 for (i
= 0; i
< spec
->num_mixers
; i
++) {
512 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
516 if (spec
->multiout
.dig_out_nid
) {
517 err
= snd_hda_create_spdif_out_ctls(codec
,
518 spec
->multiout
.dig_out_nid
);
521 err
= snd_hda_create_spdif_share_sw(codec
,
525 spec
->multiout
.share_spdif
= 1;
527 if (spec
->dig_in_nid
) {
528 err
= snd_hda_create_spdif_in_ctls(codec
,spec
->dig_in_nid
);
533 /* if we have no master control, let's create it */
534 if (spec
->vmaster_nid
&&
535 !snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
536 unsigned int vmaster_tlv
[4];
537 snd_hda_set_vmaster_tlv(codec
, spec
->vmaster_nid
,
538 HDA_OUTPUT
, vmaster_tlv
);
539 err
= snd_hda_add_vmaster(codec
, "Master Playback Volume",
540 vmaster_tlv
, slave_vols
);
544 if (spec
->vmaster_nid
&&
545 !snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
546 err
= snd_hda_add_vmaster(codec
, "Master Playback Switch",
552 if (spec
->input_mux
) {
553 err
= snd_hda_add_new_ctls(codec
, cxt_capture_mixers
);
561 static struct hda_codec_ops conexant_patch_ops
= {
562 .build_controls
= conexant_build_controls
,
563 .build_pcms
= conexant_build_pcms
,
564 .init
= conexant_init
,
565 .free
= conexant_free
,
570 * the private value = nid | (invert << 8)
573 #define cxt_eapd_info snd_ctl_boolean_mono_info
575 static int cxt_eapd_get(struct snd_kcontrol
*kcontrol
,
576 struct snd_ctl_elem_value
*ucontrol
)
578 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
579 struct conexant_spec
*spec
= codec
->spec
;
580 int invert
= (kcontrol
->private_value
>> 8) & 1;
582 ucontrol
->value
.integer
.value
[0] = !spec
->cur_eapd
;
584 ucontrol
->value
.integer
.value
[0] = spec
->cur_eapd
;
589 static int cxt_eapd_put(struct snd_kcontrol
*kcontrol
,
590 struct snd_ctl_elem_value
*ucontrol
)
592 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
593 struct conexant_spec
*spec
= codec
->spec
;
594 int invert
= (kcontrol
->private_value
>> 8) & 1;
595 hda_nid_t nid
= kcontrol
->private_value
& 0xff;
598 eapd
= !!ucontrol
->value
.integer
.value
[0];
601 if (eapd
== spec
->cur_eapd
)
604 spec
->cur_eapd
= eapd
;
605 snd_hda_codec_write_cache(codec
, nid
,
606 0, AC_VERB_SET_EAPD_BTLENABLE
,
611 /* controls for test mode */
612 #ifdef CONFIG_SND_DEBUG
614 #define CXT_EAPD_SWITCH(xname, nid, mask) \
615 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
616 .info = cxt_eapd_info, \
617 .get = cxt_eapd_get, \
618 .put = cxt_eapd_put, \
619 .private_value = nid | (mask<<16) }
623 static int conexant_ch_mode_info(struct snd_kcontrol
*kcontrol
,
624 struct snd_ctl_elem_info
*uinfo
)
626 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
627 struct conexant_spec
*spec
= codec
->spec
;
628 return snd_hda_ch_mode_info(codec
, uinfo
, spec
->channel_mode
,
629 spec
->num_channel_mode
);
632 static int conexant_ch_mode_get(struct snd_kcontrol
*kcontrol
,
633 struct snd_ctl_elem_value
*ucontrol
)
635 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
636 struct conexant_spec
*spec
= codec
->spec
;
637 return snd_hda_ch_mode_get(codec
, ucontrol
, spec
->channel_mode
,
638 spec
->num_channel_mode
,
639 spec
->multiout
.max_channels
);
642 static int conexant_ch_mode_put(struct snd_kcontrol
*kcontrol
,
643 struct snd_ctl_elem_value
*ucontrol
)
645 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
646 struct conexant_spec
*spec
= codec
->spec
;
647 int err
= snd_hda_ch_mode_put(codec
, ucontrol
, spec
->channel_mode
,
648 spec
->num_channel_mode
,
649 &spec
->multiout
.max_channels
);
650 if (err
>= 0 && spec
->need_dac_fix
)
651 spec
->multiout
.num_dacs
= spec
->multiout
.max_channels
/ 2;
655 #define CXT_PIN_MODE(xname, nid, dir) \
656 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
657 .info = conexant_ch_mode_info, \
658 .get = conexant_ch_mode_get, \
659 .put = conexant_ch_mode_put, \
660 .private_value = nid | (dir<<16) }
662 #endif /* CONFIG_SND_DEBUG */
664 /* Conexant 5045 specific */
666 static hda_nid_t cxt5045_dac_nids
[1] = { 0x19 };
667 static hda_nid_t cxt5045_adc_nids
[1] = { 0x1a };
668 static hda_nid_t cxt5045_capsrc_nids
[1] = { 0x1a };
669 #define CXT5045_SPDIF_OUT 0x18
671 static struct hda_channel_mode cxt5045_modes
[1] = {
675 static struct hda_input_mux cxt5045_capture_source
= {
683 static struct hda_input_mux cxt5045_capture_source_benq
= {
694 static struct hda_input_mux cxt5045_capture_source_hp530
= {
702 /* turn on/off EAPD (+ mute HP) as a master switch */
703 static int cxt5045_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
704 struct snd_ctl_elem_value
*ucontrol
)
706 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
707 struct conexant_spec
*spec
= codec
->spec
;
710 if (!cxt_eapd_put(kcontrol
, ucontrol
))
713 /* toggle internal speakers mute depending of presence of
716 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
717 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
720 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
721 snd_hda_codec_amp_stereo(codec
, 0x11, HDA_OUTPUT
, 0,
726 /* bind volumes of both NID 0x10 and 0x11 */
727 static struct hda_bind_ctls cxt5045_hp_bind_master_vol
= {
728 .ops
= &snd_hda_bind_vol
,
730 HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT
),
731 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT
),
736 /* toggle input of built-in and mic jack appropriately */
737 static void cxt5045_hp_automic(struct hda_codec
*codec
)
739 static struct hda_verb mic_jack_on
[] = {
740 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
741 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
744 static struct hda_verb mic_jack_off
[] = {
745 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
746 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
749 unsigned int present
;
751 present
= snd_hda_jack_detect(codec
, 0x12);
753 snd_hda_sequence_write(codec
, mic_jack_on
);
755 snd_hda_sequence_write(codec
, mic_jack_off
);
759 /* mute internal speaker if HP is plugged */
760 static void cxt5045_hp_automute(struct hda_codec
*codec
)
762 struct conexant_spec
*spec
= codec
->spec
;
765 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x11);
767 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
768 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
772 /* unsolicited event for HP jack sensing */
773 static void cxt5045_hp_unsol_event(struct hda_codec
*codec
,
778 case CONEXANT_HP_EVENT
:
779 cxt5045_hp_automute(codec
);
781 case CONEXANT_MIC_EVENT
:
782 cxt5045_hp_automic(codec
);
788 static struct snd_kcontrol_new cxt5045_mixers
[] = {
789 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x01, HDA_INPUT
),
790 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x01, HDA_INPUT
),
791 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x02, HDA_INPUT
),
792 HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x02, HDA_INPUT
),
793 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT
),
794 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT
),
795 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
796 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x1, HDA_INPUT
),
797 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
798 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
799 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol
),
801 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
802 .name
= "Master Playback Switch",
803 .info
= cxt_eapd_info
,
805 .put
= cxt5045_hp_master_sw_put
,
806 .private_value
= 0x10,
812 static struct snd_kcontrol_new cxt5045_benq_mixers
[] = {
813 HDA_CODEC_VOLUME("CD Capture Volume", 0x1a, 0x04, HDA_INPUT
),
814 HDA_CODEC_MUTE("CD Capture Switch", 0x1a, 0x04, HDA_INPUT
),
815 HDA_CODEC_VOLUME("CD Playback Volume", 0x17, 0x4, HDA_INPUT
),
816 HDA_CODEC_MUTE("CD Playback Switch", 0x17, 0x4, HDA_INPUT
),
818 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1a, 0x03, HDA_INPUT
),
819 HDA_CODEC_MUTE("Line In Capture Switch", 0x1a, 0x03, HDA_INPUT
),
820 HDA_CODEC_VOLUME("Line In Playback Volume", 0x17, 0x3, HDA_INPUT
),
821 HDA_CODEC_MUTE("Line In Playback Switch", 0x17, 0x3, HDA_INPUT
),
823 HDA_CODEC_VOLUME("Mixer Capture Volume", 0x1a, 0x0, HDA_INPUT
),
824 HDA_CODEC_MUTE("Mixer Capture Switch", 0x1a, 0x0, HDA_INPUT
),
829 static struct snd_kcontrol_new cxt5045_mixers_hp530
[] = {
830 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x02, HDA_INPUT
),
831 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x02, HDA_INPUT
),
832 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x01, HDA_INPUT
),
833 HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x01, HDA_INPUT
),
834 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT
),
835 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT
),
836 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
837 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
838 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
839 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x1, HDA_INPUT
),
840 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol
),
842 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
843 .name
= "Master Playback Switch",
844 .info
= cxt_eapd_info
,
846 .put
= cxt5045_hp_master_sw_put
,
847 .private_value
= 0x10,
853 static struct hda_verb cxt5045_init_verbs
[] = {
855 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
856 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
858 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
859 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
860 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
861 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
862 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
863 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
864 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
865 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
866 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
867 /* Record selector: Int mic */
868 {0x1a, AC_VERB_SET_CONNECT_SEL
,0x1},
869 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
870 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
871 /* SPDIF route: PCM */
872 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
873 { 0x13, AC_VERB_SET_CONNECT_SEL
, 0x0 },
875 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2 }, /* default on */
879 static struct hda_verb cxt5045_benq_init_verbs
[] = {
881 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
882 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
883 /* Line In,HP, Amp */
884 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
885 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
886 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
887 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
888 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
889 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
890 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
891 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
892 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
893 /* Record selector: Int mic */
894 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x1},
895 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
896 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
897 /* SPDIF route: PCM */
898 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
899 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0},
901 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
905 static struct hda_verb cxt5045_hp_sense_init_verbs
[] = {
906 /* pin sensing on HP jack */
907 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
911 static struct hda_verb cxt5045_mic_sense_init_verbs
[] = {
912 /* pin sensing on HP jack */
913 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
917 #ifdef CONFIG_SND_DEBUG
918 /* Test configuration for debugging, modelled after the ALC260 test
921 static struct hda_input_mux cxt5045_test_capture_source
= {
926 { "LINE1 pin", 0x2 },
927 { "HP-OUT pin", 0x3 },
932 static struct snd_kcontrol_new cxt5045_test_mixer
[] = {
934 /* Output controls */
935 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT
),
936 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT
),
937 HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
938 HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
939 HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
940 HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
942 /* Modes for retasking pin widgets */
943 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT
),
944 CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT
),
946 /* EAPD Switch Control */
947 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
949 /* Loopback mixer controls */
951 HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT
),
952 HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT
),
953 HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT
),
954 HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT
),
955 HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT
),
956 HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT
),
957 HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT
),
958 HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT
),
959 HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT
),
960 HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT
),
962 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
963 .name
= "Input Source",
964 .info
= conexant_mux_enum_info
,
965 .get
= conexant_mux_enum_get
,
966 .put
= conexant_mux_enum_put
,
968 /* Audio input controls */
969 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT
),
970 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT
),
971 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT
),
972 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT
),
973 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT
),
974 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT
),
975 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT
),
976 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT
),
977 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT
),
978 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT
),
982 static struct hda_verb cxt5045_test_init_verbs
[] = {
983 /* Set connections */
984 { 0x10, AC_VERB_SET_CONNECT_SEL
, 0x0 },
985 { 0x11, AC_VERB_SET_CONNECT_SEL
, 0x0 },
986 { 0x12, AC_VERB_SET_CONNECT_SEL
, 0x0 },
987 /* Enable retasking pins as output, initially without power amp */
988 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
989 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
991 /* Disable digital (SPDIF) pins initially, but users can enable
992 * them via a mixer switch. In the case of SPDIF-out, this initverb
993 * payload also sets the generation to 0, output to be in "consumer"
994 * PCM format, copyright asserted, no pre-emphasis and no validity
997 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
998 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
1000 /* Start with output sum widgets muted and their output gains at min */
1001 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1002 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1004 /* Unmute retasking pin widget output buffers since the default
1005 * state appears to be output. As the pin mode is changed by the
1006 * user the pin mode control will take care of enabling the pin's
1007 * input/output buffers as needed.
1009 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1010 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1012 /* Mute capture amp left and right */
1013 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1015 /* Set ADC connection select to match default mixer setting (mic1
1018 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1019 {0x17, AC_VERB_SET_CONNECT_SEL
, 0x00},
1021 /* Mute all inputs to mixer widget (even unconnected ones) */
1022 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* Mixer pin */
1023 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* Mic1 pin */
1024 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* Line pin */
1025 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* HP pin */
1026 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
1033 /* initialize jack-sensing, too */
1034 static int cxt5045_init(struct hda_codec
*codec
)
1036 conexant_init(codec
);
1037 cxt5045_hp_automute(codec
);
1043 CXT5045_LAPTOP_HPSENSE
,
1044 CXT5045_LAPTOP_MICSENSE
,
1045 CXT5045_LAPTOP_HPMICSENSE
,
1047 CXT5045_LAPTOP_HP530
,
1048 #ifdef CONFIG_SND_DEBUG
1054 static const char *cxt5045_models
[CXT5045_MODELS
] = {
1055 [CXT5045_LAPTOP_HPSENSE
] = "laptop-hpsense",
1056 [CXT5045_LAPTOP_MICSENSE
] = "laptop-micsense",
1057 [CXT5045_LAPTOP_HPMICSENSE
] = "laptop-hpmicsense",
1058 [CXT5045_BENQ
] = "benq",
1059 [CXT5045_LAPTOP_HP530
] = "laptop-hp530",
1060 #ifdef CONFIG_SND_DEBUG
1061 [CXT5045_TEST
] = "test",
1065 static struct snd_pci_quirk cxt5045_cfg_tbl
[] = {
1066 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530
),
1067 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1068 CXT5045_LAPTOP_HPSENSE
),
1069 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE
),
1070 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ
),
1071 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE
),
1072 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE
),
1073 SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505",
1074 CXT5045_LAPTOP_HPMICSENSE
),
1075 SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1076 SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1077 SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
1078 SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell",
1079 CXT5045_LAPTOP_HPMICSENSE
),
1080 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE
),
1084 static int patch_cxt5045(struct hda_codec
*codec
)
1086 struct conexant_spec
*spec
;
1089 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1093 codec
->pin_amp_workaround
= 1;
1095 spec
->multiout
.max_channels
= 2;
1096 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5045_dac_nids
);
1097 spec
->multiout
.dac_nids
= cxt5045_dac_nids
;
1098 spec
->multiout
.dig_out_nid
= CXT5045_SPDIF_OUT
;
1099 spec
->num_adc_nids
= 1;
1100 spec
->adc_nids
= cxt5045_adc_nids
;
1101 spec
->capsrc_nids
= cxt5045_capsrc_nids
;
1102 spec
->input_mux
= &cxt5045_capture_source
;
1103 spec
->num_mixers
= 1;
1104 spec
->mixers
[0] = cxt5045_mixers
;
1105 spec
->num_init_verbs
= 1;
1106 spec
->init_verbs
[0] = cxt5045_init_verbs
;
1107 spec
->spdif_route
= 0;
1108 spec
->num_channel_mode
= ARRAY_SIZE(cxt5045_modes
),
1109 spec
->channel_mode
= cxt5045_modes
,
1112 codec
->patch_ops
= conexant_patch_ops
;
1114 board_config
= snd_hda_check_board_config(codec
, CXT5045_MODELS
,
1117 switch (board_config
) {
1118 case CXT5045_LAPTOP_HPSENSE
:
1119 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1120 spec
->input_mux
= &cxt5045_capture_source
;
1121 spec
->num_init_verbs
= 2;
1122 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1123 spec
->mixers
[0] = cxt5045_mixers
;
1124 codec
->patch_ops
.init
= cxt5045_init
;
1126 case CXT5045_LAPTOP_MICSENSE
:
1127 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1128 spec
->input_mux
= &cxt5045_capture_source
;
1129 spec
->num_init_verbs
= 2;
1130 spec
->init_verbs
[1] = cxt5045_mic_sense_init_verbs
;
1131 spec
->mixers
[0] = cxt5045_mixers
;
1132 codec
->patch_ops
.init
= cxt5045_init
;
1135 case CXT5045_LAPTOP_HPMICSENSE
:
1136 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1137 spec
->input_mux
= &cxt5045_capture_source
;
1138 spec
->num_init_verbs
= 3;
1139 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1140 spec
->init_verbs
[2] = cxt5045_mic_sense_init_verbs
;
1141 spec
->mixers
[0] = cxt5045_mixers
;
1142 codec
->patch_ops
.init
= cxt5045_init
;
1145 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1146 spec
->input_mux
= &cxt5045_capture_source_benq
;
1147 spec
->num_init_verbs
= 1;
1148 spec
->init_verbs
[0] = cxt5045_benq_init_verbs
;
1149 spec
->mixers
[0] = cxt5045_mixers
;
1150 spec
->mixers
[1] = cxt5045_benq_mixers
;
1151 spec
->num_mixers
= 2;
1152 codec
->patch_ops
.init
= cxt5045_init
;
1154 case CXT5045_LAPTOP_HP530
:
1155 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
1156 spec
->input_mux
= &cxt5045_capture_source_hp530
;
1157 spec
->num_init_verbs
= 2;
1158 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
1159 spec
->mixers
[0] = cxt5045_mixers_hp530
;
1160 codec
->patch_ops
.init
= cxt5045_init
;
1162 #ifdef CONFIG_SND_DEBUG
1164 spec
->input_mux
= &cxt5045_test_capture_source
;
1165 spec
->mixers
[0] = cxt5045_test_mixer
;
1166 spec
->init_verbs
[0] = cxt5045_test_init_verbs
;
1172 switch (codec
->subsystem_id
>> 16) {
1175 /* HP & Fujitsu-Siemens laptops have really bad sound over 0dB
1176 * on NID 0x17. Fix max PCM level to 0 dB
1177 * (originally it has 0x2b steps with 0dB offset 0x14)
1179 snd_hda_override_amp_caps(codec
, 0x17, HDA_INPUT
,
1180 (0x14 << AC_AMPCAP_OFFSET_SHIFT
) |
1181 (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
1182 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
1183 (1 << AC_AMPCAP_MUTE_SHIFT
));
1191 /* Conexant 5047 specific */
1192 #define CXT5047_SPDIF_OUT 0x11
1194 static hda_nid_t cxt5047_dac_nids
[1] = { 0x10 }; /* 0x1c */
1195 static hda_nid_t cxt5047_adc_nids
[1] = { 0x12 };
1196 static hda_nid_t cxt5047_capsrc_nids
[1] = { 0x1a };
1198 static struct hda_channel_mode cxt5047_modes
[1] = {
1202 static struct hda_input_mux cxt5047_toshiba_capture_source
= {
1210 /* turn on/off EAPD (+ mute HP) as a master switch */
1211 static int cxt5047_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1212 struct snd_ctl_elem_value
*ucontrol
)
1214 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1215 struct conexant_spec
*spec
= codec
->spec
;
1218 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1221 /* toggle internal speakers mute depending of presence of
1222 * the headphone jack
1224 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
1225 /* NOTE: Conexat codec needs the index for *OUTPUT* amp of
1226 * pin widgets unlike other codecs. In this case, we need to
1227 * set index 0x01 for the volume from the mixer amp 0x19.
1229 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0x01,
1230 HDA_AMP_MUTE
, bits
);
1231 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
1232 snd_hda_codec_amp_stereo(codec
, 0x13, HDA_OUTPUT
, 0,
1233 HDA_AMP_MUTE
, bits
);
1237 /* mute internal speaker if HP is plugged */
1238 static void cxt5047_hp_automute(struct hda_codec
*codec
)
1240 struct conexant_spec
*spec
= codec
->spec
;
1243 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x13);
1245 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
1246 /* See the note in cxt5047_hp_master_sw_put */
1247 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0x01,
1248 HDA_AMP_MUTE
, bits
);
1251 /* toggle input of built-in and mic jack appropriately */
1252 static void cxt5047_hp_automic(struct hda_codec
*codec
)
1254 static struct hda_verb mic_jack_on
[] = {
1255 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1256 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1259 static struct hda_verb mic_jack_off
[] = {
1260 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1261 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1264 unsigned int present
;
1266 present
= snd_hda_jack_detect(codec
, 0x15);
1268 snd_hda_sequence_write(codec
, mic_jack_on
);
1270 snd_hda_sequence_write(codec
, mic_jack_off
);
1273 /* unsolicited event for HP jack sensing */
1274 static void cxt5047_hp_unsol_event(struct hda_codec
*codec
,
1277 switch (res
>> 26) {
1278 case CONEXANT_HP_EVENT
:
1279 cxt5047_hp_automute(codec
);
1281 case CONEXANT_MIC_EVENT
:
1282 cxt5047_hp_automic(codec
);
1287 static struct snd_kcontrol_new cxt5047_base_mixers
[] = {
1288 HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT
),
1289 HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT
),
1290 HDA_CODEC_VOLUME("Mic Boost", 0x1a, 0x0, HDA_OUTPUT
),
1291 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT
),
1292 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT
),
1293 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT
),
1294 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT
),
1296 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1297 .name
= "Master Playback Switch",
1298 .info
= cxt_eapd_info
,
1299 .get
= cxt_eapd_get
,
1300 .put
= cxt5047_hp_master_sw_put
,
1301 .private_value
= 0x13,
1307 static struct snd_kcontrol_new cxt5047_hp_spk_mixers
[] = {
1308 /* See the note in cxt5047_hp_master_sw_put */
1309 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT
),
1310 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1314 static struct snd_kcontrol_new cxt5047_hp_only_mixers
[] = {
1315 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1319 static struct hda_verb cxt5047_init_verbs
[] = {
1320 /* Line in, Mic, Built-in Mic */
1321 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1322 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1323 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1325 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1326 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* mixer(0x19) */
1327 {0x1d, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* mixer(0x19) */
1328 /* Record selector: Mic */
1329 {0x12, AC_VERB_SET_CONNECT_SEL
,0x03},
1330 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
,
1331 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
1332 {0x1A, AC_VERB_SET_CONNECT_SEL
,0x02},
1333 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1334 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x00},
1335 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1336 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x03},
1337 /* SPDIF route: PCM */
1338 { 0x18, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1339 /* Enable unsolicited events */
1340 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
1341 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
1345 /* configuration for Toshiba Laptops */
1346 static struct hda_verb cxt5047_toshiba_init_verbs
[] = {
1347 {0x13, AC_VERB_SET_EAPD_BTLENABLE
, 0x0}, /* default off */
1351 /* Test configuration for debugging, modelled after the ALC260 test
1354 #ifdef CONFIG_SND_DEBUG
1355 static struct hda_input_mux cxt5047_test_capture_source
= {
1358 { "LINE1 pin", 0x0 },
1359 { "MIC1 pin", 0x1 },
1360 { "MIC2 pin", 0x2 },
1365 static struct snd_kcontrol_new cxt5047_test_mixer
[] = {
1367 /* Output only controls */
1368 HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT
),
1369 HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT
),
1370 HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT
),
1371 HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT
),
1372 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
1373 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT
),
1374 HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
1375 HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
1376 HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT
),
1377 HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT
),
1378 HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT
),
1379 HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT
),
1381 /* Modes for retasking pin widgets */
1382 CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT
),
1383 CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT
),
1385 /* EAPD Switch Control */
1386 CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0),
1388 /* Loopback mixer controls */
1389 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT
),
1390 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT
),
1391 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT
),
1392 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT
),
1393 HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT
),
1394 HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT
),
1395 HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT
),
1396 HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT
),
1398 HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT
),
1399 HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT
),
1400 HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT
),
1401 HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT
),
1402 HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT
),
1403 HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT
),
1404 HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT
),
1405 HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT
),
1407 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1408 .name
= "Input Source",
1409 .info
= conexant_mux_enum_info
,
1410 .get
= conexant_mux_enum_get
,
1411 .put
= conexant_mux_enum_put
,
1413 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT
),
1418 static struct hda_verb cxt5047_test_init_verbs
[] = {
1419 /* Enable retasking pins as output, initially without power amp */
1420 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1421 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1422 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1424 /* Disable digital (SPDIF) pins initially, but users can enable
1425 * them via a mixer switch. In the case of SPDIF-out, this initverb
1426 * payload also sets the generation to 0, output to be in "consumer"
1427 * PCM format, copyright asserted, no pre-emphasis and no validity
1430 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
1432 /* Ensure mic1, mic2, line1 pin widgets take input from the
1433 * OUT1 sum bus when acting as an output.
1435 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0},
1436 {0x1b, AC_VERB_SET_CONNECT_SEL
, 0},
1438 /* Start with output sum widgets muted and their output gains at min */
1439 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1440 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1442 /* Unmute retasking pin widget output buffers since the default
1443 * state appears to be output. As the pin mode is changed by the
1444 * user the pin mode control will take care of enabling the pin's
1445 * input/output buffers as needed.
1447 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1448 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1449 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1451 /* Mute capture amp left and right */
1452 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1454 /* Set ADC connection select to match default mixer setting (mic1
1457 {0x12, AC_VERB_SET_CONNECT_SEL
, 0x00},
1459 /* Mute all inputs to mixer widget (even unconnected ones) */
1460 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* mic1 pin */
1461 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* mic2 pin */
1462 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* line1 pin */
1463 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* line2 pin */
1464 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
1465 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)}, /* Beep-gen pin */
1466 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)}, /* Line-out pin */
1467 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)}, /* HP-pin pin */
1474 /* initialize jack-sensing, too */
1475 static int cxt5047_hp_init(struct hda_codec
*codec
)
1477 conexant_init(codec
);
1478 cxt5047_hp_automute(codec
);
1484 CXT5047_LAPTOP
, /* Laptops w/o EAPD support */
1485 CXT5047_LAPTOP_HP
, /* Some HP laptops */
1486 CXT5047_LAPTOP_EAPD
, /* Laptops with EAPD support */
1487 #ifdef CONFIG_SND_DEBUG
1493 static const char *cxt5047_models
[CXT5047_MODELS
] = {
1494 [CXT5047_LAPTOP
] = "laptop",
1495 [CXT5047_LAPTOP_HP
] = "laptop-hp",
1496 [CXT5047_LAPTOP_EAPD
] = "laptop-eapd",
1497 #ifdef CONFIG_SND_DEBUG
1498 [CXT5047_TEST
] = "test",
1502 static struct snd_pci_quirk cxt5047_cfg_tbl
[] = {
1503 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP
),
1504 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1506 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD
),
1510 static int patch_cxt5047(struct hda_codec
*codec
)
1512 struct conexant_spec
*spec
;
1515 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1519 codec
->pin_amp_workaround
= 1;
1521 spec
->multiout
.max_channels
= 2;
1522 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5047_dac_nids
);
1523 spec
->multiout
.dac_nids
= cxt5047_dac_nids
;
1524 spec
->multiout
.dig_out_nid
= CXT5047_SPDIF_OUT
;
1525 spec
->num_adc_nids
= 1;
1526 spec
->adc_nids
= cxt5047_adc_nids
;
1527 spec
->capsrc_nids
= cxt5047_capsrc_nids
;
1528 spec
->num_mixers
= 1;
1529 spec
->mixers
[0] = cxt5047_base_mixers
;
1530 spec
->num_init_verbs
= 1;
1531 spec
->init_verbs
[0] = cxt5047_init_verbs
;
1532 spec
->spdif_route
= 0;
1533 spec
->num_channel_mode
= ARRAY_SIZE(cxt5047_modes
),
1534 spec
->channel_mode
= cxt5047_modes
,
1536 codec
->patch_ops
= conexant_patch_ops
;
1538 board_config
= snd_hda_check_board_config(codec
, CXT5047_MODELS
,
1541 switch (board_config
) {
1542 case CXT5047_LAPTOP
:
1543 spec
->num_mixers
= 2;
1544 spec
->mixers
[1] = cxt5047_hp_spk_mixers
;
1545 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1547 case CXT5047_LAPTOP_HP
:
1548 spec
->num_mixers
= 2;
1549 spec
->mixers
[1] = cxt5047_hp_only_mixers
;
1550 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1551 codec
->patch_ops
.init
= cxt5047_hp_init
;
1553 case CXT5047_LAPTOP_EAPD
:
1554 spec
->input_mux
= &cxt5047_toshiba_capture_source
;
1555 spec
->num_mixers
= 2;
1556 spec
->mixers
[1] = cxt5047_hp_spk_mixers
;
1557 spec
->num_init_verbs
= 2;
1558 spec
->init_verbs
[1] = cxt5047_toshiba_init_verbs
;
1559 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1561 #ifdef CONFIG_SND_DEBUG
1563 spec
->input_mux
= &cxt5047_test_capture_source
;
1564 spec
->mixers
[0] = cxt5047_test_mixer
;
1565 spec
->init_verbs
[0] = cxt5047_test_init_verbs
;
1566 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1569 spec
->vmaster_nid
= 0x13;
1573 /* Conexant 5051 specific */
1574 static hda_nid_t cxt5051_dac_nids
[1] = { 0x10 };
1575 static hda_nid_t cxt5051_adc_nids
[2] = { 0x14, 0x15 };
1577 static struct hda_channel_mode cxt5051_modes
[1] = {
1581 static void cxt5051_update_speaker(struct hda_codec
*codec
)
1583 struct conexant_spec
*spec
= codec
->spec
;
1584 unsigned int pinctl
;
1585 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
1586 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1590 /* turn on/off EAPD (+ mute HP) as a master switch */
1591 static int cxt5051_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1592 struct snd_ctl_elem_value
*ucontrol
)
1594 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1596 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1598 cxt5051_update_speaker(codec
);
1602 /* toggle input of built-in and mic jack appropriately */
1603 static void cxt5051_portb_automic(struct hda_codec
*codec
)
1605 struct conexant_spec
*spec
= codec
->spec
;
1606 unsigned int present
;
1608 if (spec
->no_auto_mic
)
1610 present
= snd_hda_jack_detect(codec
, 0x17);
1611 snd_hda_codec_write(codec
, 0x14, 0,
1612 AC_VERB_SET_CONNECT_SEL
,
1613 present
? 0x01 : 0x00);
1616 /* switch the current ADC according to the jack state */
1617 static void cxt5051_portc_automic(struct hda_codec
*codec
)
1619 struct conexant_spec
*spec
= codec
->spec
;
1620 unsigned int present
;
1623 if (spec
->no_auto_mic
)
1625 present
= snd_hda_jack_detect(codec
, 0x18);
1627 spec
->cur_adc_idx
= 1;
1629 spec
->cur_adc_idx
= 0;
1630 new_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
1631 if (spec
->cur_adc
&& spec
->cur_adc
!= new_adc
) {
1632 /* stream is running, let's swap the current ADC */
1633 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
1634 spec
->cur_adc
= new_adc
;
1635 snd_hda_codec_setup_stream(codec
, new_adc
,
1636 spec
->cur_adc_stream_tag
, 0,
1637 spec
->cur_adc_format
);
1641 /* mute internal speaker if HP is plugged */
1642 static void cxt5051_hp_automute(struct hda_codec
*codec
)
1644 struct conexant_spec
*spec
= codec
->spec
;
1646 spec
->hp_present
= snd_hda_jack_detect(codec
, 0x16);
1647 cxt5051_update_speaker(codec
);
1650 /* unsolicited event for HP jack sensing */
1651 static void cxt5051_hp_unsol_event(struct hda_codec
*codec
,
1654 int nid
= (res
& AC_UNSOL_RES_SUBTAG
) >> 20;
1655 switch (res
>> 26) {
1656 case CONEXANT_HP_EVENT
:
1657 cxt5051_hp_automute(codec
);
1659 case CXT5051_PORTB_EVENT
:
1660 cxt5051_portb_automic(codec
);
1662 case CXT5051_PORTC_EVENT
:
1663 cxt5051_portc_automic(codec
);
1666 conexant_report_jack(codec
, nid
);
1669 static struct snd_kcontrol_new cxt5051_mixers
[] = {
1670 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1671 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1672 HDA_CODEC_VOLUME("External Mic Volume", 0x14, 0x01, HDA_INPUT
),
1673 HDA_CODEC_MUTE("External Mic Switch", 0x14, 0x01, HDA_INPUT
),
1674 HDA_CODEC_VOLUME("Docking Mic Volume", 0x15, 0x00, HDA_INPUT
),
1675 HDA_CODEC_MUTE("Docking Mic Switch", 0x15, 0x00, HDA_INPUT
),
1676 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
1678 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1679 .name
= "Master Playback Switch",
1680 .info
= cxt_eapd_info
,
1681 .get
= cxt_eapd_get
,
1682 .put
= cxt5051_hp_master_sw_put
,
1683 .private_value
= 0x1a,
1689 static struct snd_kcontrol_new cxt5051_hp_mixers
[] = {
1690 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1691 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1692 HDA_CODEC_VOLUME("External Mic Volume", 0x15, 0x00, HDA_INPUT
),
1693 HDA_CODEC_MUTE("External Mic Switch", 0x15, 0x00, HDA_INPUT
),
1694 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
1696 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1697 .name
= "Master Playback Switch",
1698 .info
= cxt_eapd_info
,
1699 .get
= cxt_eapd_get
,
1700 .put
= cxt5051_hp_master_sw_put
,
1701 .private_value
= 0x1a,
1707 static struct snd_kcontrol_new cxt5051_hp_dv6736_mixers
[] = {
1708 HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x00, HDA_INPUT
),
1709 HDA_CODEC_MUTE("Mic Switch", 0x14, 0x00, HDA_INPUT
),
1710 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
1712 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1713 .name
= "Master Playback Switch",
1714 .info
= cxt_eapd_info
,
1715 .get
= cxt_eapd_get
,
1716 .put
= cxt5051_hp_master_sw_put
,
1717 .private_value
= 0x1a,
1723 static struct hda_verb cxt5051_init_verbs
[] = {
1725 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1726 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1727 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1728 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1729 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1730 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1732 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1733 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1735 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1736 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1738 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1739 /* Record selector: Int mic */
1740 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1741 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1742 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1743 /* SPDIF route: PCM */
1744 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1746 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1747 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1748 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CXT5051_PORTB_EVENT
},
1749 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CXT5051_PORTC_EVENT
},
1753 static struct hda_verb cxt5051_hp_dv6736_init_verbs
[] = {
1755 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1756 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1757 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1758 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x0},
1760 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1761 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1763 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1764 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1766 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1767 /* Record selector: Int mic */
1768 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1769 {0x14, AC_VERB_SET_CONNECT_SEL
, 0x1},
1770 /* SPDIF route: PCM */
1771 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1773 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1774 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1775 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CXT5051_PORTB_EVENT
},
1779 static struct hda_verb cxt5051_lenovo_x200_init_verbs
[] = {
1781 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1782 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1783 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1784 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1785 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1786 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1788 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1789 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1791 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1792 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1794 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1795 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00},
1797 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1798 /* Record selector: Int mic */
1799 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1800 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1801 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1802 /* SPDIF route: PCM */
1803 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1805 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1806 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1807 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CXT5051_PORTB_EVENT
},
1808 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CXT5051_PORTC_EVENT
},
1809 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1813 /* initialize jack-sensing, too */
1814 static int cxt5051_init(struct hda_codec
*codec
)
1816 conexant_init(codec
);
1817 conexant_init_jacks(codec
);
1818 if (codec
->patch_ops
.unsol_event
) {
1819 cxt5051_hp_automute(codec
);
1820 cxt5051_portb_automic(codec
);
1821 cxt5051_portc_automic(codec
);
1828 CXT5051_LAPTOP
, /* Laptops w/ EAPD support */
1829 CXT5051_HP
, /* no docking */
1830 CXT5051_HP_DV6736
, /* HP without mic switch */
1831 CXT5051_LENOVO_X200
, /* Lenovo X200 laptop */
1835 static const char *cxt5051_models
[CXT5051_MODELS
] = {
1836 [CXT5051_LAPTOP
] = "laptop",
1837 [CXT5051_HP
] = "hp",
1838 [CXT5051_HP_DV6736
] = "hp-dv6736",
1839 [CXT5051_LENOVO_X200
] = "lenovo-x200",
1842 static struct snd_pci_quirk cxt5051_cfg_tbl
[] = {
1843 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736
),
1844 SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP
),
1845 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
1847 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP
),
1848 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT5051_LENOVO_X200
),
1852 static int patch_cxt5051(struct hda_codec
*codec
)
1854 struct conexant_spec
*spec
;
1857 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1861 codec
->pin_amp_workaround
= 1;
1863 codec
->patch_ops
= conexant_patch_ops
;
1864 codec
->patch_ops
.init
= cxt5051_init
;
1866 spec
->multiout
.max_channels
= 2;
1867 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5051_dac_nids
);
1868 spec
->multiout
.dac_nids
= cxt5051_dac_nids
;
1869 spec
->multiout
.dig_out_nid
= CXT5051_SPDIF_OUT
;
1870 spec
->num_adc_nids
= 1; /* not 2; via auto-mic switch */
1871 spec
->adc_nids
= cxt5051_adc_nids
;
1872 spec
->num_mixers
= 1;
1873 spec
->mixers
[0] = cxt5051_mixers
;
1874 spec
->num_init_verbs
= 1;
1875 spec
->init_verbs
[0] = cxt5051_init_verbs
;
1876 spec
->spdif_route
= 0;
1877 spec
->num_channel_mode
= ARRAY_SIZE(cxt5051_modes
);
1878 spec
->channel_mode
= cxt5051_modes
;
1880 spec
->cur_adc_idx
= 0;
1882 codec
->patch_ops
.unsol_event
= cxt5051_hp_unsol_event
;
1884 board_config
= snd_hda_check_board_config(codec
, CXT5051_MODELS
,
1887 switch (board_config
) {
1889 spec
->mixers
[0] = cxt5051_hp_mixers
;
1891 case CXT5051_HP_DV6736
:
1892 spec
->init_verbs
[0] = cxt5051_hp_dv6736_init_verbs
;
1893 spec
->mixers
[0] = cxt5051_hp_dv6736_mixers
;
1894 spec
->no_auto_mic
= 1;
1896 case CXT5051_LENOVO_X200
:
1897 spec
->init_verbs
[0] = cxt5051_lenovo_x200_init_verbs
;
1904 /* Conexant 5066 specific */
1906 static hda_nid_t cxt5066_dac_nids
[1] = { 0x10 };
1907 static hda_nid_t cxt5066_adc_nids
[3] = { 0x14, 0x15, 0x16 };
1908 static hda_nid_t cxt5066_capsrc_nids
[1] = { 0x17 };
1909 #define CXT5066_SPDIF_OUT 0x21
1911 /* OLPC's microphone port is DC coupled for use with external sensors,
1912 * therefore we use a 50% mic bias in order to center the input signal with
1913 * the DC input range of the codec. */
1914 #define CXT5066_OLPC_EXT_MIC_BIAS PIN_VREF50
1916 static struct hda_channel_mode cxt5066_modes
[1] = {
1920 static void cxt5066_update_speaker(struct hda_codec
*codec
)
1922 struct conexant_spec
*spec
= codec
->spec
;
1923 unsigned int pinctl
;
1925 snd_printdd("CXT5066: update speaker, hp_present=%d\n",
1929 pinctl
= ((spec
->hp_present
& 1) && spec
->cur_eapd
) ? PIN_HP
: 0;
1930 snd_hda_codec_write(codec
, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1933 /* Port D (HP/LO) */
1934 pinctl
= ((spec
->hp_present
& 2) && spec
->cur_eapd
)
1935 ? spec
->port_d_mode
: 0;
1936 snd_hda_codec_write(codec
, 0x1c, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1940 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
1941 snd_hda_codec_write(codec
, 0x1f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1944 if (spec
->dell_automute
) {
1945 /* DELL AIO Port Rule: PortA > PortD > IntSpk */
1946 pinctl
= (!(spec
->hp_present
& 1) && spec
->cur_eapd
)
1948 snd_hda_codec_write(codec
, 0x1c, 0,
1949 AC_VERB_SET_PIN_WIDGET_CONTROL
, pinctl
);
1953 /* turn on/off EAPD (+ mute HP) as a master switch */
1954 static int cxt5066_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1955 struct snd_ctl_elem_value
*ucontrol
)
1957 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1959 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1962 cxt5066_update_speaker(codec
);
1966 /* toggle input of built-in and mic jack appropriately */
1967 static void cxt5066_automic(struct hda_codec
*codec
)
1969 struct conexant_spec
*spec
= codec
->spec
;
1970 struct hda_verb ext_mic_present
[] = {
1971 /* enable external mic, port B */
1972 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, spec
->ext_mic_bias
},
1974 /* switch to external mic input */
1975 {0x17, AC_VERB_SET_CONNECT_SEL
, 0},
1977 /* disable internal mic, port C */
1978 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
1981 static struct hda_verb ext_mic_absent
[] = {
1982 /* enable internal mic, port C */
1983 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1985 /* switch to internal mic input */
1986 {0x17, AC_VERB_SET_CONNECT_SEL
, 1},
1988 /* disable external mic, port B */
1989 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
1992 unsigned int present
;
1994 present
= snd_hda_jack_detect(codec
, 0x1a);
1996 snd_printdd("CXT5066: external microphone detected\n");
1997 snd_hda_sequence_write(codec
, ext_mic_present
);
1999 snd_printdd("CXT5066: external microphone absent\n");
2000 snd_hda_sequence_write(codec
, ext_mic_absent
);
2004 /* toggle input of built-in digital mic and mic jack appropriately */
2005 static void cxt5066_vostro_automic(struct hda_codec
*codec
)
2007 struct conexant_spec
*spec
= codec
->spec
;
2008 unsigned int present
;
2010 struct hda_verb ext_mic_present
[] = {
2011 /* enable external mic, port B */
2012 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, spec
->ext_mic_bias
},
2014 /* switch to external mic input */
2015 {0x17, AC_VERB_SET_CONNECT_SEL
, 0},
2016 {0x14, AC_VERB_SET_CONNECT_SEL
, 0},
2018 /* disable internal digital mic */
2019 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2022 static struct hda_verb ext_mic_absent
[] = {
2023 /* enable internal mic, port C */
2024 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2026 /* switch to internal mic input */
2027 {0x14, AC_VERB_SET_CONNECT_SEL
, 2},
2029 /* disable external mic, port B */
2030 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2034 present
= snd_hda_jack_detect(codec
, 0x1a);
2036 snd_printdd("CXT5066: external microphone detected\n");
2037 snd_hda_sequence_write(codec
, ext_mic_present
);
2039 snd_printdd("CXT5066: external microphone absent\n");
2040 snd_hda_sequence_write(codec
, ext_mic_absent
);
2044 /* mute internal speaker if HP is plugged */
2045 static void cxt5066_hp_automute(struct hda_codec
*codec
)
2047 struct conexant_spec
*spec
= codec
->spec
;
2048 unsigned int portA
, portD
;
2051 portA
= snd_hda_jack_detect(codec
, 0x19);
2054 portD
= snd_hda_jack_detect(codec
, 0x1c);
2056 spec
->hp_present
= !!(portA
| portD
);
2057 snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n",
2058 portA
, portD
, spec
->hp_present
);
2059 cxt5066_update_speaker(codec
);
2062 /* unsolicited event for jack sensing */
2063 static void cxt5066_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2065 snd_printdd("CXT5066: unsol event %x (%x)\n", res
, res
>> 26);
2066 switch (res
>> 26) {
2067 case CONEXANT_HP_EVENT
:
2068 cxt5066_hp_automute(codec
);
2070 case CONEXANT_MIC_EVENT
:
2071 cxt5066_automic(codec
);
2076 /* unsolicited event for jack sensing */
2077 static void cxt5066_vostro_event(struct hda_codec
*codec
, unsigned int res
)
2079 snd_printdd("CXT5066_vostro: unsol event %x (%x)\n", res
, res
>> 26);
2080 switch (res
>> 26) {
2081 case CONEXANT_HP_EVENT
:
2082 cxt5066_hp_automute(codec
);
2084 case CONEXANT_MIC_EVENT
:
2085 cxt5066_vostro_automic(codec
);
2090 static const struct hda_input_mux cxt5066_analog_mic_boost
= {
2101 static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol
*kcontrol
,
2102 struct snd_ctl_elem_info
*uinfo
)
2104 return snd_hda_input_mux_info(&cxt5066_analog_mic_boost
, uinfo
);
2107 static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol
*kcontrol
,
2108 struct snd_ctl_elem_value
*ucontrol
)
2110 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2113 val
= snd_hda_codec_read(codec
, 0x17, 0,
2114 AC_VERB_GET_AMP_GAIN_MUTE
, AC_AMP_GET_OUTPUT
);
2116 ucontrol
->value
.enumerated
.item
[0] = val
& AC_AMP_GAIN
;
2120 static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol
*kcontrol
,
2121 struct snd_ctl_elem_value
*ucontrol
)
2123 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2124 const struct hda_input_mux
*imux
= &cxt5066_analog_mic_boost
;
2127 if (!imux
->num_items
)
2129 idx
= ucontrol
->value
.enumerated
.item
[0];
2130 if (idx
>= imux
->num_items
)
2131 idx
= imux
->num_items
- 1;
2133 snd_hda_codec_write_cache(codec
, 0x17, 0,
2134 AC_VERB_SET_AMP_GAIN_MUTE
,
2135 AC_AMP_SET_RIGHT
| AC_AMP_SET_LEFT
| AC_AMP_SET_OUTPUT
|
2136 imux
->items
[idx
].index
);
2141 static struct hda_input_mux cxt5066_capture_source
= {
2151 static struct hda_bind_ctls cxt5066_bind_capture_vol_others
= {
2152 .ops
= &snd_hda_bind_vol
,
2154 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT
),
2155 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT
),
2160 static struct hda_bind_ctls cxt5066_bind_capture_sw_others
= {
2161 .ops
= &snd_hda_bind_sw
,
2163 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT
),
2164 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT
),
2169 static struct snd_kcontrol_new cxt5066_mixer_master
[] = {
2170 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
2174 static struct snd_kcontrol_new cxt5066_mixer_master_olpc
[] = {
2176 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2177 .name
= "Master Playback Volume",
2178 .access
= SNDRV_CTL_ELEM_ACCESS_READWRITE
|
2179 SNDRV_CTL_ELEM_ACCESS_TLV_READ
|
2180 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK
,
2181 .subdevice
= HDA_SUBDEV_NID_FLAG
| HDA_SUBDEV_AMP_FLAG
| 0x10,
2182 .info
= snd_hda_mixer_amp_volume_info
,
2183 .get
= snd_hda_mixer_amp_volume_get
,
2184 .put
= snd_hda_mixer_amp_volume_put
,
2185 .tlv
= { .c
= snd_hda_mixer_amp_tlv
},
2186 /* offset by 28 volume steps to limit minimum gain to -46dB */
2188 HDA_COMPOSE_AMP_VAL_OFS(0x10, 3, 0, HDA_OUTPUT
, 28),
2193 static struct snd_kcontrol_new cxt5066_mixers
[] = {
2195 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2196 .name
= "Master Playback Switch",
2197 .info
= cxt_eapd_info
,
2198 .get
= cxt_eapd_get
,
2199 .put
= cxt5066_hp_master_sw_put
,
2200 .private_value
= 0x1d,
2204 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2205 .name
= "Analog Mic Boost Capture Enum",
2206 .info
= cxt5066_mic_boost_mux_enum_info
,
2207 .get
= cxt5066_mic_boost_mux_enum_get
,
2208 .put
= cxt5066_mic_boost_mux_enum_put
,
2211 HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others
),
2212 HDA_BIND_SW("Capture Switch", &cxt5066_bind_capture_sw_others
),
2216 static struct hda_verb cxt5066_init_verbs
[] = {
2217 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port B */
2218 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Port C */
2219 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port F */
2220 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* Port E */
2223 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2224 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2227 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2228 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2230 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2231 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2234 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2236 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2237 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2238 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2239 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(2) | 0x50},
2240 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2241 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2243 /* no digital microphone support yet */
2244 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2246 /* Audio input selector */
2247 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2249 /* SPDIF route: PCM */
2250 {0x20, AC_VERB_SET_CONNECT_SEL
, 0x0},
2251 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x0},
2253 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2254 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2257 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2259 /* not handling these yet */
2260 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2261 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2262 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2263 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2264 {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2265 {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2266 {0x20, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2267 {0x22, AC_VERB_SET_UNSOLICITED_ENABLE
, 0},
2271 static struct hda_verb cxt5066_init_verbs_olpc
[] = {
2272 /* Port A: headphones */
2273 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2274 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2276 /* Port B: external microphone */
2277 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, CXT5066_OLPC_EXT_MIC_BIAS
},
2279 /* Port C: internal microphone */
2280 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2282 /* Port D: unused */
2283 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2285 /* Port E: unused, but has primary EAPD */
2286 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2287 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2289 /* Port F: unused */
2290 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2292 /* Port G: internal speakers */
2293 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2294 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2297 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2300 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2302 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x50},
2303 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2304 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2305 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2306 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2307 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2308 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2309 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2310 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2311 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2312 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2313 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2315 /* Disable digital microphone port */
2316 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2318 /* Audio input selectors */
2319 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2320 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2323 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2324 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2326 /* enable unsolicited events for Port A and B */
2327 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2328 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2332 static struct hda_verb cxt5066_init_verbs_vostro
[] = {
2333 /* Port A: headphones */
2334 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2335 {0x19, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2337 /* Port B: external microphone */
2338 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2340 /* Port C: unused */
2341 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2343 /* Port D: unused */
2344 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2346 /* Port E: unused, but has primary EAPD */
2347 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2348 {0x1d, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
2350 /* Port F: unused */
2351 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2353 /* Port G: internal speakers */
2354 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2355 {0x1f, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC1 */
2358 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2361 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2363 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2364 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2365 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2366 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2367 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2368 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2369 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2370 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2371 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2372 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2373 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2374 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2376 /* Digital microphone port */
2377 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2379 /* Audio input selectors */
2380 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x3},
2381 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2384 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2385 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0},
2387 /* enable unsolicited events for Port A and B */
2388 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
2389 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
2393 static struct hda_verb cxt5066_init_verbs_portd_lo
[] = {
2394 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2398 /* initialize jack-sensing, too */
2399 static int cxt5066_init(struct hda_codec
*codec
)
2401 snd_printdd("CXT5066: init\n");
2402 conexant_init(codec
);
2403 if (codec
->patch_ops
.unsol_event
) {
2404 cxt5066_hp_automute(codec
);
2405 cxt5066_automic(codec
);
2411 CXT5066_LAPTOP
, /* Laptops w/ EAPD support */
2412 CXT5066_DELL_LAPTOP
, /* Dell Laptop */
2413 CXT5066_OLPC_XO_1_5
, /* OLPC XO 1.5 */
2414 CXT5066_DELL_VOSTO
, /* Dell Vostro 1015i */
2418 static const char *cxt5066_models
[CXT5066_MODELS
] = {
2419 [CXT5066_LAPTOP
] = "laptop",
2420 [CXT5066_DELL_LAPTOP
] = "dell-laptop",
2421 [CXT5066_OLPC_XO_1_5
] = "olpc-xo-1_5",
2422 [CXT5066_DELL_VOSTO
] = "dell-vostro"
2425 static struct snd_pci_quirk cxt5066_cfg_tbl
[] = {
2426 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
2428 SND_PCI_QUIRK(0x1028, 0x02f5, "Dell",
2429 CXT5066_DELL_LAPTOP
),
2430 SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5
),
2431 SND_PCI_QUIRK(0x1028, 0x0402, "Dell Vostro", CXT5066_DELL_VOSTO
),
2435 static int patch_cxt5066(struct hda_codec
*codec
)
2437 struct conexant_spec
*spec
;
2440 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
2445 codec
->patch_ops
= conexant_patch_ops
;
2446 codec
->patch_ops
.init
= cxt5066_init
;
2448 spec
->dell_automute
= 0;
2449 spec
->multiout
.max_channels
= 2;
2450 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5066_dac_nids
);
2451 spec
->multiout
.dac_nids
= cxt5066_dac_nids
;
2452 spec
->multiout
.dig_out_nid
= CXT5066_SPDIF_OUT
;
2453 spec
->num_adc_nids
= 1;
2454 spec
->adc_nids
= cxt5066_adc_nids
;
2455 spec
->capsrc_nids
= cxt5066_capsrc_nids
;
2456 spec
->input_mux
= &cxt5066_capture_source
;
2458 spec
->port_d_mode
= PIN_HP
;
2459 spec
->ext_mic_bias
= PIN_VREF80
;
2461 spec
->num_init_verbs
= 1;
2462 spec
->init_verbs
[0] = cxt5066_init_verbs
;
2463 spec
->num_channel_mode
= ARRAY_SIZE(cxt5066_modes
);
2464 spec
->channel_mode
= cxt5066_modes
;
2466 spec
->cur_adc_idx
= 0;
2468 board_config
= snd_hda_check_board_config(codec
, CXT5066_MODELS
,
2469 cxt5066_models
, cxt5066_cfg_tbl
);
2470 switch (board_config
) {
2472 case CXT5066_LAPTOP
:
2473 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
2474 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
2476 case CXT5066_DELL_LAPTOP
:
2477 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master
;
2478 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
2480 spec
->port_d_mode
= PIN_OUT
;
2481 spec
->init_verbs
[spec
->num_init_verbs
] = cxt5066_init_verbs_portd_lo
;
2482 spec
->num_init_verbs
++;
2483 spec
->dell_automute
= 1;
2485 case CXT5066_OLPC_XO_1_5
:
2486 codec
->patch_ops
.unsol_event
= cxt5066_unsol_event
;
2487 spec
->init_verbs
[0] = cxt5066_init_verbs_olpc
;
2488 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master_olpc
;
2489 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
2490 spec
->port_d_mode
= 0;
2491 spec
->ext_mic_bias
= CXT5066_OLPC_EXT_MIC_BIAS
;
2494 spec
->multiout
.dig_out_nid
= 0;
2496 /* input source automatically selected */
2497 spec
->input_mux
= NULL
;
2499 case CXT5066_DELL_VOSTO
:
2500 codec
->patch_ops
.unsol_event
= cxt5066_vostro_event
;
2501 spec
->init_verbs
[0] = cxt5066_init_verbs_vostro
;
2502 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixer_master_olpc
;
2503 spec
->mixers
[spec
->num_mixers
++] = cxt5066_mixers
;
2504 spec
->port_d_mode
= 0;
2507 spec
->multiout
.dig_out_nid
= 0;
2509 /* input source automatically selected */
2510 spec
->input_mux
= NULL
;
2520 static struct hda_codec_preset snd_hda_preset_conexant
[] = {
2521 { .id
= 0x14f15045, .name
= "CX20549 (Venice)",
2522 .patch
= patch_cxt5045
},
2523 { .id
= 0x14f15047, .name
= "CX20551 (Waikiki)",
2524 .patch
= patch_cxt5047
},
2525 { .id
= 0x14f15051, .name
= "CX20561 (Hermosa)",
2526 .patch
= patch_cxt5051
},
2527 { .id
= 0x14f15066, .name
= "CX20582 (Pebble)",
2528 .patch
= patch_cxt5066
},
2529 { .id
= 0x14f15067, .name
= "CX20583 (Pebble HSF)",
2530 .patch
= patch_cxt5066
},
2534 MODULE_ALIAS("snd-hda-codec-id:14f15045");
2535 MODULE_ALIAS("snd-hda-codec-id:14f15047");
2536 MODULE_ALIAS("snd-hda-codec-id:14f15051");
2537 MODULE_ALIAS("snd-hda-codec-id:14f15066");
2538 MODULE_ALIAS("snd-hda-codec-id:14f15067");
2540 MODULE_LICENSE("GPL");
2541 MODULE_DESCRIPTION("Conexant HD-audio codec");
2543 static struct hda_codec_preset_list conexant_list
= {
2544 .preset
= snd_hda_preset_conexant
,
2545 .owner
= THIS_MODULE
,
2548 static int __init
patch_conexant_init(void)
2550 return snd_hda_add_codec_preset(&conexant_list
);
2553 static void __exit
patch_conexant_exit(void)
2555 snd_hda_delete_codec_preset(&conexant_list
);
2558 module_init(patch_conexant_init
)
2559 module_exit(patch_conexant_exit
)