blob: 26a84e2f0051db72da2559262733a090e1e75e14 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Takashi Iwaid32410b12005-11-24 16:06:23 +01002 * HD audio interface patch for AD1981HD, AD1983, AD1986A, AD1988
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
4 * Copyright (c) 2005 Takashi Iwai <tiwai@suse.de>
5 *
6 * This driver is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This driver is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <sound/driver.h>
22#include <linux/init.h>
23#include <linux/delay.h>
24#include <linux/slab.h>
25#include <linux/pci.h>
Ingo Molnar62932df2006-01-16 16:34:20 +010026#include <linux/mutex.h>
27
Linus Torvalds1da177e2005-04-16 15:20:36 -070028#include <sound/core.h>
29#include "hda_codec.h"
30#include "hda_local.h"
31
Takashi Iwai4a3fdf32005-04-14 13:35:51 +020032struct ad198x_spec {
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +010033 struct snd_kcontrol_new *mixers[5];
Takashi Iwai985be542005-11-02 18:26:49 +010034 int num_mixers;
35
Takashi Iwaid32410b12005-11-24 16:06:23 +010036 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai985be542005-11-02 18:26:49 +010037 * don't forget NULL termination!
38 */
39 unsigned int num_init_verbs;
40
41 /* playback */
42 struct hda_multi_out multiout; /* playback set-up
43 * max_channels, dacs must be set
44 * dig_out_nid and hp_nid are optional
45 */
Takashi Iwaifd66e0d2005-11-17 15:31:34 +010046 unsigned int cur_eapd;
Takashi Iwai2125cad2006-03-27 12:52:22 +020047 unsigned int need_dac_fix;
Takashi Iwai985be542005-11-02 18:26:49 +010048
49 /* capture */
50 unsigned int num_adc_nids;
51 hda_nid_t *adc_nids;
52 hda_nid_t dig_in_nid; /* digital-in NID; optional */
53
54 /* capture source */
Takashi Iwai4a3fdf32005-04-14 13:35:51 +020055 const struct hda_input_mux *input_mux;
Takashi Iwai2e5b9562005-11-21 16:36:15 +010056 hda_nid_t *capsrc_nids;
Takashi Iwai985be542005-11-02 18:26:49 +010057 unsigned int cur_mux[3];
58
59 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +010060 const struct hda_channel_mode *channel_mode;
Takashi Iwai985be542005-11-02 18:26:49 +010061 int num_channel_mode;
62
63 /* PCM information */
64 struct hda_pcm pcm_rec[2]; /* used in alc_build_pcms() */
65
Ingo Molnar62932df2006-01-16 16:34:20 +010066 struct mutex amp_mutex; /* PCM volume/mute control mutex */
Takashi Iwai4a3fdf32005-04-14 13:35:51 +020067 unsigned int spdif_route;
Takashi Iwaid32410b12005-11-24 16:06:23 +010068
69 /* dynamic controls, init_verbs and input_mux */
70 struct auto_pin_cfg autocfg;
71 unsigned int num_kctl_alloc, num_kctl_used;
72 struct snd_kcontrol_new *kctl_alloc;
73 struct hda_input_mux private_imux;
74 hda_nid_t private_dac_nids[4];
Linus Torvalds1da177e2005-04-16 15:20:36 -070075};
76
Takashi Iwai4a3fdf32005-04-14 13:35:51 +020077/*
78 * input MUX handling (common part)
79 */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +010080static int ad198x_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Takashi Iwai4a3fdf32005-04-14 13:35:51 +020081{
82 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
83 struct ad198x_spec *spec = codec->spec;
84
85 return snd_hda_input_mux_info(spec->input_mux, uinfo);
86}
87
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +010088static int ad198x_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Takashi Iwai4a3fdf32005-04-14 13:35:51 +020089{
90 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
91 struct ad198x_spec *spec = codec->spec;
Takashi Iwai985be542005-11-02 18:26:49 +010092 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai4a3fdf32005-04-14 13:35:51 +020093
Takashi Iwai985be542005-11-02 18:26:49 +010094 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
Takashi Iwai4a3fdf32005-04-14 13:35:51 +020095 return 0;
96}
97
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +010098static int ad198x_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Takashi Iwai4a3fdf32005-04-14 13:35:51 +020099{
100 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
101 struct ad198x_spec *spec = codec->spec;
Takashi Iwai985be542005-11-02 18:26:49 +0100102 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200103
104 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Takashi Iwai2e5b9562005-11-21 16:36:15 +0100105 spec->capsrc_nids[adc_idx],
106 &spec->cur_mux[adc_idx]);
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200107}
108
109/*
110 * initialization (common callbacks)
111 */
112static int ad198x_init(struct hda_codec *codec)
113{
114 struct ad198x_spec *spec = codec->spec;
Takashi Iwai985be542005-11-02 18:26:49 +0100115 int i;
116
117 for (i = 0; i < spec->num_init_verbs; i++)
118 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200119 return 0;
120}
121
122static int ad198x_build_controls(struct hda_codec *codec)
123{
124 struct ad198x_spec *spec = codec->spec;
Takashi Iwai985be542005-11-02 18:26:49 +0100125 unsigned int i;
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200126 int err;
127
Takashi Iwai985be542005-11-02 18:26:49 +0100128 for (i = 0; i < spec->num_mixers; i++) {
129 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
130 if (err < 0)
131 return err;
132 }
133 if (spec->multiout.dig_out_nid) {
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200134 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
Takashi Iwai985be542005-11-02 18:26:49 +0100135 if (err < 0)
136 return err;
137 }
138 if (spec->dig_in_nid) {
139 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
140 if (err < 0)
141 return err;
142 }
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200143 return 0;
144}
145
146/*
147 * Analog playback callbacks
148 */
149static int ad198x_playback_pcm_open(struct hda_pcm_stream *hinfo,
150 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100151 struct snd_pcm_substream *substream)
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200152{
153 struct ad198x_spec *spec = codec->spec;
154 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
155}
156
157static int ad198x_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
158 struct hda_codec *codec,
159 unsigned int stream_tag,
160 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100161 struct snd_pcm_substream *substream)
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200162{
163 struct ad198x_spec *spec = codec->spec;
164 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
165 format, substream);
166}
167
168static int ad198x_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
169 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100170 struct snd_pcm_substream *substream)
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200171{
172 struct ad198x_spec *spec = codec->spec;
173 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
174}
175
176/*
177 * Digital out
178 */
179static int ad198x_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
180 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100181 struct snd_pcm_substream *substream)
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200182{
183 struct ad198x_spec *spec = codec->spec;
184 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
185}
186
187static int ad198x_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
188 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100189 struct snd_pcm_substream *substream)
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200190{
191 struct ad198x_spec *spec = codec->spec;
192 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
193}
194
195/*
196 * Analog capture
197 */
198static int ad198x_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
199 struct hda_codec *codec,
200 unsigned int stream_tag,
201 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100202 struct snd_pcm_substream *substream)
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200203{
204 struct ad198x_spec *spec = codec->spec;
Takashi Iwai985be542005-11-02 18:26:49 +0100205 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
206 stream_tag, 0, format);
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200207 return 0;
208}
209
210static int ad198x_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
211 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100212 struct snd_pcm_substream *substream)
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200213{
214 struct ad198x_spec *spec = codec->spec;
Takashi Iwai985be542005-11-02 18:26:49 +0100215 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
216 0, 0, 0);
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200217 return 0;
218}
219
220
221/*
222 */
223static struct hda_pcm_stream ad198x_pcm_analog_playback = {
224 .substreams = 1,
225 .channels_min = 2,
Takashi Iwai985be542005-11-02 18:26:49 +0100226 .channels_max = 6, /* changed later */
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200227 .nid = 0, /* fill later */
228 .ops = {
229 .open = ad198x_playback_pcm_open,
230 .prepare = ad198x_playback_pcm_prepare,
231 .cleanup = ad198x_playback_pcm_cleanup
232 },
233};
234
235static struct hda_pcm_stream ad198x_pcm_analog_capture = {
Takashi Iwai985be542005-11-02 18:26:49 +0100236 .substreams = 1,
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200237 .channels_min = 2,
238 .channels_max = 2,
239 .nid = 0, /* fill later */
240 .ops = {
241 .prepare = ad198x_capture_pcm_prepare,
242 .cleanup = ad198x_capture_pcm_cleanup
243 },
244};
245
246static struct hda_pcm_stream ad198x_pcm_digital_playback = {
247 .substreams = 1,
248 .channels_min = 2,
249 .channels_max = 2,
250 .nid = 0, /* fill later */
251 .ops = {
252 .open = ad198x_dig_playback_pcm_open,
253 .close = ad198x_dig_playback_pcm_close
254 },
255};
256
Takashi Iwai985be542005-11-02 18:26:49 +0100257static struct hda_pcm_stream ad198x_pcm_digital_capture = {
258 .substreams = 1,
259 .channels_min = 2,
260 .channels_max = 2,
261 /* NID is set in alc_build_pcms */
262};
263
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200264static int ad198x_build_pcms(struct hda_codec *codec)
265{
266 struct ad198x_spec *spec = codec->spec;
267 struct hda_pcm *info = spec->pcm_rec;
268
269 codec->num_pcms = 1;
270 codec->pcm_info = info;
271
272 info->name = "AD198x Analog";
273 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_analog_playback;
274 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->multiout.max_channels;
275 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
276 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_analog_capture;
Takashi Iwai985be542005-11-02 18:26:49 +0100277 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adc_nids;
278 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200279
280 if (spec->multiout.dig_out_nid) {
281 info++;
282 codec->num_pcms++;
283 info->name = "AD198x Digital";
284 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_digital_playback;
285 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
Takashi Iwai985be542005-11-02 18:26:49 +0100286 if (spec->dig_in_nid) {
287 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_digital_capture;
288 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
289 }
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200290 }
291
292 return 0;
293}
294
295static void ad198x_free(struct hda_codec *codec)
296{
Takashi Iwaid32410b12005-11-24 16:06:23 +0100297 struct ad198x_spec *spec = codec->spec;
298 unsigned int i;
299
300 if (spec->kctl_alloc) {
301 for (i = 0; i < spec->num_kctl_used; i++)
302 kfree(spec->kctl_alloc[i].name);
303 kfree(spec->kctl_alloc);
304 }
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200305 kfree(codec->spec);
306}
307
308#ifdef CONFIG_PM
309static int ad198x_resume(struct hda_codec *codec)
310{
311 struct ad198x_spec *spec = codec->spec;
Takashi Iwai985be542005-11-02 18:26:49 +0100312 int i;
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200313
Takashi Iwai18a815d2006-03-01 19:54:39 +0100314 codec->patch_ops.init(codec);
Takashi Iwai985be542005-11-02 18:26:49 +0100315 for (i = 0; i < spec->num_mixers; i++)
316 snd_hda_resume_ctls(codec, spec->mixers[i]);
317 if (spec->multiout.dig_out_nid)
318 snd_hda_resume_spdif_out(codec);
319 if (spec->dig_in_nid)
320 snd_hda_resume_spdif_in(codec);
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200321 return 0;
322}
323#endif
324
325static struct hda_codec_ops ad198x_patch_ops = {
326 .build_controls = ad198x_build_controls,
327 .build_pcms = ad198x_build_pcms,
328 .init = ad198x_init,
329 .free = ad198x_free,
330#ifdef CONFIG_PM
331 .resume = ad198x_resume,
332#endif
333};
334
335
336/*
Takashi Iwai18a815d2006-03-01 19:54:39 +0100337 * EAPD control
338 * the private value = nid | (invert << 8)
339 */
340static int ad198x_eapd_info(struct snd_kcontrol *kcontrol,
341 struct snd_ctl_elem_info *uinfo)
342{
343 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
344 uinfo->count = 1;
345 uinfo->value.integer.min = 0;
346 uinfo->value.integer.max = 1;
347 return 0;
348}
349
350static int ad198x_eapd_get(struct snd_kcontrol *kcontrol,
351 struct snd_ctl_elem_value *ucontrol)
352{
353 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
354 struct ad198x_spec *spec = codec->spec;
355 int invert = (kcontrol->private_value >> 8) & 1;
356 if (invert)
357 ucontrol->value.integer.value[0] = ! spec->cur_eapd;
358 else
359 ucontrol->value.integer.value[0] = spec->cur_eapd;
360 return 0;
361}
362
363static int ad198x_eapd_put(struct snd_kcontrol *kcontrol,
364 struct snd_ctl_elem_value *ucontrol)
365{
366 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
367 struct ad198x_spec *spec = codec->spec;
368 int invert = (kcontrol->private_value >> 8) & 1;
369 hda_nid_t nid = kcontrol->private_value & 0xff;
370 unsigned int eapd;
371 eapd = ucontrol->value.integer.value[0];
372 if (invert)
373 eapd = !eapd;
374 if (eapd == spec->cur_eapd && ! codec->in_resume)
375 return 0;
376 spec->cur_eapd = eapd;
377 snd_hda_codec_write(codec, nid,
378 0, AC_VERB_SET_EAPD_BTLENABLE,
379 eapd ? 0x02 : 0x00);
380 return 1;
381}
382
Takashi Iwai9230d212006-03-13 13:49:49 +0100383static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol,
384 struct snd_ctl_elem_info *uinfo);
385static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol,
386 struct snd_ctl_elem_value *ucontrol);
387static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol,
388 struct snd_ctl_elem_value *ucontrol);
389
390
Takashi Iwai18a815d2006-03-01 19:54:39 +0100391/*
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200392 * AD1986A specific
393 */
394
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395#define AD1986A_SPDIF_OUT 0x02
396#define AD1986A_FRONT_DAC 0x03
397#define AD1986A_SURR_DAC 0x04
398#define AD1986A_CLFE_DAC 0x05
399#define AD1986A_ADC 0x06
400
401static hda_nid_t ad1986a_dac_nids[3] = {
402 AD1986A_FRONT_DAC, AD1986A_SURR_DAC, AD1986A_CLFE_DAC
403};
Takashi Iwai985be542005-11-02 18:26:49 +0100404static hda_nid_t ad1986a_adc_nids[1] = { AD1986A_ADC };
Takashi Iwai18a815d2006-03-01 19:54:39 +0100405static hda_nid_t ad1986a_capsrc_nids[1] = { 0x12 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406
407static struct hda_input_mux ad1986a_capture_source = {
408 .num_items = 7,
409 .items = {
410 { "Mic", 0x0 },
411 { "CD", 0x1 },
412 { "Aux", 0x3 },
413 { "Line", 0x4 },
414 { "Mix", 0x5 },
415 { "Mono", 0x6 },
416 { "Phone", 0x7 },
417 },
418};
419
420/*
421 * PCM control
422 *
423 * bind volumes/mutes of 3 DACs as a single PCM control for simplicity
424 */
425
426#define ad1986a_pcm_amp_vol_info snd_hda_mixer_amp_volume_info
427
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100428static int ad1986a_pcm_amp_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429{
430 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200431 struct ad198x_spec *ad = codec->spec;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432
Ingo Molnar62932df2006-01-16 16:34:20 +0100433 mutex_lock(&ad->amp_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434 snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
Ingo Molnar62932df2006-01-16 16:34:20 +0100435 mutex_unlock(&ad->amp_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436 return 0;
437}
438
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100439static int ad1986a_pcm_amp_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440{
441 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200442 struct ad198x_spec *ad = codec->spec;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443 int i, change = 0;
444
Ingo Molnar62932df2006-01-16 16:34:20 +0100445 mutex_lock(&ad->amp_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446 for (i = 0; i < ARRAY_SIZE(ad1986a_dac_nids); i++) {
447 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(ad1986a_dac_nids[i], 3, 0, HDA_OUTPUT);
448 change |= snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
449 }
450 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT);
Ingo Molnar62932df2006-01-16 16:34:20 +0100451 mutex_unlock(&ad->amp_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452 return change;
453}
454
Takashi Iwaiead9b7c2005-06-08 14:48:19 +0200455#define ad1986a_pcm_amp_sw_info snd_hda_mixer_amp_switch_info
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100457static int ad1986a_pcm_amp_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458{
459 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200460 struct ad198x_spec *ad = codec->spec;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461
Ingo Molnar62932df2006-01-16 16:34:20 +0100462 mutex_lock(&ad->amp_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463 snd_hda_mixer_amp_switch_get(kcontrol, ucontrol);
Ingo Molnar62932df2006-01-16 16:34:20 +0100464 mutex_unlock(&ad->amp_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465 return 0;
466}
467
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100468static int ad1986a_pcm_amp_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469{
470 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200471 struct ad198x_spec *ad = codec->spec;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 int i, change = 0;
473
Ingo Molnar62932df2006-01-16 16:34:20 +0100474 mutex_lock(&ad->amp_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475 for (i = 0; i < ARRAY_SIZE(ad1986a_dac_nids); i++) {
476 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(ad1986a_dac_nids[i], 3, 0, HDA_OUTPUT);
477 change |= snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
478 }
479 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT);
Ingo Molnar62932df2006-01-16 16:34:20 +0100480 mutex_unlock(&ad->amp_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481 return change;
482}
483
484/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485 * mixers
486 */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100487static struct snd_kcontrol_new ad1986a_mixers[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 {
489 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
490 .name = "PCM Playback Volume",
Jaroslav Kysela302e9c52006-07-05 17:39:49 +0200491 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
492 SNDRV_CTL_ELEM_ACCESS_TLV_READ |
493 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494 .info = ad1986a_pcm_amp_vol_info,
495 .get = ad1986a_pcm_amp_vol_get,
496 .put = ad1986a_pcm_amp_vol_put,
Takashi Iwaic2566522006-08-17 18:21:36 +0200497 .tlv = { .c = snd_hda_mixer_amp_tlv },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498 .private_value = HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT)
499 },
500 {
501 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
502 .name = "PCM Playback Switch",
503 .info = ad1986a_pcm_amp_sw_info,
504 .get = ad1986a_pcm_amp_sw_get,
505 .put = ad1986a_pcm_amp_sw_put,
506 .private_value = HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT)
507 },
508 HDA_CODEC_VOLUME("Front Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
509 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
510 HDA_CODEC_VOLUME("Surround Playback Volume", 0x1c, 0x0, HDA_OUTPUT),
511 HDA_CODEC_MUTE("Surround Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
512 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x1d, 1, 0x0, HDA_OUTPUT),
513 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x1d, 2, 0x0, HDA_OUTPUT),
514 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x1d, 1, 0x0, HDA_OUTPUT),
515 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x1d, 2, 0x0, HDA_OUTPUT),
516 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT),
517 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
518 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT),
519 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT),
520 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT),
521 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT),
522 HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT),
523 HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT),
524 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
525 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
Takashi Iwaife8970b2007-02-26 16:00:34 +0100526 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT),
528 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT),
529 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
530 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT),
531 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
532 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
533 {
534 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
535 .name = "Capture Source",
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200536 .info = ad198x_mux_enum_info,
537 .get = ad198x_mux_enum_get,
538 .put = ad198x_mux_enum_put,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539 },
540 HDA_CODEC_MUTE("Stereo Downmix Switch", 0x09, 0x0, HDA_OUTPUT),
541 { } /* end */
542};
543
Takashi Iwai9230d212006-03-13 13:49:49 +0100544/* additional mixers for 3stack mode */
545static struct snd_kcontrol_new ad1986a_3st_mixers[] = {
546 {
547 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
548 .name = "Channel Mode",
549 .info = ad198x_ch_mode_info,
550 .get = ad198x_ch_mode_get,
551 .put = ad198x_ch_mode_put,
552 },
553 { } /* end */
554};
555
556/* laptop model - 2ch only */
557static hda_nid_t ad1986a_laptop_dac_nids[1] = { AD1986A_FRONT_DAC };
558
559static struct snd_kcontrol_new ad1986a_laptop_mixers[] = {
560 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
561 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
562 HDA_CODEC_VOLUME("Master Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
563 HDA_CODEC_MUTE("Master Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
564 /* HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT),
565 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT), */
566 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT),
567 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT),
568 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT),
569 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT),
570 HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT),
571 HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT),
572 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
573 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
Takashi Iwaife8970b2007-02-26 16:00:34 +0100574 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai9230d212006-03-13 13:49:49 +0100575 /* HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT),
576 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT),
577 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
578 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), */
579 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
580 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
581 {
582 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
583 .name = "Capture Source",
584 .info = ad198x_mux_enum_info,
585 .get = ad198x_mux_enum_get,
586 .put = ad198x_mux_enum_put,
587 },
588 { } /* end */
589};
590
Takashi Iwai825aa972006-03-17 10:50:49 +0100591/* laptop-eapd model - 2ch only */
592
593/* master controls both pins 0x1a and 0x1b */
594static int ad1986a_laptop_master_vol_put(struct snd_kcontrol *kcontrol,
595 struct snd_ctl_elem_value *ucontrol)
596{
597 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
598 long *valp = ucontrol->value.integer.value;
599 int change;
600
601 change = snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0,
602 0x7f, valp[0] & 0x7f);
603 change |= snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0,
604 0x7f, valp[1] & 0x7f);
605 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
606 0x7f, valp[0] & 0x7f);
607 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
608 0x7f, valp[1] & 0x7f);
609 return change;
610}
611
612static int ad1986a_laptop_master_sw_put(struct snd_kcontrol *kcontrol,
613 struct snd_ctl_elem_value *ucontrol)
614{
615 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
616 long *valp = ucontrol->value.integer.value;
617 int change;
618
619 change = snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0,
620 0x80, valp[0] ? 0 : 0x80);
621 change |= snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0,
622 0x80, valp[1] ? 0 : 0x80);
623 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
624 0x80, valp[0] ? 0 : 0x80);
625 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
626 0x80, valp[1] ? 0 : 0x80);
627 return change;
628}
629
630static struct hda_input_mux ad1986a_laptop_eapd_capture_source = {
631 .num_items = 3,
632 .items = {
633 { "Mic", 0x0 },
634 { "Internal Mic", 0x4 },
635 { "Mix", 0x5 },
636 },
637};
638
639static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = {
640 {
641 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
642 .name = "Master Playback Volume",
643 .info = snd_hda_mixer_amp_volume_info,
644 .get = snd_hda_mixer_amp_volume_get,
645 .put = ad1986a_laptop_master_vol_put,
Takashi Iwaic2566522006-08-17 18:21:36 +0200646 .tlv = { .c = snd_hda_mixer_amp_tlv },
Takashi Iwai825aa972006-03-17 10:50:49 +0100647 .private_value = HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT),
648 },
649 {
650 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
651 .name = "Master Playback Switch",
652 .info = snd_hda_mixer_amp_switch_info,
653 .get = snd_hda_mixer_amp_switch_get,
654 .put = ad1986a_laptop_master_sw_put,
655 .private_value = HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT),
656 },
657 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
658 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
659 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x0, HDA_OUTPUT),
660 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x0, HDA_OUTPUT),
661 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
662 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
Takashi Iwaife8970b2007-02-26 16:00:34 +0100663 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai825aa972006-03-17 10:50:49 +0100664 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
665 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
666 {
667 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
668 .name = "Capture Source",
669 .info = ad198x_mux_enum_info,
670 .get = ad198x_mux_enum_get,
671 .put = ad198x_mux_enum_put,
672 },
673 {
674 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
675 .name = "External Amplifier",
676 .info = ad198x_eapd_info,
677 .get = ad198x_eapd_get,
678 .put = ad198x_eapd_put,
679 .private_value = 0x1b | (1 << 8), /* port-D, inversed */
680 },
681 { } /* end */
682};
683
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684/*
685 * initialization verbs
686 */
687static struct hda_verb ad1986a_init_verbs[] = {
688 /* Front, Surround, CLFE DAC; mute as default */
689 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
690 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
691 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
692 /* Downmix - off */
693 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
694 /* HP, Line-Out, Surround, CLFE selectors */
695 {0x0a, AC_VERB_SET_CONNECT_SEL, 0x0},
696 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x0},
697 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0},
698 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
699 /* Mono selector */
700 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x0},
701 /* Mic selector: Mic 1/2 pin */
702 {0x0f, AC_VERB_SET_CONNECT_SEL, 0x0},
703 /* Line-in selector: Line-in */
704 {0x10, AC_VERB_SET_CONNECT_SEL, 0x0},
705 /* Mic 1/2 swap */
706 {0x11, AC_VERB_SET_CONNECT_SEL, 0x0},
707 /* Record selector: mic */
708 {0x12, AC_VERB_SET_CONNECT_SEL, 0x0},
709 /* Mic, Phone, CD, Aux, Line-In amp; mute as default */
710 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
711 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
712 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
713 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
714 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
715 /* PC beep */
716 {0x18, AC_VERB_SET_CONNECT_SEL, 0x0},
717 /* HP, Line-Out, Surround, CLFE, Mono pins; mute as default */
718 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
719 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
720 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
721 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
722 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200723 /* HP Pin */
724 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
725 /* Front, Surround, CLFE Pins */
726 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
727 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
728 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
729 /* Mono Pin */
730 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
731 /* Mic Pin */
732 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
733 /* Line, Aux, CD, Beep-In Pin */
734 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
735 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
736 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
737 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
738 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739 { } /* end */
740};
741
Takashi Iwai9230d212006-03-13 13:49:49 +0100742/* additional verbs for 3-stack model */
743static struct hda_verb ad1986a_3st_init_verbs[] = {
744 /* Mic and line-in selectors */
745 {0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
746 {0x10, AC_VERB_SET_CONNECT_SEL, 0x1},
747 { } /* end */
748};
749
750static struct hda_verb ad1986a_ch2_init[] = {
751 /* Surround out -> Line In */
752 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
753 { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
754 /* CLFE -> Mic in */
755 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
756 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
757 { } /* end */
758};
759
760static struct hda_verb ad1986a_ch4_init[] = {
761 /* Surround out -> Surround */
762 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
763 { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
764 /* CLFE -> Mic in */
765 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
766 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
767 { } /* end */
768};
769
770static struct hda_verb ad1986a_ch6_init[] = {
771 /* Surround out -> Surround out */
772 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
773 { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
774 /* CLFE -> CLFE */
775 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
776 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
777 { } /* end */
778};
779
780static struct hda_channel_mode ad1986a_modes[3] = {
781 { 2, ad1986a_ch2_init },
782 { 4, ad1986a_ch4_init },
783 { 6, ad1986a_ch6_init },
784};
785
Takashi Iwai825aa972006-03-17 10:50:49 +0100786/* eapd initialization */
787static struct hda_verb ad1986a_eapd_init_verbs[] = {
Tobin Davisf36090f2007-01-08 11:07:12 +0100788 {0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00 },
Takashi Iwai825aa972006-03-17 10:50:49 +0100789 {}
790};
791
Tobin Davisf36090f2007-01-08 11:07:12 +0100792/* Ultra initialization */
793static struct hda_verb ad1986a_ultra_init[] = {
794 /* eapd initialization */
795 { 0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00 },
796 /* CLFE -> Mic in */
797 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2 },
798 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
799 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
800 { } /* end */
801};
802
Takashi Iwai9230d212006-03-13 13:49:49 +0100803/* models */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100804enum {
805 AD1986A_6STACK,
806 AD1986A_3STACK,
807 AD1986A_LAPTOP,
808 AD1986A_LAPTOP_EAPD,
Tobin Davisf36090f2007-01-08 11:07:12 +0100809 AD1986A_ULTRA,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100810 AD1986A_MODELS
811};
Takashi Iwai9230d212006-03-13 13:49:49 +0100812
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100813static const char *ad1986a_models[AD1986A_MODELS] = {
814 [AD1986A_6STACK] = "6stack",
815 [AD1986A_3STACK] = "3stack",
816 [AD1986A_LAPTOP] = "laptop",
817 [AD1986A_LAPTOP_EAPD] = "laptop-eapd",
Tobin Davisf36090f2007-01-08 11:07:12 +0100818 [AD1986A_ULTRA] = "ultra",
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100819};
820
821static struct snd_pci_quirk ad1986a_cfg_tbl[] = {
822 SND_PCI_QUIRK(0x103c, 0x30af, "HP B2800", AD1986A_LAPTOP_EAPD),
823 SND_PCI_QUIRK(0x10de, 0xcb84, "ASUS A8N-VM", AD1986A_3STACK),
824 SND_PCI_QUIRK(0x1043, 0x1153, "ASUS M9", AD1986A_LAPTOP_EAPD),
825 SND_PCI_QUIRK(0x1043, 0x1213, "ASUS A6J", AD1986A_LAPTOP_EAPD),
826 SND_PCI_QUIRK(0x1043, 0x11f7, "ASUS U5A", AD1986A_LAPTOP_EAPD),
827 SND_PCI_QUIRK(0x1043, 0x1263, "ASUS U5F", AD1986A_LAPTOP_EAPD),
828 SND_PCI_QUIRK(0x1043, 0x1297, "ASUS Z62F", AD1986A_LAPTOP_EAPD),
829 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS V1j", AD1986A_LAPTOP_EAPD),
830 SND_PCI_QUIRK(0x1043, 0x1302, "ASUS W3j", AD1986A_LAPTOP_EAPD),
831 SND_PCI_QUIRK(0x1043, 0x817f, "ASUS P5", AD1986A_3STACK),
832 SND_PCI_QUIRK(0x1043, 0x818f, "ASUS P5", AD1986A_LAPTOP),
833 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS P5", AD1986A_3STACK),
834 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS M2N", AD1986A_3STACK),
835 SND_PCI_QUIRK(0x1043, 0x8234, "ASUS M2N", AD1986A_3STACK),
836 SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP),
837 SND_PCI_QUIRK(0x144d, 0xc023, "Samsung X60", AD1986A_LAPTOP_EAPD),
838 SND_PCI_QUIRK(0x144d, 0xc024, "Samsung R65", AD1986A_LAPTOP_EAPD),
839 SND_PCI_QUIRK(0x144d, 0xc026, "Samsung X11", AD1986A_LAPTOP_EAPD),
Tobin Davisf36090f2007-01-08 11:07:12 +0100840 SND_PCI_QUIRK(0x144d, 0xc504, "Samsung Q35", AD1986A_3STACK),
841 SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_ULTRA),
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100842 SND_PCI_QUIRK(0x17aa, 0x1017, "Lenovo A60", AD1986A_3STACK),
843 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo N100", AD1986A_LAPTOP_EAPD),
844 SND_PCI_QUIRK(0x17c0, 0x2017, "Samsung M50", AD1986A_LAPTOP),
Takashi Iwai9230d212006-03-13 13:49:49 +0100845 {}
846};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700847
Linus Torvalds1da177e2005-04-16 15:20:36 -0700848static int patch_ad1986a(struct hda_codec *codec)
849{
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200850 struct ad198x_spec *spec;
Takashi Iwai9230d212006-03-13 13:49:49 +0100851 int board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700852
Takashi Iwaie560d8d2005-09-09 14:21:46 +0200853 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700854 if (spec == NULL)
855 return -ENOMEM;
856
Ingo Molnar62932df2006-01-16 16:34:20 +0100857 mutex_init(&spec->amp_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700858 codec->spec = spec;
859
860 spec->multiout.max_channels = 6;
861 spec->multiout.num_dacs = ARRAY_SIZE(ad1986a_dac_nids);
862 spec->multiout.dac_nids = ad1986a_dac_nids;
863 spec->multiout.dig_out_nid = AD1986A_SPDIF_OUT;
Takashi Iwai985be542005-11-02 18:26:49 +0100864 spec->num_adc_nids = 1;
865 spec->adc_nids = ad1986a_adc_nids;
Takashi Iwaia7ee8202006-03-01 20:05:39 +0100866 spec->capsrc_nids = ad1986a_capsrc_nids;
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200867 spec->input_mux = &ad1986a_capture_source;
Takashi Iwai985be542005-11-02 18:26:49 +0100868 spec->num_mixers = 1;
869 spec->mixers[0] = ad1986a_mixers;
870 spec->num_init_verbs = 1;
871 spec->init_verbs[0] = ad1986a_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700872
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200873 codec->patch_ops = ad198x_patch_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700874
Takashi Iwai9230d212006-03-13 13:49:49 +0100875 /* override some parameters */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100876 board_config = snd_hda_check_board_config(codec, AD1986A_MODELS,
877 ad1986a_models,
878 ad1986a_cfg_tbl);
Takashi Iwai9230d212006-03-13 13:49:49 +0100879 switch (board_config) {
880 case AD1986A_3STACK:
881 spec->num_mixers = 2;
882 spec->mixers[1] = ad1986a_3st_mixers;
Takashi Iwai2125cad2006-03-27 12:52:22 +0200883 spec->num_init_verbs = 3;
Takashi Iwai9230d212006-03-13 13:49:49 +0100884 spec->init_verbs[1] = ad1986a_3st_init_verbs;
Takashi Iwai2125cad2006-03-27 12:52:22 +0200885 spec->init_verbs[2] = ad1986a_ch2_init;
Takashi Iwai9230d212006-03-13 13:49:49 +0100886 spec->channel_mode = ad1986a_modes;
887 spec->num_channel_mode = ARRAY_SIZE(ad1986a_modes);
Takashi Iwai2125cad2006-03-27 12:52:22 +0200888 spec->need_dac_fix = 1;
889 spec->multiout.max_channels = 2;
890 spec->multiout.num_dacs = 1;
Takashi Iwai9230d212006-03-13 13:49:49 +0100891 break;
892 case AD1986A_LAPTOP:
893 spec->mixers[0] = ad1986a_laptop_mixers;
894 spec->multiout.max_channels = 2;
895 spec->multiout.num_dacs = 1;
896 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
897 break;
Takashi Iwai825aa972006-03-17 10:50:49 +0100898 case AD1986A_LAPTOP_EAPD:
899 spec->mixers[0] = ad1986a_laptop_eapd_mixers;
900 spec->num_init_verbs = 2;
901 spec->init_verbs[1] = ad1986a_eapd_init_verbs;
902 spec->multiout.max_channels = 2;
903 spec->multiout.num_dacs = 1;
904 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
905 spec->multiout.dig_out_nid = 0;
906 spec->input_mux = &ad1986a_laptop_eapd_capture_source;
907 break;
Tobin Davisf36090f2007-01-08 11:07:12 +0100908 case AD1986A_ULTRA:
909 spec->mixers[0] = ad1986a_laptop_eapd_mixers;
910 spec->num_init_verbs = 2;
911 spec->init_verbs[1] = ad1986a_ultra_init;
912 spec->multiout.max_channels = 2;
913 spec->multiout.num_dacs = 1;
914 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
915 spec->multiout.dig_out_nid = 0;
916 break;
Takashi Iwai9230d212006-03-13 13:49:49 +0100917 }
918
Linus Torvalds1da177e2005-04-16 15:20:36 -0700919 return 0;
920}
921
922/*
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200923 * AD1983 specific
924 */
925
926#define AD1983_SPDIF_OUT 0x02
927#define AD1983_DAC 0x03
928#define AD1983_ADC 0x04
929
930static hda_nid_t ad1983_dac_nids[1] = { AD1983_DAC };
Takashi Iwai985be542005-11-02 18:26:49 +0100931static hda_nid_t ad1983_adc_nids[1] = { AD1983_ADC };
Takashi Iwai18a815d2006-03-01 19:54:39 +0100932static hda_nid_t ad1983_capsrc_nids[1] = { 0x15 };
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200933
934static struct hda_input_mux ad1983_capture_source = {
935 .num_items = 4,
936 .items = {
937 { "Mic", 0x0 },
938 { "Line", 0x1 },
939 { "Mix", 0x2 },
940 { "Mix Mono", 0x3 },
941 },
942};
943
944/*
945 * SPDIF playback route
946 */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100947static int ad1983_spdif_route_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200948{
949 static char *texts[] = { "PCM", "ADC" };
950
951 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
952 uinfo->count = 1;
953 uinfo->value.enumerated.items = 2;
954 if (uinfo->value.enumerated.item > 1)
955 uinfo->value.enumerated.item = 1;
956 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
957 return 0;
958}
959
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100960static int ad1983_spdif_route_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200961{
962 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
963 struct ad198x_spec *spec = codec->spec;
964
965 ucontrol->value.enumerated.item[0] = spec->spdif_route;
966 return 0;
967}
968
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100969static int ad1983_spdif_route_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200970{
971 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
972 struct ad198x_spec *spec = codec->spec;
973
974 if (spec->spdif_route != ucontrol->value.enumerated.item[0]) {
975 spec->spdif_route = ucontrol->value.enumerated.item[0];
976 snd_hda_codec_write(codec, spec->multiout.dig_out_nid, 0,
977 AC_VERB_SET_CONNECT_SEL, spec->spdif_route);
978 return 1;
979 }
980 return 0;
981}
982
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100983static struct snd_kcontrol_new ad1983_mixers[] = {
Takashi Iwai4a3fdf32005-04-14 13:35:51 +0200984 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT),
985 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT),
986 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT),
987 HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT),
988 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT),
989 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT),
990 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
991 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
992 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
993 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
994 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT),
995 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT),
996 HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x10, 1, 0x0, HDA_OUTPUT),
997 HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x10, 1, 0x0, HDA_OUTPUT),
998 HDA_CODEC_VOLUME("Mic Boost", 0x0c, 0x0, HDA_OUTPUT),
999 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1000 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
1001 {
1002 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1003 .name = "Capture Source",
1004 .info = ad198x_mux_enum_info,
1005 .get = ad198x_mux_enum_get,
1006 .put = ad198x_mux_enum_put,
1007 },
1008 {
1009 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Takashi Iwai6540dff2006-06-13 11:57:22 +02001010 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
Takashi Iwai4a3fdf32005-04-14 13:35:51 +02001011 .info = ad1983_spdif_route_info,
1012 .get = ad1983_spdif_route_get,
1013 .put = ad1983_spdif_route_put,
1014 },
1015 { } /* end */
1016};
1017
1018static struct hda_verb ad1983_init_verbs[] = {
1019 /* Front, HP, Mono; mute as default */
1020 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1021 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1022 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1023 /* Beep, PCM, Mic, Line-In: mute */
1024 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1025 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1026 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1027 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1028 /* Front, HP selectors; from Mix */
1029 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
1030 {0x06, AC_VERB_SET_CONNECT_SEL, 0x01},
1031 /* Mono selector; from Mix */
1032 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03},
1033 /* Mic selector; Mic */
1034 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0},
1035 /* Line-in selector: Line-in */
1036 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
1037 /* Mic boost: 0dB */
1038 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1039 /* Record selector: mic */
1040 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0},
1041 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1042 /* SPDIF route: PCM */
1043 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0},
1044 /* Front Pin */
1045 {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1046 /* HP Pin */
1047 {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
1048 /* Mono Pin */
1049 {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1050 /* Mic Pin */
1051 {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
1052 /* Line Pin */
1053 {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
1054 { } /* end */
1055};
1056
Takashi Iwai985be542005-11-02 18:26:49 +01001057
Takashi Iwai4a3fdf32005-04-14 13:35:51 +02001058static int patch_ad1983(struct hda_codec *codec)
1059{
1060 struct ad198x_spec *spec;
1061
Takashi Iwaie560d8d2005-09-09 14:21:46 +02001062 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Takashi Iwai4a3fdf32005-04-14 13:35:51 +02001063 if (spec == NULL)
1064 return -ENOMEM;
1065
Ingo Molnar62932df2006-01-16 16:34:20 +01001066 mutex_init(&spec->amp_mutex);
Takashi Iwai4a3fdf32005-04-14 13:35:51 +02001067 codec->spec = spec;
1068
1069 spec->multiout.max_channels = 2;
1070 spec->multiout.num_dacs = ARRAY_SIZE(ad1983_dac_nids);
1071 spec->multiout.dac_nids = ad1983_dac_nids;
1072 spec->multiout.dig_out_nid = AD1983_SPDIF_OUT;
Takashi Iwai985be542005-11-02 18:26:49 +01001073 spec->num_adc_nids = 1;
1074 spec->adc_nids = ad1983_adc_nids;
Takashi Iwai18a815d2006-03-01 19:54:39 +01001075 spec->capsrc_nids = ad1983_capsrc_nids;
Takashi Iwai4a3fdf32005-04-14 13:35:51 +02001076 spec->input_mux = &ad1983_capture_source;
Takashi Iwai985be542005-11-02 18:26:49 +01001077 spec->num_mixers = 1;
1078 spec->mixers[0] = ad1983_mixers;
1079 spec->num_init_verbs = 1;
1080 spec->init_verbs[0] = ad1983_init_verbs;
Takashi Iwai4a3fdf32005-04-14 13:35:51 +02001081 spec->spdif_route = 0;
1082
1083 codec->patch_ops = ad198x_patch_ops;
1084
1085 return 0;
1086}
1087
1088
1089/*
1090 * AD1981 HD specific
1091 */
1092
1093#define AD1981_SPDIF_OUT 0x02
1094#define AD1981_DAC 0x03
1095#define AD1981_ADC 0x04
1096
1097static hda_nid_t ad1981_dac_nids[1] = { AD1981_DAC };
Takashi Iwai985be542005-11-02 18:26:49 +01001098static hda_nid_t ad1981_adc_nids[1] = { AD1981_ADC };
Takashi Iwai18a815d2006-03-01 19:54:39 +01001099static hda_nid_t ad1981_capsrc_nids[1] = { 0x15 };
Takashi Iwai4a3fdf32005-04-14 13:35:51 +02001100
1101/* 0x0c, 0x09, 0x0e, 0x0f, 0x19, 0x05, 0x18, 0x17 */
1102static struct hda_input_mux ad1981_capture_source = {
1103 .num_items = 7,
1104 .items = {
1105 { "Front Mic", 0x0 },
1106 { "Line", 0x1 },
1107 { "Mix", 0x2 },
1108 { "Mix Mono", 0x3 },
1109 { "CD", 0x4 },
1110 { "Mic", 0x6 },
1111 { "Aux", 0x7 },
1112 },
1113};
1114
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001115static struct snd_kcontrol_new ad1981_mixers[] = {
Takashi Iwai4a3fdf32005-04-14 13:35:51 +02001116 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT),
1117 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT),
1118 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT),
1119 HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT),
1120 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT),
1121 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT),
1122 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
1123 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
1124 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
1125 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
1126 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1127 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1128 HDA_CODEC_VOLUME("Aux Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
1129 HDA_CODEC_MUTE("Aux Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1130 HDA_CODEC_VOLUME("Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT),
1131 HDA_CODEC_MUTE("Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
1132 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1133 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1134 HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1135 HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x0d, 1, 0x0, HDA_OUTPUT),
1136 HDA_CODEC_VOLUME("Front Mic Boost", 0x08, 0x0, HDA_INPUT),
1137 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x0, HDA_INPUT),
1138 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1139 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
1140 {
1141 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1142 .name = "Capture Source",
1143 .info = ad198x_mux_enum_info,
1144 .get = ad198x_mux_enum_get,
1145 .put = ad198x_mux_enum_put,
1146 },
1147 /* identical with AD1983 */
1148 {
1149 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Takashi Iwai6540dff2006-06-13 11:57:22 +02001150 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
Takashi Iwai4a3fdf32005-04-14 13:35:51 +02001151 .info = ad1983_spdif_route_info,
1152 .get = ad1983_spdif_route_get,
1153 .put = ad1983_spdif_route_put,
1154 },
1155 { } /* end */
1156};
1157
1158static struct hda_verb ad1981_init_verbs[] = {
1159 /* Front, HP, Mono; mute as default */
1160 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1161 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1162 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1163 /* Beep, PCM, Front Mic, Line, Rear Mic, Aux, CD-In: mute */
1164 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1165 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1166 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1167 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1168 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1169 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1170 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1171 /* Front, HP selectors; from Mix */
1172 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
1173 {0x06, AC_VERB_SET_CONNECT_SEL, 0x01},
1174 /* Mono selector; from Mix */
1175 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03},
1176 /* Mic Mixer; select Front Mic */
1177 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1178 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1179 /* Mic boost: 0dB */
1180 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1181 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1182 /* Record selector: Front mic */
1183 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0},
1184 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1185 /* SPDIF route: PCM */
1186 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0},
1187 /* Front Pin */
1188 {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1189 /* HP Pin */
1190 {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
1191 /* Mono Pin */
1192 {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1193 /* Front & Rear Mic Pins */
1194 {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
1195 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
1196 /* Line Pin */
1197 {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
1198 /* Digital Beep */
1199 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
1200 /* Line-Out as Input: disabled */
1201 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1202 { } /* end */
1203};
1204
Takashi Iwai18a815d2006-03-01 19:54:39 +01001205/*
1206 * Patch for HP nx6320
1207 *
1208 * nx6320 uses EAPD in the reserve way - EAPD-on means the internal
1209 * speaker output enabled _and_ mute-LED off.
1210 */
1211
1212#define AD1981_HP_EVENT 0x37
1213#define AD1981_MIC_EVENT 0x38
1214
1215static struct hda_verb ad1981_hp_init_verbs[] = {
1216 {0x05, AC_VERB_SET_EAPD_BTLENABLE, 0x00 }, /* default off */
1217 /* pin sensing on HP and Mic jacks */
1218 {0x06, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_HP_EVENT},
1219 {0x08, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_MIC_EVENT},
1220 {}
1221};
1222
1223/* turn on/off EAPD (+ mute HP) as a master switch */
1224static int ad1981_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1225 struct snd_ctl_elem_value *ucontrol)
1226{
1227 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1228 struct ad198x_spec *spec = codec->spec;
1229
1230 if (! ad198x_eapd_put(kcontrol, ucontrol))
1231 return 0;
1232
1233 /* toggle HP mute appropriately */
1234 snd_hda_codec_amp_update(codec, 0x06, 0, HDA_OUTPUT, 0,
1235 0x80, spec->cur_eapd ? 0 : 0x80);
1236 snd_hda_codec_amp_update(codec, 0x06, 1, HDA_OUTPUT, 0,
1237 0x80, spec->cur_eapd ? 0 : 0x80);
1238 return 1;
1239}
1240
1241/* bind volumes of both NID 0x05 and 0x06 */
1242static int ad1981_hp_master_vol_put(struct snd_kcontrol *kcontrol,
1243 struct snd_ctl_elem_value *ucontrol)
1244{
1245 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1246 long *valp = ucontrol->value.integer.value;
1247 int change;
1248
1249 change = snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
1250 0x7f, valp[0] & 0x7f);
1251 change |= snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
1252 0x7f, valp[1] & 0x7f);
1253 snd_hda_codec_amp_update(codec, 0x06, 0, HDA_OUTPUT, 0,
1254 0x7f, valp[0] & 0x7f);
1255 snd_hda_codec_amp_update(codec, 0x06, 1, HDA_OUTPUT, 0,
1256 0x7f, valp[1] & 0x7f);
1257 return change;
1258}
1259
1260/* mute internal speaker if HP is plugged */
1261static void ad1981_hp_automute(struct hda_codec *codec)
1262{
1263 unsigned int present;
1264
1265 present = snd_hda_codec_read(codec, 0x06, 0,
1266 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1267 snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
1268 0x80, present ? 0x80 : 0);
1269 snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
1270 0x80, present ? 0x80 : 0);
1271}
1272
1273/* toggle input of built-in and mic jack appropriately */
1274static void ad1981_hp_automic(struct hda_codec *codec)
1275{
1276 static struct hda_verb mic_jack_on[] = {
1277 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1278 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1279 {}
1280 };
1281 static struct hda_verb mic_jack_off[] = {
1282 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1283 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1284 {}
1285 };
1286 unsigned int present;
1287
1288 present = snd_hda_codec_read(codec, 0x08, 0,
1289 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1290 if (present)
1291 snd_hda_sequence_write(codec, mic_jack_on);
1292 else
1293 snd_hda_sequence_write(codec, mic_jack_off);
1294}
1295
1296/* unsolicited event for HP jack sensing */
1297static void ad1981_hp_unsol_event(struct hda_codec *codec,
1298 unsigned int res)
1299{
1300 res >>= 26;
1301 switch (res) {
1302 case AD1981_HP_EVENT:
1303 ad1981_hp_automute(codec);
1304 break;
1305 case AD1981_MIC_EVENT:
1306 ad1981_hp_automic(codec);
1307 break;
1308 }
1309}
1310
1311static struct hda_input_mux ad1981_hp_capture_source = {
1312 .num_items = 3,
1313 .items = {
1314 { "Mic", 0x0 },
1315 { "Docking-Station", 0x1 },
1316 { "Mix", 0x2 },
1317 },
1318};
1319
1320static struct snd_kcontrol_new ad1981_hp_mixers[] = {
1321 {
1322 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1323 .name = "Master Playback Volume",
1324 .info = snd_hda_mixer_amp_volume_info,
1325 .get = snd_hda_mixer_amp_volume_get,
1326 .put = ad1981_hp_master_vol_put,
1327 .private_value = HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
1328 },
1329 {
1330 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1331 .name = "Master Playback Switch",
1332 .info = ad198x_eapd_info,
1333 .get = ad198x_eapd_get,
1334 .put = ad1981_hp_master_sw_put,
1335 .private_value = 0x05,
1336 },
1337 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
1338 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
1339#if 0
1340 /* FIXME: analog mic/line loopback doesn't work with my tests...
1341 * (although recording is OK)
1342 */
1343 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
1344 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
1345 HDA_CODEC_VOLUME("Docking-Station Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1346 HDA_CODEC_MUTE("Docking-Station Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1347 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT),
1348 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
1349 /* FIXME: does this laptop have analog CD connection? */
1350 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1351 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1352#endif
1353 HDA_CODEC_VOLUME("Mic Boost", 0x08, 0x0, HDA_INPUT),
1354 HDA_CODEC_VOLUME("Internal Mic Boost", 0x18, 0x0, HDA_INPUT),
1355 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1356 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
1357 {
1358 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1359 .name = "Capture Source",
1360 .info = ad198x_mux_enum_info,
1361 .get = ad198x_mux_enum_get,
1362 .put = ad198x_mux_enum_put,
1363 },
1364 { } /* end */
1365};
1366
1367/* initialize jack-sensing, too */
1368static int ad1981_hp_init(struct hda_codec *codec)
1369{
1370 ad198x_init(codec);
1371 ad1981_hp_automute(codec);
1372 ad1981_hp_automic(codec);
1373 return 0;
1374}
1375
Takashi Iwai01686c52006-04-18 12:54:11 +02001376/* configuration for Lenovo Thinkpad T60 */
1377static struct snd_kcontrol_new ad1981_thinkpad_mixers[] = {
1378 HDA_CODEC_VOLUME("Master Playback Volume", 0x05, 0x0, HDA_OUTPUT),
1379 HDA_CODEC_MUTE("Master Playback Switch", 0x05, 0x0, HDA_OUTPUT),
1380 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
1381 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
1382 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
1383 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
1384 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1385 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1386 HDA_CODEC_VOLUME("Mic Boost", 0x08, 0x0, HDA_INPUT),
1387 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1388 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
1389 {
1390 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1391 .name = "Capture Source",
1392 .info = ad198x_mux_enum_info,
1393 .get = ad198x_mux_enum_get,
1394 .put = ad198x_mux_enum_put,
1395 },
Takashi Iwai6540dff2006-06-13 11:57:22 +02001396 /* identical with AD1983 */
1397 {
1398 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1399 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
1400 .info = ad1983_spdif_route_info,
1401 .get = ad1983_spdif_route_get,
1402 .put = ad1983_spdif_route_put,
1403 },
Takashi Iwai01686c52006-04-18 12:54:11 +02001404 { } /* end */
1405};
1406
1407static struct hda_input_mux ad1981_thinkpad_capture_source = {
1408 .num_items = 3,
1409 .items = {
1410 { "Mic", 0x0 },
1411 { "Mix", 0x2 },
1412 { "CD", 0x4 },
1413 },
1414};
1415
Takashi Iwai18a815d2006-03-01 19:54:39 +01001416/* models */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001417enum {
1418 AD1981_BASIC,
1419 AD1981_HP,
1420 AD1981_THINKPAD,
1421 AD1981_MODELS
1422};
Takashi Iwai18a815d2006-03-01 19:54:39 +01001423
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001424static const char *ad1981_models[AD1981_MODELS] = {
1425 [AD1981_HP] = "hp",
1426 [AD1981_THINKPAD] = "thinkpad",
1427 [AD1981_BASIC] = "basic",
1428};
1429
1430static struct snd_pci_quirk ad1981_cfg_tbl[] = {
Takashi Iwai8970ccd2006-04-18 12:50:40 +02001431 /* All HP models */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001432 SND_PCI_QUIRK(0x103c, 0, "HP nx", AD1981_HP),
1433 /* HP nx6320 (reversed SSID, H/W bug) */
1434 SND_PCI_QUIRK(0x30b0, 0x103c, "HP nx6320", AD1981_HP),
Takashi Iwai01686c52006-04-18 12:54:11 +02001435 /* Lenovo Thinkpad T60/X60/Z6xx */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001436 SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1981_THINKPAD),
1437 SND_PCI_QUIRK(0x1014, 0x0597, "Lenovo Z60", AD1981_THINKPAD),
Takashi Iwai18a815d2006-03-01 19:54:39 +01001438 {}
1439};
1440
Takashi Iwai4a3fdf32005-04-14 13:35:51 +02001441static int patch_ad1981(struct hda_codec *codec)
1442{
1443 struct ad198x_spec *spec;
Takashi Iwai18a815d2006-03-01 19:54:39 +01001444 int board_config;
Takashi Iwai4a3fdf32005-04-14 13:35:51 +02001445
Takashi Iwaie560d8d2005-09-09 14:21:46 +02001446 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Takashi Iwai4a3fdf32005-04-14 13:35:51 +02001447 if (spec == NULL)
1448 return -ENOMEM;
1449
Ingo Molnar62932df2006-01-16 16:34:20 +01001450 mutex_init(&spec->amp_mutex);
Takashi Iwai4a3fdf32005-04-14 13:35:51 +02001451 codec->spec = spec;
1452
1453 spec->multiout.max_channels = 2;
1454 spec->multiout.num_dacs = ARRAY_SIZE(ad1981_dac_nids);
1455 spec->multiout.dac_nids = ad1981_dac_nids;
1456 spec->multiout.dig_out_nid = AD1981_SPDIF_OUT;
Takashi Iwai985be542005-11-02 18:26:49 +01001457 spec->num_adc_nids = 1;
1458 spec->adc_nids = ad1981_adc_nids;
Takashi Iwai18a815d2006-03-01 19:54:39 +01001459 spec->capsrc_nids = ad1981_capsrc_nids;
Takashi Iwai4a3fdf32005-04-14 13:35:51 +02001460 spec->input_mux = &ad1981_capture_source;
Takashi Iwai985be542005-11-02 18:26:49 +01001461 spec->num_mixers = 1;
1462 spec->mixers[0] = ad1981_mixers;
1463 spec->num_init_verbs = 1;
1464 spec->init_verbs[0] = ad1981_init_verbs;
Takashi Iwai4a3fdf32005-04-14 13:35:51 +02001465 spec->spdif_route = 0;
1466
1467 codec->patch_ops = ad198x_patch_ops;
1468
Takashi Iwai18a815d2006-03-01 19:54:39 +01001469 /* override some parameters */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001470 board_config = snd_hda_check_board_config(codec, AD1981_MODELS,
1471 ad1981_models,
1472 ad1981_cfg_tbl);
Takashi Iwai18a815d2006-03-01 19:54:39 +01001473 switch (board_config) {
1474 case AD1981_HP:
1475 spec->mixers[0] = ad1981_hp_mixers;
1476 spec->num_init_verbs = 2;
1477 spec->init_verbs[1] = ad1981_hp_init_verbs;
1478 spec->multiout.dig_out_nid = 0;
1479 spec->input_mux = &ad1981_hp_capture_source;
1480
1481 codec->patch_ops.init = ad1981_hp_init;
1482 codec->patch_ops.unsol_event = ad1981_hp_unsol_event;
1483 break;
Takashi Iwai01686c52006-04-18 12:54:11 +02001484 case AD1981_THINKPAD:
1485 spec->mixers[0] = ad1981_thinkpad_mixers;
Takashi Iwai01686c52006-04-18 12:54:11 +02001486 spec->input_mux = &ad1981_thinkpad_capture_source;
1487 break;
Takashi Iwai18a815d2006-03-01 19:54:39 +01001488 }
1489
Takashi Iwai4a3fdf32005-04-14 13:35:51 +02001490 return 0;
1491}
1492
1493
1494/*
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01001495 * AD1988
1496 *
1497 * Output pins and routes
1498 *
Takashi Iwaid32410b12005-11-24 16:06:23 +01001499 * Pin Mix Sel DAC (*)
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01001500 * port-A 0x11 (mute/hp) <- 0x22 <- 0x37 <- 03/04/06
1501 * port-B 0x14 (mute/hp) <- 0x2b <- 0x30 <- 03/04/06
1502 * port-C 0x15 (mute) <- 0x2c <- 0x31 <- 05/0a
1503 * port-D 0x12 (mute/hp) <- 0x29 <- 04
1504 * port-E 0x17 (mute/hp) <- 0x26 <- 0x32 <- 05/0a
1505 * port-F 0x16 (mute) <- 0x2a <- 06
1506 * port-G 0x24 (mute) <- 0x27 <- 05
1507 * port-H 0x25 (mute) <- 0x28 <- 0a
1508 * mono 0x13 (mute/amp)<- 0x1e <- 0x36 <- 03/04/06
1509 *
Takashi Iwaid32410b12005-11-24 16:06:23 +01001510 * DAC0 = 03h, DAC1 = 04h, DAC2 = 05h, DAC3 = 06h, DAC4 = 0ah
1511 * (*) DAC2/3/4 are swapped to DAC3/4/2 on AD198A rev.2 due to a h/w bug.
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01001512 *
1513 * Input pins and routes
1514 *
1515 * pin boost mix input # / adc input #
1516 * port-A 0x11 -> 0x38 -> mix 2, ADC 0
1517 * port-B 0x14 -> 0x39 -> mix 0, ADC 1
1518 * port-C 0x15 -> 0x3a -> 33:0 - mix 1, ADC 2
1519 * port-D 0x12 -> 0x3d -> mix 3, ADC 8
1520 * port-E 0x17 -> 0x3c -> 34:0 - mix 4, ADC 4
1521 * port-F 0x16 -> 0x3b -> mix 5, ADC 3
1522 * port-G 0x24 -> N/A -> 33:1 - mix 1, 34:1 - mix 4, ADC 6
1523 * port-H 0x25 -> N/A -> 33:2 - mix 1, 34:2 - mix 4, ADC 7
1524 *
1525 *
1526 * DAC assignment
Takashi Iwaid32410b12005-11-24 16:06:23 +01001527 * 6stack - front/surr/CLFE/side/opt DACs - 04/06/05/0a/03
Takashi Iwaif8c7c7b2005-11-24 16:17:20 +01001528 * 3stack - front/surr/CLFE/opt DACs - 04/05/0a/03
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01001529 *
1530 * Inputs of Analog Mix (0x20)
1531 * 0:Port-B (front mic)
1532 * 1:Port-C/G/H (line-in)
1533 * 2:Port-A
1534 * 3:Port-D (line-in/2)
1535 * 4:Port-E/G/H (mic-in)
1536 * 5:Port-F (mic2-in)
1537 * 6:CD
1538 * 7:Beep
1539 *
1540 * ADC selection
1541 * 0:Port-A
1542 * 1:Port-B (front mic-in)
1543 * 2:Port-C (line-in)
1544 * 3:Port-F (mic2-in)
1545 * 4:Port-E (mic-in)
1546 * 5:CD
1547 * 6:Port-G
1548 * 7:Port-H
1549 * 8:Port-D (line-in/2)
1550 * 9:Mix
1551 *
1552 * Proposed pin assignments by the datasheet
1553 *
1554 * 6-stack
1555 * Port-A front headphone
1556 * B front mic-in
1557 * C rear line-in
1558 * D rear front-out
1559 * E rear mic-in
1560 * F rear surround
1561 * G rear CLFE
1562 * H rear side
1563 *
1564 * 3-stack
1565 * Port-A front headphone
1566 * B front mic
1567 * C rear line-in/surround
1568 * D rear front-out
1569 * E rear mic-in/CLFE
1570 *
1571 * laptop
1572 * Port-A headphone
1573 * B mic-in
1574 * C docking station
1575 * D internal speaker (with EAPD)
1576 * E/F quad mic array
1577 */
1578
1579
1580/* models */
1581enum {
1582 AD1988_6STACK,
1583 AD1988_6STACK_DIG,
1584 AD1988_3STACK,
1585 AD1988_3STACK_DIG,
1586 AD1988_LAPTOP,
1587 AD1988_LAPTOP_DIG,
Takashi Iwaid32410b12005-11-24 16:06:23 +01001588 AD1988_AUTO,
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01001589 AD1988_MODEL_LAST,
1590};
1591
Takashi Iwaid32410b12005-11-24 16:06:23 +01001592/* reivision id to check workarounds */
1593#define AD1988A_REV2 0x100200
1594
Takashi Iwai1a806f42006-07-03 15:58:16 +02001595#define is_rev2(codec) \
1596 ((codec)->vendor_id == 0x11d41988 && \
1597 (codec)->revision_id == AD1988A_REV2)
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01001598
1599/*
1600 * mixers
1601 */
1602
Takashi Iwaid32410b12005-11-24 16:06:23 +01001603static hda_nid_t ad1988_6stack_dac_nids[4] = {
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01001604 0x04, 0x06, 0x05, 0x0a
1605};
1606
Takashi Iwaid32410b12005-11-24 16:06:23 +01001607static hda_nid_t ad1988_3stack_dac_nids[3] = {
Takashi Iwaif8c7c7b2005-11-24 16:17:20 +01001608 0x04, 0x05, 0x0a
Takashi Iwaid32410b12005-11-24 16:06:23 +01001609};
1610
1611/* for AD1988A revision-2, DAC2-4 are swapped */
1612static hda_nid_t ad1988_6stack_dac_nids_rev2[4] = {
1613 0x04, 0x05, 0x0a, 0x06
1614};
1615
1616static hda_nid_t ad1988_3stack_dac_nids_rev2[3] = {
Takashi Iwaif8c7c7b2005-11-24 16:17:20 +01001617 0x04, 0x0a, 0x06
Takashi Iwaid32410b12005-11-24 16:06:23 +01001618};
1619
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01001620static hda_nid_t ad1988_adc_nids[3] = {
1621 0x08, 0x09, 0x0f
1622};
1623
Takashi Iwai2e5b9562005-11-21 16:36:15 +01001624static hda_nid_t ad1988_capsrc_nids[3] = {
1625 0x0c, 0x0d, 0x0e
1626};
1627
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01001628#define AD1988_SPDIF_OUT 0x02
1629#define AD1988_SPDIF_IN 0x07
1630
1631static struct hda_input_mux ad1988_6stack_capture_source = {
1632 .num_items = 5,
1633 .items = {
1634 { "Front Mic", 0x0 },
1635 { "Line", 0x1 },
1636 { "Mic", 0x4 },
1637 { "CD", 0x5 },
1638 { "Mix", 0x9 },
1639 },
1640};
1641
1642static struct hda_input_mux ad1988_laptop_capture_source = {
1643 .num_items = 3,
1644 .items = {
1645 { "Mic/Line", 0x0 },
1646 { "CD", 0x5 },
1647 { "Mix", 0x9 },
1648 },
1649};
1650
1651/*
1652 */
1653static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol,
1654 struct snd_ctl_elem_info *uinfo)
1655{
1656 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1657 struct ad198x_spec *spec = codec->spec;
1658 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
1659 spec->num_channel_mode);
1660}
1661
1662static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol,
1663 struct snd_ctl_elem_value *ucontrol)
1664{
1665 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1666 struct ad198x_spec *spec = codec->spec;
1667 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
1668 spec->num_channel_mode, spec->multiout.max_channels);
1669}
1670
1671static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol,
1672 struct snd_ctl_elem_value *ucontrol)
1673{
1674 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1675 struct ad198x_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +02001676 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
1677 spec->num_channel_mode,
1678 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +02001679 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai2125cad2006-03-27 12:52:22 +02001680 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
Takashi Iwai4e195a72006-07-28 14:47:34 +02001681 return err;
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01001682}
1683
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01001684/* 6-stack mode */
Takashi Iwaid32410b12005-11-24 16:06:23 +01001685static struct snd_kcontrol_new ad1988_6stack_mixers1[] = {
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01001686 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1687 HDA_CODEC_VOLUME("Surround Playback Volume", 0x06, 0x0, HDA_OUTPUT),
1688 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT),
1689 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT),
1690 HDA_CODEC_VOLUME("Side Playback Volume", 0x0a, 0x0, HDA_OUTPUT),
Takashi Iwai2ece5f422006-07-06 19:16:40 +02001691 { } /* end */
Takashi Iwaid32410b12005-11-24 16:06:23 +01001692};
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01001693
Takashi Iwaid32410b12005-11-24 16:06:23 +01001694static struct snd_kcontrol_new ad1988_6stack_mixers1_rev2[] = {
1695 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1696 HDA_CODEC_VOLUME("Surround Playback Volume", 0x05, 0x0, HDA_OUTPUT),
1697 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
1698 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0a, 2, 0x0, HDA_OUTPUT),
1699 HDA_CODEC_VOLUME("Side Playback Volume", 0x06, 0x0, HDA_OUTPUT),
Takashi Iwai2ece5f422006-07-06 19:16:40 +02001700 { } /* end */
Takashi Iwaid32410b12005-11-24 16:06:23 +01001701};
1702
1703static struct snd_kcontrol_new ad1988_6stack_mixers2[] = {
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01001704 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT),
1705 HDA_BIND_MUTE("Surround Playback Switch", 0x2a, 2, HDA_INPUT),
1706 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x27, 1, 2, HDA_INPUT),
1707 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x27, 2, 2, HDA_INPUT),
1708 HDA_BIND_MUTE("Side Playback Switch", 0x28, 2, HDA_INPUT),
1709 HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT),
1710 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT),
1711
1712 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT),
1713 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT),
1714 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT),
1715 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT),
1716 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
1717 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
1718 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT),
1719 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT),
1720
1721 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
1722 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
1723
Takashi Iwai2e5b9562005-11-21 16:36:15 +01001724 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01001725 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
1726
1727 HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT),
1728 HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT),
1729
1730 { } /* end */
1731};
1732
1733/* 3-stack mode */
Takashi Iwaid32410b12005-11-24 16:06:23 +01001734static struct snd_kcontrol_new ad1988_3stack_mixers1[] = {
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01001735 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
Takashi Iwaid32410b12005-11-24 16:06:23 +01001736 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT),
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01001737 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT),
1738 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT),
Takashi Iwai2ece5f422006-07-06 19:16:40 +02001739 { } /* end */
Takashi Iwaid32410b12005-11-24 16:06:23 +01001740};
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01001741
Takashi Iwaid32410b12005-11-24 16:06:23 +01001742static struct snd_kcontrol_new ad1988_3stack_mixers1_rev2[] = {
1743 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
Takashi Iwaif8c7c7b2005-11-24 16:17:20 +01001744 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT),
1745 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x06, 1, 0x0, HDA_OUTPUT),
1746 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x06, 2, 0x0, HDA_OUTPUT),
Takashi Iwai2ece5f422006-07-06 19:16:40 +02001747 { } /* end */
Takashi Iwaid32410b12005-11-24 16:06:23 +01001748};
1749
1750static struct snd_kcontrol_new ad1988_3stack_mixers2[] = {
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01001751 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT),
Takashi Iwaid32410b12005-11-24 16:06:23 +01001752 HDA_BIND_MUTE("Surround Playback Switch", 0x2c, 2, HDA_INPUT),
1753 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x26, 1, 2, HDA_INPUT),
1754 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x26, 2, 2, HDA_INPUT),
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01001755 HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT),
1756 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT),
1757
1758 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT),
1759 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT),
1760 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT),
1761 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT),
1762 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
1763 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
1764 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT),
1765 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT),
1766
1767 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
1768 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
1769
Takashi Iwai2e5b9562005-11-21 16:36:15 +01001770 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01001771 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
1772
1773 HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT),
1774 HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT),
1775 {
1776 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1777 .name = "Channel Mode",
1778 .info = ad198x_ch_mode_info,
1779 .get = ad198x_ch_mode_get,
1780 .put = ad198x_ch_mode_put,
1781 },
1782
1783 { } /* end */
1784};
1785
1786/* laptop mode */
1787static struct snd_kcontrol_new ad1988_laptop_mixers[] = {
1788 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1789 HDA_CODEC_MUTE("PCM Playback Switch", 0x29, 0x0, HDA_INPUT),
1790 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT),
1791
1792 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT),
1793 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT),
1794 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x0, HDA_INPUT),
1795 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x0, HDA_INPUT),
1796 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
1797 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
1798
1799 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
1800 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
1801
Takashi Iwai2e5b9562005-11-21 16:36:15 +01001802 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01001803 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
1804
1805 HDA_CODEC_VOLUME("Mic Boost", 0x39, 0x0, HDA_OUTPUT),
1806
1807 {
1808 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1809 .name = "External Amplifier",
Takashi Iwai18a815d2006-03-01 19:54:39 +01001810 .info = ad198x_eapd_info,
1811 .get = ad198x_eapd_get,
1812 .put = ad198x_eapd_put,
1813 .private_value = 0x12 | (1 << 8), /* port-D, inversed */
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01001814 },
1815
1816 { } /* end */
1817};
1818
1819/* capture */
1820static struct snd_kcontrol_new ad1988_capture_mixers[] = {
1821 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
1822 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
1823 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
1824 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
1825 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x0e, 0x0, HDA_OUTPUT),
1826 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x0e, 0x0, HDA_OUTPUT),
1827 {
1828 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1829 /* The multiple "Capture Source" controls confuse alsamixer
1830 * So call somewhat different..
1831 * FIXME: the controls appear in the "playback" view!
1832 */
1833 /* .name = "Capture Source", */
1834 .name = "Input Source",
1835 .count = 3,
1836 .info = ad198x_mux_enum_info,
1837 .get = ad198x_mux_enum_get,
1838 .put = ad198x_mux_enum_put,
1839 },
1840 { } /* end */
1841};
1842
1843static int ad1988_spdif_playback_source_info(struct snd_kcontrol *kcontrol,
1844 struct snd_ctl_elem_info *uinfo)
1845{
1846 static char *texts[] = {
1847 "PCM", "ADC1", "ADC2", "ADC3"
1848 };
1849 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1850 uinfo->count = 1;
1851 uinfo->value.enumerated.items = 4;
1852 if (uinfo->value.enumerated.item >= 4)
1853 uinfo->value.enumerated.item = 3;
1854 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1855 return 0;
1856}
1857
1858static int ad1988_spdif_playback_source_get(struct snd_kcontrol *kcontrol,
1859 struct snd_ctl_elem_value *ucontrol)
1860{
1861 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1862 unsigned int sel;
1863
1864 sel = snd_hda_codec_read(codec, 0x02, 0, AC_VERB_GET_CONNECT_SEL, 0);
1865 if (sel > 0) {
1866 sel = snd_hda_codec_read(codec, 0x0b, 0, AC_VERB_GET_CONNECT_SEL, 0);
1867 if (sel <= 3)
1868 sel++;
1869 else
1870 sel = 0;
1871 }
1872 ucontrol->value.enumerated.item[0] = sel;
1873 return 0;
1874}
1875
1876static int ad1988_spdif_playback_source_put(struct snd_kcontrol *kcontrol,
1877 struct snd_ctl_elem_value *ucontrol)
1878{
1879 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1880 unsigned int sel;
1881 int change;
1882
1883 sel = snd_hda_codec_read(codec, 0x02, 0, AC_VERB_GET_CONNECT_SEL, 0);
1884 if (! ucontrol->value.enumerated.item[0]) {
1885 change = sel != 0;
1886 if (change)
1887 snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL, 0);
1888 } else {
1889 change = sel == 0;
1890 if (change)
1891 snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL, 1);
1892 sel = snd_hda_codec_read(codec, 0x0b, 0, AC_VERB_GET_CONNECT_SEL, 0) + 1;
1893 change |= sel == ucontrol->value.enumerated.item[0];
1894 if (change)
1895 snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL,
1896 ucontrol->value.enumerated.item[0] - 1);
1897 }
1898 return change;
1899}
1900
1901static struct snd_kcontrol_new ad1988_spdif_out_mixers[] = {
1902 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
1903 {
1904 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1905 .name = "IEC958 Playback Source",
1906 .info = ad1988_spdif_playback_source_info,
1907 .get = ad1988_spdif_playback_source_get,
1908 .put = ad1988_spdif_playback_source_put,
1909 },
1910 { } /* end */
1911};
1912
1913static struct snd_kcontrol_new ad1988_spdif_in_mixers[] = {
1914 HDA_CODEC_VOLUME("IEC958 Capture Volume", 0x1c, 0x0, HDA_INPUT),
1915 { } /* end */
1916};
1917
1918
1919/*
1920 * initialization verbs
1921 */
1922
1923/*
1924 * for 6-stack (+dig)
1925 */
1926static struct hda_verb ad1988_6stack_init_verbs[] = {
Takashi Iwai2e5b9562005-11-21 16:36:15 +01001927 /* Front, Surround, CLFE, side DAC; unmute as default */
1928 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1929 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1930 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1931 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01001932 /* Port-A front headphon path */
1933 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */
1934 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1935 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1936 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1937 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1938 /* Port-D line-out path */
1939 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1940 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1941 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1942 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1943 /* Port-F surround path */
1944 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1945 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1946 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1947 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1948 /* Port-G CLFE path */
1949 {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1950 {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1951 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1952 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1953 /* Port-H side path */
1954 {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1955 {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1956 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1957 {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1958 /* Mono out path */
1959 {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */
1960 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1961 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1962 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1963 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */
1964 /* Port-B front mic-in path */
1965 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1966 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1967 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1968 /* Port-C line-in path */
1969 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1970 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1971 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1972 {0x33, AC_VERB_SET_CONNECT_SEL, 0x0},
1973 /* Port-E mic-in path */
1974 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1975 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1976 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1977 {0x34, AC_VERB_SET_CONNECT_SEL, 0x0},
1978
1979 { }
1980};
1981
1982static struct hda_verb ad1988_capture_init_verbs[] = {
1983 /* mute analog mix */
1984 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1985 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1986 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1987 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1988 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1989 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
1990 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1991 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
1992 /* select ADCs - front-mic */
1993 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
1994 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
1995 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
1996 /* ADCs; muted */
1997 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1998 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1999 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2000
2001 { }
2002};
2003
2004static struct hda_verb ad1988_spdif_init_verbs[] = {
2005 /* SPDIF out sel */
2006 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */
2007 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x0}, /* ADC1 */
2008 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2009 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2010 /* SPDIF out pin */
2011 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
2012 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x17}, /* 0dB */
2013
2014 { }
2015};
2016
2017/*
2018 * verbs for 3stack (+dig)
2019 */
2020static struct hda_verb ad1988_3stack_ch2_init[] = {
2021 /* set port-C to line-in */
2022 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2023 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2024 /* set port-E to mic-in */
2025 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2026 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2027 { } /* end */
2028};
2029
2030static struct hda_verb ad1988_3stack_ch6_init[] = {
2031 /* set port-C to surround out */
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01002032 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
Takashi Iwaid32410b12005-11-24 16:06:23 +01002033 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01002034 /* set port-E to CLFE out */
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01002035 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
Takashi Iwaid32410b12005-11-24 16:06:23 +01002036 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01002037 { } /* end */
2038};
2039
2040static struct hda_channel_mode ad1988_3stack_modes[2] = {
2041 { 2, ad1988_3stack_ch2_init },
2042 { 6, ad1988_3stack_ch6_init },
2043};
2044
2045static struct hda_verb ad1988_3stack_init_verbs[] = {
Takashi Iwai2e5b9562005-11-21 16:36:15 +01002046 /* Front, Surround, CLFE, side DAC; unmute as default */
2047 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2048 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2049 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2050 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01002051 /* Port-A front headphon path */
2052 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */
2053 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2054 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2055 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2056 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2057 /* Port-D line-out path */
2058 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2059 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2060 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2061 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2062 /* Mono out path */
2063 {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */
2064 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2065 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2066 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2067 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */
2068 /* Port-B front mic-in path */
2069 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2070 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2071 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwaid32410b12005-11-24 16:06:23 +01002072 /* Port-C line-in/surround path - 6ch mode as default */
2073 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2074 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01002075 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwaid32410b12005-11-24 16:06:23 +01002076 {0x31, AC_VERB_SET_CONNECT_SEL, 0x0}, /* output sel: DAC 0x05 */
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01002077 {0x33, AC_VERB_SET_CONNECT_SEL, 0x0},
Takashi Iwaid32410b12005-11-24 16:06:23 +01002078 /* Port-E mic-in/CLFE path - 6ch mode as default */
2079 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2080 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01002081 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwaif8c7c7b2005-11-24 16:17:20 +01002082 {0x32, AC_VERB_SET_CONNECT_SEL, 0x1}, /* output sel: DAC 0x0a */
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01002083 {0x34, AC_VERB_SET_CONNECT_SEL, 0x0},
2084 /* mute analog mix */
2085 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2086 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2087 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2088 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2089 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2090 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
2091 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2092 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2093 /* select ADCs - front-mic */
2094 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
2095 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
2096 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
2097 /* ADCs; muted */
2098 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2099 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2100 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2101 { }
2102};
2103
2104/*
2105 * verbs for laptop mode (+dig)
2106 */
2107static struct hda_verb ad1988_laptop_hp_on[] = {
2108 /* unmute port-A and mute port-D */
2109 { 0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2110 { 0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2111 { } /* end */
2112};
2113static struct hda_verb ad1988_laptop_hp_off[] = {
2114 /* mute port-A and unmute port-D */
2115 { 0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2116 { 0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2117 { } /* end */
2118};
2119
2120#define AD1988_HP_EVENT 0x01
2121
2122static struct hda_verb ad1988_laptop_init_verbs[] = {
Takashi Iwai2e5b9562005-11-21 16:36:15 +01002123 /* Front, Surround, CLFE, side DAC; unmute as default */
2124 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2125 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2126 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2127 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01002128 /* Port-A front headphon path */
2129 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */
2130 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2131 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2132 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2133 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2134 /* unsolicited event for pin-sense */
2135 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1988_HP_EVENT },
2136 /* Port-D line-out path + EAPD */
2137 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2138 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2139 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2140 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2141 {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x00}, /* EAPD-off */
2142 /* Mono out path */
2143 {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */
2144 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2145 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2146 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2147 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */
2148 /* Port-B mic-in path */
2149 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2150 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2151 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2152 /* Port-C docking station - try to output */
2153 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2154 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2155 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2156 {0x33, AC_VERB_SET_CONNECT_SEL, 0x0},
2157 /* mute analog mix */
2158 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2159 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2160 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2161 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2162 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2163 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
2164 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2165 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2166 /* select ADCs - mic */
2167 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
2168 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
2169 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
2170 /* ADCs; muted */
2171 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2172 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2173 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2174 { }
2175};
2176
2177static void ad1988_laptop_unsol_event(struct hda_codec *codec, unsigned int res)
2178{
2179 if ((res >> 26) != AD1988_HP_EVENT)
2180 return;
2181 if (snd_hda_codec_read(codec, 0x11, 0, AC_VERB_GET_PIN_SENSE, 0) & (1 << 31))
2182 snd_hda_sequence_write(codec, ad1988_laptop_hp_on);
2183 else
2184 snd_hda_sequence_write(codec, ad1988_laptop_hp_off);
2185}
2186
2187
2188/*
Takashi Iwaid32410b12005-11-24 16:06:23 +01002189 * Automatic parse of I/O pins from the BIOS configuration
2190 */
2191
2192#define NUM_CONTROL_ALLOC 32
2193#define NUM_VERB_ALLOC 32
2194
2195enum {
2196 AD_CTL_WIDGET_VOL,
2197 AD_CTL_WIDGET_MUTE,
2198 AD_CTL_BIND_MUTE,
2199};
2200static struct snd_kcontrol_new ad1988_control_templates[] = {
2201 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2202 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2203 HDA_BIND_MUTE(NULL, 0, 0, 0),
2204};
2205
2206/* add dynamic controls */
2207static int add_control(struct ad198x_spec *spec, int type, const char *name,
2208 unsigned long val)
2209{
2210 struct snd_kcontrol_new *knew;
2211
2212 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2213 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2214
2215 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2216 if (! knew)
2217 return -ENOMEM;
2218 if (spec->kctl_alloc) {
2219 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2220 kfree(spec->kctl_alloc);
2221 }
2222 spec->kctl_alloc = knew;
2223 spec->num_kctl_alloc = num;
2224 }
2225
2226 knew = &spec->kctl_alloc[spec->num_kctl_used];
2227 *knew = ad1988_control_templates[type];
2228 knew->name = kstrdup(name, GFP_KERNEL);
2229 if (! knew->name)
2230 return -ENOMEM;
2231 knew->private_value = val;
2232 spec->num_kctl_used++;
2233 return 0;
2234}
2235
2236#define AD1988_PIN_CD_NID 0x18
2237#define AD1988_PIN_BEEP_NID 0x10
2238
2239static hda_nid_t ad1988_mixer_nids[8] = {
2240 /* A B C D E F G H */
2241 0x22, 0x2b, 0x2c, 0x29, 0x26, 0x2a, 0x27, 0x28
2242};
2243
2244static inline hda_nid_t ad1988_idx_to_dac(struct hda_codec *codec, int idx)
2245{
2246 static hda_nid_t idx_to_dac[8] = {
2247 /* A B C D E F G H */
Takashi Iwaif8c7c7b2005-11-24 16:17:20 +01002248 0x04, 0x06, 0x05, 0x04, 0x0a, 0x06, 0x05, 0x0a
Takashi Iwaid32410b12005-11-24 16:06:23 +01002249 };
2250 static hda_nid_t idx_to_dac_rev2[8] = {
2251 /* A B C D E F G H */
Takashi Iwaif8c7c7b2005-11-24 16:17:20 +01002252 0x04, 0x05, 0x0a, 0x04, 0x06, 0x05, 0x0a, 0x06
Takashi Iwaid32410b12005-11-24 16:06:23 +01002253 };
Takashi Iwai1a806f42006-07-03 15:58:16 +02002254 if (is_rev2(codec))
Takashi Iwaid32410b12005-11-24 16:06:23 +01002255 return idx_to_dac_rev2[idx];
2256 else
2257 return idx_to_dac[idx];
2258}
2259
2260static hda_nid_t ad1988_boost_nids[8] = {
2261 0x38, 0x39, 0x3a, 0x3d, 0x3c, 0x3b, 0, 0
2262};
2263
2264static int ad1988_pin_idx(hda_nid_t nid)
2265{
2266 static hda_nid_t ad1988_io_pins[8] = {
2267 0x11, 0x14, 0x15, 0x12, 0x17, 0x16, 0x24, 0x25
2268 };
2269 int i;
2270 for (i = 0; i < ARRAY_SIZE(ad1988_io_pins); i++)
2271 if (ad1988_io_pins[i] == nid)
2272 return i;
2273 return 0; /* should be -1 */
2274}
2275
2276static int ad1988_pin_to_loopback_idx(hda_nid_t nid)
2277{
2278 static int loopback_idx[8] = {
2279 2, 0, 1, 3, 4, 5, 1, 4
2280 };
2281 switch (nid) {
2282 case AD1988_PIN_CD_NID:
2283 return 6;
2284 default:
2285 return loopback_idx[ad1988_pin_idx(nid)];
2286 }
2287}
2288
2289static int ad1988_pin_to_adc_idx(hda_nid_t nid)
2290{
2291 static int adc_idx[8] = {
2292 0, 1, 2, 8, 4, 3, 6, 7
2293 };
2294 switch (nid) {
2295 case AD1988_PIN_CD_NID:
2296 return 5;
2297 default:
2298 return adc_idx[ad1988_pin_idx(nid)];
2299 }
2300}
2301
2302/* fill in the dac_nids table from the parsed pin configuration */
2303static int ad1988_auto_fill_dac_nids(struct hda_codec *codec,
2304 const struct auto_pin_cfg *cfg)
2305{
2306 struct ad198x_spec *spec = codec->spec;
2307 int i, idx;
2308
2309 spec->multiout.dac_nids = spec->private_dac_nids;
2310
2311 /* check the pins hardwired to audio widget */
2312 for (i = 0; i < cfg->line_outs; i++) {
2313 idx = ad1988_pin_idx(cfg->line_out_pins[i]);
2314 spec->multiout.dac_nids[i] = ad1988_idx_to_dac(codec, idx);
2315 }
2316 spec->multiout.num_dacs = cfg->line_outs;
2317 return 0;
2318}
2319
2320/* add playback controls from the parsed DAC table */
2321static int ad1988_auto_create_multi_out_ctls(struct ad198x_spec *spec,
2322 const struct auto_pin_cfg *cfg)
2323{
2324 char name[32];
2325 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
2326 hda_nid_t nid;
2327 int i, err;
2328
2329 for (i = 0; i < cfg->line_outs; i++) {
2330 hda_nid_t dac = spec->multiout.dac_nids[i];
2331 if (! dac)
2332 continue;
2333 nid = ad1988_mixer_nids[ad1988_pin_idx(cfg->line_out_pins[i])];
2334 if (i == 2) {
2335 /* Center/LFE */
2336 err = add_control(spec, AD_CTL_WIDGET_VOL,
2337 "Center Playback Volume",
2338 HDA_COMPOSE_AMP_VAL(dac, 1, 0, HDA_OUTPUT));
2339 if (err < 0)
2340 return err;
2341 err = add_control(spec, AD_CTL_WIDGET_VOL,
2342 "LFE Playback Volume",
2343 HDA_COMPOSE_AMP_VAL(dac, 2, 0, HDA_OUTPUT));
2344 if (err < 0)
2345 return err;
2346 err = add_control(spec, AD_CTL_BIND_MUTE,
2347 "Center Playback Switch",
2348 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT));
2349 if (err < 0)
2350 return err;
2351 err = add_control(spec, AD_CTL_BIND_MUTE,
2352 "LFE Playback Switch",
2353 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT));
2354 if (err < 0)
2355 return err;
2356 } else {
2357 sprintf(name, "%s Playback Volume", chname[i]);
2358 err = add_control(spec, AD_CTL_WIDGET_VOL, name,
2359 HDA_COMPOSE_AMP_VAL(dac, 3, 0, HDA_OUTPUT));
2360 if (err < 0)
2361 return err;
2362 sprintf(name, "%s Playback Switch", chname[i]);
2363 err = add_control(spec, AD_CTL_BIND_MUTE, name,
2364 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
2365 if (err < 0)
2366 return err;
2367 }
2368 }
2369 return 0;
2370}
2371
2372/* add playback controls for speaker and HP outputs */
2373static int ad1988_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
2374 const char *pfx)
2375{
2376 struct ad198x_spec *spec = codec->spec;
2377 hda_nid_t nid;
2378 int idx, err;
2379 char name[32];
2380
2381 if (! pin)
2382 return 0;
2383
2384 idx = ad1988_pin_idx(pin);
2385 nid = ad1988_idx_to_dac(codec, idx);
Takashi Iwai82bc9552006-03-21 11:24:42 +01002386 /* specify the DAC as the extra output */
2387 if (! spec->multiout.hp_nid)
Takashi Iwaid32410b12005-11-24 16:06:23 +01002388 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01002389 else
2390 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaid32410b12005-11-24 16:06:23 +01002391 /* control HP volume/switch on the output mixer amp */
2392 sprintf(name, "%s Playback Volume", pfx);
2393 if ((err = add_control(spec, AD_CTL_WIDGET_VOL, name,
2394 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2395 return err;
2396 nid = ad1988_mixer_nids[idx];
2397 sprintf(name, "%s Playback Switch", pfx);
2398 if ((err = add_control(spec, AD_CTL_BIND_MUTE, name,
2399 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2400 return err;
2401 return 0;
2402}
2403
2404/* create input playback/capture controls for the given pin */
2405static int new_analog_input(struct ad198x_spec *spec, hda_nid_t pin,
2406 const char *ctlname, int boost)
2407{
2408 char name[32];
2409 int err, idx;
2410
2411 sprintf(name, "%s Playback Volume", ctlname);
2412 idx = ad1988_pin_to_loopback_idx(pin);
2413 if ((err = add_control(spec, AD_CTL_WIDGET_VOL, name,
2414 HDA_COMPOSE_AMP_VAL(0x20, 3, idx, HDA_INPUT))) < 0)
2415 return err;
2416 sprintf(name, "%s Playback Switch", ctlname);
2417 if ((err = add_control(spec, AD_CTL_WIDGET_MUTE, name,
2418 HDA_COMPOSE_AMP_VAL(0x20, 3, idx, HDA_INPUT))) < 0)
2419 return err;
2420 if (boost) {
2421 hda_nid_t bnid;
2422 idx = ad1988_pin_idx(pin);
2423 bnid = ad1988_boost_nids[idx];
2424 if (bnid) {
2425 sprintf(name, "%s Boost", ctlname);
2426 return add_control(spec, AD_CTL_WIDGET_VOL, name,
2427 HDA_COMPOSE_AMP_VAL(bnid, 3, idx, HDA_OUTPUT));
2428
2429 }
2430 }
2431 return 0;
2432}
2433
2434/* create playback/capture controls for input pins */
2435static int ad1988_auto_create_analog_input_ctls(struct ad198x_spec *spec,
2436 const struct auto_pin_cfg *cfg)
2437{
Takashi Iwaid32410b12005-11-24 16:06:23 +01002438 struct hda_input_mux *imux = &spec->private_imux;
2439 int i, err;
2440
2441 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai4a471b72005-12-07 13:56:29 +01002442 err = new_analog_input(spec, cfg->input_pins[i],
2443 auto_pin_cfg_labels[i],
Takashi Iwaid32410b12005-11-24 16:06:23 +01002444 i <= AUTO_PIN_FRONT_MIC);
2445 if (err < 0)
2446 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002447 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Takashi Iwaid32410b12005-11-24 16:06:23 +01002448 imux->items[imux->num_items].index = ad1988_pin_to_adc_idx(cfg->input_pins[i]);
2449 imux->num_items++;
2450 }
2451 imux->items[imux->num_items].label = "Mix";
2452 imux->items[imux->num_items].index = 9;
2453 imux->num_items++;
2454
2455 if ((err = add_control(spec, AD_CTL_WIDGET_VOL,
2456 "Analog Mix Playback Volume",
2457 HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT))) < 0)
2458 return err;
2459 if ((err = add_control(spec, AD_CTL_WIDGET_MUTE,
2460 "Analog Mix Playback Switch",
2461 HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT))) < 0)
2462 return err;
2463
2464 return 0;
2465}
2466
2467static void ad1988_auto_set_output_and_unmute(struct hda_codec *codec,
2468 hda_nid_t nid, int pin_type,
2469 int dac_idx)
2470{
2471 /* set as output */
2472 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2473 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2474 switch (nid) {
2475 case 0x11: /* port-A - DAC 04 */
2476 snd_hda_codec_write(codec, 0x37, 0, AC_VERB_SET_CONNECT_SEL, 0x01);
2477 break;
2478 case 0x14: /* port-B - DAC 06 */
2479 snd_hda_codec_write(codec, 0x30, 0, AC_VERB_SET_CONNECT_SEL, 0x02);
2480 break;
2481 case 0x15: /* port-C - DAC 05 */
2482 snd_hda_codec_write(codec, 0x31, 0, AC_VERB_SET_CONNECT_SEL, 0x00);
2483 break;
Takashi Iwaif8c7c7b2005-11-24 16:17:20 +01002484 case 0x17: /* port-E - DAC 0a */
Takashi Iwaid32410b12005-11-24 16:06:23 +01002485 snd_hda_codec_write(codec, 0x32, 0, AC_VERB_SET_CONNECT_SEL, 0x01);
2486 break;
2487 case 0x13: /* mono - DAC 04 */
2488 snd_hda_codec_write(codec, 0x36, 0, AC_VERB_SET_CONNECT_SEL, 0x01);
2489 break;
2490 }
2491}
2492
2493static void ad1988_auto_init_multi_out(struct hda_codec *codec)
2494{
2495 struct ad198x_spec *spec = codec->spec;
2496 int i;
2497
2498 for (i = 0; i < spec->autocfg.line_outs; i++) {
2499 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2500 ad1988_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2501 }
2502}
2503
2504static void ad1988_auto_init_extra_out(struct hda_codec *codec)
2505{
2506 struct ad198x_spec *spec = codec->spec;
2507 hda_nid_t pin;
2508
Takashi Iwai82bc9552006-03-21 11:24:42 +01002509 pin = spec->autocfg.speaker_pins[0];
Takashi Iwaid32410b12005-11-24 16:06:23 +01002510 if (pin) /* connect to front */
2511 ad1988_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002512 pin = spec->autocfg.hp_pins[0];
Takashi Iwaid32410b12005-11-24 16:06:23 +01002513 if (pin) /* connect to front */
2514 ad1988_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2515}
2516
2517static void ad1988_auto_init_analog_input(struct hda_codec *codec)
2518{
2519 struct ad198x_spec *spec = codec->spec;
2520 int i, idx;
2521
2522 for (i = 0; i < AUTO_PIN_LAST; i++) {
2523 hda_nid_t nid = spec->autocfg.input_pins[i];
2524 if (! nid)
2525 continue;
2526 switch (nid) {
2527 case 0x15: /* port-C */
2528 snd_hda_codec_write(codec, 0x33, 0, AC_VERB_SET_CONNECT_SEL, 0x0);
2529 break;
2530 case 0x17: /* port-E */
2531 snd_hda_codec_write(codec, 0x34, 0, AC_VERB_SET_CONNECT_SEL, 0x0);
2532 break;
2533 }
2534 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2535 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2536 if (nid != AD1988_PIN_CD_NID)
2537 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2538 AMP_OUT_MUTE);
2539 idx = ad1988_pin_idx(nid);
2540 if (ad1988_boost_nids[idx])
2541 snd_hda_codec_write(codec, ad1988_boost_nids[idx], 0,
2542 AC_VERB_SET_AMP_GAIN_MUTE,
2543 AMP_OUT_ZERO);
2544 }
2545}
2546
2547/* parse the BIOS configuration and set up the alc_spec */
2548/* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2549static int ad1988_parse_auto_config(struct hda_codec *codec)
2550{
2551 struct ad198x_spec *spec = codec->spec;
2552 int err;
2553
Kailang Yangdf694da2005-12-05 19:42:22 +01002554 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Takashi Iwaid32410b12005-11-24 16:06:23 +01002555 return err;
2556 if ((err = ad1988_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
2557 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01002558 if (! spec->autocfg.line_outs)
Takashi Iwaid32410b12005-11-24 16:06:23 +01002559 return 0; /* can't find valid BIOS pin config */
2560 if ((err = ad1988_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
Takashi Iwai82bc9552006-03-21 11:24:42 +01002561 (err = ad1988_auto_create_extra_out(codec,
2562 spec->autocfg.speaker_pins[0],
Takashi Iwaid32410b12005-11-24 16:06:23 +01002563 "Speaker")) < 0 ||
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002564 (err = ad1988_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaid32410b12005-11-24 16:06:23 +01002565 "Headphone")) < 0 ||
2566 (err = ad1988_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2567 return err;
2568
2569 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2570
2571 if (spec->autocfg.dig_out_pin)
2572 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
2573 if (spec->autocfg.dig_in_pin)
2574 spec->dig_in_nid = AD1988_SPDIF_IN;
2575
2576 if (spec->kctl_alloc)
2577 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2578
2579 spec->init_verbs[spec->num_init_verbs++] = ad1988_6stack_init_verbs;
2580
2581 spec->input_mux = &spec->private_imux;
2582
2583 return 1;
2584}
2585
2586/* init callback for auto-configuration model -- overriding the default init */
2587static int ad1988_auto_init(struct hda_codec *codec)
2588{
2589 ad198x_init(codec);
2590 ad1988_auto_init_multi_out(codec);
2591 ad1988_auto_init_extra_out(codec);
2592 ad1988_auto_init_analog_input(codec);
2593 return 0;
2594}
2595
2596
2597/*
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01002598 */
2599
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002600static const char *ad1988_models[AD1988_MODEL_LAST] = {
2601 [AD1988_6STACK] = "6stack",
2602 [AD1988_6STACK_DIG] = "6stack-dig",
2603 [AD1988_3STACK] = "3stack",
2604 [AD1988_3STACK_DIG] = "3stack-dig",
2605 [AD1988_LAPTOP] = "laptop",
2606 [AD1988_LAPTOP_DIG] = "laptop-dig",
2607 [AD1988_AUTO] = "auto",
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01002608};
2609
Tobin Davisa64c8cd2007-03-12 11:36:00 +01002610static struct snd_pci_quirk ad1988_cfg_tbl[] = {
2611 SND_PCI_QUIRK(0x1043, 0x81f6, "Asus M2N-SLI", AD1988_6STACK_DIG),
2612 {}
2613};
2614
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01002615static int patch_ad1988(struct hda_codec *codec)
2616{
2617 struct ad198x_spec *spec;
2618 int board_config;
2619
2620 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2621 if (spec == NULL)
2622 return -ENOMEM;
2623
Ingo Molnar62932df2006-01-16 16:34:20 +01002624 mutex_init(&spec->amp_mutex);
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01002625 codec->spec = spec;
2626
Takashi Iwai1a806f42006-07-03 15:58:16 +02002627 if (is_rev2(codec))
Takashi Iwaif8c7c7b2005-11-24 16:17:20 +01002628 snd_printk(KERN_INFO "patch_analog: AD1988A rev.2 is detected, enable workarounds\n");
2629
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002630 board_config = snd_hda_check_board_config(codec, AD1988_MODEL_LAST,
Tobin Davisa64c8cd2007-03-12 11:36:00 +01002631 ad1988_models, ad1988_cfg_tbl);
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002632 if (board_config < 0) {
Takashi Iwaid32410b12005-11-24 16:06:23 +01002633 printk(KERN_INFO "hda_codec: Unknown model for AD1988, trying auto-probe from BIOS...\n");
2634 board_config = AD1988_AUTO;
2635 }
2636
2637 if (board_config == AD1988_AUTO) {
2638 /* automatic parse from the BIOS config */
2639 int err = ad1988_parse_auto_config(codec);
2640 if (err < 0) {
2641 ad198x_free(codec);
2642 return err;
2643 } else if (! err) {
2644 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 6-stack mode...\n");
2645 board_config = AD1988_6STACK;
2646 }
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01002647 }
2648
2649 switch (board_config) {
2650 case AD1988_6STACK:
2651 case AD1988_6STACK_DIG:
2652 spec->multiout.max_channels = 8;
2653 spec->multiout.num_dacs = 4;
Takashi Iwai1a806f42006-07-03 15:58:16 +02002654 if (is_rev2(codec))
Takashi Iwaid32410b12005-11-24 16:06:23 +01002655 spec->multiout.dac_nids = ad1988_6stack_dac_nids_rev2;
2656 else
2657 spec->multiout.dac_nids = ad1988_6stack_dac_nids;
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01002658 spec->input_mux = &ad1988_6stack_capture_source;
Takashi Iwaid32410b12005-11-24 16:06:23 +01002659 spec->num_mixers = 2;
Takashi Iwai1a806f42006-07-03 15:58:16 +02002660 if (is_rev2(codec))
Takashi Iwaid32410b12005-11-24 16:06:23 +01002661 spec->mixers[0] = ad1988_6stack_mixers1_rev2;
2662 else
2663 spec->mixers[0] = ad1988_6stack_mixers1;
2664 spec->mixers[1] = ad1988_6stack_mixers2;
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01002665 spec->num_init_verbs = 1;
2666 spec->init_verbs[0] = ad1988_6stack_init_verbs;
2667 if (board_config == AD1988_6STACK_DIG) {
2668 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
2669 spec->dig_in_nid = AD1988_SPDIF_IN;
2670 }
2671 break;
2672 case AD1988_3STACK:
2673 case AD1988_3STACK_DIG:
2674 spec->multiout.max_channels = 6;
2675 spec->multiout.num_dacs = 3;
Takashi Iwai1a806f42006-07-03 15:58:16 +02002676 if (is_rev2(codec))
Takashi Iwaid32410b12005-11-24 16:06:23 +01002677 spec->multiout.dac_nids = ad1988_3stack_dac_nids_rev2;
2678 else
2679 spec->multiout.dac_nids = ad1988_3stack_dac_nids;
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01002680 spec->input_mux = &ad1988_6stack_capture_source;
2681 spec->channel_mode = ad1988_3stack_modes;
2682 spec->num_channel_mode = ARRAY_SIZE(ad1988_3stack_modes);
Takashi Iwaid32410b12005-11-24 16:06:23 +01002683 spec->num_mixers = 2;
Takashi Iwai1a806f42006-07-03 15:58:16 +02002684 if (is_rev2(codec))
Takashi Iwaid32410b12005-11-24 16:06:23 +01002685 spec->mixers[0] = ad1988_3stack_mixers1_rev2;
2686 else
2687 spec->mixers[0] = ad1988_3stack_mixers1;
2688 spec->mixers[1] = ad1988_3stack_mixers2;
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01002689 spec->num_init_verbs = 1;
2690 spec->init_verbs[0] = ad1988_3stack_init_verbs;
2691 if (board_config == AD1988_3STACK_DIG)
2692 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
2693 break;
2694 case AD1988_LAPTOP:
2695 case AD1988_LAPTOP_DIG:
2696 spec->multiout.max_channels = 2;
2697 spec->multiout.num_dacs = 1;
Takashi Iwaid32410b12005-11-24 16:06:23 +01002698 spec->multiout.dac_nids = ad1988_3stack_dac_nids;
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01002699 spec->input_mux = &ad1988_laptop_capture_source;
2700 spec->num_mixers = 1;
2701 spec->mixers[0] = ad1988_laptop_mixers;
2702 spec->num_init_verbs = 1;
2703 spec->init_verbs[0] = ad1988_laptop_init_verbs;
2704 if (board_config == AD1988_LAPTOP_DIG)
2705 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
2706 break;
2707 }
2708
Takashi Iwaid32410b12005-11-24 16:06:23 +01002709 spec->num_adc_nids = ARRAY_SIZE(ad1988_adc_nids);
2710 spec->adc_nids = ad1988_adc_nids;
2711 spec->capsrc_nids = ad1988_capsrc_nids;
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01002712 spec->mixers[spec->num_mixers++] = ad1988_capture_mixers;
2713 spec->init_verbs[spec->num_init_verbs++] = ad1988_capture_init_verbs;
2714 if (spec->multiout.dig_out_nid) {
2715 spec->mixers[spec->num_mixers++] = ad1988_spdif_out_mixers;
2716 spec->init_verbs[spec->num_init_verbs++] = ad1988_spdif_init_verbs;
2717 }
2718 if (spec->dig_in_nid)
2719 spec->mixers[spec->num_mixers++] = ad1988_spdif_in_mixers;
2720
2721 codec->patch_ops = ad198x_patch_ops;
2722 switch (board_config) {
Takashi Iwaid32410b12005-11-24 16:06:23 +01002723 case AD1988_AUTO:
2724 codec->patch_ops.init = ad1988_auto_init;
2725 break;
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01002726 case AD1988_LAPTOP:
2727 case AD1988_LAPTOP_DIG:
2728 codec->patch_ops.unsol_event = ad1988_laptop_unsol_event;
2729 break;
2730 }
2731
2732 return 0;
2733}
2734
2735
2736/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002737 * patch entries
2738 */
2739struct hda_codec_preset snd_hda_preset_analog[] = {
Takashi Iwai4a3fdf32005-04-14 13:35:51 +02002740 { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 },
2741 { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002742 { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a },
Takashi Iwaifd66e0d2005-11-17 15:31:34 +01002743 { .id = 0x11d41988, .name = "AD1988", .patch = patch_ad1988 },
Takashi Iwai71b2ccc2006-04-21 16:09:31 +02002744 { .id = 0x11d4198b, .name = "AD1988B", .patch = patch_ad1988 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002745 {} /* terminator */
2746};