blob: c7fb0b8dfb8ffaf4fc34b30f4b25748672a06a52 [file] [log] [blame]
Tobin Davisc9b443d2006-11-14 12:13:39 +01001/*
2 * HD audio interface patch for Conexant HDA audio codec
3 *
4 * Copyright (c) 2006 Pototskiy Akex <alex.pototskiy@gmail.com>
5 * Takashi Iwai <tiwai@suse.de>
6 * Tobin Davis <tdavis@dsl-only.net>
7 *
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.
12 *
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.
17 *
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
21 */
22
23#include <sound/driver.h>
24#include <linux/init.h>
25#include <linux/delay.h>
26#include <linux/slab.h>
27#include <linux/pci.h>
28#include <sound/core.h>
29#include "hda_codec.h"
30#include "hda_local.h"
31
32#define CXT_PIN_DIR_IN 0x00
33#define CXT_PIN_DIR_OUT 0x01
34#define CXT_PIN_DIR_INOUT 0x02
35#define CXT_PIN_DIR_IN_NOMICBIAS 0x03
36#define CXT_PIN_DIR_INOUT_NOMICBIAS 0x04
37
38#define CONEXANT_HP_EVENT 0x37
39#define CONEXANT_MIC_EVENT 0x38
40
41
42
43struct conexant_spec {
44
45 struct snd_kcontrol_new *mixers[5];
46 int num_mixers;
47
48 const struct hda_verb *init_verbs[5]; /* initialization verbs
49 * don't forget NULL
50 * termination!
51 */
52 unsigned int num_init_verbs;
53
54 /* playback */
55 struct hda_multi_out multiout; /* playback set-up
56 * max_channels, dacs must be set
57 * dig_out_nid and hp_nid are optional
58 */
59 unsigned int cur_eapd;
Tobin Davis82f30042007-02-13 12:45:44 +010060 unsigned int hp_present;
Tobin Davisc9b443d2006-11-14 12:13:39 +010061 unsigned int need_dac_fix;
62
63 /* capture */
64 unsigned int num_adc_nids;
65 hda_nid_t *adc_nids;
66 hda_nid_t dig_in_nid; /* digital-in NID; optional */
67
68 /* capture source */
69 const struct hda_input_mux *input_mux;
70 hda_nid_t *capsrc_nids;
71 unsigned int cur_mux[3];
72
73 /* channel model */
74 const struct hda_channel_mode *channel_mode;
75 int num_channel_mode;
76
77 /* PCM information */
78 struct hda_pcm pcm_rec[2]; /* used in build_pcms() */
79
80 struct mutex amp_mutex; /* PCM volume/mute control mutex */
81 unsigned int spdif_route;
82
83 /* dynamic controls, init_verbs and input_mux */
84 struct auto_pin_cfg autocfg;
85 unsigned int num_kctl_alloc, num_kctl_used;
86 struct snd_kcontrol_new *kctl_alloc;
87 struct hda_input_mux private_imux;
88 hda_nid_t private_dac_nids[4];
89
90};
91
92static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo,
93 struct hda_codec *codec,
94 struct snd_pcm_substream *substream)
95{
96 struct conexant_spec *spec = codec->spec;
97 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
98}
99
100static int conexant_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
101 struct hda_codec *codec,
102 unsigned int stream_tag,
103 unsigned int format,
104 struct snd_pcm_substream *substream)
105{
106 struct conexant_spec *spec = codec->spec;
107 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
108 stream_tag,
109 format, substream);
110}
111
112static int conexant_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
113 struct hda_codec *codec,
114 struct snd_pcm_substream *substream)
115{
116 struct conexant_spec *spec = codec->spec;
117 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
118}
119
120/*
121 * Digital out
122 */
123static int conexant_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
124 struct hda_codec *codec,
125 struct snd_pcm_substream *substream)
126{
127 struct conexant_spec *spec = codec->spec;
128 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
129}
130
131static int conexant_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
132 struct hda_codec *codec,
133 struct snd_pcm_substream *substream)
134{
135 struct conexant_spec *spec = codec->spec;
136 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
137}
138
139/*
140 * Analog capture
141 */
142static int conexant_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
143 struct hda_codec *codec,
144 unsigned int stream_tag,
145 unsigned int format,
146 struct snd_pcm_substream *substream)
147{
148 struct conexant_spec *spec = codec->spec;
149 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
150 stream_tag, 0, format);
151 return 0;
152}
153
154static int conexant_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
155 struct hda_codec *codec,
156 struct snd_pcm_substream *substream)
157{
158 struct conexant_spec *spec = codec->spec;
159 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
160 0, 0, 0);
161 return 0;
162}
163
164
165
166static struct hda_pcm_stream conexant_pcm_analog_playback = {
167 .substreams = 1,
168 .channels_min = 2,
169 .channels_max = 2,
170 .nid = 0, /* fill later */
171 .ops = {
172 .open = conexant_playback_pcm_open,
173 .prepare = conexant_playback_pcm_prepare,
174 .cleanup = conexant_playback_pcm_cleanup
175 },
176};
177
178static struct hda_pcm_stream conexant_pcm_analog_capture = {
179 .substreams = 1,
180 .channels_min = 2,
181 .channels_max = 2,
182 .nid = 0, /* fill later */
183 .ops = {
184 .prepare = conexant_capture_pcm_prepare,
185 .cleanup = conexant_capture_pcm_cleanup
186 },
187};
188
189
190static struct hda_pcm_stream conexant_pcm_digital_playback = {
191 .substreams = 1,
192 .channels_min = 2,
193 .channels_max = 2,
194 .nid = 0, /* fill later */
195 .ops = {
196 .open = conexant_dig_playback_pcm_open,
197 .close = conexant_dig_playback_pcm_close
198 },
199};
200
201static struct hda_pcm_stream conexant_pcm_digital_capture = {
202 .substreams = 1,
203 .channels_min = 2,
204 .channels_max = 2,
205 /* NID is set in alc_build_pcms */
206};
207
208static int conexant_build_pcms(struct hda_codec *codec)
209{
210 struct conexant_spec *spec = codec->spec;
211 struct hda_pcm *info = spec->pcm_rec;
212
213 codec->num_pcms = 1;
214 codec->pcm_info = info;
215
216 info->name = "CONEXANT Analog";
217 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = conexant_pcm_analog_playback;
218 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max =
219 spec->multiout.max_channels;
220 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
221 spec->multiout.dac_nids[0];
222 info->stream[SNDRV_PCM_STREAM_CAPTURE] = conexant_pcm_analog_capture;
223 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adc_nids;
224 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
225
226 if (spec->multiout.dig_out_nid) {
227 info++;
228 codec->num_pcms++;
229 info->name = "Conexant Digital";
230 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
231 conexant_pcm_digital_playback;
232 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
233 spec->multiout.dig_out_nid;
234 if (spec->dig_in_nid) {
235 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
236 conexant_pcm_digital_capture;
237 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
238 spec->dig_in_nid;
239 }
240 }
241
242 return 0;
243}
244
245static int conexant_mux_enum_info(struct snd_kcontrol *kcontrol,
246 struct snd_ctl_elem_info *uinfo)
247{
248 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
249 struct conexant_spec *spec = codec->spec;
250
251 return snd_hda_input_mux_info(spec->input_mux, uinfo);
252}
253
254static int conexant_mux_enum_get(struct snd_kcontrol *kcontrol,
255 struct snd_ctl_elem_value *ucontrol)
256{
257 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
258 struct conexant_spec *spec = codec->spec;
259 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
260
261 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
262 return 0;
263}
264
265static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol,
266 struct snd_ctl_elem_value *ucontrol)
267{
268 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
269 struct conexant_spec *spec = codec->spec;
270 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
271
272 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
273 spec->capsrc_nids[adc_idx],
274 &spec->cur_mux[adc_idx]);
275}
276
277static int conexant_init(struct hda_codec *codec)
278{
279 struct conexant_spec *spec = codec->spec;
280 int i;
281
282 for (i = 0; i < spec->num_init_verbs; i++)
283 snd_hda_sequence_write(codec, spec->init_verbs[i]);
284 return 0;
285}
286
287static void conexant_free(struct hda_codec *codec)
288{
289 struct conexant_spec *spec = codec->spec;
290 unsigned int i;
291
292 if (spec->kctl_alloc) {
293 for (i = 0; i < spec->num_kctl_used; i++)
294 kfree(spec->kctl_alloc[i].name);
295 kfree(spec->kctl_alloc);
296 }
297
298 kfree(codec->spec);
299}
300
301#ifdef CONFIG_PM
302static int conexant_resume(struct hda_codec *codec)
303{
304 struct conexant_spec *spec = codec->spec;
305 int i;
306
307 codec->patch_ops.init(codec);
308 for (i = 0; i < spec->num_mixers; i++)
309 snd_hda_resume_ctls(codec, spec->mixers[i]);
310 if (spec->multiout.dig_out_nid)
311 snd_hda_resume_spdif_out(codec);
312 if (spec->dig_in_nid)
313 snd_hda_resume_spdif_in(codec);
314 return 0;
315}
316#endif
317
318static int conexant_build_controls(struct hda_codec *codec)
319{
320 struct conexant_spec *spec = codec->spec;
321 unsigned int i;
322 int err;
323
324 for (i = 0; i < spec->num_mixers; i++) {
325 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
326 if (err < 0)
327 return err;
328 }
329 if (spec->multiout.dig_out_nid) {
330 err = snd_hda_create_spdif_out_ctls(codec,
331 spec->multiout.dig_out_nid);
332 if (err < 0)
333 return err;
334 }
335 if (spec->dig_in_nid) {
336 err = snd_hda_create_spdif_in_ctls(codec,spec->dig_in_nid);
337 if (err < 0)
338 return err;
339 }
340 return 0;
341}
342
343static struct hda_codec_ops conexant_patch_ops = {
344 .build_controls = conexant_build_controls,
345 .build_pcms = conexant_build_pcms,
346 .init = conexant_init,
347 .free = conexant_free,
348#ifdef CONFIG_PM
349 .resume = conexant_resume,
350#endif
351};
352
353/*
354 * EAPD control
355 * the private value = nid | (invert << 8)
356 */
357
Tobin Davis82f30042007-02-13 12:45:44 +0100358static int cxt_eapd_info(struct snd_kcontrol *kcontrol,
Tobin Davisc9b443d2006-11-14 12:13:39 +0100359 struct snd_ctl_elem_info *uinfo)
360{
361 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
362 uinfo->count = 1;
363 uinfo->value.integer.min = 0;
364 uinfo->value.integer.max = 1;
365 return 0;
366}
367
Tobin Davis82f30042007-02-13 12:45:44 +0100368static int cxt_eapd_get(struct snd_kcontrol *kcontrol,
Tobin Davisc9b443d2006-11-14 12:13:39 +0100369 struct snd_ctl_elem_value *ucontrol)
370{
371 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
372 struct conexant_spec *spec = codec->spec;
373 int invert = (kcontrol->private_value >> 8) & 1;
374 if (invert)
375 ucontrol->value.integer.value[0] = !spec->cur_eapd;
376 else
377 ucontrol->value.integer.value[0] = spec->cur_eapd;
378 return 0;
Tobin Davis82f30042007-02-13 12:45:44 +0100379
Tobin Davisc9b443d2006-11-14 12:13:39 +0100380}
381
Tobin Davis82f30042007-02-13 12:45:44 +0100382static int cxt_eapd_put(struct snd_kcontrol *kcontrol,
Tobin Davisc9b443d2006-11-14 12:13:39 +0100383 struct snd_ctl_elem_value *ucontrol)
384{
385 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
386 struct conexant_spec *spec = codec->spec;
387 int invert = (kcontrol->private_value >> 8) & 1;
388 hda_nid_t nid = kcontrol->private_value & 0xff;
389 unsigned int eapd;
Tobin Davis82f30042007-02-13 12:45:44 +0100390
Tobin Davisc9b443d2006-11-14 12:13:39 +0100391 eapd = ucontrol->value.integer.value[0];
392 if (invert)
393 eapd = !eapd;
394 if (eapd == spec->cur_eapd && !codec->in_resume)
395 return 0;
Tobin Davis82f30042007-02-13 12:45:44 +0100396
Tobin Davisc9b443d2006-11-14 12:13:39 +0100397 spec->cur_eapd = eapd;
398 snd_hda_codec_write(codec, nid,
399 0, AC_VERB_SET_EAPD_BTLENABLE,
400 eapd ? 0x02 : 0x00);
401 return 1;
402}
403
Takashi Iwai86d72bd2006-11-28 11:33:10 +0100404/* controls for test mode */
405#ifdef CONFIG_SND_DEBUG
406
Tobin Davis82f30042007-02-13 12:45:44 +0100407#define CXT_EAPD_SWITCH(xname, nid, mask) \
408 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
409 .info = cxt_eapd_info, \
410 .get = cxt_eapd_get, \
411 .put = cxt_eapd_put, \
412 .private_value = nid | (mask<<16) }
413
414
415
Tobin Davisc9b443d2006-11-14 12:13:39 +0100416static int conexant_ch_mode_info(struct snd_kcontrol *kcontrol,
417 struct snd_ctl_elem_info *uinfo)
418{
419 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
420 struct conexant_spec *spec = codec->spec;
421 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
422 spec->num_channel_mode);
423}
424
425static int conexant_ch_mode_get(struct snd_kcontrol *kcontrol,
426 struct snd_ctl_elem_value *ucontrol)
427{
428 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
429 struct conexant_spec *spec = codec->spec;
430 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
431 spec->num_channel_mode,
432 spec->multiout.max_channels);
433}
434
435static int conexant_ch_mode_put(struct snd_kcontrol *kcontrol,
436 struct snd_ctl_elem_value *ucontrol)
437{
438 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
439 struct conexant_spec *spec = codec->spec;
440 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
441 spec->num_channel_mode,
442 &spec->multiout.max_channels);
443 if (err >= 0 && spec->need_dac_fix)
444 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
445 return err;
446}
447
448#define CXT_PIN_MODE(xname, nid, dir) \
449 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
450 .info = conexant_ch_mode_info, \
451 .get = conexant_ch_mode_get, \
452 .put = conexant_ch_mode_put, \
453 .private_value = nid | (dir<<16) }
454
Takashi Iwai86d72bd2006-11-28 11:33:10 +0100455#endif /* CONFIG_SND_DEBUG */
456
Tobin Davisc9b443d2006-11-14 12:13:39 +0100457/* Conexant 5045 specific */
458
459static hda_nid_t cxt5045_dac_nids[1] = { 0x19 };
460static hda_nid_t cxt5045_adc_nids[1] = { 0x1a };
461static hda_nid_t cxt5045_capsrc_nids[1] = { 0x1a };
462#define CXT5045_SPDIF_OUT 0x13
463
Tobin Davis5cd57522006-11-20 17:42:09 +0100464static struct hda_channel_mode cxt5045_modes[1] = {
465 { 2, NULL },
466};
Tobin Davisc9b443d2006-11-14 12:13:39 +0100467
468static struct hda_input_mux cxt5045_capture_source = {
469 .num_items = 2,
470 .items = {
Tobin Davis82f30042007-02-13 12:45:44 +0100471 { "IntMic", 0x1 },
Tobin Davisc9b443d2006-11-14 12:13:39 +0100472 { "LineIn", 0x2 },
473 }
474};
475
476/* turn on/off EAPD (+ mute HP) as a master switch */
477static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol,
478 struct snd_ctl_elem_value *ucontrol)
479{
480 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
481 struct conexant_spec *spec = codec->spec;
Tobin Davis82f30042007-02-13 12:45:44 +0100482 unsigned int bits;
Tobin Davisc9b443d2006-11-14 12:13:39 +0100483
Tobin Davis82f30042007-02-13 12:45:44 +0100484 if (!cxt_eapd_put(kcontrol, ucontrol))
Tobin Davisc9b443d2006-11-14 12:13:39 +0100485 return 0;
486
Tobin Davis82f30042007-02-13 12:45:44 +0100487 /* toggle internal speakers mute depending of presence of
488 * the headphone jack
489 */
490 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : 0x80;
491 snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0, 0x80, bits);
492 snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0, 0x80, bits);
Tobin Davis7f296732007-03-12 11:39:01 +0100493
Tobin Davis82f30042007-02-13 12:45:44 +0100494 bits = spec->cur_eapd ? 0 : 0x80;
495 snd_hda_codec_amp_update(codec, 0x11, 0, HDA_OUTPUT, 0, 0x80, bits);
496 snd_hda_codec_amp_update(codec, 0x11, 1, HDA_OUTPUT, 0, 0x80, bits);
Tobin Davisc9b443d2006-11-14 12:13:39 +0100497 return 1;
498}
499
500/* bind volumes of both NID 0x10 and 0x11 */
501static int cxt5045_hp_master_vol_put(struct snd_kcontrol *kcontrol,
502 struct snd_ctl_elem_value *ucontrol)
503{
504 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
505 long *valp = ucontrol->value.integer.value;
506 int change;
507
508 change = snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0,
509 0x7f, valp[0] & 0x7f);
510 change |= snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0,
511 0x7f, valp[1] & 0x7f);
512 snd_hda_codec_amp_update(codec, 0x11, 0, HDA_OUTPUT, 0,
513 0x7f, valp[0] & 0x7f);
514 snd_hda_codec_amp_update(codec, 0x11, 1, HDA_OUTPUT, 0,
515 0x7f, valp[1] & 0x7f);
516 return change;
517}
518
Tobin Davis7f296732007-03-12 11:39:01 +0100519/* toggle input of built-in and mic jack appropriately */
520static void cxt5045_hp_automic(struct hda_codec *codec)
521{
522 static struct hda_verb mic_jack_on[] = {
523 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
524 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
525 {}
526 };
527 static struct hda_verb mic_jack_off[] = {
528 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
529 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
530 {}
531 };
532 unsigned int present;
533
534 present = snd_hda_codec_read(codec, 0x12, 0,
535 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
536 if (present)
537 snd_hda_sequence_write(codec, mic_jack_on);
538 else
539 snd_hda_sequence_write(codec, mic_jack_off);
540}
541
Tobin Davisc9b443d2006-11-14 12:13:39 +0100542
543/* mute internal speaker if HP is plugged */
544static void cxt5045_hp_automute(struct hda_codec *codec)
545{
Tobin Davis82f30042007-02-13 12:45:44 +0100546 struct conexant_spec *spec = codec->spec;
Tobin Davisdd87da12007-02-26 16:07:42 +0100547 unsigned int bits;
Tobin Davisc9b443d2006-11-14 12:13:39 +0100548
Tobin Davis82f30042007-02-13 12:45:44 +0100549 spec->hp_present = snd_hda_codec_read(codec, 0x11, 0,
Tobin Davisc9b443d2006-11-14 12:13:39 +0100550 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Tobin Davisdd87da12007-02-26 16:07:42 +0100551
Tobin Davis7f296732007-03-12 11:39:01 +0100552 bits = (spec->hp_present || !spec->cur_eapd) ? 0x80 : 0;
Tobin Davis82f30042007-02-13 12:45:44 +0100553 snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0, 0x80, bits);
554 snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0, 0x80, bits);
Tobin Davisc9b443d2006-11-14 12:13:39 +0100555}
556
557/* unsolicited event for HP jack sensing */
558static void cxt5045_hp_unsol_event(struct hda_codec *codec,
559 unsigned int res)
560{
561 res >>= 26;
562 switch (res) {
563 case CONEXANT_HP_EVENT:
564 cxt5045_hp_automute(codec);
565 break;
Tobin Davis7f296732007-03-12 11:39:01 +0100566 case CONEXANT_MIC_EVENT:
567 cxt5045_hp_automic(codec);
568 break;
569
Tobin Davisc9b443d2006-11-14 12:13:39 +0100570 }
571}
572
573static struct snd_kcontrol_new cxt5045_mixers[] = {
574 {
575 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
576 .name = "Capture Source",
577 .info = conexant_mux_enum_info,
578 .get = conexant_mux_enum_get,
579 .put = conexant_mux_enum_put
580 },
Tobin Davis7f296732007-03-12 11:39:01 +0100581 HDA_CODEC_VOLUME("Int Mic Volume", 0x1a, 0x01, HDA_INPUT),
582 HDA_CODEC_MUTE("Int Mic Switch", 0x1a, 0x01, HDA_INPUT),
583 HDA_CODEC_VOLUME("Ext Mic Volume", 0x1a, 0x02, HDA_INPUT),
584 HDA_CODEC_MUTE("Ext Mic Switch", 0x1a, 0x02, HDA_INPUT),
Tobin Davisc9b443d2006-11-14 12:13:39 +0100585 {
586 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
587 .name = "Master Playback Volume",
588 .info = snd_hda_mixer_amp_volume_info,
589 .get = snd_hda_mixer_amp_volume_get,
590 .put = cxt5045_hp_master_vol_put,
Tobin Davis82f30042007-02-13 12:45:44 +0100591 .private_value = HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT),
Tobin Davisc9b443d2006-11-14 12:13:39 +0100592 },
593 {
594 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
595 .name = "Master Playback Switch",
Tobin Davis82f30042007-02-13 12:45:44 +0100596 .info = cxt_eapd_info,
597 .get = cxt_eapd_get,
Tobin Davisc9b443d2006-11-14 12:13:39 +0100598 .put = cxt5045_hp_master_sw_put,
Tobin Davis82f30042007-02-13 12:45:44 +0100599 .private_value = 0x10,
Tobin Davisc9b443d2006-11-14 12:13:39 +0100600 },
601
602 {}
603};
604
605static struct hda_verb cxt5045_init_verbs[] = {
606 /* Line in, Mic */
607 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Tobin Davis7f296732007-03-12 11:39:01 +0100608 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
Tobin Davisc9b443d2006-11-14 12:13:39 +0100609 /* HP, Amp */
Tobin Davis82f30042007-02-13 12:45:44 +0100610 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
611 {0x17, AC_VERB_SET_CONNECT_SEL,0x01},
Tobin Davisc9b443d2006-11-14 12:13:39 +0100612 {0x17, AC_VERB_SET_AMP_GAIN_MUTE,
Tobin Davis82f30042007-02-13 12:45:44 +0100613 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x01},
614 {0x17, AC_VERB_SET_AMP_GAIN_MUTE,
615 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x02},
616 {0x17, AC_VERB_SET_AMP_GAIN_MUTE,
617 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03},
618 {0x17, AC_VERB_SET_AMP_GAIN_MUTE,
619 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x04},
620 /* Record selector: Int mic */
Tobin Davis7f296732007-03-12 11:39:01 +0100621 {0x1a, AC_VERB_SET_CONNECT_SEL,0x1},
Tobin Davis82f30042007-02-13 12:45:44 +0100622 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE,
Tobin Davisc9b443d2006-11-14 12:13:39 +0100623 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
624 /* SPDIF route: PCM */
625 { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 },
Tobin Davisc9b443d2006-11-14 12:13:39 +0100626 /* EAPD */
Tobin Davis82f30042007-02-13 12:45:44 +0100627 {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */
Tobin Davisc9b443d2006-11-14 12:13:39 +0100628 { } /* end */
629};
630
Tobin Davis7f296732007-03-12 11:39:01 +0100631
632static struct hda_verb cxt5045_hp_sense_init_verbs[] = {
633 /* pin sensing on HP jack */
634 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
635};
636
637static struct hda_verb cxt5045_mic_sense_init_verbs[] = {
638 /* pin sensing on HP jack */
639 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
640};
641
Tobin Davisc9b443d2006-11-14 12:13:39 +0100642#ifdef CONFIG_SND_DEBUG
643/* Test configuration for debugging, modelled after the ALC260 test
644 * configuration.
645 */
646static struct hda_input_mux cxt5045_test_capture_source = {
647 .num_items = 5,
648 .items = {
649 { "MIXER", 0x0 },
650 { "MIC1 pin", 0x1 },
651 { "LINE1 pin", 0x2 },
652 { "HP-OUT pin", 0x3 },
653 { "CD pin", 0x4 },
654 },
655};
656
657static struct snd_kcontrol_new cxt5045_test_mixer[] = {
658
659 /* Output controls */
Tobin Davisc9b443d2006-11-14 12:13:39 +0100660 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT),
661 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT),
Tobin Davis7f296732007-03-12 11:39:01 +0100662 HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT),
663 HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT),
664 HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT),
665 HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT),
Tobin Davisc9b443d2006-11-14 12:13:39 +0100666
667 /* Modes for retasking pin widgets */
668 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT),
669 CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT),
670
Tobin Davis82f30042007-02-13 12:45:44 +0100671 /* EAPD Switch Control */
672 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
673
Tobin Davisc9b443d2006-11-14 12:13:39 +0100674 /* Loopback mixer controls */
Tobin Davisc9b443d2006-11-14 12:13:39 +0100675
Tobin Davis7f296732007-03-12 11:39:01 +0100676 HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT),
677 HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT),
678 HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT),
679 HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT),
680 HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT),
681 HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT),
682 HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT),
683 HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT),
684 HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT),
685 HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT),
Tobin Davisc9b443d2006-11-14 12:13:39 +0100686 {
687 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
688 .name = "Input Source",
689 .info = conexant_mux_enum_info,
690 .get = conexant_mux_enum_get,
691 .put = conexant_mux_enum_put,
692 },
Tobin Davisc9b443d2006-11-14 12:13:39 +0100693 { } /* end */
694};
695
696static struct hda_verb cxt5045_test_init_verbs[] = {
Tobin Davis7f296732007-03-12 11:39:01 +0100697 /* Set connections */
698 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
699 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x0 },
700 { 0x12, AC_VERB_SET_CONNECT_SEL, 0x0 },
Tobin Davisc9b443d2006-11-14 12:13:39 +0100701 /* Enable retasking pins as output, initially without power amp */
702 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Tobin Davis7f296732007-03-12 11:39:01 +0100703 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Tobin Davisc9b443d2006-11-14 12:13:39 +0100704
705 /* Disable digital (SPDIF) pins initially, but users can enable
706 * them via a mixer switch. In the case of SPDIF-out, this initverb
707 * payload also sets the generation to 0, output to be in "consumer"
708 * PCM format, copyright asserted, no pre-emphasis and no validity
709 * control.
710 */
711 {0x13, AC_VERB_SET_DIGI_CONVERT_1, 0},
712
713 /* Start with output sum widgets muted and their output gains at min */
714 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
715 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
716
717 /* Unmute retasking pin widget output buffers since the default
718 * state appears to be output. As the pin mode is changed by the
719 * user the pin mode control will take care of enabling the pin's
720 * input/output buffers as needed.
721 */
722 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
723 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
724
725 /* Mute capture amp left and right */
726 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
727
728 /* Set ADC connection select to match default mixer setting (mic1
729 * pin)
730 */
731 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
Tobin Davis7f296732007-03-12 11:39:01 +0100732 {0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
Tobin Davisc9b443d2006-11-14 12:13:39 +0100733
734 /* Mute all inputs to mixer widget (even unconnected ones) */
735 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer pin */
736 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* Mic1 pin */
737 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* Line pin */
738 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* HP pin */
739 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
740
741 { }
742};
743#endif
744
745
746/* initialize jack-sensing, too */
747static int cxt5045_init(struct hda_codec *codec)
748{
749 conexant_init(codec);
750 cxt5045_hp_automute(codec);
751 return 0;
752}
753
754
755enum {
Tobin Davis7f296732007-03-12 11:39:01 +0100756 CXT5045_LAPTOP, /* Laptops w/ EAPD support */
757 CXT5045_FUJITSU, /* Laptops w/ EAPD support */
Tobin Davisc9b443d2006-11-14 12:13:39 +0100758#ifdef CONFIG_SND_DEBUG
759 CXT5045_TEST,
760#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100761 CXT5045_MODELS
Tobin Davisc9b443d2006-11-14 12:13:39 +0100762};
763
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100764static const char *cxt5045_models[CXT5045_MODELS] = {
765 [CXT5045_LAPTOP] = "laptop",
Tobin Davis7f296732007-03-12 11:39:01 +0100766 [CXT5045_FUJITSU] = "fujitsu",
Tobin Davisc9b443d2006-11-14 12:13:39 +0100767#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100768 [CXT5045_TEST] = "test",
Tobin Davisc9b443d2006-11-14 12:13:39 +0100769#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100770};
771
772static struct snd_pci_quirk cxt5045_cfg_tbl[] = {
773 SND_PCI_QUIRK(0x103c, 0x30b7, "HP DV6000Z", CXT5045_LAPTOP),
Tobin Davis82f30042007-02-13 12:45:44 +0100774 SND_PCI_QUIRK(0x103c, 0x30bb, "HP DV8000", CXT5045_LAPTOP),
Tobin Davis7f296732007-03-12 11:39:01 +0100775 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_FUJITSU),
776 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP),
Tobin Davisc9b443d2006-11-14 12:13:39 +0100777 {}
778};
779
780static int patch_cxt5045(struct hda_codec *codec)
781{
782 struct conexant_spec *spec;
783 int board_config;
784
785 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
786 if (!spec)
787 return -ENOMEM;
788 mutex_init(&spec->amp_mutex);
789 codec->spec = spec;
790
791 spec->multiout.max_channels = 2;
792 spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids);
793 spec->multiout.dac_nids = cxt5045_dac_nids;
794 spec->multiout.dig_out_nid = CXT5045_SPDIF_OUT;
795 spec->num_adc_nids = 1;
796 spec->adc_nids = cxt5045_adc_nids;
797 spec->capsrc_nids = cxt5045_capsrc_nids;
798 spec->input_mux = &cxt5045_capture_source;
799 spec->num_mixers = 1;
800 spec->mixers[0] = cxt5045_mixers;
801 spec->num_init_verbs = 1;
802 spec->init_verbs[0] = cxt5045_init_verbs;
803 spec->spdif_route = 0;
Tobin Davis5cd57522006-11-20 17:42:09 +0100804 spec->num_channel_mode = ARRAY_SIZE(cxt5045_modes),
805 spec->channel_mode = cxt5045_modes,
806
Tobin Davisc9b443d2006-11-14 12:13:39 +0100807
808 codec->patch_ops = conexant_patch_ops;
Tobin Davisc9b443d2006-11-14 12:13:39 +0100809
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100810 board_config = snd_hda_check_board_config(codec, CXT5045_MODELS,
811 cxt5045_models,
812 cxt5045_cfg_tbl);
Tobin Davisc9b443d2006-11-14 12:13:39 +0100813 switch (board_config) {
814 case CXT5045_LAPTOP:
Tobin Davis7f296732007-03-12 11:39:01 +0100815 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
Tobin Davisc9b443d2006-11-14 12:13:39 +0100816 spec->input_mux = &cxt5045_capture_source;
817 spec->num_init_verbs = 2;
Tobin Davis7f296732007-03-12 11:39:01 +0100818 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
819 spec->mixers[0] = cxt5045_mixers;
820 codec->patch_ops.init = cxt5045_init;
821 break;
822 case CXT5045_FUJITSU:
823 spec->input_mux = &cxt5045_capture_source;
824 spec->num_init_verbs = 2;
825 spec->init_verbs[1] = cxt5045_mic_sense_init_verbs;
Tobin Davisc9b443d2006-11-14 12:13:39 +0100826 spec->mixers[0] = cxt5045_mixers;
827 codec->patch_ops.init = cxt5045_init;
828 break;
829#ifdef CONFIG_SND_DEBUG
830 case CXT5045_TEST:
831 spec->input_mux = &cxt5045_test_capture_source;
832 spec->mixers[0] = cxt5045_test_mixer;
833 spec->init_verbs[0] = cxt5045_test_init_verbs;
834#endif
835 }
836 return 0;
837}
838
839
840/* Conexant 5047 specific */
Tobin Davis82f30042007-02-13 12:45:44 +0100841#define CXT5047_SPDIF_OUT 0x11
Tobin Davisc9b443d2006-11-14 12:13:39 +0100842
Tobin Davis82f30042007-02-13 12:45:44 +0100843static hda_nid_t cxt5047_dac_nids[2] = { 0x10, 0x1c };
Tobin Davisc9b443d2006-11-14 12:13:39 +0100844static hda_nid_t cxt5047_adc_nids[1] = { 0x12 };
845static hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a };
Tobin Davisc9b443d2006-11-14 12:13:39 +0100846
Tobin Davis5cd57522006-11-20 17:42:09 +0100847static struct hda_channel_mode cxt5047_modes[1] = {
848 { 2, NULL },
849};
Tobin Davisc9b443d2006-11-14 12:13:39 +0100850
851static struct hda_input_mux cxt5047_capture_source = {
Tobin Davis7f296732007-03-12 11:39:01 +0100852 .num_items = 1,
Tobin Davisc9b443d2006-11-14 12:13:39 +0100853 .items = {
Tobin Davis7f296732007-03-12 11:39:01 +0100854 { "Mic", 0x2 },
Tobin Davisc9b443d2006-11-14 12:13:39 +0100855 }
856};
857
858static struct hda_input_mux cxt5047_hp_capture_source = {
859 .num_items = 1,
860 .items = {
Tobin Davis82f30042007-02-13 12:45:44 +0100861 { "ExtMic", 0x2 },
862 }
863};
864
865static struct hda_input_mux cxt5047_toshiba_capture_source = {
866 .num_items = 2,
867 .items = {
868 { "ExtMic", 0x2 },
869 { "Line-In", 0x1 },
Tobin Davisc9b443d2006-11-14 12:13:39 +0100870 }
871};
872
873/* turn on/off EAPD (+ mute HP) as a master switch */
874static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol,
875 struct snd_ctl_elem_value *ucontrol)
876{
877 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
878 struct conexant_spec *spec = codec->spec;
Tobin Davis82f30042007-02-13 12:45:44 +0100879 unsigned int bits;
Tobin Davisc9b443d2006-11-14 12:13:39 +0100880
Tobin Davis82f30042007-02-13 12:45:44 +0100881 if (!cxt_eapd_put(kcontrol, ucontrol))
Tobin Davisc9b443d2006-11-14 12:13:39 +0100882 return 0;
883
Tobin Davis82f30042007-02-13 12:45:44 +0100884 /* toggle internal speakers mute depending of presence of
885 * the headphone jack
886 */
887 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : 0x80;
888 snd_hda_codec_amp_update(codec, 0x1d, 0, HDA_OUTPUT, 0, 0x80, bits);
889 snd_hda_codec_amp_update(codec, 0x1d, 1, HDA_OUTPUT, 0, 0x80, bits);
890 bits = spec->cur_eapd ? 0 : 0x80;
891 snd_hda_codec_amp_update(codec, 0x13, 0, HDA_OUTPUT, 0, 0x80, bits);
892 snd_hda_codec_amp_update(codec, 0x13, 1, HDA_OUTPUT, 0, 0x80, bits);
Tobin Davisc9b443d2006-11-14 12:13:39 +0100893 return 1;
894}
895
Tobin Davis82f30042007-02-13 12:45:44 +0100896/* bind volumes of both NID 0x13 (Headphones) and 0x1d (Speakers) */
Tobin Davisc9b443d2006-11-14 12:13:39 +0100897static int cxt5047_hp_master_vol_put(struct snd_kcontrol *kcontrol,
898 struct snd_ctl_elem_value *ucontrol)
899{
900 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
901 long *valp = ucontrol->value.integer.value;
902 int change;
903
Tobin Davis82f30042007-02-13 12:45:44 +0100904 change = snd_hda_codec_amp_update(codec, 0x1d, 0, HDA_OUTPUT, 0,
Tobin Davisc9b443d2006-11-14 12:13:39 +0100905 0x7f, valp[0] & 0x7f);
Tobin Davis82f30042007-02-13 12:45:44 +0100906 change |= snd_hda_codec_amp_update(codec, 0x1d, 1, HDA_OUTPUT, 0,
Tobin Davisc9b443d2006-11-14 12:13:39 +0100907 0x7f, valp[1] & 0x7f);
908 snd_hda_codec_amp_update(codec, 0x13, 0, HDA_OUTPUT, 0,
909 0x7f, valp[0] & 0x7f);
910 snd_hda_codec_amp_update(codec, 0x13, 1, HDA_OUTPUT, 0,
911 0x7f, valp[1] & 0x7f);
912 return change;
913}
Tobin Davisc9b443d2006-11-14 12:13:39 +0100914
915/* mute internal speaker if HP is plugged */
916static void cxt5047_hp_automute(struct hda_codec *codec)
917{
Tobin Davis82f30042007-02-13 12:45:44 +0100918 struct conexant_spec *spec = codec->spec;
Tobin Davisdd87da12007-02-26 16:07:42 +0100919 unsigned int bits;
Tobin Davisc9b443d2006-11-14 12:13:39 +0100920
Tobin Davis82f30042007-02-13 12:45:44 +0100921 spec->hp_present = snd_hda_codec_read(codec, 0x13, 0,
Tobin Davisc9b443d2006-11-14 12:13:39 +0100922 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Tobin Davisdd87da12007-02-26 16:07:42 +0100923
924 bits = (spec->hp_present || !spec->cur_eapd) ? 0x80 : 0;
Tobin Davis82f30042007-02-13 12:45:44 +0100925 snd_hda_codec_amp_update(codec, 0x1d, 0, HDA_OUTPUT, 0, 0x80, bits);
926 snd_hda_codec_amp_update(codec, 0x1d, 1, HDA_OUTPUT, 0, 0x80, bits);
927 /* Mute/Unmute PCM 2 for good measure - some systems need this */
928 snd_hda_codec_amp_update(codec, 0x1c, 0, HDA_OUTPUT, 0, 0x80, bits);
929 snd_hda_codec_amp_update(codec, 0x1c, 1, HDA_OUTPUT, 0, 0x80, bits);
Tobin Davisc9b443d2006-11-14 12:13:39 +0100930}
931
932/* toggle input of built-in and mic jack appropriately */
933static void cxt5047_hp_automic(struct hda_codec *codec)
934{
935 static struct hda_verb mic_jack_on[] = {
936 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
937 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
938 {}
939 };
940 static struct hda_verb mic_jack_off[] = {
941 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
942 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
943 {}
944 };
945 unsigned int present;
946
Tobin Davis7f296732007-03-12 11:39:01 +0100947 present = snd_hda_codec_read(codec, 0x15, 0,
Tobin Davisc9b443d2006-11-14 12:13:39 +0100948 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
949 if (present)
950 snd_hda_sequence_write(codec, mic_jack_on);
951 else
952 snd_hda_sequence_write(codec, mic_jack_off);
953}
954
955/* unsolicited event for HP jack sensing */
956static void cxt5047_hp_unsol_event(struct hda_codec *codec,
957 unsigned int res)
958{
959 res >>= 26;
960 switch (res) {
961 case CONEXANT_HP_EVENT:
962 cxt5047_hp_automute(codec);
963 break;
964 case CONEXANT_MIC_EVENT:
965 cxt5047_hp_automic(codec);
966 break;
967 }
968}
969
970static struct snd_kcontrol_new cxt5047_mixers[] = {
Tobin Davisc9b443d2006-11-14 12:13:39 +0100971 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
972 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
Tobin Davis7f296732007-03-12 11:39:01 +0100973 HDA_CODEC_VOLUME("Mic Gain Volume", 0x1a, 0x0, HDA_OUTPUT),
974 HDA_CODEC_MUTE("Mic Gain Switch", 0x1a, 0x0, HDA_OUTPUT),
Tobin Davisc9b443d2006-11-14 12:13:39 +0100975 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
976 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
977 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
978 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
Tobin Davis82f30042007-02-13 12:45:44 +0100979 HDA_CODEC_VOLUME("PCM-2 Volume", 0x1c, 0x00, HDA_OUTPUT),
980 HDA_CODEC_MUTE("PCM-2 Switch", 0x1c, 0x00, HDA_OUTPUT),
981 {
982 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
983 .name = "Master Playback Volume",
984 .info = snd_hda_mixer_amp_volume_info,
985 .get = snd_hda_mixer_amp_volume_get,
986 .put = cxt5047_hp_master_vol_put,
987 .private_value = HDA_COMPOSE_AMP_VAL(0x13, 3, 0, HDA_OUTPUT),
988 },
Tobin Davisc9b443d2006-11-14 12:13:39 +0100989 {
990 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
991 .name = "Master Playback Switch",
Tobin Davis82f30042007-02-13 12:45:44 +0100992 .info = cxt_eapd_info,
993 .get = cxt_eapd_get,
994 .put = cxt5047_hp_master_sw_put,
995 .private_value = 0x13,
996 },
997
998 {}
999};
1000
1001static struct snd_kcontrol_new cxt5047_toshiba_mixers[] = {
1002 {
1003 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1004 .name = "Capture Source",
1005 .info = conexant_mux_enum_info,
1006 .get = conexant_mux_enum_get,
1007 .put = conexant_mux_enum_put
1008 },
1009 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1010 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
1011 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1012 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1013 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1014 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1015 {
1016 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1017 .name = "Master Playback Volume",
1018 .info = snd_hda_mixer_amp_volume_info,
1019 .get = snd_hda_mixer_amp_volume_get,
1020 .put = cxt5047_hp_master_vol_put,
1021 .private_value = HDA_COMPOSE_AMP_VAL(0x13, 3, 0, HDA_OUTPUT),
1022 },
1023 {
1024 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1025 .name = "Master Playback Switch",
1026 .info = cxt_eapd_info,
1027 .get = cxt_eapd_get,
Tobin Davisc9b443d2006-11-14 12:13:39 +01001028 .put = cxt5047_hp_master_sw_put,
1029 .private_value = 0x13,
1030 },
1031
1032 {}
1033};
1034
1035static struct snd_kcontrol_new cxt5047_hp_mixers[] = {
1036 {
1037 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1038 .name = "Capture Source",
1039 .info = conexant_mux_enum_info,
1040 .get = conexant_mux_enum_get,
1041 .put = conexant_mux_enum_put
1042 },
1043 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1044 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19,0x02,HDA_INPUT),
1045 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1046 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1047 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1048 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1049 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT),
1050 {
1051 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1052 .name = "Master Playback Switch",
Tobin Davis82f30042007-02-13 12:45:44 +01001053 .info = cxt_eapd_info,
1054 .get = cxt_eapd_get,
Tobin Davisc9b443d2006-11-14 12:13:39 +01001055 .put = cxt5047_hp_master_sw_put,
1056 .private_value = 0x13,
1057 },
1058 { } /* end */
1059};
1060
1061static struct hda_verb cxt5047_init_verbs[] = {
1062 /* Line in, Mic, Built-in Mic */
1063 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1064 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1065 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
Tobin Davis7f296732007-03-12 11:39:01 +01001066 /* HP, Speaker */
Tobin Davisc9b443d2006-11-14 12:13:39 +01001067 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
Tobin Davis7f296732007-03-12 11:39:01 +01001068 {0x1d, AC_VERB_SET_CONNECT_SEL,0x0},
1069 /* Record selector: Mic */
1070 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1071 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1072 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1073 {0x1A, AC_VERB_SET_CONNECT_SEL,0x02},
Tobin Davisc9b443d2006-11-14 12:13:39 +01001074 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1075 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00},
1076 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1077 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03},
Tobin Davisc9b443d2006-11-14 12:13:39 +01001078 /* SPDIF route: PCM */
1079 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 },
Tobin Davis82f30042007-02-13 12:45:44 +01001080 /* Enable unsolicited events */
1081 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1082 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
Tobin Davisc9b443d2006-11-14 12:13:39 +01001083 { } /* end */
1084};
1085
1086/* configuration for Toshiba Laptops */
1087static struct hda_verb cxt5047_toshiba_init_verbs[] = {
1088 {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0 }, /* default on */
1089 /* pin sensing on HP and Mic jacks */
1090 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1091 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
Tobin Davis82f30042007-02-13 12:45:44 +01001092 /* Speaker routing */
1093 {0x1d, AC_VERB_SET_CONNECT_SEL,0x1},
Tobin Davisc9b443d2006-11-14 12:13:39 +01001094 {}
1095};
1096
1097/* configuration for HP Laptops */
1098static struct hda_verb cxt5047_hp_init_verbs[] = {
Tobin Davis82f30042007-02-13 12:45:44 +01001099 /* pin sensing on HP jack */
Tobin Davisc9b443d2006-11-14 12:13:39 +01001100 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
Tobin Davis82f30042007-02-13 12:45:44 +01001101 /* Record selector: Ext Mic */
1102 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
Tobin Davis82f30042007-02-13 12:45:44 +01001103 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1104 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1105 /* Speaker routing */
1106 {0x1d, AC_VERB_SET_CONNECT_SEL,0x1},
Tobin Davisc9b443d2006-11-14 12:13:39 +01001107 {}
1108};
1109
1110/* Test configuration for debugging, modelled after the ALC260 test
1111 * configuration.
1112 */
1113#ifdef CONFIG_SND_DEBUG
1114static struct hda_input_mux cxt5047_test_capture_source = {
Tobin Davis82f30042007-02-13 12:45:44 +01001115 .num_items = 4,
Tobin Davisc9b443d2006-11-14 12:13:39 +01001116 .items = {
Tobin Davis82f30042007-02-13 12:45:44 +01001117 { "LINE1 pin", 0x0 },
1118 { "MIC1 pin", 0x1 },
1119 { "MIC2 pin", 0x2 },
1120 { "CD pin", 0x3 },
Tobin Davisc9b443d2006-11-14 12:13:39 +01001121 },
1122};
1123
1124static struct snd_kcontrol_new cxt5047_test_mixer[] = {
1125
1126 /* Output only controls */
Tobin Davis82f30042007-02-13 12:45:44 +01001127 HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT),
1128 HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT),
1129 HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT),
1130 HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT),
Tobin Davisc9b443d2006-11-14 12:13:39 +01001131 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1132 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1133 HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1134 HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT),
Tobin Davis82f30042007-02-13 12:45:44 +01001135 HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT),
1136 HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1137 HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT),
1138 HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Tobin Davisc9b443d2006-11-14 12:13:39 +01001139
1140 /* Modes for retasking pin widgets */
1141 CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT),
1142 CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT),
1143
Tobin Davis82f30042007-02-13 12:45:44 +01001144 /* EAPD Switch Control */
1145 CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0),
1146
Tobin Davisc9b443d2006-11-14 12:13:39 +01001147 /* Loopback mixer controls */
Tobin Davis82f30042007-02-13 12:45:44 +01001148 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT),
1149 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT),
1150 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT),
1151 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT),
1152 HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT),
1153 HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT),
1154 HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT),
1155 HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT),
Tobin Davisc9b443d2006-11-14 12:13:39 +01001156
Tobin Davis82f30042007-02-13 12:45:44 +01001157 HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT),
1158 HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT),
1159 HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT),
1160 HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT),
1161 HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT),
1162 HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT),
1163 HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT),
1164 HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT),
Tobin Davisc9b443d2006-11-14 12:13:39 +01001165 {
1166 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1167 .name = "Input Source",
1168 .info = conexant_mux_enum_info,
1169 .get = conexant_mux_enum_get,
1170 .put = conexant_mux_enum_put,
1171 },
Tobin Davisc9b443d2006-11-14 12:13:39 +01001172 { } /* end */
1173};
1174
1175static struct hda_verb cxt5047_test_init_verbs[] = {
Tobin Davisc9b443d2006-11-14 12:13:39 +01001176 /* Enable retasking pins as output, initially without power amp */
1177 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1178 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1179 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1180
1181 /* Disable digital (SPDIF) pins initially, but users can enable
1182 * them via a mixer switch. In the case of SPDIF-out, this initverb
1183 * payload also sets the generation to 0, output to be in "consumer"
1184 * PCM format, copyright asserted, no pre-emphasis and no validity
1185 * control.
1186 */
1187 {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0},
1188
1189 /* Ensure mic1, mic2, line1 pin widgets take input from the
1190 * OUT1 sum bus when acting as an output.
1191 */
1192 {0x1a, AC_VERB_SET_CONNECT_SEL, 0},
1193 {0x1b, AC_VERB_SET_CONNECT_SEL, 0},
1194
1195 /* Start with output sum widgets muted and their output gains at min */
1196 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1197 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1198
1199 /* Unmute retasking pin widget output buffers since the default
1200 * state appears to be output. As the pin mode is changed by the
1201 * user the pin mode control will take care of enabling the pin's
1202 * input/output buffers as needed.
1203 */
1204 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1205 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1206 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1207
1208 /* Mute capture amp left and right */
1209 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1210
1211 /* Set ADC connection select to match default mixer setting (mic1
1212 * pin)
1213 */
1214 {0x12, AC_VERB_SET_CONNECT_SEL, 0x00},
1215
1216 /* Mute all inputs to mixer widget (even unconnected ones) */
1217 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
1218 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
1219 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
1220 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
1221 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
1222 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
1223 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
1224 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
1225
1226 { }
1227};
1228#endif
1229
1230
1231/* initialize jack-sensing, too */
1232static int cxt5047_hp_init(struct hda_codec *codec)
1233{
1234 conexant_init(codec);
1235 cxt5047_hp_automute(codec);
Tobin Davisc9b443d2006-11-14 12:13:39 +01001236 return 0;
1237}
1238
1239
1240enum {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001241 CXT5047_LAPTOP, /* Laptops w/o EAPD support */
1242 CXT5047_LAPTOP_HP, /* Some HP laptops */
1243 CXT5047_LAPTOP_EAPD, /* Laptops with EAPD support */
Tobin Davisc9b443d2006-11-14 12:13:39 +01001244#ifdef CONFIG_SND_DEBUG
1245 CXT5047_TEST,
1246#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001247 CXT5047_MODELS
Tobin Davisc9b443d2006-11-14 12:13:39 +01001248};
1249
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001250static const char *cxt5047_models[CXT5047_MODELS] = {
1251 [CXT5047_LAPTOP] = "laptop",
1252 [CXT5047_LAPTOP_HP] = "laptop-hp",
1253 [CXT5047_LAPTOP_EAPD] = "laptop-eapd",
Tobin Davisc9b443d2006-11-14 12:13:39 +01001254#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001255 [CXT5047_TEST] = "test",
Tobin Davisc9b443d2006-11-14 12:13:39 +01001256#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001257};
1258
1259static struct snd_pci_quirk cxt5047_cfg_tbl[] = {
1260 SND_PCI_QUIRK(0x103c, 0x30a0, "HP DV1000", CXT5047_LAPTOP),
1261 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV2000T/DV3000T", CXT5047_LAPTOP),
Tobin Davis82f30042007-02-13 12:45:44 +01001262 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2000Z", CXT5047_LAPTOP),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001263 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP),
1264 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD),
Tobin Davisc9b443d2006-11-14 12:13:39 +01001265 {}
1266};
1267
1268static int patch_cxt5047(struct hda_codec *codec)
1269{
1270 struct conexant_spec *spec;
1271 int board_config;
1272
1273 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1274 if (!spec)
1275 return -ENOMEM;
1276 mutex_init(&spec->amp_mutex);
1277 codec->spec = spec;
1278
1279 spec->multiout.max_channels = 2;
1280 spec->multiout.num_dacs = ARRAY_SIZE(cxt5047_dac_nids);
1281 spec->multiout.dac_nids = cxt5047_dac_nids;
1282 spec->multiout.dig_out_nid = CXT5047_SPDIF_OUT;
1283 spec->num_adc_nids = 1;
1284 spec->adc_nids = cxt5047_adc_nids;
1285 spec->capsrc_nids = cxt5047_capsrc_nids;
1286 spec->input_mux = &cxt5047_capture_source;
1287 spec->num_mixers = 1;
1288 spec->mixers[0] = cxt5047_mixers;
1289 spec->num_init_verbs = 1;
1290 spec->init_verbs[0] = cxt5047_init_verbs;
1291 spec->spdif_route = 0;
Tobin Davis5cd57522006-11-20 17:42:09 +01001292 spec->num_channel_mode = ARRAY_SIZE(cxt5047_modes),
1293 spec->channel_mode = cxt5047_modes,
Tobin Davisc9b443d2006-11-14 12:13:39 +01001294
1295 codec->patch_ops = conexant_patch_ops;
1296 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1297
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001298 board_config = snd_hda_check_board_config(codec, CXT5047_MODELS,
1299 cxt5047_models,
1300 cxt5047_cfg_tbl);
Tobin Davisc9b443d2006-11-14 12:13:39 +01001301 switch (board_config) {
1302 case CXT5047_LAPTOP:
1303 break;
1304 case CXT5047_LAPTOP_HP:
1305 spec->input_mux = &cxt5047_hp_capture_source;
1306 spec->num_init_verbs = 2;
1307 spec->init_verbs[1] = cxt5047_hp_init_verbs;
1308 spec->mixers[0] = cxt5047_hp_mixers;
1309 codec->patch_ops.init = cxt5047_hp_init;
1310 break;
1311 case CXT5047_LAPTOP_EAPD:
Tobin Davis82f30042007-02-13 12:45:44 +01001312 spec->input_mux = &cxt5047_toshiba_capture_source;
Tobin Davisc9b443d2006-11-14 12:13:39 +01001313 spec->num_init_verbs = 2;
1314 spec->init_verbs[1] = cxt5047_toshiba_init_verbs;
Tobin Davis82f30042007-02-13 12:45:44 +01001315 spec->mixers[0] = cxt5047_toshiba_mixers;
Tobin Davisc9b443d2006-11-14 12:13:39 +01001316 break;
1317#ifdef CONFIG_SND_DEBUG
1318 case CXT5047_TEST:
1319 spec->input_mux = &cxt5047_test_capture_source;
1320 spec->mixers[0] = cxt5047_test_mixer;
1321 spec->init_verbs[0] = cxt5047_test_init_verbs;
1322#endif
1323 }
1324 return 0;
1325}
1326
1327struct hda_codec_preset snd_hda_preset_conexant[] = {
Tobin Davis82f30042007-02-13 12:45:44 +01001328 { .id = 0x14f15045, .name = "CX20549 (Venice)",
1329 .patch = patch_cxt5045 },
1330 { .id = 0x14f15047, .name = "CX20551 (Waikiki)",
1331 .patch = patch_cxt5047 },
Tobin Davisc9b443d2006-11-14 12:13:39 +01001332 {} /* terminator */
1333};