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 "hda_codec.h"
29 #include "hda_local.h"
31 #define CXT_PIN_DIR_IN 0x00
32 #define CXT_PIN_DIR_OUT 0x01
33 #define CXT_PIN_DIR_INOUT 0x02
34 #define CXT_PIN_DIR_IN_NOMICBIAS 0x03
35 #define CXT_PIN_DIR_INOUT_NOMICBIAS 0x04
37 #define CONEXANT_HP_EVENT 0x37
38 #define CONEXANT_MIC_EVENT 0x38
42 struct conexant_spec
{
44 struct snd_kcontrol_new
*mixers
[5];
47 const struct hda_verb
*init_verbs
[5]; /* initialization verbs
51 unsigned int num_init_verbs
;
54 struct hda_multi_out multiout
; /* playback set-up
55 * max_channels, dacs must be set
56 * dig_out_nid and hp_nid are optional
58 unsigned int cur_eapd
;
59 unsigned int hp_present
;
60 unsigned int need_dac_fix
;
63 unsigned int num_adc_nids
;
65 hda_nid_t dig_in_nid
; /* digital-in NID; optional */
67 unsigned int cur_adc_idx
;
69 unsigned int cur_adc_stream_tag
;
70 unsigned int cur_adc_format
;
73 const struct hda_input_mux
*input_mux
;
74 hda_nid_t
*capsrc_nids
;
75 unsigned int cur_mux
[3];
78 const struct hda_channel_mode
*channel_mode
;
82 struct hda_pcm pcm_rec
[2]; /* used in build_pcms() */
84 unsigned int spdif_route
;
86 /* dynamic controls, init_verbs and input_mux */
87 struct auto_pin_cfg autocfg
;
88 struct hda_input_mux private_imux
;
89 hda_nid_t private_dac_nids
[AUTO_CFG_MAX_OUTS
];
93 static int conexant_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
94 struct hda_codec
*codec
,
95 struct snd_pcm_substream
*substream
)
97 struct conexant_spec
*spec
= codec
->spec
;
98 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
102 static int conexant_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
103 struct hda_codec
*codec
,
104 unsigned int stream_tag
,
106 struct snd_pcm_substream
*substream
)
108 struct conexant_spec
*spec
= codec
->spec
;
109 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
,
114 static int conexant_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
115 struct hda_codec
*codec
,
116 struct snd_pcm_substream
*substream
)
118 struct conexant_spec
*spec
= codec
->spec
;
119 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
125 static int conexant_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
126 struct hda_codec
*codec
,
127 struct snd_pcm_substream
*substream
)
129 struct conexant_spec
*spec
= codec
->spec
;
130 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
133 static int conexant_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
134 struct hda_codec
*codec
,
135 struct snd_pcm_substream
*substream
)
137 struct conexant_spec
*spec
= codec
->spec
;
138 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
141 static int conexant_dig_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_dig_prepare(codec
, &spec
->multiout
,
156 static int conexant_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
157 struct hda_codec
*codec
,
158 unsigned int stream_tag
,
160 struct snd_pcm_substream
*substream
)
162 struct conexant_spec
*spec
= codec
->spec
;
163 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
],
164 stream_tag
, 0, format
);
168 static int conexant_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
169 struct hda_codec
*codec
,
170 struct snd_pcm_substream
*substream
)
172 struct conexant_spec
*spec
= codec
->spec
;
173 snd_hda_codec_cleanup_stream(codec
, spec
->adc_nids
[substream
->number
]);
179 static struct hda_pcm_stream conexant_pcm_analog_playback
= {
183 .nid
= 0, /* fill later */
185 .open
= conexant_playback_pcm_open
,
186 .prepare
= conexant_playback_pcm_prepare
,
187 .cleanup
= conexant_playback_pcm_cleanup
191 static struct hda_pcm_stream conexant_pcm_analog_capture
= {
195 .nid
= 0, /* fill later */
197 .prepare
= conexant_capture_pcm_prepare
,
198 .cleanup
= conexant_capture_pcm_cleanup
203 static struct hda_pcm_stream conexant_pcm_digital_playback
= {
207 .nid
= 0, /* fill later */
209 .open
= conexant_dig_playback_pcm_open
,
210 .close
= conexant_dig_playback_pcm_close
,
211 .prepare
= conexant_dig_playback_pcm_prepare
215 static struct hda_pcm_stream conexant_pcm_digital_capture
= {
219 /* NID is set in alc_build_pcms */
222 static int cx5051_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
223 struct hda_codec
*codec
,
224 unsigned int stream_tag
,
226 struct snd_pcm_substream
*substream
)
228 struct conexant_spec
*spec
= codec
->spec
;
229 spec
->cur_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
230 spec
->cur_adc_stream_tag
= stream_tag
;
231 spec
->cur_adc_format
= format
;
232 snd_hda_codec_setup_stream(codec
, spec
->cur_adc
, stream_tag
, 0, format
);
236 static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
237 struct hda_codec
*codec
,
238 struct snd_pcm_substream
*substream
)
240 struct conexant_spec
*spec
= codec
->spec
;
241 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
246 static struct hda_pcm_stream cx5051_pcm_analog_capture
= {
250 .nid
= 0, /* fill later */
252 .prepare
= cx5051_capture_pcm_prepare
,
253 .cleanup
= cx5051_capture_pcm_cleanup
257 static int conexant_build_pcms(struct hda_codec
*codec
)
259 struct conexant_spec
*spec
= codec
->spec
;
260 struct hda_pcm
*info
= spec
->pcm_rec
;
263 codec
->pcm_info
= info
;
265 info
->name
= "CONEXANT Analog";
266 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = conexant_pcm_analog_playback
;
267 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
=
268 spec
->multiout
.max_channels
;
269 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
270 spec
->multiout
.dac_nids
[0];
271 if (codec
->vendor_id
== 0x14f15051)
272 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
273 cx5051_pcm_analog_capture
;
275 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
276 conexant_pcm_analog_capture
;
277 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
= spec
->num_adc_nids
;
278 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
280 if (spec
->multiout
.dig_out_nid
) {
283 info
->name
= "Conexant Digital";
284 info
->pcm_type
= HDA_PCM_TYPE_SPDIF
;
285 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] =
286 conexant_pcm_digital_playback
;
287 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
288 spec
->multiout
.dig_out_nid
;
289 if (spec
->dig_in_nid
) {
290 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
291 conexant_pcm_digital_capture
;
292 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
=
300 static int conexant_mux_enum_info(struct snd_kcontrol
*kcontrol
,
301 struct snd_ctl_elem_info
*uinfo
)
303 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
304 struct conexant_spec
*spec
= codec
->spec
;
306 return snd_hda_input_mux_info(spec
->input_mux
, uinfo
);
309 static int conexant_mux_enum_get(struct snd_kcontrol
*kcontrol
,
310 struct snd_ctl_elem_value
*ucontrol
)
312 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
313 struct conexant_spec
*spec
= codec
->spec
;
314 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
316 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
320 static int conexant_mux_enum_put(struct snd_kcontrol
*kcontrol
,
321 struct snd_ctl_elem_value
*ucontrol
)
323 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
324 struct conexant_spec
*spec
= codec
->spec
;
325 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
327 return snd_hda_input_mux_put(codec
, spec
->input_mux
, ucontrol
,
328 spec
->capsrc_nids
[adc_idx
],
329 &spec
->cur_mux
[adc_idx
]);
332 static int conexant_init(struct hda_codec
*codec
)
334 struct conexant_spec
*spec
= codec
->spec
;
337 for (i
= 0; i
< spec
->num_init_verbs
; i
++)
338 snd_hda_sequence_write(codec
, spec
->init_verbs
[i
]);
342 static void conexant_free(struct hda_codec
*codec
)
347 static int conexant_build_controls(struct hda_codec
*codec
)
349 struct conexant_spec
*spec
= codec
->spec
;
353 for (i
= 0; i
< spec
->num_mixers
; i
++) {
354 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
358 if (spec
->multiout
.dig_out_nid
) {
359 err
= snd_hda_create_spdif_out_ctls(codec
,
360 spec
->multiout
.dig_out_nid
);
363 err
= snd_hda_create_spdif_share_sw(codec
,
367 spec
->multiout
.share_spdif
= 1;
369 if (spec
->dig_in_nid
) {
370 err
= snd_hda_create_spdif_in_ctls(codec
,spec
->dig_in_nid
);
377 static struct hda_codec_ops conexant_patch_ops
= {
378 .build_controls
= conexant_build_controls
,
379 .build_pcms
= conexant_build_pcms
,
380 .init
= conexant_init
,
381 .free
= conexant_free
,
386 * the private value = nid | (invert << 8)
389 #define cxt_eapd_info snd_ctl_boolean_mono_info
391 static int cxt_eapd_get(struct snd_kcontrol
*kcontrol
,
392 struct snd_ctl_elem_value
*ucontrol
)
394 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
395 struct conexant_spec
*spec
= codec
->spec
;
396 int invert
= (kcontrol
->private_value
>> 8) & 1;
398 ucontrol
->value
.integer
.value
[0] = !spec
->cur_eapd
;
400 ucontrol
->value
.integer
.value
[0] = spec
->cur_eapd
;
405 static int cxt_eapd_put(struct snd_kcontrol
*kcontrol
,
406 struct snd_ctl_elem_value
*ucontrol
)
408 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
409 struct conexant_spec
*spec
= codec
->spec
;
410 int invert
= (kcontrol
->private_value
>> 8) & 1;
411 hda_nid_t nid
= kcontrol
->private_value
& 0xff;
414 eapd
= !!ucontrol
->value
.integer
.value
[0];
417 if (eapd
== spec
->cur_eapd
)
420 spec
->cur_eapd
= eapd
;
421 snd_hda_codec_write_cache(codec
, nid
,
422 0, AC_VERB_SET_EAPD_BTLENABLE
,
427 /* controls for test mode */
428 #ifdef CONFIG_SND_DEBUG
430 #define CXT_EAPD_SWITCH(xname, nid, mask) \
431 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
432 .info = cxt_eapd_info, \
433 .get = cxt_eapd_get, \
434 .put = cxt_eapd_put, \
435 .private_value = nid | (mask<<16) }
439 static int conexant_ch_mode_info(struct snd_kcontrol
*kcontrol
,
440 struct snd_ctl_elem_info
*uinfo
)
442 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
443 struct conexant_spec
*spec
= codec
->spec
;
444 return snd_hda_ch_mode_info(codec
, uinfo
, spec
->channel_mode
,
445 spec
->num_channel_mode
);
448 static int conexant_ch_mode_get(struct snd_kcontrol
*kcontrol
,
449 struct snd_ctl_elem_value
*ucontrol
)
451 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
452 struct conexant_spec
*spec
= codec
->spec
;
453 return snd_hda_ch_mode_get(codec
, ucontrol
, spec
->channel_mode
,
454 spec
->num_channel_mode
,
455 spec
->multiout
.max_channels
);
458 static int conexant_ch_mode_put(struct snd_kcontrol
*kcontrol
,
459 struct snd_ctl_elem_value
*ucontrol
)
461 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
462 struct conexant_spec
*spec
= codec
->spec
;
463 int err
= snd_hda_ch_mode_put(codec
, ucontrol
, spec
->channel_mode
,
464 spec
->num_channel_mode
,
465 &spec
->multiout
.max_channels
);
466 if (err
>= 0 && spec
->need_dac_fix
)
467 spec
->multiout
.num_dacs
= spec
->multiout
.max_channels
/ 2;
471 #define CXT_PIN_MODE(xname, nid, dir) \
472 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
473 .info = conexant_ch_mode_info, \
474 .get = conexant_ch_mode_get, \
475 .put = conexant_ch_mode_put, \
476 .private_value = nid | (dir<<16) }
478 #endif /* CONFIG_SND_DEBUG */
480 /* Conexant 5045 specific */
482 static hda_nid_t cxt5045_dac_nids
[1] = { 0x19 };
483 static hda_nid_t cxt5045_adc_nids
[1] = { 0x1a };
484 static hda_nid_t cxt5045_capsrc_nids
[1] = { 0x1a };
485 #define CXT5045_SPDIF_OUT 0x18
487 static struct hda_channel_mode cxt5045_modes
[1] = {
491 static struct hda_input_mux cxt5045_capture_source
= {
499 static struct hda_input_mux cxt5045_capture_source_benq
= {
508 static struct hda_input_mux cxt5045_capture_source_hp530
= {
516 /* turn on/off EAPD (+ mute HP) as a master switch */
517 static int cxt5045_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
518 struct snd_ctl_elem_value
*ucontrol
)
520 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
521 struct conexant_spec
*spec
= codec
->spec
;
524 if (!cxt_eapd_put(kcontrol
, ucontrol
))
527 /* toggle internal speakers mute depending of presence of
530 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
531 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
534 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
535 snd_hda_codec_amp_stereo(codec
, 0x11, HDA_OUTPUT
, 0,
540 /* bind volumes of both NID 0x10 and 0x11 */
541 static struct hda_bind_ctls cxt5045_hp_bind_master_vol
= {
542 .ops
= &snd_hda_bind_vol
,
544 HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT
),
545 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT
),
550 /* toggle input of built-in and mic jack appropriately */
551 static void cxt5045_hp_automic(struct hda_codec
*codec
)
553 static struct hda_verb mic_jack_on
[] = {
554 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
555 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
558 static struct hda_verb mic_jack_off
[] = {
559 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
560 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
563 unsigned int present
;
565 present
= snd_hda_codec_read(codec
, 0x12, 0,
566 AC_VERB_GET_PIN_SENSE
, 0) & 0x80000000;
568 snd_hda_sequence_write(codec
, mic_jack_on
);
570 snd_hda_sequence_write(codec
, mic_jack_off
);
574 /* mute internal speaker if HP is plugged */
575 static void cxt5045_hp_automute(struct hda_codec
*codec
)
577 struct conexant_spec
*spec
= codec
->spec
;
580 spec
->hp_present
= snd_hda_codec_read(codec
, 0x11, 0,
581 AC_VERB_GET_PIN_SENSE
, 0) & 0x80000000;
583 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
584 snd_hda_codec_amp_stereo(codec
, 0x10, HDA_OUTPUT
, 0,
588 /* unsolicited event for HP jack sensing */
589 static void cxt5045_hp_unsol_event(struct hda_codec
*codec
,
594 case CONEXANT_HP_EVENT
:
595 cxt5045_hp_automute(codec
);
597 case CONEXANT_MIC_EVENT
:
598 cxt5045_hp_automic(codec
);
604 static struct snd_kcontrol_new cxt5045_mixers
[] = {
606 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
607 .name
= "Capture Source",
608 .info
= conexant_mux_enum_info
,
609 .get
= conexant_mux_enum_get
,
610 .put
= conexant_mux_enum_put
612 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x01, HDA_INPUT
),
613 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x01, HDA_INPUT
),
614 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x02, HDA_INPUT
),
615 HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x02, HDA_INPUT
),
616 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT
),
617 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT
),
618 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
619 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x1, HDA_INPUT
),
620 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
621 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
622 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol
),
624 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
625 .name
= "Master Playback Switch",
626 .info
= cxt_eapd_info
,
628 .put
= cxt5045_hp_master_sw_put
,
629 .private_value
= 0x10,
635 static struct snd_kcontrol_new cxt5045_benq_mixers
[] = {
636 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1a, 0x03, HDA_INPUT
),
637 HDA_CODEC_MUTE("Line In Capture Switch", 0x1a, 0x03, HDA_INPUT
),
638 HDA_CODEC_VOLUME("Line In Playback Volume", 0x17, 0x3, HDA_INPUT
),
639 HDA_CODEC_MUTE("Line In Playback Switch", 0x17, 0x3, HDA_INPUT
),
644 static struct snd_kcontrol_new cxt5045_mixers_hp530
[] = {
646 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
647 .name
= "Capture Source",
648 .info
= conexant_mux_enum_info
,
649 .get
= conexant_mux_enum_get
,
650 .put
= conexant_mux_enum_put
652 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x02, HDA_INPUT
),
653 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x02, HDA_INPUT
),
654 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x01, HDA_INPUT
),
655 HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x01, HDA_INPUT
),
656 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT
),
657 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT
),
658 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x2, HDA_INPUT
),
659 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x2, HDA_INPUT
),
660 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x1, HDA_INPUT
),
661 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x1, HDA_INPUT
),
662 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol
),
664 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
665 .name
= "Master Playback Switch",
666 .info
= cxt_eapd_info
,
668 .put
= cxt5045_hp_master_sw_put
,
669 .private_value
= 0x10,
675 static struct hda_verb cxt5045_init_verbs
[] = {
677 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
678 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
680 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
681 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
682 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
683 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
684 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
685 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
686 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
687 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
688 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
689 /* Record selector: Int mic */
690 {0x1a, AC_VERB_SET_CONNECT_SEL
,0x1},
691 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
692 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
693 /* SPDIF route: PCM */
694 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
695 { 0x13, AC_VERB_SET_CONNECT_SEL
, 0x0 },
697 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2 }, /* default on */
701 static struct hda_verb cxt5045_benq_init_verbs
[] = {
703 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
704 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_80
},
705 /* Line In,HP, Amp */
706 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
707 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
708 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
709 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x1},
710 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
711 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
712 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
713 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
714 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
715 /* Record selector: Int mic */
716 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x1},
717 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
,
718 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
719 /* SPDIF route: PCM */
720 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
721 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0},
723 {0x10, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
727 static struct hda_verb cxt5045_hp_sense_init_verbs
[] = {
728 /* pin sensing on HP jack */
729 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
733 static struct hda_verb cxt5045_mic_sense_init_verbs
[] = {
734 /* pin sensing on HP jack */
735 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
739 #ifdef CONFIG_SND_DEBUG
740 /* Test configuration for debugging, modelled after the ALC260 test
743 static struct hda_input_mux cxt5045_test_capture_source
= {
748 { "LINE1 pin", 0x2 },
749 { "HP-OUT pin", 0x3 },
754 static struct snd_kcontrol_new cxt5045_test_mixer
[] = {
756 /* Output controls */
757 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT
),
758 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT
),
759 HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
760 HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
761 HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
762 HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
764 /* Modes for retasking pin widgets */
765 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT
),
766 CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT
),
768 /* EAPD Switch Control */
769 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
771 /* Loopback mixer controls */
773 HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT
),
774 HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT
),
775 HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT
),
776 HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT
),
777 HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT
),
778 HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT
),
779 HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT
),
780 HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT
),
781 HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT
),
782 HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT
),
784 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
785 .name
= "Input Source",
786 .info
= conexant_mux_enum_info
,
787 .get
= conexant_mux_enum_get
,
788 .put
= conexant_mux_enum_put
,
790 /* Audio input controls */
791 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT
),
792 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT
),
793 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT
),
794 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT
),
795 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT
),
796 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT
),
797 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT
),
798 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT
),
799 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT
),
800 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT
),
804 static struct hda_verb cxt5045_test_init_verbs
[] = {
805 /* Set connections */
806 { 0x10, AC_VERB_SET_CONNECT_SEL
, 0x0 },
807 { 0x11, AC_VERB_SET_CONNECT_SEL
, 0x0 },
808 { 0x12, AC_VERB_SET_CONNECT_SEL
, 0x0 },
809 /* Enable retasking pins as output, initially without power amp */
810 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
811 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
813 /* Disable digital (SPDIF) pins initially, but users can enable
814 * them via a mixer switch. In the case of SPDIF-out, this initverb
815 * payload also sets the generation to 0, output to be in "consumer"
816 * PCM format, copyright asserted, no pre-emphasis and no validity
819 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
820 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
822 /* Start with output sum widgets muted and their output gains at min */
823 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
824 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
826 /* Unmute retasking pin widget output buffers since the default
827 * state appears to be output. As the pin mode is changed by the
828 * user the pin mode control will take care of enabling the pin's
829 * input/output buffers as needed.
831 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
832 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
834 /* Mute capture amp left and right */
835 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
837 /* Set ADC connection select to match default mixer setting (mic1
840 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
841 {0x17, AC_VERB_SET_CONNECT_SEL
, 0x00},
843 /* Mute all inputs to mixer widget (even unconnected ones) */
844 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* Mixer pin */
845 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* Mic1 pin */
846 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* Line pin */
847 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* HP pin */
848 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
855 /* initialize jack-sensing, too */
856 static int cxt5045_init(struct hda_codec
*codec
)
858 conexant_init(codec
);
859 cxt5045_hp_automute(codec
);
865 CXT5045_LAPTOP_HPSENSE
,
866 CXT5045_LAPTOP_MICSENSE
,
867 CXT5045_LAPTOP_HPMICSENSE
,
869 CXT5045_LAPTOP_HP530
,
870 #ifdef CONFIG_SND_DEBUG
876 static const char *cxt5045_models
[CXT5045_MODELS
] = {
877 [CXT5045_LAPTOP_HPSENSE
] = "laptop-hpsense",
878 [CXT5045_LAPTOP_MICSENSE
] = "laptop-micsense",
879 [CXT5045_LAPTOP_HPMICSENSE
] = "laptop-hpmicsense",
880 [CXT5045_BENQ
] = "benq",
881 [CXT5045_LAPTOP_HP530
] = "laptop-hp530",
882 #ifdef CONFIG_SND_DEBUG
883 [CXT5045_TEST
] = "test",
887 static struct snd_pci_quirk cxt5045_cfg_tbl
[] = {
888 SND_PCI_QUIRK(0x103c, 0x30a5, "HP", CXT5045_LAPTOP_HPSENSE
),
889 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV Series", CXT5045_LAPTOP_HPSENSE
),
890 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2120", CXT5045_LAPTOP_HPSENSE
),
891 SND_PCI_QUIRK(0x103c, 0x30b7, "HP DV6000Z", CXT5045_LAPTOP_HPSENSE
),
892 SND_PCI_QUIRK(0x103c, 0x30bb, "HP DV8000", CXT5045_LAPTOP_HPSENSE
),
893 SND_PCI_QUIRK(0x103c, 0x30cd, "HP DV Series", CXT5045_LAPTOP_HPSENSE
),
894 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV9533EG", CXT5045_LAPTOP_HPSENSE
),
895 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530
),
896 SND_PCI_QUIRK(0x103c, 0x30d9, "HP Spartan", CXT5045_LAPTOP_HPSENSE
),
897 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE
),
898 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ
),
899 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE
),
900 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE
),
901 SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505",
902 CXT5045_LAPTOP_HPMICSENSE
),
903 SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
904 SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
905 SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE
),
906 SND_PCI_QUIRK(0x1631, 0xc106, "Packard Bell", CXT5045_LAPTOP_HPMICSENSE
),
907 SND_PCI_QUIRK(0x1631, 0xc107, "Packard Bell", CXT5045_LAPTOP_HPMICSENSE
),
908 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE
),
912 static int patch_cxt5045(struct hda_codec
*codec
)
914 struct conexant_spec
*spec
;
917 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
922 spec
->multiout
.max_channels
= 2;
923 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5045_dac_nids
);
924 spec
->multiout
.dac_nids
= cxt5045_dac_nids
;
925 spec
->multiout
.dig_out_nid
= CXT5045_SPDIF_OUT
;
926 spec
->num_adc_nids
= 1;
927 spec
->adc_nids
= cxt5045_adc_nids
;
928 spec
->capsrc_nids
= cxt5045_capsrc_nids
;
929 spec
->input_mux
= &cxt5045_capture_source
;
930 spec
->num_mixers
= 1;
931 spec
->mixers
[0] = cxt5045_mixers
;
932 spec
->num_init_verbs
= 1;
933 spec
->init_verbs
[0] = cxt5045_init_verbs
;
934 spec
->spdif_route
= 0;
935 spec
->num_channel_mode
= ARRAY_SIZE(cxt5045_modes
),
936 spec
->channel_mode
= cxt5045_modes
,
939 codec
->patch_ops
= conexant_patch_ops
;
941 board_config
= snd_hda_check_board_config(codec
, CXT5045_MODELS
,
944 switch (board_config
) {
945 case CXT5045_LAPTOP_HPSENSE
:
946 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
947 spec
->input_mux
= &cxt5045_capture_source
;
948 spec
->num_init_verbs
= 2;
949 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
950 spec
->mixers
[0] = cxt5045_mixers
;
951 codec
->patch_ops
.init
= cxt5045_init
;
953 case CXT5045_LAPTOP_MICSENSE
:
954 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
955 spec
->input_mux
= &cxt5045_capture_source
;
956 spec
->num_init_verbs
= 2;
957 spec
->init_verbs
[1] = cxt5045_mic_sense_init_verbs
;
958 spec
->mixers
[0] = cxt5045_mixers
;
959 codec
->patch_ops
.init
= cxt5045_init
;
962 case CXT5045_LAPTOP_HPMICSENSE
:
963 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
964 spec
->input_mux
= &cxt5045_capture_source
;
965 spec
->num_init_verbs
= 3;
966 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
967 spec
->init_verbs
[2] = cxt5045_mic_sense_init_verbs
;
968 spec
->mixers
[0] = cxt5045_mixers
;
969 codec
->patch_ops
.init
= cxt5045_init
;
972 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
973 spec
->input_mux
= &cxt5045_capture_source_benq
;
974 spec
->num_init_verbs
= 1;
975 spec
->init_verbs
[0] = cxt5045_benq_init_verbs
;
976 spec
->mixers
[0] = cxt5045_mixers
;
977 spec
->mixers
[1] = cxt5045_benq_mixers
;
978 spec
->num_mixers
= 2;
979 codec
->patch_ops
.init
= cxt5045_init
;
981 case CXT5045_LAPTOP_HP530
:
982 codec
->patch_ops
.unsol_event
= cxt5045_hp_unsol_event
;
983 spec
->input_mux
= &cxt5045_capture_source_hp530
;
984 spec
->num_init_verbs
= 2;
985 spec
->init_verbs
[1] = cxt5045_hp_sense_init_verbs
;
986 spec
->mixers
[0] = cxt5045_mixers_hp530
;
987 codec
->patch_ops
.init
= cxt5045_init
;
989 #ifdef CONFIG_SND_DEBUG
991 spec
->input_mux
= &cxt5045_test_capture_source
;
992 spec
->mixers
[0] = cxt5045_test_mixer
;
993 spec
->init_verbs
[0] = cxt5045_test_init_verbs
;
999 switch (codec
->subsystem_id
>> 16) {
1001 /* HP laptop has a really bad sound over 0dB on NID 0x17.
1002 * Fix max PCM level to 0 dB
1003 * (originall it has 0x2b steps with 0dB offset 0x14)
1005 snd_hda_override_amp_caps(codec
, 0x17, HDA_INPUT
,
1006 (0x14 << AC_AMPCAP_OFFSET_SHIFT
) |
1007 (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
1008 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
1009 (1 << AC_AMPCAP_MUTE_SHIFT
));
1017 /* Conexant 5047 specific */
1018 #define CXT5047_SPDIF_OUT 0x11
1020 static hda_nid_t cxt5047_dac_nids
[2] = { 0x10, 0x1c };
1021 static hda_nid_t cxt5047_adc_nids
[1] = { 0x12 };
1022 static hda_nid_t cxt5047_capsrc_nids
[1] = { 0x1a };
1024 static struct hda_channel_mode cxt5047_modes
[1] = {
1028 static struct hda_input_mux cxt5047_capture_source
= {
1035 static struct hda_input_mux cxt5047_hp_capture_source
= {
1042 static struct hda_input_mux cxt5047_toshiba_capture_source
= {
1050 /* turn on/off EAPD (+ mute HP) as a master switch */
1051 static int cxt5047_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1052 struct snd_ctl_elem_value
*ucontrol
)
1054 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1055 struct conexant_spec
*spec
= codec
->spec
;
1058 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1061 /* toggle internal speakers mute depending of presence of
1062 * the headphone jack
1064 bits
= (!spec
->hp_present
&& spec
->cur_eapd
) ? 0 : HDA_AMP_MUTE
;
1065 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0,
1066 HDA_AMP_MUTE
, bits
);
1067 bits
= spec
->cur_eapd
? 0 : HDA_AMP_MUTE
;
1068 snd_hda_codec_amp_stereo(codec
, 0x13, HDA_OUTPUT
, 0,
1069 HDA_AMP_MUTE
, bits
);
1073 /* bind volumes of both NID 0x13 (Headphones) and 0x1d (Speakers) */
1074 static struct hda_bind_ctls cxt5047_bind_master_vol
= {
1075 .ops
= &snd_hda_bind_vol
,
1077 HDA_COMPOSE_AMP_VAL(0x13, 3, 0, HDA_OUTPUT
),
1078 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT
),
1083 /* mute internal speaker if HP is plugged */
1084 static void cxt5047_hp_automute(struct hda_codec
*codec
)
1086 struct conexant_spec
*spec
= codec
->spec
;
1089 spec
->hp_present
= snd_hda_codec_read(codec
, 0x13, 0,
1090 AC_VERB_GET_PIN_SENSE
, 0) & 0x80000000;
1092 bits
= (spec
->hp_present
|| !spec
->cur_eapd
) ? HDA_AMP_MUTE
: 0;
1093 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0,
1094 HDA_AMP_MUTE
, bits
);
1095 /* Mute/Unmute PCM 2 for good measure - some systems need this */
1096 snd_hda_codec_amp_stereo(codec
, 0x1c, HDA_OUTPUT
, 0,
1097 HDA_AMP_MUTE
, bits
);
1100 /* mute internal speaker if HP is plugged */
1101 static void cxt5047_hp2_automute(struct hda_codec
*codec
)
1103 struct conexant_spec
*spec
= codec
->spec
;
1106 spec
->hp_present
= snd_hda_codec_read(codec
, 0x13, 0,
1107 AC_VERB_GET_PIN_SENSE
, 0) & 0x80000000;
1109 bits
= spec
->hp_present
? HDA_AMP_MUTE
: 0;
1110 snd_hda_codec_amp_stereo(codec
, 0x1d, HDA_OUTPUT
, 0,
1111 HDA_AMP_MUTE
, bits
);
1112 /* Mute/Unmute PCM 2 for good measure - some systems need this */
1113 snd_hda_codec_amp_stereo(codec
, 0x1c, HDA_OUTPUT
, 0,
1114 HDA_AMP_MUTE
, bits
);
1117 /* toggle input of built-in and mic jack appropriately */
1118 static void cxt5047_hp_automic(struct hda_codec
*codec
)
1120 static struct hda_verb mic_jack_on
[] = {
1121 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1122 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1125 static struct hda_verb mic_jack_off
[] = {
1126 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1127 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1130 unsigned int present
;
1132 present
= snd_hda_codec_read(codec
, 0x15, 0,
1133 AC_VERB_GET_PIN_SENSE
, 0) & 0x80000000;
1135 snd_hda_sequence_write(codec
, mic_jack_on
);
1137 snd_hda_sequence_write(codec
, mic_jack_off
);
1140 /* unsolicited event for HP jack sensing */
1141 static void cxt5047_hp_unsol_event(struct hda_codec
*codec
,
1144 switch (res
>> 26) {
1145 case CONEXANT_HP_EVENT
:
1146 cxt5047_hp_automute(codec
);
1148 case CONEXANT_MIC_EVENT
:
1149 cxt5047_hp_automic(codec
);
1154 /* unsolicited event for HP jack sensing - non-EAPD systems */
1155 static void cxt5047_hp2_unsol_event(struct hda_codec
*codec
,
1160 case CONEXANT_HP_EVENT
:
1161 cxt5047_hp2_automute(codec
);
1163 case CONEXANT_MIC_EVENT
:
1164 cxt5047_hp_automic(codec
);
1169 static struct snd_kcontrol_new cxt5047_mixers
[] = {
1170 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT
),
1171 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT
),
1172 HDA_CODEC_VOLUME("Mic Gain Volume", 0x1a, 0x0, HDA_OUTPUT
),
1173 HDA_CODEC_MUTE("Mic Gain Switch", 0x1a, 0x0, HDA_OUTPUT
),
1174 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT
),
1175 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT
),
1176 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT
),
1177 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT
),
1178 HDA_CODEC_VOLUME("PCM-2 Volume", 0x1c, 0x00, HDA_OUTPUT
),
1179 HDA_CODEC_MUTE("PCM-2 Switch", 0x1c, 0x00, HDA_OUTPUT
),
1180 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x00, HDA_OUTPUT
),
1181 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x00, HDA_OUTPUT
),
1182 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1183 HDA_CODEC_MUTE("Headphone Playback Switch", 0x13, 0x00, HDA_OUTPUT
),
1188 static struct snd_kcontrol_new cxt5047_toshiba_mixers
[] = {
1190 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1191 .name
= "Capture Source",
1192 .info
= conexant_mux_enum_info
,
1193 .get
= conexant_mux_enum_get
,
1194 .put
= conexant_mux_enum_put
1196 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT
),
1197 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT
),
1198 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT
),
1199 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT
),
1200 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT
),
1201 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT
),
1202 HDA_BIND_VOL("Master Playback Volume", &cxt5047_bind_master_vol
),
1204 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1205 .name
= "Master Playback Switch",
1206 .info
= cxt_eapd_info
,
1207 .get
= cxt_eapd_get
,
1208 .put
= cxt5047_hp_master_sw_put
,
1209 .private_value
= 0x13,
1215 static struct snd_kcontrol_new cxt5047_hp_mixers
[] = {
1217 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1218 .name
= "Capture Source",
1219 .info
= conexant_mux_enum_info
,
1220 .get
= conexant_mux_enum_get
,
1221 .put
= conexant_mux_enum_put
1223 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT
),
1224 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19,0x02,HDA_INPUT
),
1225 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT
),
1226 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT
),
1227 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT
),
1228 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT
),
1229 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT
),
1231 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1232 .name
= "Master Playback Switch",
1233 .info
= cxt_eapd_info
,
1234 .get
= cxt_eapd_get
,
1235 .put
= cxt5047_hp_master_sw_put
,
1236 .private_value
= 0x13,
1241 static struct hda_verb cxt5047_init_verbs
[] = {
1242 /* Line in, Mic, Built-in Mic */
1243 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1244 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1245 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
|AC_PINCTL_VREF_50
},
1247 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1248 {0x13, AC_VERB_SET_CONNECT_SEL
,0x1},
1249 {0x1d, AC_VERB_SET_CONNECT_SEL
,0x0},
1250 /* Record selector: Mic */
1251 {0x12, AC_VERB_SET_CONNECT_SEL
,0x03},
1252 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
,
1253 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
1254 {0x1A, AC_VERB_SET_CONNECT_SEL
,0x02},
1255 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1256 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x00},
1257 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE
,
1258 AC_AMP_SET_OUTPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x03},
1259 /* SPDIF route: PCM */
1260 { 0x18, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1261 /* Enable unsolicited events */
1262 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
1263 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
1267 /* configuration for Toshiba Laptops */
1268 static struct hda_verb cxt5047_toshiba_init_verbs
[] = {
1269 {0x13, AC_VERB_SET_EAPD_BTLENABLE
, 0x0 }, /* default on */
1270 /* pin sensing on HP and Mic jacks */
1271 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
1272 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_MIC_EVENT
},
1273 /* Speaker routing */
1274 {0x1d, AC_VERB_SET_CONNECT_SEL
,0x1},
1278 /* configuration for HP Laptops */
1279 static struct hda_verb cxt5047_hp_init_verbs
[] = {
1280 /* pin sensing on HP jack */
1281 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| CONEXANT_HP_EVENT
},
1282 /* 0x13 is actually shared by both HP and speaker;
1283 * setting the connection to 0 (=0x19) makes the master volume control
1284 * working mysteriouslly...
1286 {0x13, AC_VERB_SET_CONNECT_SEL
, 0x0},
1287 /* Record selector: Ext Mic */
1288 {0x12, AC_VERB_SET_CONNECT_SEL
,0x03},
1289 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
,
1290 AC_AMP_SET_INPUT
|AC_AMP_SET_RIGHT
|AC_AMP_SET_LEFT
|0x17},
1291 /* Speaker routing */
1292 {0x1d, AC_VERB_SET_CONNECT_SEL
,0x1},
1296 /* Test configuration for debugging, modelled after the ALC260 test
1299 #ifdef CONFIG_SND_DEBUG
1300 static struct hda_input_mux cxt5047_test_capture_source
= {
1303 { "LINE1 pin", 0x0 },
1304 { "MIC1 pin", 0x1 },
1305 { "MIC2 pin", 0x2 },
1310 static struct snd_kcontrol_new cxt5047_test_mixer
[] = {
1312 /* Output only controls */
1313 HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT
),
1314 HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT
),
1315 HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT
),
1316 HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT
),
1317 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
1318 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT
),
1319 HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
1320 HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
1321 HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT
),
1322 HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT
),
1323 HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT
),
1324 HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT
),
1326 /* Modes for retasking pin widgets */
1327 CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT
),
1328 CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT
),
1330 /* EAPD Switch Control */
1331 CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0),
1333 /* Loopback mixer controls */
1334 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT
),
1335 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT
),
1336 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT
),
1337 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT
),
1338 HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT
),
1339 HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT
),
1340 HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT
),
1341 HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT
),
1343 HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT
),
1344 HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT
),
1345 HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT
),
1346 HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT
),
1347 HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT
),
1348 HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT
),
1349 HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT
),
1350 HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT
),
1352 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1353 .name
= "Input Source",
1354 .info
= conexant_mux_enum_info
,
1355 .get
= conexant_mux_enum_get
,
1356 .put
= conexant_mux_enum_put
,
1358 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT
),
1359 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT
),
1360 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT
),
1361 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT
),
1362 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT
),
1363 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT
),
1364 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT
),
1365 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT
),
1366 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT
),
1367 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT
),
1372 static struct hda_verb cxt5047_test_init_verbs
[] = {
1373 /* Enable retasking pins as output, initially without power amp */
1374 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1375 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1376 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1378 /* Disable digital (SPDIF) pins initially, but users can enable
1379 * them via a mixer switch. In the case of SPDIF-out, this initverb
1380 * payload also sets the generation to 0, output to be in "consumer"
1381 * PCM format, copyright asserted, no pre-emphasis and no validity
1384 {0x18, AC_VERB_SET_DIGI_CONVERT_1
, 0},
1386 /* Ensure mic1, mic2, line1 pin widgets take input from the
1387 * OUT1 sum bus when acting as an output.
1389 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0},
1390 {0x1b, AC_VERB_SET_CONNECT_SEL
, 0},
1392 /* Start with output sum widgets muted and their output gains at min */
1393 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1394 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1396 /* Unmute retasking pin widget output buffers since the default
1397 * state appears to be output. As the pin mode is changed by the
1398 * user the pin mode control will take care of enabling the pin's
1399 * input/output buffers as needed.
1401 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1402 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1403 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1405 /* Mute capture amp left and right */
1406 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1408 /* Set ADC connection select to match default mixer setting (mic1
1411 {0x12, AC_VERB_SET_CONNECT_SEL
, 0x00},
1413 /* Mute all inputs to mixer widget (even unconnected ones) */
1414 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* mic1 pin */
1415 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)}, /* mic2 pin */
1416 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)}, /* line1 pin */
1417 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)}, /* line2 pin */
1418 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)}, /* CD pin */
1419 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)}, /* Beep-gen pin */
1420 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)}, /* Line-out pin */
1421 {0x19, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)}, /* HP-pin pin */
1428 /* initialize jack-sensing, too */
1429 static int cxt5047_hp_init(struct hda_codec
*codec
)
1431 conexant_init(codec
);
1432 cxt5047_hp_automute(codec
);
1438 CXT5047_LAPTOP
, /* Laptops w/o EAPD support */
1439 CXT5047_LAPTOP_HP
, /* Some HP laptops */
1440 CXT5047_LAPTOP_EAPD
, /* Laptops with EAPD support */
1441 #ifdef CONFIG_SND_DEBUG
1447 static const char *cxt5047_models
[CXT5047_MODELS
] = {
1448 [CXT5047_LAPTOP
] = "laptop",
1449 [CXT5047_LAPTOP_HP
] = "laptop-hp",
1450 [CXT5047_LAPTOP_EAPD
] = "laptop-eapd",
1451 #ifdef CONFIG_SND_DEBUG
1452 [CXT5047_TEST
] = "test",
1456 static struct snd_pci_quirk cxt5047_cfg_tbl
[] = {
1457 SND_PCI_QUIRK(0x103c, 0x30a0, "HP DV1000", CXT5047_LAPTOP
),
1458 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP
),
1459 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV2000T/DV3000T", CXT5047_LAPTOP
),
1460 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2000Z", CXT5047_LAPTOP
),
1461 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD
),
1465 static int patch_cxt5047(struct hda_codec
*codec
)
1467 struct conexant_spec
*spec
;
1470 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1475 spec
->multiout
.max_channels
= 2;
1476 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5047_dac_nids
);
1477 spec
->multiout
.dac_nids
= cxt5047_dac_nids
;
1478 spec
->multiout
.dig_out_nid
= CXT5047_SPDIF_OUT
;
1479 spec
->num_adc_nids
= 1;
1480 spec
->adc_nids
= cxt5047_adc_nids
;
1481 spec
->capsrc_nids
= cxt5047_capsrc_nids
;
1482 spec
->input_mux
= &cxt5047_capture_source
;
1483 spec
->num_mixers
= 1;
1484 spec
->mixers
[0] = cxt5047_mixers
;
1485 spec
->num_init_verbs
= 1;
1486 spec
->init_verbs
[0] = cxt5047_init_verbs
;
1487 spec
->spdif_route
= 0;
1488 spec
->num_channel_mode
= ARRAY_SIZE(cxt5047_modes
),
1489 spec
->channel_mode
= cxt5047_modes
,
1491 codec
->patch_ops
= conexant_patch_ops
;
1493 board_config
= snd_hda_check_board_config(codec
, CXT5047_MODELS
,
1496 switch (board_config
) {
1497 case CXT5047_LAPTOP
:
1498 codec
->patch_ops
.unsol_event
= cxt5047_hp2_unsol_event
;
1500 case CXT5047_LAPTOP_HP
:
1501 spec
->input_mux
= &cxt5047_hp_capture_source
;
1502 spec
->num_init_verbs
= 2;
1503 spec
->init_verbs
[1] = cxt5047_hp_init_verbs
;
1504 spec
->mixers
[0] = cxt5047_hp_mixers
;
1505 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1506 codec
->patch_ops
.init
= cxt5047_hp_init
;
1508 case CXT5047_LAPTOP_EAPD
:
1509 spec
->input_mux
= &cxt5047_toshiba_capture_source
;
1510 spec
->num_init_verbs
= 2;
1511 spec
->init_verbs
[1] = cxt5047_toshiba_init_verbs
;
1512 spec
->mixers
[0] = cxt5047_toshiba_mixers
;
1513 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1515 #ifdef CONFIG_SND_DEBUG
1517 spec
->input_mux
= &cxt5047_test_capture_source
;
1518 spec
->mixers
[0] = cxt5047_test_mixer
;
1519 spec
->init_verbs
[0] = cxt5047_test_init_verbs
;
1520 codec
->patch_ops
.unsol_event
= cxt5047_hp_unsol_event
;
1526 /* Conexant 5051 specific */
1527 static hda_nid_t cxt5051_dac_nids
[1] = { 0x10 };
1528 static hda_nid_t cxt5051_adc_nids
[2] = { 0x14, 0x15 };
1529 #define CXT5051_SPDIF_OUT 0x1C
1530 #define CXT5051_PORTB_EVENT 0x38
1531 #define CXT5051_PORTC_EVENT 0x39
1533 static struct hda_channel_mode cxt5051_modes
[1] = {
1537 static void cxt5051_update_speaker(struct hda_codec
*codec
)
1539 struct conexant_spec
*spec
= codec
->spec
;
1540 unsigned int pinctl
;
1541 pinctl
= (!spec
->hp_present
&& spec
->cur_eapd
) ? PIN_OUT
: 0;
1542 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
1546 /* turn on/off EAPD (+ mute HP) as a master switch */
1547 static int cxt5051_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1548 struct snd_ctl_elem_value
*ucontrol
)
1550 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1552 if (!cxt_eapd_put(kcontrol
, ucontrol
))
1554 cxt5051_update_speaker(codec
);
1558 /* toggle input of built-in and mic jack appropriately */
1559 static void cxt5051_portb_automic(struct hda_codec
*codec
)
1561 unsigned int present
;
1563 present
= snd_hda_codec_read(codec
, 0x17, 0,
1564 AC_VERB_GET_PIN_SENSE
, 0) &
1565 AC_PINSENSE_PRESENCE
;
1566 snd_hda_codec_write(codec
, 0x14, 0,
1567 AC_VERB_SET_CONNECT_SEL
,
1568 present
? 0x01 : 0x00);
1571 /* switch the current ADC according to the jack state */
1572 static void cxt5051_portc_automic(struct hda_codec
*codec
)
1574 struct conexant_spec
*spec
= codec
->spec
;
1575 unsigned int present
;
1578 present
= snd_hda_codec_read(codec
, 0x18, 0,
1579 AC_VERB_GET_PIN_SENSE
, 0) &
1580 AC_PINSENSE_PRESENCE
;
1582 spec
->cur_adc_idx
= 1;
1584 spec
->cur_adc_idx
= 0;
1585 new_adc
= spec
->adc_nids
[spec
->cur_adc_idx
];
1586 if (spec
->cur_adc
&& spec
->cur_adc
!= new_adc
) {
1587 /* stream is running, let's swap the current ADC */
1588 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
1589 spec
->cur_adc
= new_adc
;
1590 snd_hda_codec_setup_stream(codec
, new_adc
,
1591 spec
->cur_adc_stream_tag
, 0,
1592 spec
->cur_adc_format
);
1596 /* mute internal speaker if HP is plugged */
1597 static void cxt5051_hp_automute(struct hda_codec
*codec
)
1599 struct conexant_spec
*spec
= codec
->spec
;
1601 spec
->hp_present
= snd_hda_codec_read(codec
, 0x16, 0,
1602 AC_VERB_GET_PIN_SENSE
, 0) &
1603 AC_PINSENSE_PRESENCE
;
1604 cxt5051_update_speaker(codec
);
1607 /* unsolicited event for HP jack sensing */
1608 static void cxt5051_hp_unsol_event(struct hda_codec
*codec
,
1611 switch (res
>> 26) {
1612 case CONEXANT_HP_EVENT
:
1613 cxt5051_hp_automute(codec
);
1615 case CXT5051_PORTB_EVENT
:
1616 cxt5051_portb_automic(codec
);
1618 case CXT5051_PORTC_EVENT
:
1619 cxt5051_portc_automic(codec
);
1624 static struct snd_kcontrol_new cxt5051_mixers
[] = {
1625 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1626 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1627 HDA_CODEC_VOLUME("External Mic Volume", 0x14, 0x01, HDA_INPUT
),
1628 HDA_CODEC_MUTE("External Mic Switch", 0x14, 0x01, HDA_INPUT
),
1629 HDA_CODEC_VOLUME("Docking Mic Volume", 0x15, 0x00, HDA_INPUT
),
1630 HDA_CODEC_MUTE("Docking Mic Switch", 0x15, 0x00, HDA_INPUT
),
1631 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
1633 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1634 .name
= "Master Playback Switch",
1635 .info
= cxt_eapd_info
,
1636 .get
= cxt_eapd_get
,
1637 .put
= cxt5051_hp_master_sw_put
,
1638 .private_value
= 0x1a,
1644 static struct snd_kcontrol_new cxt5051_hp_mixers
[] = {
1645 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT
),
1646 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT
),
1647 HDA_CODEC_VOLUME("External Mic Volume", 0x15, 0x00, HDA_INPUT
),
1648 HDA_CODEC_MUTE("External Mic Switch", 0x15, 0x00, HDA_INPUT
),
1649 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT
),
1651 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1652 .name
= "Master Playback Switch",
1653 .info
= cxt_eapd_info
,
1654 .get
= cxt_eapd_get
,
1655 .put
= cxt5051_hp_master_sw_put
,
1656 .private_value
= 0x1a,
1662 static struct hda_verb cxt5051_init_verbs
[] = {
1664 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1665 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1666 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1667 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1668 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1669 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x03},
1671 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1672 {0x1a, AC_VERB_SET_CONNECT_SEL
, 0x00},
1674 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1675 {0x16, AC_VERB_SET_CONNECT_SEL
, 0x00},
1677 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1678 /* Record selector: Int mic */
1679 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1680 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1) | 0x44},
1681 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x44},
1682 /* SPDIF route: PCM */
1683 {0x1c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1685 {0x1a, AC_VERB_SET_EAPD_BTLENABLE
, 0x2}, /* default on */
1686 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CONEXANT_HP_EVENT
},
1687 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CXT5051_PORTB_EVENT
},
1688 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
|CXT5051_PORTC_EVENT
},
1692 /* initialize jack-sensing, too */
1693 static int cxt5051_init(struct hda_codec
*codec
)
1695 conexant_init(codec
);
1696 if (codec
->patch_ops
.unsol_event
) {
1697 cxt5051_hp_automute(codec
);
1698 cxt5051_portb_automic(codec
);
1699 cxt5051_portc_automic(codec
);
1706 CXT5051_LAPTOP
, /* Laptops w/ EAPD support */
1707 CXT5051_HP
, /* no docking */
1711 static const char *cxt5051_models
[CXT5051_MODELS
] = {
1712 [CXT5051_LAPTOP
] = "laptop",
1713 [CXT5051_HP
] = "hp",
1716 static struct snd_pci_quirk cxt5051_cfg_tbl
[] = {
1717 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
1719 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP
),
1723 static int patch_cxt5051(struct hda_codec
*codec
)
1725 struct conexant_spec
*spec
;
1728 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1733 codec
->patch_ops
= conexant_patch_ops
;
1734 codec
->patch_ops
.init
= cxt5051_init
;
1736 spec
->multiout
.max_channels
= 2;
1737 spec
->multiout
.num_dacs
= ARRAY_SIZE(cxt5051_dac_nids
);
1738 spec
->multiout
.dac_nids
= cxt5051_dac_nids
;
1739 spec
->multiout
.dig_out_nid
= CXT5051_SPDIF_OUT
;
1740 spec
->num_adc_nids
= 1; /* not 2; via auto-mic switch */
1741 spec
->adc_nids
= cxt5051_adc_nids
;
1742 spec
->num_mixers
= 1;
1743 spec
->mixers
[0] = cxt5051_mixers
;
1744 spec
->num_init_verbs
= 1;
1745 spec
->init_verbs
[0] = cxt5051_init_verbs
;
1746 spec
->spdif_route
= 0;
1747 spec
->num_channel_mode
= ARRAY_SIZE(cxt5051_modes
);
1748 spec
->channel_mode
= cxt5051_modes
;
1750 spec
->cur_adc_idx
= 0;
1752 board_config
= snd_hda_check_board_config(codec
, CXT5051_MODELS
,
1755 switch (board_config
) {
1757 codec
->patch_ops
.unsol_event
= cxt5051_hp_unsol_event
;
1758 spec
->mixers
[0] = cxt5051_hp_mixers
;
1761 case CXT5051_LAPTOP
:
1762 codec
->patch_ops
.unsol_event
= cxt5051_hp_unsol_event
;
1773 static struct hda_codec_preset snd_hda_preset_conexant
[] = {
1774 { .id
= 0x14f15045, .name
= "CX20549 (Venice)",
1775 .patch
= patch_cxt5045
},
1776 { .id
= 0x14f15047, .name
= "CX20551 (Waikiki)",
1777 .patch
= patch_cxt5047
},
1778 { .id
= 0x14f15051, .name
= "CX20561 (Hermosa)",
1779 .patch
= patch_cxt5051
},
1783 MODULE_ALIAS("snd-hda-codec-id:14f15045");
1784 MODULE_ALIAS("snd-hda-codec-id:14f15047");
1785 MODULE_ALIAS("snd-hda-codec-id:14f15051");
1787 MODULE_LICENSE("GPL");
1788 MODULE_DESCRIPTION("Conexant HD-audio codec");
1790 static struct hda_codec_preset_list conexant_list
= {
1791 .preset
= snd_hda_preset_conexant
,
1792 .owner
= THIS_MODULE
,
1795 static int __init
patch_conexant_init(void)
1797 return snd_hda_add_codec_preset(&conexant_list
);
1800 static void __exit
patch_conexant_exit(void)
1802 snd_hda_delete_codec_preset(&conexant_list
);
1805 module_init(patch_conexant_init
)
1806 module_exit(patch_conexant_exit
)