blob: 08c5b32dcd637669727a7a9e7acd7c8b4289481a [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
Tobin Davisc9b443d2006-11-14 12:13:39 +010023#include <linux/init.h>
24#include <linux/delay.h>
25#include <linux/slab.h>
26#include <linux/pci.h>
27#include <sound/core.h>
Ulrich Dangelbc7a1662009-01-02 19:30:13 +010028#include <sound/jack.h>
29
Tobin Davisc9b443d2006-11-14 12:13:39 +010030#include "hda_codec.h"
31#include "hda_local.h"
Einar Rünkaruc0f8faf2009-12-16 22:41:36 +020032#include "hda_beep.h"
Tobin Davisc9b443d2006-11-14 12:13:39 +010033
34#define CXT_PIN_DIR_IN 0x00
35#define CXT_PIN_DIR_OUT 0x01
36#define CXT_PIN_DIR_INOUT 0x02
37#define CXT_PIN_DIR_IN_NOMICBIAS 0x03
38#define CXT_PIN_DIR_INOUT_NOMICBIAS 0x04
39
40#define CONEXANT_HP_EVENT 0x37
41#define CONEXANT_MIC_EVENT 0x38
42
Ulrich Dangelbc7a1662009-01-02 19:30:13 +010043/* Conexant 5051 specific */
Tobin Davisc9b443d2006-11-14 12:13:39 +010044
Ulrich Dangelbc7a1662009-01-02 19:30:13 +010045#define CXT5051_SPDIF_OUT 0x1C
46#define CXT5051_PORTB_EVENT 0x38
47#define CXT5051_PORTC_EVENT 0x39
48
49
50struct conexant_jack {
51
52 hda_nid_t nid;
53 int type;
54 struct snd_jack *jack;
55
56};
Tobin Davisc9b443d2006-11-14 12:13:39 +010057
58struct conexant_spec {
59
60 struct snd_kcontrol_new *mixers[5];
61 int num_mixers;
Takashi Iwaidd5746a2009-03-10 14:30:40 +010062 hda_nid_t vmaster_nid;
Tobin Davisc9b443d2006-11-14 12:13:39 +010063
64 const struct hda_verb *init_verbs[5]; /* initialization verbs
65 * don't forget NULL
66 * termination!
67 */
68 unsigned int num_init_verbs;
69
70 /* playback */
71 struct hda_multi_out multiout; /* playback set-up
72 * max_channels, dacs must be set
73 * dig_out_nid and hp_nid are optional
74 */
75 unsigned int cur_eapd;
Tobin Davis82f30042007-02-13 12:45:44 +010076 unsigned int hp_present;
Takashi Iwai79d7d532009-03-04 09:03:50 +010077 unsigned int no_auto_mic;
Tobin Davisc9b443d2006-11-14 12:13:39 +010078 unsigned int need_dac_fix;
79
80 /* capture */
81 unsigned int num_adc_nids;
82 hda_nid_t *adc_nids;
83 hda_nid_t dig_in_nid; /* digital-in NID; optional */
84
Takashi Iwai461e2c72008-01-25 11:35:17 +010085 unsigned int cur_adc_idx;
86 hda_nid_t cur_adc;
87 unsigned int cur_adc_stream_tag;
88 unsigned int cur_adc_format;
89
Tobin Davisc9b443d2006-11-14 12:13:39 +010090 /* capture source */
91 const struct hda_input_mux *input_mux;
92 hda_nid_t *capsrc_nids;
93 unsigned int cur_mux[3];
94
95 /* channel model */
96 const struct hda_channel_mode *channel_mode;
97 int num_channel_mode;
98
99 /* PCM information */
100 struct hda_pcm pcm_rec[2]; /* used in build_pcms() */
101
Tobin Davisc9b443d2006-11-14 12:13:39 +0100102 unsigned int spdif_route;
103
Ulrich Dangelbc7a1662009-01-02 19:30:13 +0100104 /* jack detection */
105 struct snd_array jacks;
106
Tobin Davisc9b443d2006-11-14 12:13:39 +0100107 /* dynamic controls, init_verbs and input_mux */
108 struct auto_pin_cfg autocfg;
Tobin Davisc9b443d2006-11-14 12:13:39 +0100109 struct hda_input_mux private_imux;
Takashi Iwai41923e42007-10-22 17:20:10 +0200110 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Tobin Davisc9b443d2006-11-14 12:13:39 +0100111
Daniel Drake0fb67e92009-07-16 14:46:57 +0100112 unsigned int dell_automute;
113 unsigned int port_d_mode;
Einar Rünkaru254bba62009-12-16 22:16:13 +0200114 unsigned int dell_vostro;
Daniel Drake75f89912010-01-07 13:46:25 +0100115
116 unsigned int ext_mic_present;
117 unsigned int recording;
118 void (*capture_prepare)(struct hda_codec *codec);
119 void (*capture_cleanup)(struct hda_codec *codec);
Daniel Drakec4cfe662010-01-07 13:47:04 +0100120
121 /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors)
122 * through the microphone jack.
123 * When the user enables this through a mixer switch, both internal and
124 * external microphones are disabled. Gain is fixed at 0dB. In this mode,
125 * we also allow the bias to be configured through a separate mixer
126 * control. */
127 unsigned int dc_enable;
128 unsigned int dc_input_bias; /* offset into cxt5066_olpc_dc_bias */
129 unsigned int mic_boost; /* offset into cxt5066_analog_mic_boost */
Tobin Davisc9b443d2006-11-14 12:13:39 +0100130};
131
132static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo,
133 struct hda_codec *codec,
134 struct snd_pcm_substream *substream)
135{
136 struct conexant_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +0100137 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
138 hinfo);
Tobin Davisc9b443d2006-11-14 12:13:39 +0100139}
140
141static int conexant_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
142 struct hda_codec *codec,
143 unsigned int stream_tag,
144 unsigned int format,
145 struct snd_pcm_substream *substream)
146{
147 struct conexant_spec *spec = codec->spec;
148 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
149 stream_tag,
150 format, substream);
151}
152
153static int conexant_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
154 struct hda_codec *codec,
155 struct snd_pcm_substream *substream)
156{
157 struct conexant_spec *spec = codec->spec;
158 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
159}
160
161/*
162 * Digital out
163 */
164static int conexant_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
165 struct hda_codec *codec,
166 struct snd_pcm_substream *substream)
167{
168 struct conexant_spec *spec = codec->spec;
169 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
170}
171
172static int conexant_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
173 struct hda_codec *codec,
174 struct snd_pcm_substream *substream)
175{
176 struct conexant_spec *spec = codec->spec;
177 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
178}
179
Takashi Iwai6b97eb42007-04-05 14:51:48 +0200180static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
181 struct hda_codec *codec,
182 unsigned int stream_tag,
183 unsigned int format,
184 struct snd_pcm_substream *substream)
185{
186 struct conexant_spec *spec = codec->spec;
187 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
188 stream_tag,
189 format, substream);
190}
191
Tobin Davisc9b443d2006-11-14 12:13:39 +0100192/*
193 * Analog capture
194 */
195static int conexant_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
196 struct hda_codec *codec,
197 unsigned int stream_tag,
198 unsigned int format,
199 struct snd_pcm_substream *substream)
200{
201 struct conexant_spec *spec = codec->spec;
Daniel Drake75f89912010-01-07 13:46:25 +0100202 if (spec->capture_prepare)
203 spec->capture_prepare(codec);
Tobin Davisc9b443d2006-11-14 12:13:39 +0100204 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
205 stream_tag, 0, format);
206 return 0;
207}
208
209static int conexant_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
210 struct hda_codec *codec,
211 struct snd_pcm_substream *substream)
212{
213 struct conexant_spec *spec = codec->spec;
Takashi Iwai888afa12008-03-18 09:57:50 +0100214 snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
Daniel Drake75f89912010-01-07 13:46:25 +0100215 if (spec->capture_cleanup)
216 spec->capture_cleanup(codec);
Tobin Davisc9b443d2006-11-14 12:13:39 +0100217 return 0;
218}
219
220
221
222static struct hda_pcm_stream conexant_pcm_analog_playback = {
223 .substreams = 1,
224 .channels_min = 2,
225 .channels_max = 2,
226 .nid = 0, /* fill later */
227 .ops = {
228 .open = conexant_playback_pcm_open,
229 .prepare = conexant_playback_pcm_prepare,
230 .cleanup = conexant_playback_pcm_cleanup
231 },
232};
233
234static struct hda_pcm_stream conexant_pcm_analog_capture = {
235 .substreams = 1,
236 .channels_min = 2,
237 .channels_max = 2,
238 .nid = 0, /* fill later */
239 .ops = {
240 .prepare = conexant_capture_pcm_prepare,
241 .cleanup = conexant_capture_pcm_cleanup
242 },
243};
244
245
246static struct hda_pcm_stream conexant_pcm_digital_playback = {
247 .substreams = 1,
248 .channels_min = 2,
249 .channels_max = 2,
250 .nid = 0, /* fill later */
251 .ops = {
252 .open = conexant_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +0200253 .close = conexant_dig_playback_pcm_close,
254 .prepare = conexant_dig_playback_pcm_prepare
Tobin Davisc9b443d2006-11-14 12:13:39 +0100255 },
256};
257
258static struct hda_pcm_stream conexant_pcm_digital_capture = {
259 .substreams = 1,
260 .channels_min = 2,
261 .channels_max = 2,
262 /* NID is set in alc_build_pcms */
263};
264
Takashi Iwai461e2c72008-01-25 11:35:17 +0100265static int cx5051_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
266 struct hda_codec *codec,
267 unsigned int stream_tag,
268 unsigned int format,
269 struct snd_pcm_substream *substream)
270{
271 struct conexant_spec *spec = codec->spec;
272 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
273 spec->cur_adc_stream_tag = stream_tag;
274 spec->cur_adc_format = format;
275 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
276 return 0;
277}
278
279static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
280 struct hda_codec *codec,
281 struct snd_pcm_substream *substream)
282{
283 struct conexant_spec *spec = codec->spec;
Takashi Iwai888afa12008-03-18 09:57:50 +0100284 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
Takashi Iwai461e2c72008-01-25 11:35:17 +0100285 spec->cur_adc = 0;
286 return 0;
287}
288
289static struct hda_pcm_stream cx5051_pcm_analog_capture = {
290 .substreams = 1,
291 .channels_min = 2,
292 .channels_max = 2,
293 .nid = 0, /* fill later */
294 .ops = {
295 .prepare = cx5051_capture_pcm_prepare,
296 .cleanup = cx5051_capture_pcm_cleanup
297 },
298};
299
Tobin Davisc9b443d2006-11-14 12:13:39 +0100300static int conexant_build_pcms(struct hda_codec *codec)
301{
302 struct conexant_spec *spec = codec->spec;
303 struct hda_pcm *info = spec->pcm_rec;
304
305 codec->num_pcms = 1;
306 codec->pcm_info = info;
307
308 info->name = "CONEXANT Analog";
309 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = conexant_pcm_analog_playback;
310 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max =
311 spec->multiout.max_channels;
312 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
313 spec->multiout.dac_nids[0];
Takashi Iwai461e2c72008-01-25 11:35:17 +0100314 if (codec->vendor_id == 0x14f15051)
315 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
316 cx5051_pcm_analog_capture;
317 else
318 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
319 conexant_pcm_analog_capture;
Tobin Davisc9b443d2006-11-14 12:13:39 +0100320 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adc_nids;
321 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
322
323 if (spec->multiout.dig_out_nid) {
324 info++;
325 codec->num_pcms++;
326 info->name = "Conexant Digital";
Takashi Iwai7ba72ba2008-02-06 14:03:20 +0100327 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Tobin Davisc9b443d2006-11-14 12:13:39 +0100328 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
329 conexant_pcm_digital_playback;
330 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
331 spec->multiout.dig_out_nid;
332 if (spec->dig_in_nid) {
333 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
334 conexant_pcm_digital_capture;
335 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
336 spec->dig_in_nid;
337 }
338 }
339
340 return 0;
341}
342
343static int conexant_mux_enum_info(struct snd_kcontrol *kcontrol,
344 struct snd_ctl_elem_info *uinfo)
345{
346 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
347 struct conexant_spec *spec = codec->spec;
348
349 return snd_hda_input_mux_info(spec->input_mux, uinfo);
350}
351
352static int conexant_mux_enum_get(struct snd_kcontrol *kcontrol,
353 struct snd_ctl_elem_value *ucontrol)
354{
355 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
356 struct conexant_spec *spec = codec->spec;
357 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
358
359 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
360 return 0;
361}
362
363static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol,
364 struct snd_ctl_elem_value *ucontrol)
365{
366 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
367 struct conexant_spec *spec = codec->spec;
368 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
369
370 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
371 spec->capsrc_nids[adc_idx],
372 &spec->cur_mux[adc_idx]);
373}
374
Takashi Iwai8c8145b2009-06-22 17:00:38 +0200375#ifdef CONFIG_SND_HDA_INPUT_JACK
Takashi Iwai95c09092009-04-14 16:15:29 +0200376static void conexant_free_jack_priv(struct snd_jack *jack)
377{
378 struct conexant_jack *jacks = jack->private_data;
379 jacks->nid = 0;
380 jacks->jack = NULL;
381}
382
Ulrich Dangelbc7a1662009-01-02 19:30:13 +0100383static int conexant_add_jack(struct hda_codec *codec,
384 hda_nid_t nid, int type)
385{
386 struct conexant_spec *spec;
387 struct conexant_jack *jack;
388 const char *name;
Takashi Iwai95c09092009-04-14 16:15:29 +0200389 int err;
Ulrich Dangelbc7a1662009-01-02 19:30:13 +0100390
391 spec = codec->spec;
392 snd_array_init(&spec->jacks, sizeof(*jack), 32);
393 jack = snd_array_new(&spec->jacks);
394 name = (type == SND_JACK_HEADPHONE) ? "Headphone" : "Mic" ;
395
396 if (!jack)
397 return -ENOMEM;
398
399 jack->nid = nid;
400 jack->type = type;
401
Takashi Iwai95c09092009-04-14 16:15:29 +0200402 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
403 if (err < 0)
404 return err;
405 jack->jack->private_data = jack;
406 jack->jack->private_free = conexant_free_jack_priv;
407 return 0;
Ulrich Dangelbc7a1662009-01-02 19:30:13 +0100408}
409
410static void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid)
411{
412 struct conexant_spec *spec = codec->spec;
413 struct conexant_jack *jacks = spec->jacks.list;
414
415 if (jacks) {
416 int i;
417 for (i = 0; i < spec->jacks.used; i++) {
418 if (jacks->nid == nid) {
419 unsigned int present;
Takashi Iwaid56757a2009-11-18 08:00:14 +0100420 present = snd_hda_jack_detect(codec, nid);
Ulrich Dangelbc7a1662009-01-02 19:30:13 +0100421
422 present = (present) ? jacks->type : 0 ;
423
424 snd_jack_report(jacks->jack,
425 present);
426 }
427 jacks++;
428 }
429 }
430}
431
432static int conexant_init_jacks(struct hda_codec *codec)
433{
Ulrich Dangelbc7a1662009-01-02 19:30:13 +0100434 struct conexant_spec *spec = codec->spec;
435 int i;
436
437 for (i = 0; i < spec->num_init_verbs; i++) {
438 const struct hda_verb *hv;
439
440 hv = spec->init_verbs[i];
441 while (hv->nid) {
442 int err = 0;
443 switch (hv->param ^ AC_USRSP_EN) {
444 case CONEXANT_HP_EVENT:
445 err = conexant_add_jack(codec, hv->nid,
446 SND_JACK_HEADPHONE);
447 conexant_report_jack(codec, hv->nid);
448 break;
449 case CXT5051_PORTC_EVENT:
450 case CONEXANT_MIC_EVENT:
451 err = conexant_add_jack(codec, hv->nid,
452 SND_JACK_MICROPHONE);
453 conexant_report_jack(codec, hv->nid);
454 break;
455 }
456 if (err < 0)
457 return err;
458 ++hv;
459 }
460 }
Ulrich Dangelbc7a1662009-01-02 19:30:13 +0100461 return 0;
462
463}
Takashi Iwai5801f992009-01-27 12:53:22 +0100464#else
465static inline void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid)
466{
467}
468
469static inline int conexant_init_jacks(struct hda_codec *codec)
470{
471 return 0;
472}
473#endif
Ulrich Dangelbc7a1662009-01-02 19:30:13 +0100474
Tobin Davisc9b443d2006-11-14 12:13:39 +0100475static int conexant_init(struct hda_codec *codec)
476{
477 struct conexant_spec *spec = codec->spec;
478 int i;
479
480 for (i = 0; i < spec->num_init_verbs; i++)
481 snd_hda_sequence_write(codec, spec->init_verbs[i]);
482 return 0;
483}
484
485static void conexant_free(struct hda_codec *codec)
486{
Takashi Iwai8c8145b2009-06-22 17:00:38 +0200487#ifdef CONFIG_SND_HDA_INPUT_JACK
Ulrich Dangelbc7a1662009-01-02 19:30:13 +0100488 struct conexant_spec *spec = codec->spec;
489 if (spec->jacks.list) {
490 struct conexant_jack *jacks = spec->jacks.list;
491 int i;
Takashi Iwai95c09092009-04-14 16:15:29 +0200492 for (i = 0; i < spec->jacks.used; i++, jacks++) {
493 if (jacks->jack)
494 snd_device_free(codec->bus->card, jacks->jack);
495 }
Ulrich Dangelbc7a1662009-01-02 19:30:13 +0100496 snd_array_free(&spec->jacks);
497 }
498#endif
Einar Rünkaruc0f8faf2009-12-16 22:41:36 +0200499 snd_hda_detach_beep_device(codec);
Tobin Davisc9b443d2006-11-14 12:13:39 +0100500 kfree(codec->spec);
501}
502
Takashi Iwaib880c742009-03-10 14:41:05 +0100503static struct snd_kcontrol_new cxt_capture_mixers[] = {
504 {
505 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
506 .name = "Capture Source",
507 .info = conexant_mux_enum_info,
508 .get = conexant_mux_enum_get,
509 .put = conexant_mux_enum_put
510 },
511 {}
512};
513
Takashi Iwaidd5746a2009-03-10 14:30:40 +0100514static const char *slave_vols[] = {
515 "Headphone Playback Volume",
516 "Speaker Playback Volume",
517 NULL
518};
519
520static const char *slave_sws[] = {
521 "Headphone Playback Switch",
522 "Speaker Playback Switch",
523 NULL
524};
525
Tobin Davisc9b443d2006-11-14 12:13:39 +0100526static int conexant_build_controls(struct hda_codec *codec)
527{
528 struct conexant_spec *spec = codec->spec;
529 unsigned int i;
530 int err;
531
532 for (i = 0; i < spec->num_mixers; i++) {
533 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
534 if (err < 0)
535 return err;
536 }
537 if (spec->multiout.dig_out_nid) {
538 err = snd_hda_create_spdif_out_ctls(codec,
539 spec->multiout.dig_out_nid);
540 if (err < 0)
541 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +0100542 err = snd_hda_create_spdif_share_sw(codec,
543 &spec->multiout);
544 if (err < 0)
545 return err;
546 spec->multiout.share_spdif = 1;
Tobin Davisc9b443d2006-11-14 12:13:39 +0100547 }
548 if (spec->dig_in_nid) {
549 err = snd_hda_create_spdif_in_ctls(codec,spec->dig_in_nid);
550 if (err < 0)
551 return err;
552 }
Takashi Iwaidd5746a2009-03-10 14:30:40 +0100553
554 /* if we have no master control, let's create it */
555 if (spec->vmaster_nid &&
556 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
557 unsigned int vmaster_tlv[4];
558 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
559 HDA_OUTPUT, vmaster_tlv);
560 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
561 vmaster_tlv, slave_vols);
562 if (err < 0)
563 return err;
564 }
565 if (spec->vmaster_nid &&
566 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
567 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
568 NULL, slave_sws);
569 if (err < 0)
570 return err;
571 }
572
Takashi Iwaib880c742009-03-10 14:41:05 +0100573 if (spec->input_mux) {
574 err = snd_hda_add_new_ctls(codec, cxt_capture_mixers);
575 if (err < 0)
576 return err;
577 }
578
Tobin Davisc9b443d2006-11-14 12:13:39 +0100579 return 0;
580}
581
582static struct hda_codec_ops conexant_patch_ops = {
583 .build_controls = conexant_build_controls,
584 .build_pcms = conexant_build_pcms,
585 .init = conexant_init,
586 .free = conexant_free,
Tobin Davisc9b443d2006-11-14 12:13:39 +0100587};
588
589/*
590 * EAPD control
591 * the private value = nid | (invert << 8)
592 */
593
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200594#define cxt_eapd_info snd_ctl_boolean_mono_info
Tobin Davisc9b443d2006-11-14 12:13:39 +0100595
Tobin Davis82f30042007-02-13 12:45:44 +0100596static int cxt_eapd_get(struct snd_kcontrol *kcontrol,
Tobin Davisc9b443d2006-11-14 12:13:39 +0100597 struct snd_ctl_elem_value *ucontrol)
598{
599 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
600 struct conexant_spec *spec = codec->spec;
601 int invert = (kcontrol->private_value >> 8) & 1;
602 if (invert)
603 ucontrol->value.integer.value[0] = !spec->cur_eapd;
604 else
605 ucontrol->value.integer.value[0] = spec->cur_eapd;
606 return 0;
Tobin Davis82f30042007-02-13 12:45:44 +0100607
Tobin Davisc9b443d2006-11-14 12:13:39 +0100608}
609
Tobin Davis82f30042007-02-13 12:45:44 +0100610static int cxt_eapd_put(struct snd_kcontrol *kcontrol,
Tobin Davisc9b443d2006-11-14 12:13:39 +0100611 struct snd_ctl_elem_value *ucontrol)
612{
613 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
614 struct conexant_spec *spec = codec->spec;
615 int invert = (kcontrol->private_value >> 8) & 1;
616 hda_nid_t nid = kcontrol->private_value & 0xff;
617 unsigned int eapd;
Tobin Davis82f30042007-02-13 12:45:44 +0100618
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100619 eapd = !!ucontrol->value.integer.value[0];
Tobin Davisc9b443d2006-11-14 12:13:39 +0100620 if (invert)
621 eapd = !eapd;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200622 if (eapd == spec->cur_eapd)
Tobin Davisc9b443d2006-11-14 12:13:39 +0100623 return 0;
Tobin Davis82f30042007-02-13 12:45:44 +0100624
Tobin Davisc9b443d2006-11-14 12:13:39 +0100625 spec->cur_eapd = eapd;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200626 snd_hda_codec_write_cache(codec, nid,
627 0, AC_VERB_SET_EAPD_BTLENABLE,
628 eapd ? 0x02 : 0x00);
Tobin Davisc9b443d2006-11-14 12:13:39 +0100629 return 1;
630}
631
Takashi Iwai86d72bd2006-11-28 11:33:10 +0100632/* controls for test mode */
633#ifdef CONFIG_SND_DEBUG
634
Tobin Davis82f30042007-02-13 12:45:44 +0100635#define CXT_EAPD_SWITCH(xname, nid, mask) \
636 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
637 .info = cxt_eapd_info, \
638 .get = cxt_eapd_get, \
639 .put = cxt_eapd_put, \
640 .private_value = nid | (mask<<16) }
641
642
643
Tobin Davisc9b443d2006-11-14 12:13:39 +0100644static int conexant_ch_mode_info(struct snd_kcontrol *kcontrol,
645 struct snd_ctl_elem_info *uinfo)
646{
647 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
648 struct conexant_spec *spec = codec->spec;
649 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
650 spec->num_channel_mode);
651}
652
653static int conexant_ch_mode_get(struct snd_kcontrol *kcontrol,
654 struct snd_ctl_elem_value *ucontrol)
655{
656 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
657 struct conexant_spec *spec = codec->spec;
658 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
659 spec->num_channel_mode,
660 spec->multiout.max_channels);
661}
662
663static int conexant_ch_mode_put(struct snd_kcontrol *kcontrol,
664 struct snd_ctl_elem_value *ucontrol)
665{
666 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
667 struct conexant_spec *spec = codec->spec;
668 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
669 spec->num_channel_mode,
670 &spec->multiout.max_channels);
671 if (err >= 0 && spec->need_dac_fix)
672 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
673 return err;
674}
675
676#define CXT_PIN_MODE(xname, nid, dir) \
677 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
678 .info = conexant_ch_mode_info, \
679 .get = conexant_ch_mode_get, \
680 .put = conexant_ch_mode_put, \
681 .private_value = nid | (dir<<16) }
682
Takashi Iwai86d72bd2006-11-28 11:33:10 +0100683#endif /* CONFIG_SND_DEBUG */
684
Tobin Davisc9b443d2006-11-14 12:13:39 +0100685/* Conexant 5045 specific */
686
687static hda_nid_t cxt5045_dac_nids[1] = { 0x19 };
688static hda_nid_t cxt5045_adc_nids[1] = { 0x1a };
689static hda_nid_t cxt5045_capsrc_nids[1] = { 0x1a };
Takashi Iwaicbef9782008-02-22 18:36:46 +0100690#define CXT5045_SPDIF_OUT 0x18
Tobin Davisc9b443d2006-11-14 12:13:39 +0100691
Tobin Davis5cd57522006-11-20 17:42:09 +0100692static struct hda_channel_mode cxt5045_modes[1] = {
693 { 2, NULL },
694};
Tobin Davisc9b443d2006-11-14 12:13:39 +0100695
696static struct hda_input_mux cxt5045_capture_source = {
697 .num_items = 2,
698 .items = {
Tobin Davis82f30042007-02-13 12:45:44 +0100699 { "IntMic", 0x1 },
Jiang zhef4beee92008-01-17 11:19:26 +0100700 { "ExtMic", 0x2 },
Tobin Davisc9b443d2006-11-14 12:13:39 +0100701 }
702};
703
Jiang Zhe5218c892008-01-17 11:18:41 +0100704static struct hda_input_mux cxt5045_capture_source_benq = {
Lukasz Marcinowski22e14132009-09-22 21:42:40 +0200705 .num_items = 5,
Jiang Zhe5218c892008-01-17 11:18:41 +0100706 .items = {
707 { "IntMic", 0x1 },
708 { "ExtMic", 0x2 },
709 { "LineIn", 0x3 },
Lukasz Marcinowski22e14132009-09-22 21:42:40 +0200710 { "CD", 0x4 },
711 { "Mixer", 0x0 },
Jiang Zhe5218c892008-01-17 11:18:41 +0100712 }
713};
714
Jiang zhe2de3c232008-03-06 11:09:09 +0100715static struct hda_input_mux cxt5045_capture_source_hp530 = {
716 .num_items = 2,
717 .items = {
718 { "ExtMic", 0x1 },
719 { "IntMic", 0x2 },
720 }
721};
722
Tobin Davisc9b443d2006-11-14 12:13:39 +0100723/* turn on/off EAPD (+ mute HP) as a master switch */
724static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol,
725 struct snd_ctl_elem_value *ucontrol)
726{
727 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
728 struct conexant_spec *spec = codec->spec;
Tobin Davis82f30042007-02-13 12:45:44 +0100729 unsigned int bits;
Tobin Davisc9b443d2006-11-14 12:13:39 +0100730
Tobin Davis82f30042007-02-13 12:45:44 +0100731 if (!cxt_eapd_put(kcontrol, ucontrol))
Tobin Davisc9b443d2006-11-14 12:13:39 +0100732 return 0;
733
Tobin Davis82f30042007-02-13 12:45:44 +0100734 /* toggle internal speakers mute depending of presence of
735 * the headphone jack
736 */
Takashi Iwai47fd8302007-08-10 17:11:07 +0200737 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE;
738 snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0,
739 HDA_AMP_MUTE, bits);
Tobin Davis7f296732007-03-12 11:39:01 +0100740
Takashi Iwai47fd8302007-08-10 17:11:07 +0200741 bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE;
742 snd_hda_codec_amp_stereo(codec, 0x11, HDA_OUTPUT, 0,
743 HDA_AMP_MUTE, bits);
Tobin Davisc9b443d2006-11-14 12:13:39 +0100744 return 1;
745}
746
747/* bind volumes of both NID 0x10 and 0x11 */
Takashi Iwaicca3b372007-08-10 17:12:15 +0200748static struct hda_bind_ctls cxt5045_hp_bind_master_vol = {
749 .ops = &snd_hda_bind_vol,
750 .values = {
751 HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT),
752 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
753 0
754 },
755};
Tobin Davisc9b443d2006-11-14 12:13:39 +0100756
Tobin Davis7f296732007-03-12 11:39:01 +0100757/* toggle input of built-in and mic jack appropriately */
758static void cxt5045_hp_automic(struct hda_codec *codec)
759{
760 static struct hda_verb mic_jack_on[] = {
761 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
762 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
763 {}
764 };
765 static struct hda_verb mic_jack_off[] = {
766 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
767 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
768 {}
769 };
770 unsigned int present;
771
Takashi Iwaid56757a2009-11-18 08:00:14 +0100772 present = snd_hda_jack_detect(codec, 0x12);
Tobin Davis7f296732007-03-12 11:39:01 +0100773 if (present)
774 snd_hda_sequence_write(codec, mic_jack_on);
775 else
776 snd_hda_sequence_write(codec, mic_jack_off);
777}
778
Tobin Davisc9b443d2006-11-14 12:13:39 +0100779
780/* mute internal speaker if HP is plugged */
781static void cxt5045_hp_automute(struct hda_codec *codec)
782{
Tobin Davis82f30042007-02-13 12:45:44 +0100783 struct conexant_spec *spec = codec->spec;
Tobin Davisdd87da12007-02-26 16:07:42 +0100784 unsigned int bits;
Tobin Davisc9b443d2006-11-14 12:13:39 +0100785
Takashi Iwaid56757a2009-11-18 08:00:14 +0100786 spec->hp_present = snd_hda_jack_detect(codec, 0x11);
Tobin Davisdd87da12007-02-26 16:07:42 +0100787
Takashi Iwai47fd8302007-08-10 17:11:07 +0200788 bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0;
789 snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0,
790 HDA_AMP_MUTE, bits);
Tobin Davisc9b443d2006-11-14 12:13:39 +0100791}
792
793/* unsolicited event for HP jack sensing */
794static void cxt5045_hp_unsol_event(struct hda_codec *codec,
795 unsigned int res)
796{
797 res >>= 26;
798 switch (res) {
799 case CONEXANT_HP_EVENT:
800 cxt5045_hp_automute(codec);
801 break;
Tobin Davis7f296732007-03-12 11:39:01 +0100802 case CONEXANT_MIC_EVENT:
803 cxt5045_hp_automic(codec);
804 break;
805
Tobin Davisc9b443d2006-11-14 12:13:39 +0100806 }
807}
808
809static struct snd_kcontrol_new cxt5045_mixers[] = {
Takashi Iwaic8229c32007-10-19 08:06:21 +0200810 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x01, HDA_INPUT),
811 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x01, HDA_INPUT),
812 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x02, HDA_INPUT),
813 HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x02, HDA_INPUT),
814 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT),
815 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT),
816 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x1, HDA_INPUT),
817 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x1, HDA_INPUT),
818 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x2, HDA_INPUT),
819 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x2, HDA_INPUT),
Takashi Iwaicca3b372007-08-10 17:12:15 +0200820 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol),
Tobin Davisc9b443d2006-11-14 12:13:39 +0100821 {
822 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
823 .name = "Master Playback Switch",
Tobin Davis82f30042007-02-13 12:45:44 +0100824 .info = cxt_eapd_info,
825 .get = cxt_eapd_get,
Tobin Davisc9b443d2006-11-14 12:13:39 +0100826 .put = cxt5045_hp_master_sw_put,
Tobin Davis82f30042007-02-13 12:45:44 +0100827 .private_value = 0x10,
Tobin Davisc9b443d2006-11-14 12:13:39 +0100828 },
829
830 {}
831};
832
Jiang Zhe5218c892008-01-17 11:18:41 +0100833static struct snd_kcontrol_new cxt5045_benq_mixers[] = {
Lukasz Marcinowski22e14132009-09-22 21:42:40 +0200834 HDA_CODEC_VOLUME("CD Capture Volume", 0x1a, 0x04, HDA_INPUT),
835 HDA_CODEC_MUTE("CD Capture Switch", 0x1a, 0x04, HDA_INPUT),
836 HDA_CODEC_VOLUME("CD Playback Volume", 0x17, 0x4, HDA_INPUT),
837 HDA_CODEC_MUTE("CD Playback Switch", 0x17, 0x4, HDA_INPUT),
838
Jiang Zhe5218c892008-01-17 11:18:41 +0100839 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1a, 0x03, HDA_INPUT),
840 HDA_CODEC_MUTE("Line In Capture Switch", 0x1a, 0x03, HDA_INPUT),
841 HDA_CODEC_VOLUME("Line In Playback Volume", 0x17, 0x3, HDA_INPUT),
842 HDA_CODEC_MUTE("Line In Playback Switch", 0x17, 0x3, HDA_INPUT),
843
Lukasz Marcinowski22e14132009-09-22 21:42:40 +0200844 HDA_CODEC_VOLUME("Mixer Capture Volume", 0x1a, 0x0, HDA_INPUT),
845 HDA_CODEC_MUTE("Mixer Capture Switch", 0x1a, 0x0, HDA_INPUT),
846
Jiang Zhe5218c892008-01-17 11:18:41 +0100847 {}
848};
849
Jiang zhe2de3c232008-03-06 11:09:09 +0100850static struct snd_kcontrol_new cxt5045_mixers_hp530[] = {
Jiang zhe2de3c232008-03-06 11:09:09 +0100851 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x02, HDA_INPUT),
852 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x02, HDA_INPUT),
853 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x01, HDA_INPUT),
854 HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x01, HDA_INPUT),
855 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT),
856 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT),
857 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x2, HDA_INPUT),
858 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x2, HDA_INPUT),
859 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x1, HDA_INPUT),
860 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x1, HDA_INPUT),
861 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol),
862 {
863 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
864 .name = "Master Playback Switch",
865 .info = cxt_eapd_info,
866 .get = cxt_eapd_get,
867 .put = cxt5045_hp_master_sw_put,
868 .private_value = 0x10,
869 },
870
871 {}
872};
873
Tobin Davisc9b443d2006-11-14 12:13:39 +0100874static struct hda_verb cxt5045_init_verbs[] = {
875 /* Line in, Mic */
Takashi Iwai4090dff2008-07-12 12:02:45 +0200876 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
Tobin Davis7f296732007-03-12 11:39:01 +0100877 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
Tobin Davisc9b443d2006-11-14 12:13:39 +0100878 /* HP, Amp */
Takashi Iwaic8229c32007-10-19 08:06:21 +0200879 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
880 {0x10, AC_VERB_SET_CONNECT_SEL, 0x1},
881 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
882 {0x11, AC_VERB_SET_CONNECT_SEL, 0x1},
883 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
884 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
885 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
886 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
887 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Tobin Davis82f30042007-02-13 12:45:44 +0100888 /* Record selector: Int mic */
Tobin Davis7f296732007-03-12 11:39:01 +0100889 {0x1a, AC_VERB_SET_CONNECT_SEL,0x1},
Tobin Davis82f30042007-02-13 12:45:44 +0100890 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE,
Tobin Davisc9b443d2006-11-14 12:13:39 +0100891 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
892 /* SPDIF route: PCM */
Takashi Iwaicbef9782008-02-22 18:36:46 +0100893 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Tobin Davisc9b443d2006-11-14 12:13:39 +0100894 { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 },
Tobin Davisc9b443d2006-11-14 12:13:39 +0100895 /* EAPD */
Tobin Davis82f30042007-02-13 12:45:44 +0100896 {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */
Tobin Davisc9b443d2006-11-14 12:13:39 +0100897 { } /* end */
898};
899
Jiang Zhe5218c892008-01-17 11:18:41 +0100900static struct hda_verb cxt5045_benq_init_verbs[] = {
901 /* Int Mic, Mic */
902 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
903 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
904 /* Line In,HP, Amp */
905 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
906 {0x10, AC_VERB_SET_CONNECT_SEL, 0x1},
907 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
908 {0x11, AC_VERB_SET_CONNECT_SEL, 0x1},
909 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
910 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
911 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
912 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
913 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
914 /* Record selector: Int mic */
915 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x1},
916 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE,
917 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
918 /* SPDIF route: PCM */
Takashi Iwaicbef9782008-02-22 18:36:46 +0100919 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jiang Zhe5218c892008-01-17 11:18:41 +0100920 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
921 /* EAPD */
922 {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
923 { } /* end */
924};
Tobin Davis7f296732007-03-12 11:39:01 +0100925
926static struct hda_verb cxt5045_hp_sense_init_verbs[] = {
927 /* pin sensing on HP jack */
928 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
Takashi Iwaid3091fa2007-03-28 15:11:53 +0200929 { } /* end */
Tobin Davis7f296732007-03-12 11:39:01 +0100930};
931
932static struct hda_verb cxt5045_mic_sense_init_verbs[] = {
933 /* pin sensing on HP jack */
934 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
Takashi Iwaid3091fa2007-03-28 15:11:53 +0200935 { } /* end */
Tobin Davis7f296732007-03-12 11:39:01 +0100936};
937
Tobin Davisc9b443d2006-11-14 12:13:39 +0100938#ifdef CONFIG_SND_DEBUG
939/* Test configuration for debugging, modelled after the ALC260 test
940 * configuration.
941 */
942static struct hda_input_mux cxt5045_test_capture_source = {
943 .num_items = 5,
944 .items = {
945 { "MIXER", 0x0 },
946 { "MIC1 pin", 0x1 },
947 { "LINE1 pin", 0x2 },
948 { "HP-OUT pin", 0x3 },
949 { "CD pin", 0x4 },
950 },
951};
952
953static struct snd_kcontrol_new cxt5045_test_mixer[] = {
954
955 /* Output controls */
Tobin Davisc9b443d2006-11-14 12:13:39 +0100956 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT),
957 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT),
Tobin Davis7f296732007-03-12 11:39:01 +0100958 HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT),
959 HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT),
960 HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT),
961 HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT),
Tobin Davisc9b443d2006-11-14 12:13:39 +0100962
963 /* Modes for retasking pin widgets */
964 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT),
965 CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT),
966
Tobin Davis82f30042007-02-13 12:45:44 +0100967 /* EAPD Switch Control */
968 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
969
Tobin Davisc9b443d2006-11-14 12:13:39 +0100970 /* Loopback mixer controls */
Tobin Davisc9b443d2006-11-14 12:13:39 +0100971
Tobin Davis7f296732007-03-12 11:39:01 +0100972 HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT),
973 HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT),
974 HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT),
975 HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT),
976 HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT),
977 HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT),
978 HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT),
979 HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT),
980 HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT),
981 HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT),
Tobin Davisc9b443d2006-11-14 12:13:39 +0100982 {
983 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
984 .name = "Input Source",
985 .info = conexant_mux_enum_info,
986 .get = conexant_mux_enum_get,
987 .put = conexant_mux_enum_put,
988 },
Tobin Davisfb3409e2007-05-17 09:40:47 +0200989 /* Audio input controls */
990 HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT),
991 HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT),
992 HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT),
993 HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT),
994 HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT),
995 HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT),
996 HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT),
997 HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT),
998 HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT),
999 HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT),
Tobin Davisc9b443d2006-11-14 12:13:39 +01001000 { } /* end */
1001};
1002
1003static struct hda_verb cxt5045_test_init_verbs[] = {
Tobin Davis7f296732007-03-12 11:39:01 +01001004 /* Set connections */
1005 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
1006 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x0 },
1007 { 0x12, AC_VERB_SET_CONNECT_SEL, 0x0 },
Tobin Davisc9b443d2006-11-14 12:13:39 +01001008 /* Enable retasking pins as output, initially without power amp */
1009 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Tobin Davis7f296732007-03-12 11:39:01 +01001010 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Tobin Davisc9b443d2006-11-14 12:13:39 +01001011
1012 /* Disable digital (SPDIF) pins initially, but users can enable
1013 * them via a mixer switch. In the case of SPDIF-out, this initverb
1014 * payload also sets the generation to 0, output to be in "consumer"
1015 * PCM format, copyright asserted, no pre-emphasis and no validity
1016 * control.
1017 */
Takashi Iwaicbef9782008-02-22 18:36:46 +01001018 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1019 {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0},
Tobin Davisc9b443d2006-11-14 12:13:39 +01001020
1021 /* Start with output sum widgets muted and their output gains at min */
1022 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1023 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1024
1025 /* Unmute retasking pin widget output buffers since the default
1026 * state appears to be output. As the pin mode is changed by the
1027 * user the pin mode control will take care of enabling the pin's
1028 * input/output buffers as needed.
1029 */
1030 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1031 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1032
1033 /* Mute capture amp left and right */
1034 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1035
1036 /* Set ADC connection select to match default mixer setting (mic1
1037 * pin)
1038 */
1039 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
Tobin Davis7f296732007-03-12 11:39:01 +01001040 {0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
Tobin Davisc9b443d2006-11-14 12:13:39 +01001041
1042 /* Mute all inputs to mixer widget (even unconnected ones) */
1043 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer pin */
1044 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* Mic1 pin */
1045 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* Line pin */
1046 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* HP pin */
1047 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
1048
1049 { }
1050};
1051#endif
1052
1053
1054/* initialize jack-sensing, too */
1055static int cxt5045_init(struct hda_codec *codec)
1056{
1057 conexant_init(codec);
1058 cxt5045_hp_automute(codec);
1059 return 0;
1060}
1061
1062
1063enum {
Marc Boucher15908c32008-01-22 15:15:59 +01001064 CXT5045_LAPTOP_HPSENSE,
1065 CXT5045_LAPTOP_MICSENSE,
1066 CXT5045_LAPTOP_HPMICSENSE,
Jiang Zhe5218c892008-01-17 11:18:41 +01001067 CXT5045_BENQ,
Jiang zhe2de3c232008-03-06 11:09:09 +01001068 CXT5045_LAPTOP_HP530,
Tobin Davisc9b443d2006-11-14 12:13:39 +01001069#ifdef CONFIG_SND_DEBUG
1070 CXT5045_TEST,
1071#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001072 CXT5045_MODELS
Tobin Davisc9b443d2006-11-14 12:13:39 +01001073};
1074
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001075static const char *cxt5045_models[CXT5045_MODELS] = {
Marc Boucher15908c32008-01-22 15:15:59 +01001076 [CXT5045_LAPTOP_HPSENSE] = "laptop-hpsense",
1077 [CXT5045_LAPTOP_MICSENSE] = "laptop-micsense",
1078 [CXT5045_LAPTOP_HPMICSENSE] = "laptop-hpmicsense",
1079 [CXT5045_BENQ] = "benq",
Jiang zhe2de3c232008-03-06 11:09:09 +01001080 [CXT5045_LAPTOP_HP530] = "laptop-hp530",
Tobin Davisc9b443d2006-11-14 12:13:39 +01001081#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001082 [CXT5045_TEST] = "test",
Tobin Davisc9b443d2006-11-14 12:13:39 +01001083#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001084};
1085
1086static struct snd_pci_quirk cxt5045_cfg_tbl[] = {
Jiang zhe2de3c232008-03-06 11:09:09 +01001087 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530),
Takashi Iwaidea0a502009-02-09 17:14:52 +01001088 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1089 CXT5045_LAPTOP_HPSENSE),
Takashi Iwai6a9dccd2008-07-01 14:52:05 +02001090 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE),
Jiang Zhe5218c892008-01-17 11:18:41 +01001091 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ),
Marc Boucher15908c32008-01-22 15:15:59 +01001092 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE),
1093 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE),
Takashi Iwai9e464152008-07-12 12:05:25 +02001094 SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505",
1095 CXT5045_LAPTOP_HPMICSENSE),
Marc Boucher15908c32008-01-22 15:15:59 +01001096 SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE),
1097 SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE),
1098 SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE),
Takashi Iwaidea0a502009-02-09 17:14:52 +01001099 SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell",
1100 CXT5045_LAPTOP_HPMICSENSE),
Marc Boucher15908c32008-01-22 15:15:59 +01001101 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE),
Tobin Davisc9b443d2006-11-14 12:13:39 +01001102 {}
1103};
1104
1105static int patch_cxt5045(struct hda_codec *codec)
1106{
1107 struct conexant_spec *spec;
1108 int board_config;
1109
1110 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1111 if (!spec)
1112 return -ENOMEM;
Tobin Davisc9b443d2006-11-14 12:13:39 +01001113 codec->spec = spec;
Takashi Iwai9421f952009-03-12 17:06:07 +01001114 codec->pin_amp_workaround = 1;
Tobin Davisc9b443d2006-11-14 12:13:39 +01001115
1116 spec->multiout.max_channels = 2;
1117 spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids);
1118 spec->multiout.dac_nids = cxt5045_dac_nids;
1119 spec->multiout.dig_out_nid = CXT5045_SPDIF_OUT;
1120 spec->num_adc_nids = 1;
1121 spec->adc_nids = cxt5045_adc_nids;
1122 spec->capsrc_nids = cxt5045_capsrc_nids;
1123 spec->input_mux = &cxt5045_capture_source;
1124 spec->num_mixers = 1;
1125 spec->mixers[0] = cxt5045_mixers;
1126 spec->num_init_verbs = 1;
1127 spec->init_verbs[0] = cxt5045_init_verbs;
1128 spec->spdif_route = 0;
Tobin Davis5cd57522006-11-20 17:42:09 +01001129 spec->num_channel_mode = ARRAY_SIZE(cxt5045_modes),
1130 spec->channel_mode = cxt5045_modes,
1131
Tobin Davisc9b443d2006-11-14 12:13:39 +01001132
1133 codec->patch_ops = conexant_patch_ops;
Tobin Davisc9b443d2006-11-14 12:13:39 +01001134
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001135 board_config = snd_hda_check_board_config(codec, CXT5045_MODELS,
1136 cxt5045_models,
1137 cxt5045_cfg_tbl);
Tobin Davisc9b443d2006-11-14 12:13:39 +01001138 switch (board_config) {
Marc Boucher15908c32008-01-22 15:15:59 +01001139 case CXT5045_LAPTOP_HPSENSE:
Tobin Davis7f296732007-03-12 11:39:01 +01001140 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
Tobin Davisc9b443d2006-11-14 12:13:39 +01001141 spec->input_mux = &cxt5045_capture_source;
1142 spec->num_init_verbs = 2;
Tobin Davis7f296732007-03-12 11:39:01 +01001143 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
1144 spec->mixers[0] = cxt5045_mixers;
1145 codec->patch_ops.init = cxt5045_init;
1146 break;
Marc Boucher15908c32008-01-22 15:15:59 +01001147 case CXT5045_LAPTOP_MICSENSE:
Takashi Iwai86376df2008-07-12 12:04:05 +02001148 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
Tobin Davis7f296732007-03-12 11:39:01 +01001149 spec->input_mux = &cxt5045_capture_source;
1150 spec->num_init_verbs = 2;
1151 spec->init_verbs[1] = cxt5045_mic_sense_init_verbs;
Tobin Davisc9b443d2006-11-14 12:13:39 +01001152 spec->mixers[0] = cxt5045_mixers;
1153 codec->patch_ops.init = cxt5045_init;
1154 break;
Marc Boucher15908c32008-01-22 15:15:59 +01001155 default:
1156 case CXT5045_LAPTOP_HPMICSENSE:
1157 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
1158 spec->input_mux = &cxt5045_capture_source;
1159 spec->num_init_verbs = 3;
1160 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
1161 spec->init_verbs[2] = cxt5045_mic_sense_init_verbs;
1162 spec->mixers[0] = cxt5045_mixers;
1163 codec->patch_ops.init = cxt5045_init;
1164 break;
Jiang Zhe5218c892008-01-17 11:18:41 +01001165 case CXT5045_BENQ:
1166 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
1167 spec->input_mux = &cxt5045_capture_source_benq;
1168 spec->num_init_verbs = 1;
1169 spec->init_verbs[0] = cxt5045_benq_init_verbs;
1170 spec->mixers[0] = cxt5045_mixers;
1171 spec->mixers[1] = cxt5045_benq_mixers;
1172 spec->num_mixers = 2;
1173 codec->patch_ops.init = cxt5045_init;
1174 break;
Jiang zhe2de3c232008-03-06 11:09:09 +01001175 case CXT5045_LAPTOP_HP530:
1176 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
1177 spec->input_mux = &cxt5045_capture_source_hp530;
1178 spec->num_init_verbs = 2;
1179 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
1180 spec->mixers[0] = cxt5045_mixers_hp530;
1181 codec->patch_ops.init = cxt5045_init;
1182 break;
Tobin Davisc9b443d2006-11-14 12:13:39 +01001183#ifdef CONFIG_SND_DEBUG
1184 case CXT5045_TEST:
1185 spec->input_mux = &cxt5045_test_capture_source;
1186 spec->mixers[0] = cxt5045_test_mixer;
1187 spec->init_verbs[0] = cxt5045_test_init_verbs;
Marc Boucher15908c32008-01-22 15:15:59 +01001188 break;
1189
Tobin Davisc9b443d2006-11-14 12:13:39 +01001190#endif
1191 }
Takashi Iwai48ecb7e2007-12-17 14:32:49 +01001192
Takashi Iwai031005f2008-06-26 14:49:58 +02001193 switch (codec->subsystem_id >> 16) {
1194 case 0x103c:
Daniel T Chen0b587fc2009-11-25 18:27:20 -05001195 case 0x1734:
1196 /* HP & Fujitsu-Siemens laptops have really bad sound over 0dB
1197 * on NID 0x17. Fix max PCM level to 0 dB
1198 * (originally it has 0x2b steps with 0dB offset 0x14)
Takashi Iwai031005f2008-06-26 14:49:58 +02001199 */
1200 snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT,
1201 (0x14 << AC_AMPCAP_OFFSET_SHIFT) |
1202 (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) |
1203 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
1204 (1 << AC_AMPCAP_MUTE_SHIFT));
1205 break;
1206 }
Takashi Iwai48ecb7e2007-12-17 14:32:49 +01001207
Tobin Davisc9b443d2006-11-14 12:13:39 +01001208 return 0;
1209}
1210
1211
1212/* Conexant 5047 specific */
Tobin Davis82f30042007-02-13 12:45:44 +01001213#define CXT5047_SPDIF_OUT 0x11
Tobin Davisc9b443d2006-11-14 12:13:39 +01001214
Takashi Iwai5b3a7442009-03-10 15:10:55 +01001215static hda_nid_t cxt5047_dac_nids[1] = { 0x10 }; /* 0x1c */
Tobin Davisc9b443d2006-11-14 12:13:39 +01001216static hda_nid_t cxt5047_adc_nids[1] = { 0x12 };
1217static hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a };
Tobin Davisc9b443d2006-11-14 12:13:39 +01001218
Tobin Davis5cd57522006-11-20 17:42:09 +01001219static struct hda_channel_mode cxt5047_modes[1] = {
1220 { 2, NULL },
1221};
Tobin Davisc9b443d2006-11-14 12:13:39 +01001222
Tobin Davis82f30042007-02-13 12:45:44 +01001223static struct hda_input_mux cxt5047_toshiba_capture_source = {
1224 .num_items = 2,
1225 .items = {
1226 { "ExtMic", 0x2 },
1227 { "Line-In", 0x1 },
Tobin Davisc9b443d2006-11-14 12:13:39 +01001228 }
1229};
1230
1231/* turn on/off EAPD (+ mute HP) as a master switch */
1232static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1233 struct snd_ctl_elem_value *ucontrol)
1234{
1235 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1236 struct conexant_spec *spec = codec->spec;
Tobin Davis82f30042007-02-13 12:45:44 +01001237 unsigned int bits;
Tobin Davisc9b443d2006-11-14 12:13:39 +01001238
Tobin Davis82f30042007-02-13 12:45:44 +01001239 if (!cxt_eapd_put(kcontrol, ucontrol))
Tobin Davisc9b443d2006-11-14 12:13:39 +01001240 return 0;
1241
Tobin Davis82f30042007-02-13 12:45:44 +01001242 /* toggle internal speakers mute depending of presence of
1243 * the headphone jack
1244 */
Takashi Iwai47fd8302007-08-10 17:11:07 +02001245 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE;
Takashi Iwai3b7523f2009-03-12 16:45:01 +01001246 /* NOTE: Conexat codec needs the index for *OUTPUT* amp of
1247 * pin widgets unlike other codecs. In this case, we need to
1248 * set index 0x01 for the volume from the mixer amp 0x19.
1249 */
Gregorio Guidi5d75bc52009-03-12 16:41:51 +01001250 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01,
Takashi Iwai47fd8302007-08-10 17:11:07 +02001251 HDA_AMP_MUTE, bits);
1252 bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE;
1253 snd_hda_codec_amp_stereo(codec, 0x13, HDA_OUTPUT, 0,
1254 HDA_AMP_MUTE, bits);
Tobin Davisc9b443d2006-11-14 12:13:39 +01001255 return 1;
1256}
1257
Tobin Davisc9b443d2006-11-14 12:13:39 +01001258/* mute internal speaker if HP is plugged */
1259static void cxt5047_hp_automute(struct hda_codec *codec)
1260{
Tobin Davis82f30042007-02-13 12:45:44 +01001261 struct conexant_spec *spec = codec->spec;
Tobin Davisdd87da12007-02-26 16:07:42 +01001262 unsigned int bits;
Tobin Davisc9b443d2006-11-14 12:13:39 +01001263
Takashi Iwaid56757a2009-11-18 08:00:14 +01001264 spec->hp_present = snd_hda_jack_detect(codec, 0x13);
Tobin Davisdd87da12007-02-26 16:07:42 +01001265
Takashi Iwai47fd8302007-08-10 17:11:07 +02001266 bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0;
Takashi Iwai3b7523f2009-03-12 16:45:01 +01001267 /* See the note in cxt5047_hp_master_sw_put */
Gregorio Guidi5d75bc52009-03-12 16:41:51 +01001268 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01,
Takashi Iwai47fd8302007-08-10 17:11:07 +02001269 HDA_AMP_MUTE, bits);
Tobin Davisc9b443d2006-11-14 12:13:39 +01001270}
1271
1272/* toggle input of built-in and mic jack appropriately */
1273static void cxt5047_hp_automic(struct hda_codec *codec)
1274{
1275 static struct hda_verb mic_jack_on[] = {
Marc Boucher9f113e02008-01-22 15:18:08 +01001276 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1277 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Tobin Davisc9b443d2006-11-14 12:13:39 +01001278 {}
1279 };
1280 static struct hda_verb mic_jack_off[] = {
Marc Boucher9f113e02008-01-22 15:18:08 +01001281 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1282 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Tobin Davisc9b443d2006-11-14 12:13:39 +01001283 {}
1284 };
1285 unsigned int present;
1286
Takashi Iwaid56757a2009-11-18 08:00:14 +01001287 present = snd_hda_jack_detect(codec, 0x15);
Tobin Davisc9b443d2006-11-14 12:13:39 +01001288 if (present)
1289 snd_hda_sequence_write(codec, mic_jack_on);
1290 else
1291 snd_hda_sequence_write(codec, mic_jack_off);
1292}
1293
1294/* unsolicited event for HP jack sensing */
1295static void cxt5047_hp_unsol_event(struct hda_codec *codec,
1296 unsigned int res)
1297{
Marc Boucher9f113e02008-01-22 15:18:08 +01001298 switch (res >> 26) {
Tobin Davisc9b443d2006-11-14 12:13:39 +01001299 case CONEXANT_HP_EVENT:
1300 cxt5047_hp_automute(codec);
1301 break;
1302 case CONEXANT_MIC_EVENT:
1303 cxt5047_hp_automic(codec);
1304 break;
1305 }
1306}
1307
Takashi Iwaidf481e42009-03-10 15:35:35 +01001308static struct snd_kcontrol_new cxt5047_base_mixers[] = {
1309 HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT),
1310 HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT),
1311 HDA_CODEC_VOLUME("Mic Boost", 0x1a, 0x0, HDA_OUTPUT),
Tobin Davisc9b443d2006-11-14 12:13:39 +01001312 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1313 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1314 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1315 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
Tobin Davis82f30042007-02-13 12:45:44 +01001316 {
1317 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1318 .name = "Master Playback Switch",
1319 .info = cxt_eapd_info,
1320 .get = cxt_eapd_get,
Tobin Davisc9b443d2006-11-14 12:13:39 +01001321 .put = cxt5047_hp_master_sw_put,
1322 .private_value = 0x13,
1323 },
1324
1325 {}
1326};
1327
Takashi Iwaidf481e42009-03-10 15:35:35 +01001328static struct snd_kcontrol_new cxt5047_hp_spk_mixers[] = {
Takashi Iwai3b7523f2009-03-12 16:45:01 +01001329 /* See the note in cxt5047_hp_master_sw_put */
Gregorio Guidi5d75bc52009-03-12 16:41:51 +01001330 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT),
Takashi Iwaidf481e42009-03-10 15:35:35 +01001331 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT),
1332 {}
1333};
1334
1335static struct snd_kcontrol_new cxt5047_hp_only_mixers[] = {
Tobin Davisc9b443d2006-11-14 12:13:39 +01001336 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT),
Tobin Davisc9b443d2006-11-14 12:13:39 +01001337 { } /* end */
1338};
1339
1340static struct hda_verb cxt5047_init_verbs[] = {
1341 /* Line in, Mic, Built-in Mic */
1342 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1343 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1344 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
Tobin Davis7f296732007-03-12 11:39:01 +01001345 /* HP, Speaker */
Tobin Davisb7589ce2007-04-24 17:56:55 +02001346 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
Takashi Iwai5b3a7442009-03-10 15:10:55 +01001347 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, /* mixer(0x19) */
1348 {0x1d, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mixer(0x19) */
Tobin Davis7f296732007-03-12 11:39:01 +01001349 /* Record selector: Mic */
1350 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1351 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1352 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1353 {0x1A, AC_VERB_SET_CONNECT_SEL,0x02},
Tobin Davisc9b443d2006-11-14 12:13:39 +01001354 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1355 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00},
1356 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1357 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03},
Tobin Davisc9b443d2006-11-14 12:13:39 +01001358 /* SPDIF route: PCM */
1359 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 },
Tobin Davis82f30042007-02-13 12:45:44 +01001360 /* Enable unsolicited events */
1361 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1362 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
Tobin Davisc9b443d2006-11-14 12:13:39 +01001363 { } /* end */
1364};
1365
1366/* configuration for Toshiba Laptops */
1367static struct hda_verb cxt5047_toshiba_init_verbs[] = {
Takashi Iwai3b628862009-03-10 14:53:54 +01001368 {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0}, /* default off */
Tobin Davisc9b443d2006-11-14 12:13:39 +01001369 {}
1370};
1371
1372/* Test configuration for debugging, modelled after the ALC260 test
1373 * configuration.
1374 */
1375#ifdef CONFIG_SND_DEBUG
1376static struct hda_input_mux cxt5047_test_capture_source = {
Tobin Davis82f30042007-02-13 12:45:44 +01001377 .num_items = 4,
Tobin Davisc9b443d2006-11-14 12:13:39 +01001378 .items = {
Tobin Davis82f30042007-02-13 12:45:44 +01001379 { "LINE1 pin", 0x0 },
1380 { "MIC1 pin", 0x1 },
1381 { "MIC2 pin", 0x2 },
1382 { "CD pin", 0x3 },
Tobin Davisc9b443d2006-11-14 12:13:39 +01001383 },
1384};
1385
1386static struct snd_kcontrol_new cxt5047_test_mixer[] = {
1387
1388 /* Output only controls */
Tobin Davis82f30042007-02-13 12:45:44 +01001389 HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT),
1390 HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT),
1391 HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT),
1392 HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT),
Tobin Davisc9b443d2006-11-14 12:13:39 +01001393 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1394 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1395 HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1396 HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT),
Tobin Davis82f30042007-02-13 12:45:44 +01001397 HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT),
1398 HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1399 HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT),
1400 HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Tobin Davisc9b443d2006-11-14 12:13:39 +01001401
1402 /* Modes for retasking pin widgets */
1403 CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT),
1404 CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT),
1405
Tobin Davis82f30042007-02-13 12:45:44 +01001406 /* EAPD Switch Control */
1407 CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0),
1408
Tobin Davisc9b443d2006-11-14 12:13:39 +01001409 /* Loopback mixer controls */
Tobin Davis82f30042007-02-13 12:45:44 +01001410 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT),
1411 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT),
1412 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT),
1413 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT),
1414 HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT),
1415 HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT),
1416 HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT),
1417 HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT),
Tobin Davisc9b443d2006-11-14 12:13:39 +01001418
Tobin Davis82f30042007-02-13 12:45:44 +01001419 HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT),
1420 HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT),
1421 HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT),
1422 HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT),
1423 HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT),
1424 HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT),
1425 HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT),
1426 HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT),
Tobin Davisc9b443d2006-11-14 12:13:39 +01001427 {
1428 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1429 .name = "Input Source",
1430 .info = conexant_mux_enum_info,
1431 .get = conexant_mux_enum_get,
1432 .put = conexant_mux_enum_put,
1433 },
Takashi Iwai854206b2009-11-30 18:22:04 +01001434 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT),
Marc Boucher9f113e02008-01-22 15:18:08 +01001435
Tobin Davisc9b443d2006-11-14 12:13:39 +01001436 { } /* end */
1437};
1438
1439static struct hda_verb cxt5047_test_init_verbs[] = {
Tobin Davisc9b443d2006-11-14 12:13:39 +01001440 /* Enable retasking pins as output, initially without power amp */
1441 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1442 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1443 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1444
1445 /* Disable digital (SPDIF) pins initially, but users can enable
1446 * them via a mixer switch. In the case of SPDIF-out, this initverb
1447 * payload also sets the generation to 0, output to be in "consumer"
1448 * PCM format, copyright asserted, no pre-emphasis and no validity
1449 * control.
1450 */
1451 {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0},
1452
1453 /* Ensure mic1, mic2, line1 pin widgets take input from the
1454 * OUT1 sum bus when acting as an output.
1455 */
1456 {0x1a, AC_VERB_SET_CONNECT_SEL, 0},
1457 {0x1b, AC_VERB_SET_CONNECT_SEL, 0},
1458
1459 /* Start with output sum widgets muted and their output gains at min */
1460 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1461 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1462
1463 /* Unmute retasking pin widget output buffers since the default
1464 * state appears to be output. As the pin mode is changed by the
1465 * user the pin mode control will take care of enabling the pin's
1466 * input/output buffers as needed.
1467 */
1468 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1469 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1470 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1471
1472 /* Mute capture amp left and right */
1473 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1474
1475 /* Set ADC connection select to match default mixer setting (mic1
1476 * pin)
1477 */
1478 {0x12, AC_VERB_SET_CONNECT_SEL, 0x00},
1479
1480 /* Mute all inputs to mixer widget (even unconnected ones) */
1481 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
1482 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
1483 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
1484 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
1485 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
1486 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
1487 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
1488 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
1489
1490 { }
1491};
1492#endif
1493
1494
1495/* initialize jack-sensing, too */
1496static int cxt5047_hp_init(struct hda_codec *codec)
1497{
1498 conexant_init(codec);
1499 cxt5047_hp_automute(codec);
Tobin Davisc9b443d2006-11-14 12:13:39 +01001500 return 0;
1501}
1502
1503
1504enum {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001505 CXT5047_LAPTOP, /* Laptops w/o EAPD support */
1506 CXT5047_LAPTOP_HP, /* Some HP laptops */
1507 CXT5047_LAPTOP_EAPD, /* Laptops with EAPD support */
Tobin Davisc9b443d2006-11-14 12:13:39 +01001508#ifdef CONFIG_SND_DEBUG
1509 CXT5047_TEST,
1510#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001511 CXT5047_MODELS
Tobin Davisc9b443d2006-11-14 12:13:39 +01001512};
1513
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001514static const char *cxt5047_models[CXT5047_MODELS] = {
1515 [CXT5047_LAPTOP] = "laptop",
1516 [CXT5047_LAPTOP_HP] = "laptop-hp",
1517 [CXT5047_LAPTOP_EAPD] = "laptop-eapd",
Tobin Davisc9b443d2006-11-14 12:13:39 +01001518#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001519 [CXT5047_TEST] = "test",
Tobin Davisc9b443d2006-11-14 12:13:39 +01001520#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001521};
1522
1523static struct snd_pci_quirk cxt5047_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01001524 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP),
Takashi Iwaidea0a502009-02-09 17:14:52 +01001525 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1526 CXT5047_LAPTOP),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001527 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD),
Tobin Davisc9b443d2006-11-14 12:13:39 +01001528 {}
1529};
1530
1531static int patch_cxt5047(struct hda_codec *codec)
1532{
1533 struct conexant_spec *spec;
1534 int board_config;
1535
1536 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1537 if (!spec)
1538 return -ENOMEM;
Tobin Davisc9b443d2006-11-14 12:13:39 +01001539 codec->spec = spec;
Takashi Iwai9421f952009-03-12 17:06:07 +01001540 codec->pin_amp_workaround = 1;
Tobin Davisc9b443d2006-11-14 12:13:39 +01001541
1542 spec->multiout.max_channels = 2;
1543 spec->multiout.num_dacs = ARRAY_SIZE(cxt5047_dac_nids);
1544 spec->multiout.dac_nids = cxt5047_dac_nids;
1545 spec->multiout.dig_out_nid = CXT5047_SPDIF_OUT;
1546 spec->num_adc_nids = 1;
1547 spec->adc_nids = cxt5047_adc_nids;
1548 spec->capsrc_nids = cxt5047_capsrc_nids;
Tobin Davisc9b443d2006-11-14 12:13:39 +01001549 spec->num_mixers = 1;
Takashi Iwaidf481e42009-03-10 15:35:35 +01001550 spec->mixers[0] = cxt5047_base_mixers;
Tobin Davisc9b443d2006-11-14 12:13:39 +01001551 spec->num_init_verbs = 1;
1552 spec->init_verbs[0] = cxt5047_init_verbs;
1553 spec->spdif_route = 0;
Tobin Davis5cd57522006-11-20 17:42:09 +01001554 spec->num_channel_mode = ARRAY_SIZE(cxt5047_modes),
1555 spec->channel_mode = cxt5047_modes,
Tobin Davisc9b443d2006-11-14 12:13:39 +01001556
1557 codec->patch_ops = conexant_patch_ops;
Tobin Davisc9b443d2006-11-14 12:13:39 +01001558
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001559 board_config = snd_hda_check_board_config(codec, CXT5047_MODELS,
1560 cxt5047_models,
1561 cxt5047_cfg_tbl);
Tobin Davisc9b443d2006-11-14 12:13:39 +01001562 switch (board_config) {
1563 case CXT5047_LAPTOP:
Takashi Iwaidf481e42009-03-10 15:35:35 +01001564 spec->num_mixers = 2;
1565 spec->mixers[1] = cxt5047_hp_spk_mixers;
1566 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
Tobin Davisc9b443d2006-11-14 12:13:39 +01001567 break;
1568 case CXT5047_LAPTOP_HP:
Takashi Iwaidf481e42009-03-10 15:35:35 +01001569 spec->num_mixers = 2;
1570 spec->mixers[1] = cxt5047_hp_only_mixers;
Tobin Davisfb3409e2007-05-17 09:40:47 +02001571 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
Tobin Davisc9b443d2006-11-14 12:13:39 +01001572 codec->patch_ops.init = cxt5047_hp_init;
1573 break;
1574 case CXT5047_LAPTOP_EAPD:
Tobin Davis82f30042007-02-13 12:45:44 +01001575 spec->input_mux = &cxt5047_toshiba_capture_source;
Takashi Iwaidf481e42009-03-10 15:35:35 +01001576 spec->num_mixers = 2;
1577 spec->mixers[1] = cxt5047_hp_spk_mixers;
Tobin Davisc9b443d2006-11-14 12:13:39 +01001578 spec->num_init_verbs = 2;
1579 spec->init_verbs[1] = cxt5047_toshiba_init_verbs;
Tobin Davisfb3409e2007-05-17 09:40:47 +02001580 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
Tobin Davisc9b443d2006-11-14 12:13:39 +01001581 break;
1582#ifdef CONFIG_SND_DEBUG
1583 case CXT5047_TEST:
1584 spec->input_mux = &cxt5047_test_capture_source;
1585 spec->mixers[0] = cxt5047_test_mixer;
1586 spec->init_verbs[0] = cxt5047_test_init_verbs;
Tobin Davisfb3409e2007-05-17 09:40:47 +02001587 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
Tobin Davisc9b443d2006-11-14 12:13:39 +01001588#endif
1589 }
Takashi Iwaidd5746a2009-03-10 14:30:40 +01001590 spec->vmaster_nid = 0x13;
Tobin Davisc9b443d2006-11-14 12:13:39 +01001591 return 0;
1592}
1593
Takashi Iwai461e2c72008-01-25 11:35:17 +01001594/* Conexant 5051 specific */
1595static hda_nid_t cxt5051_dac_nids[1] = { 0x10 };
1596static hda_nid_t cxt5051_adc_nids[2] = { 0x14, 0x15 };
Takashi Iwai461e2c72008-01-25 11:35:17 +01001597
1598static struct hda_channel_mode cxt5051_modes[1] = {
1599 { 2, NULL },
1600};
1601
1602static void cxt5051_update_speaker(struct hda_codec *codec)
1603{
1604 struct conexant_spec *spec = codec->spec;
1605 unsigned int pinctl;
1606 pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0;
1607 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
1608 pinctl);
1609}
1610
1611/* turn on/off EAPD (+ mute HP) as a master switch */
1612static int cxt5051_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1613 struct snd_ctl_elem_value *ucontrol)
1614{
1615 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1616
1617 if (!cxt_eapd_put(kcontrol, ucontrol))
1618 return 0;
1619 cxt5051_update_speaker(codec);
1620 return 1;
1621}
1622
1623/* toggle input of built-in and mic jack appropriately */
1624static void cxt5051_portb_automic(struct hda_codec *codec)
1625{
Takashi Iwai79d7d532009-03-04 09:03:50 +01001626 struct conexant_spec *spec = codec->spec;
Takashi Iwai461e2c72008-01-25 11:35:17 +01001627 unsigned int present;
1628
Takashi Iwai79d7d532009-03-04 09:03:50 +01001629 if (spec->no_auto_mic)
1630 return;
Takashi Iwaid56757a2009-11-18 08:00:14 +01001631 present = snd_hda_jack_detect(codec, 0x17);
Takashi Iwai461e2c72008-01-25 11:35:17 +01001632 snd_hda_codec_write(codec, 0x14, 0,
1633 AC_VERB_SET_CONNECT_SEL,
1634 present ? 0x01 : 0x00);
1635}
1636
1637/* switch the current ADC according to the jack state */
1638static void cxt5051_portc_automic(struct hda_codec *codec)
1639{
1640 struct conexant_spec *spec = codec->spec;
1641 unsigned int present;
1642 hda_nid_t new_adc;
1643
Takashi Iwai79d7d532009-03-04 09:03:50 +01001644 if (spec->no_auto_mic)
1645 return;
Takashi Iwaid56757a2009-11-18 08:00:14 +01001646 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai461e2c72008-01-25 11:35:17 +01001647 if (present)
1648 spec->cur_adc_idx = 1;
1649 else
1650 spec->cur_adc_idx = 0;
1651 new_adc = spec->adc_nids[spec->cur_adc_idx];
1652 if (spec->cur_adc && spec->cur_adc != new_adc) {
1653 /* stream is running, let's swap the current ADC */
Takashi Iwai888afa12008-03-18 09:57:50 +01001654 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
Takashi Iwai461e2c72008-01-25 11:35:17 +01001655 spec->cur_adc = new_adc;
1656 snd_hda_codec_setup_stream(codec, new_adc,
1657 spec->cur_adc_stream_tag, 0,
1658 spec->cur_adc_format);
1659 }
1660}
1661
1662/* mute internal speaker if HP is plugged */
1663static void cxt5051_hp_automute(struct hda_codec *codec)
1664{
1665 struct conexant_spec *spec = codec->spec;
1666
Takashi Iwaid56757a2009-11-18 08:00:14 +01001667 spec->hp_present = snd_hda_jack_detect(codec, 0x16);
Takashi Iwai461e2c72008-01-25 11:35:17 +01001668 cxt5051_update_speaker(codec);
1669}
1670
1671/* unsolicited event for HP jack sensing */
1672static void cxt5051_hp_unsol_event(struct hda_codec *codec,
1673 unsigned int res)
1674{
Ulrich Dangelacf26c02009-01-02 19:30:14 +01001675 int nid = (res & AC_UNSOL_RES_SUBTAG) >> 20;
Takashi Iwai461e2c72008-01-25 11:35:17 +01001676 switch (res >> 26) {
1677 case CONEXANT_HP_EVENT:
1678 cxt5051_hp_automute(codec);
1679 break;
1680 case CXT5051_PORTB_EVENT:
1681 cxt5051_portb_automic(codec);
1682 break;
1683 case CXT5051_PORTC_EVENT:
1684 cxt5051_portc_automic(codec);
1685 break;
1686 }
Ulrich Dangelacf26c02009-01-02 19:30:14 +01001687 conexant_report_jack(codec, nid);
Takashi Iwai461e2c72008-01-25 11:35:17 +01001688}
1689
1690static struct snd_kcontrol_new cxt5051_mixers[] = {
1691 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT),
1692 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT),
1693 HDA_CODEC_VOLUME("External Mic Volume", 0x14, 0x01, HDA_INPUT),
1694 HDA_CODEC_MUTE("External Mic Switch", 0x14, 0x01, HDA_INPUT),
1695 HDA_CODEC_VOLUME("Docking Mic Volume", 0x15, 0x00, HDA_INPUT),
1696 HDA_CODEC_MUTE("Docking Mic Switch", 0x15, 0x00, HDA_INPUT),
1697 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT),
1698 {
1699 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1700 .name = "Master Playback Switch",
1701 .info = cxt_eapd_info,
1702 .get = cxt_eapd_get,
1703 .put = cxt5051_hp_master_sw_put,
1704 .private_value = 0x1a,
1705 },
1706
1707 {}
1708};
1709
1710static struct snd_kcontrol_new cxt5051_hp_mixers[] = {
1711 HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT),
1712 HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT),
1713 HDA_CODEC_VOLUME("External Mic Volume", 0x15, 0x00, HDA_INPUT),
1714 HDA_CODEC_MUTE("External Mic Switch", 0x15, 0x00, HDA_INPUT),
1715 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT),
1716 {
1717 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1718 .name = "Master Playback Switch",
1719 .info = cxt_eapd_info,
1720 .get = cxt_eapd_get,
1721 .put = cxt5051_hp_master_sw_put,
1722 .private_value = 0x1a,
1723 },
1724
1725 {}
1726};
1727
Takashi Iwai79d7d532009-03-04 09:03:50 +01001728static struct snd_kcontrol_new cxt5051_hp_dv6736_mixers[] = {
Takashi Iwai4e4ac602010-01-23 22:29:54 +01001729 HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x00, HDA_INPUT),
1730 HDA_CODEC_MUTE("Capture Switch", 0x14, 0x00, HDA_INPUT),
Takashi Iwai79d7d532009-03-04 09:03:50 +01001731 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT),
1732 {
1733 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1734 .name = "Master Playback Switch",
1735 .info = cxt_eapd_info,
1736 .get = cxt_eapd_get,
1737 .put = cxt5051_hp_master_sw_put,
1738 .private_value = 0x1a,
1739 },
1740
1741 {}
1742};
1743
Ken Proxcd9d95a2010-01-08 09:01:47 +01001744static struct snd_kcontrol_new cxt5051_f700_mixers[] = {
Takashi Iwai5f6c3de2010-01-23 22:19:29 +01001745 HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x01, HDA_INPUT),
1746 HDA_CODEC_MUTE("Capture Switch", 0x14, 0x01, HDA_INPUT),
Ken Proxcd9d95a2010-01-08 09:01:47 +01001747 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT),
1748 {
1749 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1750 .name = "Master Playback Switch",
1751 .info = cxt_eapd_info,
1752 .get = cxt_eapd_get,
1753 .put = cxt5051_hp_master_sw_put,
1754 .private_value = 0x1a,
1755 },
1756
1757 {}
1758};
1759
Takashi Iwai461e2c72008-01-25 11:35:17 +01001760static struct hda_verb cxt5051_init_verbs[] = {
1761 /* Line in, Mic */
1762 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1763 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1764 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1765 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1766 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1767 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1768 /* SPK */
1769 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1770 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
1771 /* HP, Amp */
1772 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1773 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
1774 /* DAC1 */
1775 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1776 /* Record selector: Int mic */
1777 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
1778 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44},
1779 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
1780 /* SPDIF route: PCM */
1781 {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0},
1782 /* EAPD */
1783 {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
1784 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
1785 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTB_EVENT},
1786 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTC_EVENT},
1787 { } /* end */
1788};
1789
Takashi Iwai79d7d532009-03-04 09:03:50 +01001790static struct hda_verb cxt5051_hp_dv6736_init_verbs[] = {
1791 /* Line in, Mic */
1792 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1793 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1794 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0},
1795 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0},
1796 /* SPK */
1797 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1798 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
1799 /* HP, Amp */
1800 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1801 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
1802 /* DAC1 */
1803 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1804 /* Record selector: Int mic */
1805 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44},
1806 {0x14, AC_VERB_SET_CONNECT_SEL, 0x1},
1807 /* SPDIF route: PCM */
1808 {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0},
1809 /* EAPD */
1810 {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
1811 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
1812 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTB_EVENT},
1813 { } /* end */
1814};
1815
Aristeu Sergio Rozanski Filho27e08982009-02-12 17:50:37 -05001816static struct hda_verb cxt5051_lenovo_x200_init_verbs[] = {
1817 /* Line in, Mic */
1818 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1819 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1820 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1821 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1822 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1823 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1824 /* SPK */
1825 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1826 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
1827 /* HP, Amp */
1828 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1829 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
1830 /* Docking HP */
1831 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1832 {0x19, AC_VERB_SET_CONNECT_SEL, 0x00},
1833 /* DAC1 */
1834 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1835 /* Record selector: Int mic */
1836 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
1837 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44},
1838 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
1839 /* SPDIF route: PCM */
1840 {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0},
1841 /* EAPD */
1842 {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
1843 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
1844 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTB_EVENT},
1845 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTC_EVENT},
1846 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
1847 { } /* end */
1848};
1849
Ken Proxcd9d95a2010-01-08 09:01:47 +01001850static struct hda_verb cxt5051_f700_init_verbs[] = {
1851 /* Line in, Mic */
1852 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x03},
1853 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1854 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0},
1855 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0},
1856 /* SPK */
1857 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1858 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
1859 /* HP, Amp */
1860 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1861 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
1862 /* DAC1 */
1863 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1864 /* Record selector: Int mic */
1865 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44},
1866 {0x14, AC_VERB_SET_CONNECT_SEL, 0x1},
1867 /* SPDIF route: PCM */
1868 {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0},
1869 /* EAPD */
1870 {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
1871 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
1872 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTB_EVENT},
1873 { } /* end */
1874};
1875
Takashi Iwai461e2c72008-01-25 11:35:17 +01001876/* initialize jack-sensing, too */
1877static int cxt5051_init(struct hda_codec *codec)
1878{
1879 conexant_init(codec);
Ulrich Dangelacf26c02009-01-02 19:30:14 +01001880 conexant_init_jacks(codec);
Takashi Iwai461e2c72008-01-25 11:35:17 +01001881 if (codec->patch_ops.unsol_event) {
1882 cxt5051_hp_automute(codec);
1883 cxt5051_portb_automic(codec);
1884 cxt5051_portc_automic(codec);
1885 }
1886 return 0;
1887}
1888
1889
1890enum {
1891 CXT5051_LAPTOP, /* Laptops w/ EAPD support */
1892 CXT5051_HP, /* no docking */
Takashi Iwai79d7d532009-03-04 09:03:50 +01001893 CXT5051_HP_DV6736, /* HP without mic switch */
Aristeu Sergio Rozanski Filho27e08982009-02-12 17:50:37 -05001894 CXT5051_LENOVO_X200, /* Lenovo X200 laptop */
Ken Proxcd9d95a2010-01-08 09:01:47 +01001895 CXT5051_F700, /* HP Compaq Presario F700 */
Takashi Iwai461e2c72008-01-25 11:35:17 +01001896 CXT5051_MODELS
1897};
1898
1899static const char *cxt5051_models[CXT5051_MODELS] = {
1900 [CXT5051_LAPTOP] = "laptop",
1901 [CXT5051_HP] = "hp",
Takashi Iwai79d7d532009-03-04 09:03:50 +01001902 [CXT5051_HP_DV6736] = "hp-dv6736",
Aristeu Sergio Rozanski Filho27e08982009-02-12 17:50:37 -05001903 [CXT5051_LENOVO_X200] = "lenovo-x200",
Takashi Iwai5f6c3de2010-01-23 22:19:29 +01001904 [CXT5051_F700] = "hp-700",
Takashi Iwai461e2c72008-01-25 11:35:17 +01001905};
1906
1907static struct snd_pci_quirk cxt5051_cfg_tbl[] = {
Takashi Iwai79d7d532009-03-04 09:03:50 +01001908 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736),
Tony Vroon1812e672009-05-27 21:00:41 +01001909 SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP),
Takashi Iwai5f6c3de2010-01-23 22:19:29 +01001910 SND_PCI_QUIRK(0x103c, 0x30ea, "Compaq Presario F700", CXT5051_F700),
Takashi Iwai461e2c72008-01-25 11:35:17 +01001911 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
1912 CXT5051_LAPTOP),
1913 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP),
Aristeu Sergio Rozanski Filho27e08982009-02-12 17:50:37 -05001914 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT5051_LENOVO_X200),
Takashi Iwai461e2c72008-01-25 11:35:17 +01001915 {}
1916};
1917
1918static int patch_cxt5051(struct hda_codec *codec)
1919{
1920 struct conexant_spec *spec;
1921 int board_config;
1922
1923 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1924 if (!spec)
1925 return -ENOMEM;
Takashi Iwai461e2c72008-01-25 11:35:17 +01001926 codec->spec = spec;
Takashi Iwai9421f952009-03-12 17:06:07 +01001927 codec->pin_amp_workaround = 1;
Takashi Iwai461e2c72008-01-25 11:35:17 +01001928
1929 codec->patch_ops = conexant_patch_ops;
1930 codec->patch_ops.init = cxt5051_init;
1931
1932 spec->multiout.max_channels = 2;
1933 spec->multiout.num_dacs = ARRAY_SIZE(cxt5051_dac_nids);
1934 spec->multiout.dac_nids = cxt5051_dac_nids;
1935 spec->multiout.dig_out_nid = CXT5051_SPDIF_OUT;
1936 spec->num_adc_nids = 1; /* not 2; via auto-mic switch */
1937 spec->adc_nids = cxt5051_adc_nids;
1938 spec->num_mixers = 1;
1939 spec->mixers[0] = cxt5051_mixers;
1940 spec->num_init_verbs = 1;
1941 spec->init_verbs[0] = cxt5051_init_verbs;
1942 spec->spdif_route = 0;
1943 spec->num_channel_mode = ARRAY_SIZE(cxt5051_modes);
1944 spec->channel_mode = cxt5051_modes;
1945 spec->cur_adc = 0;
1946 spec->cur_adc_idx = 0;
1947
Takashi Iwai79d7d532009-03-04 09:03:50 +01001948 codec->patch_ops.unsol_event = cxt5051_hp_unsol_event;
1949
Takashi Iwai461e2c72008-01-25 11:35:17 +01001950 board_config = snd_hda_check_board_config(codec, CXT5051_MODELS,
1951 cxt5051_models,
1952 cxt5051_cfg_tbl);
1953 switch (board_config) {
1954 case CXT5051_HP:
Takashi Iwai461e2c72008-01-25 11:35:17 +01001955 spec->mixers[0] = cxt5051_hp_mixers;
1956 break;
Takashi Iwai79d7d532009-03-04 09:03:50 +01001957 case CXT5051_HP_DV6736:
1958 spec->init_verbs[0] = cxt5051_hp_dv6736_init_verbs;
1959 spec->mixers[0] = cxt5051_hp_dv6736_mixers;
1960 spec->no_auto_mic = 1;
1961 break;
Aristeu Sergio Rozanski Filho27e08982009-02-12 17:50:37 -05001962 case CXT5051_LENOVO_X200:
1963 spec->init_verbs[0] = cxt5051_lenovo_x200_init_verbs;
Takashi Iwai461e2c72008-01-25 11:35:17 +01001964 break;
Ken Proxcd9d95a2010-01-08 09:01:47 +01001965 case CXT5051_F700:
1966 spec->init_verbs[0] = cxt5051_f700_init_verbs;
1967 spec->mixers[0] = cxt5051_f700_mixers;
1968 spec->no_auto_mic = 1;
1969 break;
Takashi Iwai461e2c72008-01-25 11:35:17 +01001970 }
1971
1972 return 0;
1973}
1974
Daniel Drake0fb67e92009-07-16 14:46:57 +01001975/* Conexant 5066 specific */
1976
1977static hda_nid_t cxt5066_dac_nids[1] = { 0x10 };
1978static hda_nid_t cxt5066_adc_nids[3] = { 0x14, 0x15, 0x16 };
1979static hda_nid_t cxt5066_capsrc_nids[1] = { 0x17 };
1980#define CXT5066_SPDIF_OUT 0x21
1981
Daniel Drakedbaccc02009-11-09 15:17:24 +00001982/* OLPC's microphone port is DC coupled for use with external sensors,
1983 * therefore we use a 50% mic bias in order to center the input signal with
1984 * the DC input range of the codec. */
1985#define CXT5066_OLPC_EXT_MIC_BIAS PIN_VREF50
1986
Daniel Drake0fb67e92009-07-16 14:46:57 +01001987static struct hda_channel_mode cxt5066_modes[1] = {
1988 { 2, NULL },
1989};
1990
1991static void cxt5066_update_speaker(struct hda_codec *codec)
1992{
1993 struct conexant_spec *spec = codec->spec;
1994 unsigned int pinctl;
1995
1996 snd_printdd("CXT5066: update speaker, hp_present=%d\n",
1997 spec->hp_present);
1998
1999 /* Port A (HP) */
2000 pinctl = ((spec->hp_present & 1) && spec->cur_eapd) ? PIN_HP : 0;
2001 snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2002 pinctl);
2003
2004 /* Port D (HP/LO) */
2005 pinctl = ((spec->hp_present & 2) && spec->cur_eapd)
2006 ? spec->port_d_mode : 0;
2007 snd_hda_codec_write(codec, 0x1c, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2008 pinctl);
2009
2010 /* CLASS_D AMP */
2011 pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0;
2012 snd_hda_codec_write(codec, 0x1f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2013 pinctl);
2014
2015 if (spec->dell_automute) {
2016 /* DELL AIO Port Rule: PortA > PortD > IntSpk */
2017 pinctl = (!(spec->hp_present & 1) && spec->cur_eapd)
2018 ? PIN_OUT : 0;
2019 snd_hda_codec_write(codec, 0x1c, 0,
2020 AC_VERB_SET_PIN_WIDGET_CONTROL, pinctl);
2021 }
2022}
2023
2024/* turn on/off EAPD (+ mute HP) as a master switch */
2025static int cxt5066_hp_master_sw_put(struct snd_kcontrol *kcontrol,
2026 struct snd_ctl_elem_value *ucontrol)
2027{
2028 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2029
2030 if (!cxt_eapd_put(kcontrol, ucontrol))
2031 return 0;
2032
2033 cxt5066_update_speaker(codec);
2034 return 1;
2035}
2036
Daniel Drakec4cfe662010-01-07 13:47:04 +01002037static const struct hda_input_mux cxt5066_olpc_dc_bias = {
2038 .num_items = 3,
2039 .items = {
2040 { "Off", PIN_IN },
2041 { "50%", PIN_VREF50 },
2042 { "80%", PIN_VREF80 },
2043 },
2044};
2045
2046static int cxt5066_set_olpc_dc_bias(struct hda_codec *codec)
2047{
2048 struct conexant_spec *spec = codec->spec;
2049 /* Even though port F is the DC input, the bias is controlled on port B.
2050 * we also leave that port as an active input (but unselected) in DC mode
2051 * just in case that is necessary to make the bias setting take effect. */
2052 return snd_hda_codec_write_cache(codec, 0x1a, 0,
2053 AC_VERB_SET_PIN_WIDGET_CONTROL,
2054 cxt5066_olpc_dc_bias.items[spec->dc_input_bias].index);
2055}
2056
Daniel Drake75f89912010-01-07 13:46:25 +01002057/* OLPC defers mic widget control until when capture is started because the
2058 * microphone LED comes on as soon as these settings are put in place. if we
2059 * did this before recording, it would give the false indication that recording
2060 * is happening when it is not. */
2061static void cxt5066_olpc_select_mic(struct hda_codec *codec)
Daniel Drake0fb67e92009-07-16 14:46:57 +01002062{
Daniel Drakedbaccc02009-11-09 15:17:24 +00002063 struct conexant_spec *spec = codec->spec;
Daniel Drake75f89912010-01-07 13:46:25 +01002064 if (!spec->recording)
2065 return;
Daniel Drake0fb67e92009-07-16 14:46:57 +01002066
Daniel Drakec4cfe662010-01-07 13:47:04 +01002067 if (spec->dc_enable) {
2068 /* in DC mode we ignore presence detection and just use the jack
2069 * through our special DC port */
2070 const struct hda_verb enable_dc_mode[] = {
2071 /* disble internal mic, port C */
2072 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2073
2074 /* enable DC capture, port F */
2075 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2076 {},
2077 };
2078
2079 snd_hda_sequence_write(codec, enable_dc_mode);
2080 /* port B input disabled (and bias set) through the following call */
2081 cxt5066_set_olpc_dc_bias(codec);
2082 return;
2083 }
2084
2085 /* disable DC (port F) */
2086 snd_hda_codec_write(codec, 0x1e, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
2087
Daniel Drake75f89912010-01-07 13:46:25 +01002088 /* external mic, port B */
2089 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2090 spec->ext_mic_present ? CXT5066_OLPC_EXT_MIC_BIAS : 0);
Daniel Drake0fb67e92009-07-16 14:46:57 +01002091
Daniel Drake75f89912010-01-07 13:46:25 +01002092 /* internal mic, port C */
2093 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2094 spec->ext_mic_present ? 0 : PIN_VREF80);
2095}
Daniel Drake0fb67e92009-07-16 14:46:57 +01002096
Daniel Drake75f89912010-01-07 13:46:25 +01002097/* toggle input of built-in and mic jack appropriately */
2098static void cxt5066_olpc_automic(struct hda_codec *codec)
2099{
2100 struct conexant_spec *spec = codec->spec;
Daniel Drake0fb67e92009-07-16 14:46:57 +01002101 unsigned int present;
2102
Daniel Drakec4cfe662010-01-07 13:47:04 +01002103 if (spec->dc_enable) /* don't do presence detection in DC mode */
2104 return;
2105
Daniel Drake75f89912010-01-07 13:46:25 +01002106 present = snd_hda_codec_read(codec, 0x1a, 0,
2107 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2108 if (present)
Daniel Drake0fb67e92009-07-16 14:46:57 +01002109 snd_printdd("CXT5066: external microphone detected\n");
Daniel Drake75f89912010-01-07 13:46:25 +01002110 else
Daniel Drake0fb67e92009-07-16 14:46:57 +01002111 snd_printdd("CXT5066: external microphone absent\n");
Daniel Drake75f89912010-01-07 13:46:25 +01002112
2113 snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL,
2114 present ? 0 : 1);
2115 spec->ext_mic_present = !!present;
2116
2117 cxt5066_olpc_select_mic(codec);
Daniel Drake0fb67e92009-07-16 14:46:57 +01002118}
2119
Einar Rünkaru95a618b2009-11-23 22:23:49 +02002120/* toggle input of built-in digital mic and mic jack appropriately */
2121static void cxt5066_vostro_automic(struct hda_codec *codec)
2122{
Einar Rünkaru95a618b2009-11-23 22:23:49 +02002123 unsigned int present;
2124
2125 struct hda_verb ext_mic_present[] = {
2126 /* enable external mic, port B */
Daniel Drake75f89912010-01-07 13:46:25 +01002127 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Einar Rünkaru95a618b2009-11-23 22:23:49 +02002128
2129 /* switch to external mic input */
2130 {0x17, AC_VERB_SET_CONNECT_SEL, 0},
2131 {0x14, AC_VERB_SET_CONNECT_SEL, 0},
2132
2133 /* disable internal digital mic */
2134 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2135 {}
2136 };
2137 static struct hda_verb ext_mic_absent[] = {
2138 /* enable internal mic, port C */
2139 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2140
2141 /* switch to internal mic input */
2142 {0x14, AC_VERB_SET_CONNECT_SEL, 2},
2143
2144 /* disable external mic, port B */
2145 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2146 {}
2147 };
2148
2149 present = snd_hda_jack_detect(codec, 0x1a);
2150 if (present) {
2151 snd_printdd("CXT5066: external microphone detected\n");
2152 snd_hda_sequence_write(codec, ext_mic_present);
2153 } else {
2154 snd_printdd("CXT5066: external microphone absent\n");
2155 snd_hda_sequence_write(codec, ext_mic_absent);
2156 }
2157}
2158
Daniel Drake0fb67e92009-07-16 14:46:57 +01002159/* mute internal speaker if HP is plugged */
2160static void cxt5066_hp_automute(struct hda_codec *codec)
2161{
2162 struct conexant_spec *spec = codec->spec;
2163 unsigned int portA, portD;
2164
2165 /* Port A */
Takashi Iwaid56757a2009-11-18 08:00:14 +01002166 portA = snd_hda_jack_detect(codec, 0x19);
Daniel Drake0fb67e92009-07-16 14:46:57 +01002167
2168 /* Port D */
Takashi Iwaid56757a2009-11-18 08:00:14 +01002169 portD = snd_hda_jack_detect(codec, 0x1c);
Daniel Drake0fb67e92009-07-16 14:46:57 +01002170
2171 spec->hp_present = !!(portA | portD);
2172 snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n",
2173 portA, portD, spec->hp_present);
2174 cxt5066_update_speaker(codec);
2175}
2176
2177/* unsolicited event for jack sensing */
Daniel Drake75f89912010-01-07 13:46:25 +01002178static void cxt5066_olpc_unsol_event(struct hda_codec *codec, unsigned int res)
Daniel Drake0fb67e92009-07-16 14:46:57 +01002179{
Daniel Drakec4cfe662010-01-07 13:47:04 +01002180 struct conexant_spec *spec = codec->spec;
Daniel Drake0fb67e92009-07-16 14:46:57 +01002181 snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26);
2182 switch (res >> 26) {
2183 case CONEXANT_HP_EVENT:
2184 cxt5066_hp_automute(codec);
2185 break;
2186 case CONEXANT_MIC_EVENT:
Daniel Drakec4cfe662010-01-07 13:47:04 +01002187 /* ignore mic events in DC mode; we're always using the jack */
2188 if (!spec->dc_enable)
2189 cxt5066_olpc_automic(codec);
Daniel Drake0fb67e92009-07-16 14:46:57 +01002190 break;
2191 }
2192}
2193
Einar Rünkaru95a618b2009-11-23 22:23:49 +02002194/* unsolicited event for jack sensing */
2195static void cxt5066_vostro_event(struct hda_codec *codec, unsigned int res)
2196{
2197 snd_printdd("CXT5066_vostro: unsol event %x (%x)\n", res, res >> 26);
2198 switch (res >> 26) {
2199 case CONEXANT_HP_EVENT:
2200 cxt5066_hp_automute(codec);
2201 break;
2202 case CONEXANT_MIC_EVENT:
2203 cxt5066_vostro_automic(codec);
2204 break;
2205 }
2206}
2207
Daniel Drake0fb67e92009-07-16 14:46:57 +01002208static const struct hda_input_mux cxt5066_analog_mic_boost = {
2209 .num_items = 5,
2210 .items = {
2211 { "0dB", 0 },
2212 { "10dB", 1 },
2213 { "20dB", 2 },
2214 { "30dB", 3 },
2215 { "40dB", 4 },
2216 },
2217};
2218
Daniel Drakec4cfe662010-01-07 13:47:04 +01002219static int cxt5066_set_mic_boost(struct hda_codec *codec)
2220{
2221 struct conexant_spec *spec = codec->spec;
2222 return snd_hda_codec_write_cache(codec, 0x17, 0,
2223 AC_VERB_SET_AMP_GAIN_MUTE,
2224 AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_OUTPUT |
2225 cxt5066_analog_mic_boost.items[spec->mic_boost].index);
2226}
2227
Daniel Drake0fb67e92009-07-16 14:46:57 +01002228static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol *kcontrol,
2229 struct snd_ctl_elem_info *uinfo)
2230{
2231 return snd_hda_input_mux_info(&cxt5066_analog_mic_boost, uinfo);
2232}
2233
2234static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol *kcontrol,
2235 struct snd_ctl_elem_value *ucontrol)
2236{
2237 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Daniel Drakec4cfe662010-01-07 13:47:04 +01002238 struct conexant_spec *spec = codec->spec;
2239 ucontrol->value.enumerated.item[0] = spec->mic_boost;
Daniel Drake0fb67e92009-07-16 14:46:57 +01002240 return 0;
2241}
2242
2243static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol *kcontrol,
2244 struct snd_ctl_elem_value *ucontrol)
2245{
2246 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Daniel Drakec4cfe662010-01-07 13:47:04 +01002247 struct conexant_spec *spec = codec->spec;
Daniel Drake0fb67e92009-07-16 14:46:57 +01002248 const struct hda_input_mux *imux = &cxt5066_analog_mic_boost;
2249 unsigned int idx;
Daniel Drake0fb67e92009-07-16 14:46:57 +01002250 idx = ucontrol->value.enumerated.item[0];
2251 if (idx >= imux->num_items)
2252 idx = imux->num_items - 1;
2253
Daniel Drakec4cfe662010-01-07 13:47:04 +01002254 spec->mic_boost = idx;
2255 if (!spec->dc_enable)
2256 cxt5066_set_mic_boost(codec);
2257 return 1;
2258}
Daniel Drake0fb67e92009-07-16 14:46:57 +01002259
Daniel Drakec4cfe662010-01-07 13:47:04 +01002260static void cxt5066_enable_dc(struct hda_codec *codec)
2261{
2262 const struct hda_verb enable_dc_mode[] = {
2263 /* disable gain */
2264 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2265
2266 /* switch to DC input */
2267 {0x17, AC_VERB_SET_CONNECT_SEL, 3},
2268 {}
2269 };
2270
2271 /* configure as input source */
2272 snd_hda_sequence_write(codec, enable_dc_mode);
2273 cxt5066_olpc_select_mic(codec); /* also sets configured bias */
2274}
2275
2276static void cxt5066_disable_dc(struct hda_codec *codec)
2277{
2278 /* reconfigure input source */
2279 cxt5066_set_mic_boost(codec);
2280 /* automic also selects the right mic if we're recording */
2281 cxt5066_olpc_automic(codec);
2282}
2283
2284static int cxt5066_olpc_dc_get(struct snd_kcontrol *kcontrol,
2285 struct snd_ctl_elem_value *ucontrol)
2286{
2287 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2288 struct conexant_spec *spec = codec->spec;
2289 ucontrol->value.integer.value[0] = spec->dc_enable;
2290 return 0;
2291}
2292
2293static int cxt5066_olpc_dc_put(struct snd_kcontrol *kcontrol,
2294 struct snd_ctl_elem_value *ucontrol)
2295{
2296 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2297 struct conexant_spec *spec = codec->spec;
2298 int dc_enable = !!ucontrol->value.integer.value[0];
2299
2300 if (dc_enable == spec->dc_enable)
2301 return 0;
2302
2303 spec->dc_enable = dc_enable;
2304 if (dc_enable)
2305 cxt5066_enable_dc(codec);
2306 else
2307 cxt5066_disable_dc(codec);
2308
2309 return 1;
2310}
2311
2312static int cxt5066_olpc_dc_bias_enum_info(struct snd_kcontrol *kcontrol,
2313 struct snd_ctl_elem_info *uinfo)
2314{
2315 return snd_hda_input_mux_info(&cxt5066_olpc_dc_bias, uinfo);
2316}
2317
2318static int cxt5066_olpc_dc_bias_enum_get(struct snd_kcontrol *kcontrol,
2319 struct snd_ctl_elem_value *ucontrol)
2320{
2321 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2322 struct conexant_spec *spec = codec->spec;
2323 ucontrol->value.enumerated.item[0] = spec->dc_input_bias;
2324 return 0;
2325}
2326
2327static int cxt5066_olpc_dc_bias_enum_put(struct snd_kcontrol *kcontrol,
2328 struct snd_ctl_elem_value *ucontrol)
2329{
2330 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2331 struct conexant_spec *spec = codec->spec;
2332 const struct hda_input_mux *imux = &cxt5066_analog_mic_boost;
2333 unsigned int idx;
2334
2335 idx = ucontrol->value.enumerated.item[0];
2336 if (idx >= imux->num_items)
2337 idx = imux->num_items - 1;
2338
2339 spec->dc_input_bias = idx;
2340 if (spec->dc_enable)
2341 cxt5066_set_olpc_dc_bias(codec);
Daniel Drake0fb67e92009-07-16 14:46:57 +01002342 return 1;
2343}
2344
Daniel Drake75f89912010-01-07 13:46:25 +01002345static void cxt5066_olpc_capture_prepare(struct hda_codec *codec)
2346{
2347 struct conexant_spec *spec = codec->spec;
2348 /* mark as recording and configure the microphone widget so that the
2349 * recording LED comes on. */
2350 spec->recording = 1;
2351 cxt5066_olpc_select_mic(codec);
2352}
2353
2354static void cxt5066_olpc_capture_cleanup(struct hda_codec *codec)
2355{
2356 struct conexant_spec *spec = codec->spec;
2357 const struct hda_verb disable_mics[] = {
2358 /* disable external mic, port B */
2359 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2360
2361 /* disble internal mic, port C */
2362 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Daniel Drakec4cfe662010-01-07 13:47:04 +01002363
2364 /* disable DC capture, port F */
2365 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Daniel Drake75f89912010-01-07 13:46:25 +01002366 {},
2367 };
2368
2369 snd_hda_sequence_write(codec, disable_mics);
2370 spec->recording = 0;
2371}
2372
Daniel Drake0fb67e92009-07-16 14:46:57 +01002373static struct hda_input_mux cxt5066_capture_source = {
2374 .num_items = 4,
2375 .items = {
2376 { "Mic B", 0 },
2377 { "Mic C", 1 },
2378 { "Mic E", 2 },
2379 { "Mic F", 3 },
2380 },
2381};
2382
2383static struct hda_bind_ctls cxt5066_bind_capture_vol_others = {
2384 .ops = &snd_hda_bind_vol,
2385 .values = {
2386 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT),
2387 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT),
2388 0
2389 },
2390};
2391
2392static struct hda_bind_ctls cxt5066_bind_capture_sw_others = {
2393 .ops = &snd_hda_bind_sw,
2394 .values = {
2395 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT),
2396 HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT),
2397 0
2398 },
2399};
2400
2401static struct snd_kcontrol_new cxt5066_mixer_master[] = {
2402 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT),
2403 {}
2404};
2405
2406static struct snd_kcontrol_new cxt5066_mixer_master_olpc[] = {
2407 {
2408 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2409 .name = "Master Playback Volume",
2410 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
2411 SNDRV_CTL_ELEM_ACCESS_TLV_READ |
2412 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK,
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002413 .subdevice = HDA_SUBDEV_AMP_FLAG,
Daniel Drake0fb67e92009-07-16 14:46:57 +01002414 .info = snd_hda_mixer_amp_volume_info,
2415 .get = snd_hda_mixer_amp_volume_get,
2416 .put = snd_hda_mixer_amp_volume_put,
2417 .tlv = { .c = snd_hda_mixer_amp_tlv },
2418 /* offset by 28 volume steps to limit minimum gain to -46dB */
2419 .private_value =
2420 HDA_COMPOSE_AMP_VAL_OFS(0x10, 3, 0, HDA_OUTPUT, 28),
2421 },
2422 {}
2423};
2424
Daniel Drakec4cfe662010-01-07 13:47:04 +01002425static struct snd_kcontrol_new cxt5066_mixer_olpc_dc[] = {
2426 {
2427 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2428 .name = "DC Mode Enable Switch",
2429 .info = snd_ctl_boolean_mono_info,
2430 .get = cxt5066_olpc_dc_get,
2431 .put = cxt5066_olpc_dc_put,
2432 },
2433 {
2434 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2435 .name = "DC Input Bias Enum",
2436 .info = cxt5066_olpc_dc_bias_enum_info,
2437 .get = cxt5066_olpc_dc_bias_enum_get,
2438 .put = cxt5066_olpc_dc_bias_enum_put,
2439 },
2440 {}
2441};
2442
Daniel Drake0fb67e92009-07-16 14:46:57 +01002443static struct snd_kcontrol_new cxt5066_mixers[] = {
2444 {
2445 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2446 .name = "Master Playback Switch",
2447 .info = cxt_eapd_info,
2448 .get = cxt_eapd_get,
2449 .put = cxt5066_hp_master_sw_put,
2450 .private_value = 0x1d,
2451 },
2452
2453 {
2454 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Daniel Drakec4cfe662010-01-07 13:47:04 +01002455 .name = "Analog Mic Boost Capture Enum",
Daniel Drake0fb67e92009-07-16 14:46:57 +01002456 .info = cxt5066_mic_boost_mux_enum_info,
2457 .get = cxt5066_mic_boost_mux_enum_get,
2458 .put = cxt5066_mic_boost_mux_enum_put,
2459 },
2460
2461 HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others),
2462 HDA_BIND_SW("Capture Switch", &cxt5066_bind_capture_sw_others),
2463 {}
2464};
2465
Einar Rünkaru254bba62009-12-16 22:16:13 +02002466static struct snd_kcontrol_new cxt5066_vostro_mixers[] = {
2467 {
2468 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2469 .name = "Int Mic Boost Capture Enum",
2470 .info = cxt5066_mic_boost_mux_enum_info,
2471 .get = cxt5066_mic_boost_mux_enum_get,
2472 .put = cxt5066_mic_boost_mux_enum_put,
2473 .private_value = 0x23 | 0x100,
2474 },
Einar Rünkaruc0f8faf2009-12-16 22:41:36 +02002475 HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT),
Einar Rünkaru254bba62009-12-16 22:16:13 +02002476 {}
2477};
2478
Daniel Drake0fb67e92009-07-16 14:46:57 +01002479static struct hda_verb cxt5066_init_verbs[] = {
2480 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */
2481 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */
2482 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */
2483 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */
2484
2485 /* Speakers */
2486 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2487 {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
2488
2489 /* HP, Amp */
2490 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2491 {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
2492
2493 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2494 {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
2495
2496 /* DAC1 */
2497 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2498
2499 /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
2500 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50},
2501 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2502 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50},
2503 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2504 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2505
2506 /* no digital microphone support yet */
2507 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2508
2509 /* Audio input selector */
2510 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3},
2511
2512 /* SPDIF route: PCM */
2513 {0x20, AC_VERB_SET_CONNECT_SEL, 0x0},
2514 {0x22, AC_VERB_SET_CONNECT_SEL, 0x0},
2515
2516 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2517 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2518
2519 /* EAPD */
2520 {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
2521
2522 /* not handling these yet */
2523 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, 0},
2524 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, 0},
2525 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, 0},
2526 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, 0},
2527 {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE, 0},
2528 {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE, 0},
2529 {0x20, AC_VERB_SET_UNSOLICITED_ENABLE, 0},
2530 {0x22, AC_VERB_SET_UNSOLICITED_ENABLE, 0},
2531 { } /* end */
2532};
2533
2534static struct hda_verb cxt5066_init_verbs_olpc[] = {
2535 /* Port A: headphones */
2536 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2537 {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
2538
2539 /* Port B: external microphone */
Daniel Drake75f89912010-01-07 13:46:25 +01002540 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Daniel Drake0fb67e92009-07-16 14:46:57 +01002541
2542 /* Port C: internal microphone */
Daniel Drake75f89912010-01-07 13:46:25 +01002543 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Daniel Drake0fb67e92009-07-16 14:46:57 +01002544
2545 /* Port D: unused */
2546 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2547
2548 /* Port E: unused, but has primary EAPD */
2549 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2550 {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
2551
Daniel Drakec4cfe662010-01-07 13:47:04 +01002552 /* Port F: external DC input through microphone port */
Daniel Drake0fb67e92009-07-16 14:46:57 +01002553 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2554
2555 /* Port G: internal speakers */
2556 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2557 {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
2558
2559 /* DAC1 */
2560 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2561
2562 /* DAC2: unused */
2563 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2564
2565 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50},
2566 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2567 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2568 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2569 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2570 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2571 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2572 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2573 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2574 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2575 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2576 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2577
2578 /* Disable digital microphone port */
2579 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2580
2581 /* Audio input selectors */
2582 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3},
2583 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2584
2585 /* Disable SPDIF */
2586 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2587 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2588
2589 /* enable unsolicited events for Port A and B */
2590 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
2591 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
2592 { } /* end */
2593};
2594
Einar Rünkaru95a618b2009-11-23 22:23:49 +02002595static struct hda_verb cxt5066_init_verbs_vostro[] = {
2596 /* Port A: headphones */
2597 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2598 {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
2599
2600 /* Port B: external microphone */
2601 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2602
2603 /* Port C: unused */
2604 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2605
2606 /* Port D: unused */
2607 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2608
2609 /* Port E: unused, but has primary EAPD */
2610 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2611 {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
2612
2613 /* Port F: unused */
2614 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2615
2616 /* Port G: internal speakers */
2617 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2618 {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
2619
2620 /* DAC1 */
2621 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2622
2623 /* DAC2: unused */
2624 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2625
2626 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2627 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2628 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2629 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2630 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2631 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2632 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2633 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2634 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2635 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2636 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2637 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2638
2639 /* Digital microphone port */
2640 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2641
2642 /* Audio input selectors */
2643 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3},
2644 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2645
2646 /* Disable SPDIF */
2647 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2648 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2649
2650 /* enable unsolicited events for Port A and B */
2651 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
2652 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
2653 { } /* end */
2654};
2655
Daniel Drake0fb67e92009-07-16 14:46:57 +01002656static struct hda_verb cxt5066_init_verbs_portd_lo[] = {
2657 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2658 { } /* end */
2659};
2660
2661/* initialize jack-sensing, too */
2662static int cxt5066_init(struct hda_codec *codec)
2663{
Einar Rünkaru254bba62009-12-16 22:16:13 +02002664 struct conexant_spec *spec = codec->spec;
2665
Daniel Drake0fb67e92009-07-16 14:46:57 +01002666 snd_printdd("CXT5066: init\n");
2667 conexant_init(codec);
2668 if (codec->patch_ops.unsol_event) {
2669 cxt5066_hp_automute(codec);
Einar Rünkaru254bba62009-12-16 22:16:13 +02002670 if (spec->dell_vostro)
2671 cxt5066_vostro_automic(codec);
Daniel Drake0fb67e92009-07-16 14:46:57 +01002672 }
Daniel Drakec4cfe662010-01-07 13:47:04 +01002673 cxt5066_set_mic_boost(codec);
Daniel Drake0fb67e92009-07-16 14:46:57 +01002674 return 0;
2675}
2676
Daniel Drake75f89912010-01-07 13:46:25 +01002677static int cxt5066_olpc_init(struct hda_codec *codec)
2678{
Daniel Drakec4cfe662010-01-07 13:47:04 +01002679 struct conexant_spec *spec = codec->spec;
Daniel Drake75f89912010-01-07 13:46:25 +01002680 snd_printdd("CXT5066: init\n");
2681 conexant_init(codec);
2682 cxt5066_hp_automute(codec);
Daniel Drakec4cfe662010-01-07 13:47:04 +01002683 if (!spec->dc_enable) {
2684 cxt5066_set_mic_boost(codec);
2685 cxt5066_olpc_automic(codec);
2686 } else {
2687 cxt5066_enable_dc(codec);
2688 }
Daniel Drake75f89912010-01-07 13:46:25 +01002689 return 0;
2690}
2691
Daniel Drake0fb67e92009-07-16 14:46:57 +01002692enum {
2693 CXT5066_LAPTOP, /* Laptops w/ EAPD support */
2694 CXT5066_DELL_LAPTOP, /* Dell Laptop */
2695 CXT5066_OLPC_XO_1_5, /* OLPC XO 1.5 */
Einar Rünkaru95a618b2009-11-23 22:23:49 +02002696 CXT5066_DELL_VOSTO, /* Dell Vostro 1015i */
Daniel Drake0fb67e92009-07-16 14:46:57 +01002697 CXT5066_MODELS
2698};
2699
2700static const char *cxt5066_models[CXT5066_MODELS] = {
2701 [CXT5066_LAPTOP] = "laptop",
2702 [CXT5066_DELL_LAPTOP] = "dell-laptop",
2703 [CXT5066_OLPC_XO_1_5] = "olpc-xo-1_5",
Einar Rünkaru95a618b2009-11-23 22:23:49 +02002704 [CXT5066_DELL_VOSTO] = "dell-vostro"
Daniel Drake0fb67e92009-07-16 14:46:57 +01002705};
2706
2707static struct snd_pci_quirk cxt5066_cfg_tbl[] = {
2708 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
2709 CXT5066_LAPTOP),
2710 SND_PCI_QUIRK(0x1028, 0x02f5, "Dell",
2711 CXT5066_DELL_LAPTOP),
Daniel Drake798a8a12009-11-04 10:11:07 +00002712 SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5),
Einar Rünkaru95a618b2009-11-23 22:23:49 +02002713 SND_PCI_QUIRK(0x1028, 0x0402, "Dell Vostro", CXT5066_DELL_VOSTO),
Daniel Drake0fb67e92009-07-16 14:46:57 +01002714 {}
2715};
2716
2717static int patch_cxt5066(struct hda_codec *codec)
2718{
2719 struct conexant_spec *spec;
2720 int board_config;
2721
2722 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2723 if (!spec)
2724 return -ENOMEM;
2725 codec->spec = spec;
2726
2727 codec->patch_ops = conexant_patch_ops;
Daniel Drake75f89912010-01-07 13:46:25 +01002728 codec->patch_ops.init = conexant_init;
Daniel Drake0fb67e92009-07-16 14:46:57 +01002729
2730 spec->dell_automute = 0;
2731 spec->multiout.max_channels = 2;
2732 spec->multiout.num_dacs = ARRAY_SIZE(cxt5066_dac_nids);
2733 spec->multiout.dac_nids = cxt5066_dac_nids;
2734 spec->multiout.dig_out_nid = CXT5066_SPDIF_OUT;
2735 spec->num_adc_nids = 1;
2736 spec->adc_nids = cxt5066_adc_nids;
2737 spec->capsrc_nids = cxt5066_capsrc_nids;
2738 spec->input_mux = &cxt5066_capture_source;
2739
2740 spec->port_d_mode = PIN_HP;
2741
2742 spec->num_init_verbs = 1;
2743 spec->init_verbs[0] = cxt5066_init_verbs;
2744 spec->num_channel_mode = ARRAY_SIZE(cxt5066_modes);
2745 spec->channel_mode = cxt5066_modes;
2746 spec->cur_adc = 0;
2747 spec->cur_adc_idx = 0;
2748
2749 board_config = snd_hda_check_board_config(codec, CXT5066_MODELS,
2750 cxt5066_models, cxt5066_cfg_tbl);
2751 switch (board_config) {
2752 default:
2753 case CXT5066_LAPTOP:
2754 spec->mixers[spec->num_mixers++] = cxt5066_mixer_master;
2755 spec->mixers[spec->num_mixers++] = cxt5066_mixers;
2756 break;
2757 case CXT5066_DELL_LAPTOP:
2758 spec->mixers[spec->num_mixers++] = cxt5066_mixer_master;
2759 spec->mixers[spec->num_mixers++] = cxt5066_mixers;
2760
2761 spec->port_d_mode = PIN_OUT;
2762 spec->init_verbs[spec->num_init_verbs] = cxt5066_init_verbs_portd_lo;
2763 spec->num_init_verbs++;
2764 spec->dell_automute = 1;
2765 break;
2766 case CXT5066_OLPC_XO_1_5:
Daniel Drake75f89912010-01-07 13:46:25 +01002767 codec->patch_ops.init = cxt5066_olpc_init;
2768 codec->patch_ops.unsol_event = cxt5066_olpc_unsol_event;
Daniel Drake0fb67e92009-07-16 14:46:57 +01002769 spec->init_verbs[0] = cxt5066_init_verbs_olpc;
2770 spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc;
Daniel Drakec4cfe662010-01-07 13:47:04 +01002771 spec->mixers[spec->num_mixers++] = cxt5066_mixer_olpc_dc;
Daniel Drake0fb67e92009-07-16 14:46:57 +01002772 spec->mixers[spec->num_mixers++] = cxt5066_mixers;
2773 spec->port_d_mode = 0;
Daniel Drakec4cfe662010-01-07 13:47:04 +01002774 spec->mic_boost = 3; /* default 30dB gain */
Daniel Drake0fb67e92009-07-16 14:46:57 +01002775
2776 /* no S/PDIF out */
2777 spec->multiout.dig_out_nid = 0;
2778
2779 /* input source automatically selected */
2780 spec->input_mux = NULL;
Daniel Drake75f89912010-01-07 13:46:25 +01002781
2782 /* our capture hooks which allow us to turn on the microphone LED
2783 * at the right time */
2784 spec->capture_prepare = cxt5066_olpc_capture_prepare;
2785 spec->capture_cleanup = cxt5066_olpc_capture_cleanup;
Daniel Drake0fb67e92009-07-16 14:46:57 +01002786 break;
Einar Rünkaru95a618b2009-11-23 22:23:49 +02002787 case CXT5066_DELL_VOSTO:
Daniel Drake75f89912010-01-07 13:46:25 +01002788 codec->patch_ops.init = cxt5066_init;
Einar Rünkaru95a618b2009-11-23 22:23:49 +02002789 codec->patch_ops.unsol_event = cxt5066_vostro_event;
2790 spec->init_verbs[0] = cxt5066_init_verbs_vostro;
2791 spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc;
2792 spec->mixers[spec->num_mixers++] = cxt5066_mixers;
Einar Rünkaru254bba62009-12-16 22:16:13 +02002793 spec->mixers[spec->num_mixers++] = cxt5066_vostro_mixers;
Einar Rünkaru95a618b2009-11-23 22:23:49 +02002794 spec->port_d_mode = 0;
Einar Rünkaru254bba62009-12-16 22:16:13 +02002795 spec->dell_vostro = 1;
Daniel Drakec4cfe662010-01-07 13:47:04 +01002796 spec->mic_boost = 3; /* default 30dB gain */
Einar Rünkaruc0f8faf2009-12-16 22:41:36 +02002797 snd_hda_attach_beep_device(codec, 0x13);
Einar Rünkaru95a618b2009-11-23 22:23:49 +02002798
2799 /* no S/PDIF out */
2800 spec->multiout.dig_out_nid = 0;
2801
2802 /* input source automatically selected */
2803 spec->input_mux = NULL;
2804 break;
Daniel Drake0fb67e92009-07-16 14:46:57 +01002805 }
2806
2807 return 0;
2808}
Takashi Iwai461e2c72008-01-25 11:35:17 +01002809
2810/*
2811 */
2812
Takashi Iwai1289e9e2008-11-27 15:47:11 +01002813static struct hda_codec_preset snd_hda_preset_conexant[] = {
Tobin Davis82f30042007-02-13 12:45:44 +01002814 { .id = 0x14f15045, .name = "CX20549 (Venice)",
2815 .patch = patch_cxt5045 },
2816 { .id = 0x14f15047, .name = "CX20551 (Waikiki)",
2817 .patch = patch_cxt5047 },
Takashi Iwai461e2c72008-01-25 11:35:17 +01002818 { .id = 0x14f15051, .name = "CX20561 (Hermosa)",
2819 .patch = patch_cxt5051 },
Daniel Drake0fb67e92009-07-16 14:46:57 +01002820 { .id = 0x14f15066, .name = "CX20582 (Pebble)",
2821 .patch = patch_cxt5066 },
Einar Rünkaru95a618b2009-11-23 22:23:49 +02002822 { .id = 0x14f15067, .name = "CX20583 (Pebble HSF)",
2823 .patch = patch_cxt5066 },
Tobin Davisc9b443d2006-11-14 12:13:39 +01002824 {} /* terminator */
2825};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01002826
2827MODULE_ALIAS("snd-hda-codec-id:14f15045");
2828MODULE_ALIAS("snd-hda-codec-id:14f15047");
2829MODULE_ALIAS("snd-hda-codec-id:14f15051");
Daniel Drake0fb67e92009-07-16 14:46:57 +01002830MODULE_ALIAS("snd-hda-codec-id:14f15066");
Einar Rünkaru95a618b2009-11-23 22:23:49 +02002831MODULE_ALIAS("snd-hda-codec-id:14f15067");
Takashi Iwai1289e9e2008-11-27 15:47:11 +01002832
2833MODULE_LICENSE("GPL");
2834MODULE_DESCRIPTION("Conexant HD-audio codec");
2835
2836static struct hda_codec_preset_list conexant_list = {
2837 .preset = snd_hda_preset_conexant,
2838 .owner = THIS_MODULE,
2839};
2840
2841static int __init patch_conexant_init(void)
2842{
2843 return snd_hda_add_codec_preset(&conexant_list);
2844}
2845
2846static void __exit patch_conexant_exit(void)
2847{
2848 snd_hda_delete_codec_preset(&conexant_list);
2849}
2850
2851module_init(patch_conexant_init)
2852module_exit(patch_conexant_exit)