blob: 08cb77f51880a31265c46cf66691715cfbf5dd55 [file] [log] [blame]
Matt2f2f4252005-04-13 14:45:30 +02001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for SigmaTel STAC92xx
5 *
6 * Copyright (c) 2005 Embedded Alley Solutions, Inc.
Matt Porter403d1942005-11-29 15:00:51 +01007 * Matt Porter <mporter@embeddedalley.com>
Matt2f2f4252005-04-13 14:45:30 +02008 *
9 * Based on patch_cmedia.c and patch_realtek.c
10 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
11 *
12 * This driver is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This driver is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */
26
Matt2f2f4252005-04-13 14:45:30 +020027#include <linux/init.h>
28#include <linux/delay.h>
29#include <linux/slab.h>
30#include <linux/pci.h>
31#include <sound/core.h>
Mattc7d4b2f2005-06-27 14:59:41 +020032#include <sound/asoundef.h>
Matt2f2f4252005-04-13 14:45:30 +020033#include "hda_codec.h"
34#include "hda_local.h"
Harvey Harrison3c9a3202008-02-29 11:59:26 +010035#include "hda_patch.h"
Matt2f2f4252005-04-13 14:45:30 +020036
Matt4e550962005-07-04 17:51:39 +020037#define NUM_CONTROL_ALLOC 32
Matthew Ranostaya64135a2008-01-10 16:55:06 +010038#define STAC_PWR_EVENT 0x20
39#define STAC_HP_EVENT 0x30
Matt4e550962005-07-04 17:51:39 +020040
Takashi Iwaif5fcc132006-11-24 17:07:44 +010041enum {
42 STAC_REF,
Tobin Davisbf277782008-02-03 20:31:47 +010043 STAC_9200_OQO,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020044 STAC_9200_DELL_D21,
45 STAC_9200_DELL_D22,
46 STAC_9200_DELL_D23,
47 STAC_9200_DELL_M21,
48 STAC_9200_DELL_M22,
49 STAC_9200_DELL_M23,
50 STAC_9200_DELL_M24,
51 STAC_9200_DELL_M25,
52 STAC_9200_DELL_M26,
53 STAC_9200_DELL_M27,
Takashi Iwai1194b5b2007-10-10 10:04:26 +020054 STAC_9200_GATEWAY,
Takashi Iwai117f2572008-03-18 09:53:23 +010055 STAC_9200_PANASONIC,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010056 STAC_9200_MODELS
57};
58
59enum {
60 STAC_9205_REF,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020061 STAC_9205_DELL_M42,
Tobin Davisae0a8ed2007-08-13 15:50:29 +020062 STAC_9205_DELL_M43,
63 STAC_9205_DELL_M44,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010064 STAC_9205_MODELS
65};
66
67enum {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010068 STAC_92HD73XX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010069 STAC_DELL_M6,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010070 STAC_92HD73XX_MODELS
71};
72
73enum {
Matthew Ranostaye035b842007-11-06 11:53:55 +010074 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010075 STAC_DELL_M4_1,
76 STAC_DELL_M4_2,
Matthew Ranostaye035b842007-11-06 11:53:55 +010077 STAC_92HD71BXX_MODELS
78};
79
80enum {
Tobin Davis8e21c342007-01-08 11:04:17 +010081 STAC_925x_REF,
82 STAC_M2_2,
83 STAC_MA6,
Tobin Davis2c11f952007-05-17 09:36:34 +020084 STAC_PA6,
Tobin Davis8e21c342007-01-08 11:04:17 +010085 STAC_925x_MODELS
86};
87
88enum {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010089 STAC_D945_REF,
90 STAC_D945GTP3,
91 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +020092 STAC_INTEL_MAC_V1,
93 STAC_INTEL_MAC_V2,
94 STAC_INTEL_MAC_V3,
95 STAC_INTEL_MAC_V4,
96 STAC_INTEL_MAC_V5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020097 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010098 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +010099 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100100 STAC_MACBOOK_PRO_V1,
101 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200102 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200103 STAC_IMAC_INTEL_20,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200104 STAC_922X_DELL_D81,
105 STAC_922X_DELL_D82,
106 STAC_922X_DELL_M81,
107 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100108 STAC_922X_MODELS
109};
110
111enum {
112 STAC_D965_REF,
113 STAC_D965_3ST,
114 STAC_D965_5ST,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200115 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100116 STAC_DELL_BIOS,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100117 STAC_927X_MODELS
118};
Matt Porter403d1942005-11-29 15:00:51 +0100119
Matt2f2f4252005-04-13 14:45:30 +0200120struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100121 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200122 unsigned int num_mixers;
123
Matt Porter403d1942005-11-29 15:00:51 +0100124 int board_config;
Mattc7d4b2f2005-06-27 14:59:41 +0200125 unsigned int surr_switch: 1;
Matt Porter403d1942005-11-29 15:00:51 +0100126 unsigned int line_switch: 1;
127 unsigned int mic_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100128 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100129 unsigned int hp_detect: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200130
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100131 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200132 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100133 unsigned int gpio_mask;
134 unsigned int gpio_dir;
135 unsigned int gpio_data;
136 unsigned int gpio_mute;
137
138 /* analog loopback */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100139 unsigned char aloopback_mask;
140 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200141
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100142 /* power management */
143 unsigned int num_pwrs;
144 hda_nid_t *pwr_nids;
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100145 hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100146
Matt2f2f4252005-04-13 14:45:30 +0200147 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100148 struct hda_input_mux *mono_mux;
149 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200150 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100151 hda_nid_t dac_nids[5];
Matt2f2f4252005-04-13 14:45:30 +0200152
153 /* capture */
154 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200155 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200156 hda_nid_t *mux_nids;
157 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200158 hda_nid_t *dmic_nids;
159 unsigned int num_dmics;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100160 hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100161 unsigned int num_dmuxes;
Mattdabbed62005-06-14 10:19:34 +0200162 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100163 hda_nid_t mono_nid;
Matt2f2f4252005-04-13 14:45:30 +0200164
Matt2f2f4252005-04-13 14:45:30 +0200165 /* pin widgets */
166 hda_nid_t *pin_nids;
167 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200168 unsigned int *pin_configs;
Richard Fish11b44bb2006-08-23 18:31:34 +0200169 unsigned int *bios_pin_configs;
Matt2f2f4252005-04-13 14:45:30 +0200170
171 /* codec specific stuff */
172 struct hda_verb *init;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100173 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200174
175 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200176 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100177 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200178 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100179 unsigned int cur_mux[3];
Matt2f2f4252005-04-13 14:45:30 +0200180
Matt Porter403d1942005-11-29 15:00:51 +0100181 /* i/o switches */
182 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200183 unsigned int clfe_swap;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +0200184 unsigned int hp_switch;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200185 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200186
Mattc7d4b2f2005-06-27 14:59:41 +0200187 struct hda_pcm pcm_rec[2]; /* PCM information */
188
189 /* dynamic controls and input_mux */
190 struct auto_pin_cfg autocfg;
191 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100192 struct snd_kcontrol_new *kctl_alloc;
Matt Porter8b657272006-10-26 17:12:59 +0200193 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200194 struct hda_input_mux private_imux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100195 struct hda_input_mux private_mono_mux;
Matt2f2f4252005-04-13 14:45:30 +0200196};
197
198static hda_nid_t stac9200_adc_nids[1] = {
199 0x03,
200};
201
202static hda_nid_t stac9200_mux_nids[1] = {
203 0x0c,
204};
205
206static hda_nid_t stac9200_dac_nids[1] = {
207 0x02,
208};
209
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100210static hda_nid_t stac92hd73xx_pwr_nids[8] = {
211 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
212 0x0f, 0x10, 0x11
213};
214
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100215static hda_nid_t stac92hd73xx_adc_nids[2] = {
216 0x1a, 0x1b
217};
218
219#define STAC92HD73XX_NUM_DMICS 2
220static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
221 0x13, 0x14, 0
222};
223
224#define STAC92HD73_DAC_COUNT 5
225static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
226 0x15, 0x16, 0x17, 0x18, 0x19,
227};
228
229static hda_nid_t stac92hd73xx_mux_nids[4] = {
230 0x28, 0x29, 0x2a, 0x2b,
231};
232
233static hda_nid_t stac92hd73xx_dmux_nids[2] = {
234 0x20, 0x21,
235};
236
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100237static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
238 0x0a, 0x0d, 0x0f
239};
240
Matthew Ranostaye035b842007-11-06 11:53:55 +0100241static hda_nid_t stac92hd71bxx_adc_nids[2] = {
242 0x12, 0x13,
243};
244
245static hda_nid_t stac92hd71bxx_mux_nids[2] = {
246 0x1a, 0x1b
247};
248
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100249static hda_nid_t stac92hd71bxx_dmux_nids[1] = {
250 0x1c,
251};
252
Takashi Iwaiaea7bb02008-02-25 18:26:41 +0100253static hda_nid_t stac92hd71bxx_dac_nids[1] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100254 0x10, /*0x11, */
255};
256
257#define STAC92HD71BXX_NUM_DMICS 2
258static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
259 0x18, 0x19, 0
260};
261
Tobin Davis8e21c342007-01-08 11:04:17 +0100262static hda_nid_t stac925x_adc_nids[1] = {
263 0x03,
264};
265
266static hda_nid_t stac925x_mux_nids[1] = {
267 0x0f,
268};
269
270static hda_nid_t stac925x_dac_nids[1] = {
271 0x02,
272};
273
Takashi Iwaif6e98522007-10-16 14:27:04 +0200274#define STAC925X_NUM_DMICS 1
275static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
276 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200277};
278
Takashi Iwai1697055e2007-12-18 18:05:52 +0100279static hda_nid_t stac925x_dmux_nids[1] = {
280 0x14,
281};
282
Matt2f2f4252005-04-13 14:45:30 +0200283static hda_nid_t stac922x_adc_nids[2] = {
284 0x06, 0x07,
285};
286
287static hda_nid_t stac922x_mux_nids[2] = {
288 0x12, 0x13,
289};
290
Matt Porter3cc08dc2006-01-23 15:27:49 +0100291static hda_nid_t stac927x_adc_nids[3] = {
292 0x07, 0x08, 0x09
293};
294
295static hda_nid_t stac927x_mux_nids[3] = {
296 0x15, 0x16, 0x17
297};
298
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100299static hda_nid_t stac927x_dac_nids[6] = {
300 0x02, 0x03, 0x04, 0x05, 0x06, 0
301};
302
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100303static hda_nid_t stac927x_dmux_nids[1] = {
304 0x1b,
305};
306
Matthew Ranostay7f168592007-10-18 17:38:17 +0200307#define STAC927X_NUM_DMICS 2
308static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
309 0x13, 0x14, 0
310};
311
Matt Porterf3302a52006-07-31 12:49:34 +0200312static hda_nid_t stac9205_adc_nids[2] = {
313 0x12, 0x13
314};
315
316static hda_nid_t stac9205_mux_nids[2] = {
317 0x19, 0x1a
318};
319
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100320static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100321 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100322};
323
Takashi Iwaif6e98522007-10-16 14:27:04 +0200324#define STAC9205_NUM_DMICS 2
325static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
326 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200327};
328
Mattc7d4b2f2005-06-27 14:59:41 +0200329static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200330 0x08, 0x09, 0x0d, 0x0e,
331 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200332};
333
Tobin Davis8e21c342007-01-08 11:04:17 +0100334static hda_nid_t stac925x_pin_nids[8] = {
335 0x07, 0x08, 0x0a, 0x0b,
336 0x0c, 0x0d, 0x10, 0x11,
337};
338
Matt2f2f4252005-04-13 14:45:30 +0200339static hda_nid_t stac922x_pin_nids[10] = {
340 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
341 0x0f, 0x10, 0x11, 0x15, 0x1b,
342};
343
Matthew Ranostaya7662642008-02-21 07:51:14 +0100344static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100345 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
346 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostaya7662642008-02-21 07:51:14 +0100347 0x14, 0x1e, 0x22
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100348};
349
Matthew Ranostaye035b842007-11-06 11:53:55 +0100350static hda_nid_t stac92hd71bxx_pin_nids[10] = {
351 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
352 0x0f, 0x14, 0x18, 0x19, 0x1e,
353};
354
Matt Porter3cc08dc2006-01-23 15:27:49 +0100355static hda_nid_t stac927x_pin_nids[14] = {
356 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
357 0x0f, 0x10, 0x11, 0x12, 0x13,
358 0x14, 0x21, 0x22, 0x23,
359};
360
Matt Porterf3302a52006-07-31 12:49:34 +0200361static hda_nid_t stac9205_pin_nids[12] = {
362 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
363 0x0f, 0x14, 0x16, 0x17, 0x18,
364 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200365};
366
Matt Porter8b657272006-10-26 17:12:59 +0200367static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
368 struct snd_ctl_elem_info *uinfo)
369{
370 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
371 struct sigmatel_spec *spec = codec->spec;
372 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
373}
374
375static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
376 struct snd_ctl_elem_value *ucontrol)
377{
378 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
379 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100380 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200381
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100382 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200383 return 0;
384}
385
386static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
387 struct snd_ctl_elem_value *ucontrol)
388{
389 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
390 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100391 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200392
393 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100394 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200395}
396
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100397static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200398{
399 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
400 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200401 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200402}
403
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100404static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200405{
406 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
407 struct sigmatel_spec *spec = codec->spec;
408 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
409
410 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
411 return 0;
412}
413
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100414static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200415{
416 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
417 struct sigmatel_spec *spec = codec->spec;
418 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
419
Mattc7d4b2f2005-06-27 14:59:41 +0200420 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200421 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
422}
423
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100424static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
425 struct snd_ctl_elem_info *uinfo)
426{
427 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
428 struct sigmatel_spec *spec = codec->spec;
429 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
430}
431
432static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
433 struct snd_ctl_elem_value *ucontrol)
434{
435 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
436 struct sigmatel_spec *spec = codec->spec;
437
438 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
439 return 0;
440}
441
442static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
443 struct snd_ctl_elem_value *ucontrol)
444{
445 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
446 struct sigmatel_spec *spec = codec->spec;
447
448 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
449 spec->mono_nid, &spec->cur_mmux);
450}
451
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200452#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
453
454static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
455 struct snd_ctl_elem_value *ucontrol)
456{
457 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100458 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200459 struct sigmatel_spec *spec = codec->spec;
460
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100461 ucontrol->value.integer.value[0] = !!(spec->aloopback &
462 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200463 return 0;
464}
465
466static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
467 struct snd_ctl_elem_value *ucontrol)
468{
469 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
470 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100471 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200472 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100473 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200474
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100475 idx_val = spec->aloopback_mask << idx;
476 if (ucontrol->value.integer.value[0])
477 val = spec->aloopback | idx_val;
478 else
479 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100480 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200481 return 0;
482
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100483 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200484
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100485 /* Only return the bits defined by the shift value of the
486 * first two bytes of the mask
487 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200488 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100489 kcontrol->private_value & 0xFFFF, 0x0);
490 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200491
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100492 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200493 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100494 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200495 } else {
496 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100497 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200498 }
499
500 snd_hda_codec_write_cache(codec, codec->afg, 0,
501 kcontrol->private_value >> 16, dac_mode);
502
503 return 1;
504}
505
Mattc7d4b2f2005-06-27 14:59:41 +0200506static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200507 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200508 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200509 {}
510};
511
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200512static struct hda_verb stac9200_eapd_init[] = {
513 /* set dac0mux for dac converter */
514 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
515 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
516 {}
517};
518
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100519static struct hda_verb stac92hd73xx_6ch_core_init[] = {
520 /* set master volume and direct control */
521 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
522 /* setup audio connections */
523 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
524 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
525 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
526 /* setup adcs to point to mixer */
527 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
528 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100529 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
530 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
531 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
532 /* setup import muxs */
533 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
534 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
535 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
536 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
537 {}
538};
539
Matthew Ranostayd654a662008-03-14 08:46:51 +0100540static struct hda_verb dell_eq_core_init[] = {
541 /* set master volume to max value without distortion
542 * and direct control */
543 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
544 /* setup audio connections */
545 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
546 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
547 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
548 /* setup adcs to point to mixer */
549 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
550 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
551 /* setup import muxs */
552 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
553 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
554 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
555 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
556 {}
557};
558
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100559static struct hda_verb dell_m6_core_init[] = {
560 /* set master volume and direct control */
561 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
562 /* setup audio connections */
Matthew Ranostay7747ecc2008-03-10 11:30:04 +0100563 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
564 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100565 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
566 /* setup adcs to point to mixer */
567 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
568 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
569 /* setup import muxs */
570 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
571 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
572 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
573 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
574 {}
575};
576
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100577static struct hda_verb stac92hd73xx_8ch_core_init[] = {
578 /* set master volume and direct control */
579 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
580 /* setup audio connections */
581 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
582 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
583 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
584 /* connect hp ports to dac3 */
585 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
586 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
587 /* setup adcs to point to mixer */
588 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
589 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100590 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
591 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
592 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
593 /* setup import muxs */
594 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
595 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
596 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
597 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
598 {}
599};
600
601static struct hda_verb stac92hd73xx_10ch_core_init[] = {
602 /* set master volume and direct control */
603 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
604 /* setup audio connections */
605 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
606 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
607 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
608 /* dac3 is connected to import3 mux */
609 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
610 /* connect hp ports to dac4 */
611 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
612 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
613 /* setup adcs to point to mixer */
614 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
615 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100616 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
617 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
618 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
619 /* setup import muxs */
620 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
621 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
622 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
623 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
624 {}
625};
626
Matthew Ranostaye035b842007-11-06 11:53:55 +0100627static struct hda_verb stac92hd71bxx_core_init[] = {
628 /* set master volume and direct control */
629 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
630 /* connect headphone jack to dac1 */
631 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100632 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
633 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
634 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
635 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
636 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100637};
638
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200639#define HD_DISABLE_PORTF 3
Matthew Ranostay541eee82007-12-14 12:08:04 +0100640static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200641 /* start of config #1 */
642
643 /* connect port 0f to audio mixer */
644 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
645 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
646 /* unmute right and left channels for node 0x0f */
647 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
648 /* start of config #2 */
649
Matthew Ranostay541eee82007-12-14 12:08:04 +0100650 /* set master volume and direct control */
651 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
652 /* connect headphone jack to dac1 */
653 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200654 /* connect port 0d to audio mixer */
Matthew Ranostay9b359472007-11-07 13:03:12 +0100655 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostay9b359472007-11-07 13:03:12 +0100656 /* unmute dac0 input in audio mixer */
657 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200658 /* unmute right and left channels for nodes 0x0a, 0xd */
Matthew Ranostaye035b842007-11-06 11:53:55 +0100659 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
660 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100661 {}
662};
663
Tobin Davis8e21c342007-01-08 11:04:17 +0100664static struct hda_verb stac925x_core_init[] = {
665 /* set dac0mux for dac converter */
666 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
667 {}
668};
669
Mattc7d4b2f2005-06-27 14:59:41 +0200670static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200671 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200672 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200673 {}
674};
675
Tobin Davis93ed1502006-09-01 21:03:12 +0200676static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200677 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200678 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200679 /* unmute node 0x1b */
680 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
681 /* select node 0x03 as DAC */
682 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
683 {}
684};
685
Matt Porter3cc08dc2006-01-23 15:27:49 +0100686static struct hda_verb stac927x_core_init[] = {
687 /* set master volume and direct control */
688 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
689 {}
690};
691
Matt Porterf3302a52006-07-31 12:49:34 +0200692static struct hda_verb stac9205_core_init[] = {
693 /* set master volume and direct control */
694 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
695 {}
696};
697
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100698#define STAC_MONO_MUX \
699 { \
700 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
701 .name = "Mono Mux", \
702 .count = 1, \
703 .info = stac92xx_mono_mux_enum_info, \
704 .get = stac92xx_mono_mux_enum_get, \
705 .put = stac92xx_mono_mux_enum_put, \
706 }
707
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200708#define STAC_INPUT_SOURCE(cnt) \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200709 { \
710 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
711 .name = "Input Source", \
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200712 .count = cnt, \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200713 .info = stac92xx_mux_enum_info, \
714 .get = stac92xx_mux_enum_get, \
715 .put = stac92xx_mux_enum_put, \
716 }
717
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100718#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200719 { \
720 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
721 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100722 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200723 .info = stac92xx_aloopback_info, \
724 .get = stac92xx_aloopback_get, \
725 .put = stac92xx_aloopback_put, \
726 .private_value = verb_read | (verb_write << 16), \
727 }
728
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100729static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200730 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
731 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200732 STAC_INPUT_SOURCE(1),
Matt2f2f4252005-04-13 14:45:30 +0200733 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
734 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Mattc7d4b2f2005-06-27 14:59:41 +0200735 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200736 { } /* end */
737};
738
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100739static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100740 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
741
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100742 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
743 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
744
745 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
746 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
747
748 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
749 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
750
751 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
752 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
753
754 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
755 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
756
757 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
758 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
759
760 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
761 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
762 { } /* end */
763};
764
765static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100766 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
767
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100768 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
769 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
770
771 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
772 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
773
774 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
775 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
776
777 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
778 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
779
780 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
781 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
782
783 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
784 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
785
786 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
787 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
788 { } /* end */
789};
790
791static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100792 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
793
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100794 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
795 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
796
797 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
798 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
799
800 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
801 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
802
803 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
804 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
805
806 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
807 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
808
809 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
810 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
811
812 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
813 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
814 { } /* end */
815};
816
Matthew Ranostay541eee82007-12-14 12:08:04 +0100817static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100818 STAC_INPUT_SOURCE(2),
Matthew Ranostaye035b842007-11-06 11:53:55 +0100819
Matthew Ranostay9b359472007-11-07 13:03:12 +0100820 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
821 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
822 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT),
823
824 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
825 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
826 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
827
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +0200828 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
829 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
830
Matthew Ranostay9b359472007-11-07 13:03:12 +0100831 HDA_CODEC_MUTE("Analog Loopback 1", 0x17, 0x3, HDA_INPUT),
832 HDA_CODEC_MUTE("Analog Loopback 2", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +0100833 { } /* end */
834};
835
Matthew Ranostay541eee82007-12-14 12:08:04 +0100836static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +0100837 STAC_INPUT_SOURCE(2),
838 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
839
Matthew Ranostay541eee82007-12-14 12:08:04 +0100840 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
841 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
842 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT),
843
844 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
845 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
846 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
847 { } /* end */
848};
849
Tobin Davis8e21c342007-01-08 11:04:17 +0100850static struct snd_kcontrol_new stac925x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200851 STAC_INPUT_SOURCE(1),
Tobin Davis8e21c342007-01-08 11:04:17 +0100852 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +0200853 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +0100854 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0f, 0, HDA_OUTPUT),
855 { } /* end */
856};
857
Takashi Iwaid1d985f2006-11-23 19:27:12 +0100858static struct snd_kcontrol_new stac9205_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200859 STAC_INPUT_SOURCE(2),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100860 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200861
862 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
863 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
864 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x19, 0x0, HDA_OUTPUT),
865
866 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
867 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
868 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x1A, 0x0, HDA_OUTPUT),
869
870 { } /* end */
871};
872
873/* This needs to be generated dynamically based on sequence */
874static struct snd_kcontrol_new stac922x_mixer[] = {
875 STAC_INPUT_SOURCE(2),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200876 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
877 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
878 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x12, 0x0, HDA_OUTPUT),
879
880 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
881 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
882 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x13, 0x0, HDA_OUTPUT),
883 { } /* end */
884};
885
886
887static struct snd_kcontrol_new stac927x_mixer[] = {
888 STAC_INPUT_SOURCE(3),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100889 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200890
891 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
892 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
893 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x15, 0x0, HDA_OUTPUT),
894
895 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
896 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
897 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x16, 0x0, HDA_OUTPUT),
898
899 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
900 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
901 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x2, 0x17, 0x0, HDA_OUTPUT),
Matt Porterf3302a52006-07-31 12:49:34 +0200902 { } /* end */
903};
904
Takashi Iwai1697055e2007-12-18 18:05:52 +0100905static struct snd_kcontrol_new stac_dmux_mixer = {
906 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
907 .name = "Digital Input Source",
908 /* count set later */
909 .info = stac92xx_dmux_enum_info,
910 .get = stac92xx_dmux_enum_get,
911 .put = stac92xx_dmux_enum_put,
912};
913
Takashi Iwai2134ea42008-01-10 16:53:55 +0100914static const char *slave_vols[] = {
915 "Front Playback Volume",
916 "Surround Playback Volume",
917 "Center Playback Volume",
918 "LFE Playback Volume",
919 "Side Playback Volume",
920 "Headphone Playback Volume",
921 "Headphone Playback Volume",
922 "Speaker Playback Volume",
923 "External Speaker Playback Volume",
924 "Speaker2 Playback Volume",
925 NULL
926};
927
928static const char *slave_sws[] = {
929 "Front Playback Switch",
930 "Surround Playback Switch",
931 "Center Playback Switch",
932 "LFE Playback Switch",
933 "Side Playback Switch",
934 "Headphone Playback Switch",
935 "Headphone Playback Switch",
936 "Speaker Playback Switch",
937 "External Speaker Playback Switch",
938 "Speaker2 Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +0100939 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +0100940 NULL
941};
942
Matt2f2f4252005-04-13 14:45:30 +0200943static int stac92xx_build_controls(struct hda_codec *codec)
944{
945 struct sigmatel_spec *spec = codec->spec;
946 int err;
Mattc7d4b2f2005-06-27 14:59:41 +0200947 int i;
Matt2f2f4252005-04-13 14:45:30 +0200948
949 err = snd_hda_add_new_ctls(codec, spec->mixer);
950 if (err < 0)
951 return err;
Mattc7d4b2f2005-06-27 14:59:41 +0200952
953 for (i = 0; i < spec->num_mixers; i++) {
954 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
955 if (err < 0)
956 return err;
957 }
Takashi Iwai1697055e2007-12-18 18:05:52 +0100958 if (spec->num_dmuxes > 0) {
959 stac_dmux_mixer.count = spec->num_dmuxes;
960 err = snd_ctl_add(codec->bus->card,
961 snd_ctl_new1(&stac_dmux_mixer, codec));
962 if (err < 0)
963 return err;
964 }
Mattc7d4b2f2005-06-27 14:59:41 +0200965
Mattdabbed62005-06-14 10:19:34 +0200966 if (spec->multiout.dig_out_nid) {
967 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
968 if (err < 0)
969 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +0100970 err = snd_hda_create_spdif_share_sw(codec,
971 &spec->multiout);
972 if (err < 0)
973 return err;
974 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +0200975 }
976 if (spec->dig_in_nid) {
977 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
978 if (err < 0)
979 return err;
980 }
Takashi Iwai2134ea42008-01-10 16:53:55 +0100981
982 /* if we have no master control, let's create it */
983 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +0100984 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +0100985 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +0100986 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +0100987 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +0100988 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +0100989 if (err < 0)
990 return err;
991 }
992 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
993 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
994 NULL, slave_sws);
995 if (err < 0)
996 return err;
997 }
998
Mattdabbed62005-06-14 10:19:34 +0200999 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001000}
1001
Matt Porter403d1942005-11-29 15:00:51 +01001002static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001003 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001004 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1005};
1006
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001007/*
1008 STAC 9200 pin configs for
1009 102801A8
1010 102801DE
1011 102801E8
1012*/
1013static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001014 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1015 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001016};
1017
1018/*
1019 STAC 9200 pin configs for
1020 102801C0
1021 102801C1
1022*/
1023static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001024 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1025 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001026};
1027
1028/*
1029 STAC 9200 pin configs for
1030 102801C4 (Dell Dimension E310)
1031 102801C5
1032 102801C7
1033 102801D9
1034 102801DA
1035 102801E3
1036*/
1037static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001038 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1039 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001040};
1041
1042
1043/*
1044 STAC 9200-32 pin configs for
1045 102801B5 (Dell Inspiron 630m)
1046 102801D8 (Dell Inspiron 640m)
1047*/
1048static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001049 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1050 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001051};
1052
1053/*
1054 STAC 9200-32 pin configs for
1055 102801C2 (Dell Latitude D620)
1056 102801C8
1057 102801CC (Dell Latitude D820)
1058 102801D4
1059 102801D6
1060*/
1061static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001062 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1063 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001064};
1065
1066/*
1067 STAC 9200-32 pin configs for
1068 102801CE (Dell XPS M1710)
1069 102801CF (Dell Precision M90)
1070*/
1071static unsigned int dell9200_m23_pin_configs[8] = {
1072 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1073 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1074};
1075
1076/*
1077 STAC 9200-32 pin configs for
1078 102801C9
1079 102801CA
1080 102801CB (Dell Latitude 120L)
1081 102801D3
1082*/
1083static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001084 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1085 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001086};
1087
1088/*
1089 STAC 9200-32 pin configs for
1090 102801BD (Dell Inspiron E1505n)
1091 102801EE
1092 102801EF
1093*/
1094static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001095 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1096 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001097};
1098
1099/*
1100 STAC 9200-32 pin configs for
1101 102801F5 (Dell Inspiron 1501)
1102 102801F6
1103*/
1104static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001105 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1106 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001107};
1108
1109/*
1110 STAC 9200-32
1111 102801CD (Dell Inspiron E1705/9400)
1112*/
1113static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001114 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1115 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001116};
1117
Tobin Davisbf277782008-02-03 20:31:47 +01001118static unsigned int oqo9200_pin_configs[8] = {
1119 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1120 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1121};
1122
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001123
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001124static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1125 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001126 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001127 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1128 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1129 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1130 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1131 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1132 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1133 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1134 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1135 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1136 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001137 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001138};
1139
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001140static const char *stac9200_models[STAC_9200_MODELS] = {
1141 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001142 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001143 [STAC_9200_DELL_D21] = "dell-d21",
1144 [STAC_9200_DELL_D22] = "dell-d22",
1145 [STAC_9200_DELL_D23] = "dell-d23",
1146 [STAC_9200_DELL_M21] = "dell-m21",
1147 [STAC_9200_DELL_M22] = "dell-m22",
1148 [STAC_9200_DELL_M23] = "dell-m23",
1149 [STAC_9200_DELL_M24] = "dell-m24",
1150 [STAC_9200_DELL_M25] = "dell-m25",
1151 [STAC_9200_DELL_M26] = "dell-m26",
1152 [STAC_9200_DELL_M27] = "dell-m27",
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001153 [STAC_9200_GATEWAY] = "gateway",
Takashi Iwai117f2572008-03-18 09:53:23 +01001154 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001155};
1156
1157static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1158 /* SigmaTel reference board */
1159 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1160 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001161 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001162 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1163 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001164 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001165 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1166 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1167 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1168 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1169 "unknown Dell", STAC_9200_DELL_D22),
1170 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1171 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001172 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001173 "Dell Latitude D620", STAC_9200_DELL_M22),
1174 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1175 "unknown Dell", STAC_9200_DELL_D23),
1176 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1177 "unknown Dell", STAC_9200_DELL_D23),
1178 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1179 "unknown Dell", STAC_9200_DELL_M22),
1180 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1181 "unknown Dell", STAC_9200_DELL_M24),
1182 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1183 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001184 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001185 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001186 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001187 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001188 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001189 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001190 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001191 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001192 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001193 "Dell Precision M90", STAC_9200_DELL_M23),
1194 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1195 "unknown Dell", STAC_9200_DELL_M22),
1196 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1197 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001198 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001199 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001200 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001201 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1202 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1203 "unknown Dell", STAC_9200_DELL_D23),
1204 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1205 "unknown Dell", STAC_9200_DELL_D23),
1206 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1207 "unknown Dell", STAC_9200_DELL_D21),
1208 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1209 "unknown Dell", STAC_9200_DELL_D23),
1210 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1211 "unknown Dell", STAC_9200_DELL_D21),
1212 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1213 "unknown Dell", STAC_9200_DELL_M25),
1214 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1215 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001216 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001217 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1218 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1219 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001220 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001221 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001222 /* Gateway machines needs EAPD to be set on resume */
1223 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1224 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1225 STAC_9200_GATEWAY),
1226 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1227 STAC_9200_GATEWAY),
Tobin Davisbf277782008-02-03 20:31:47 +01001228 /* OQO Mobile */
1229 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001230 {} /* terminator */
1231};
1232
Tobin Davis8e21c342007-01-08 11:04:17 +01001233static unsigned int ref925x_pin_configs[8] = {
1234 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001235 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001236};
1237
1238static unsigned int stac925x_MA6_pin_configs[8] = {
1239 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1240 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1241};
1242
Tobin Davis2c11f952007-05-17 09:36:34 +02001243static unsigned int stac925x_PA6_pin_configs[8] = {
1244 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1245 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1246};
1247
Tobin Davis8e21c342007-01-08 11:04:17 +01001248static unsigned int stac925xM2_2_pin_configs[8] = {
Steve Longerbeam7353e142007-05-29 14:36:17 +02001249 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1250 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001251};
1252
1253static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1254 [STAC_REF] = ref925x_pin_configs,
1255 [STAC_M2_2] = stac925xM2_2_pin_configs,
1256 [STAC_MA6] = stac925x_MA6_pin_configs,
Tobin Davis2c11f952007-05-17 09:36:34 +02001257 [STAC_PA6] = stac925x_PA6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001258};
1259
1260static const char *stac925x_models[STAC_925x_MODELS] = {
1261 [STAC_REF] = "ref",
1262 [STAC_M2_2] = "m2-2",
1263 [STAC_MA6] = "m6",
Tobin Davis2c11f952007-05-17 09:36:34 +02001264 [STAC_PA6] = "pa6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001265};
1266
1267static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1268 /* SigmaTel reference board */
1269 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001270 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Tobin Davis8e21c342007-01-08 11:04:17 +01001271 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1272 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1273 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
Tobin Davis2c11f952007-05-17 09:36:34 +02001274 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
Tobin Davis8e21c342007-01-08 11:04:17 +01001275 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1276 {} /* terminator */
1277};
1278
Matthew Ranostaya7662642008-02-21 07:51:14 +01001279static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001280 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1281 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1282 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001283 0x01452050,
1284};
1285
1286static unsigned int dell_m6_pin_configs[13] = {
1287 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001288 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001289 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1290 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001291};
1292
1293static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001294 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1295 [STAC_DELL_M6] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001296};
1297
1298static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1299 [STAC_92HD73XX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001300 [STAC_DELL_M6] = "dell-m6",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001301};
1302
1303static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1304 /* SigmaTel reference board */
1305 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001306 "DFI LanParty", STAC_92HD73XX_REF),
1307 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1308 "unknown Dell", STAC_DELL_M6),
1309 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1310 "unknown Dell", STAC_DELL_M6),
1311 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1312 "unknown Dell", STAC_DELL_M6),
1313 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1314 "unknown Dell", STAC_DELL_M6),
1315 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1316 "unknown Dell", STAC_DELL_M6),
1317 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1318 "unknown Dell", STAC_DELL_M6),
1319 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1320 "unknown Dell", STAC_DELL_M6),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001321 {} /* terminator */
1322};
1323
Matthew Ranostaye035b842007-11-06 11:53:55 +01001324static unsigned int ref92hd71bxx_pin_configs[10] = {
1325 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostayb22b4822008-01-22 12:32:30 +01001326 0x0181302e, 0x01114010, 0x01019020, 0x90a000f0,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001327 0x90a000f0, 0x01452050,
1328};
1329
Matthew Ranostayaafc4412008-06-13 18:04:33 +02001330static unsigned int dell_m4_1_pin_configs[10] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001331 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001332 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001333 0x40f000f0, 0x4f0000f0,
1334};
1335
Matthew Ranostayaafc4412008-06-13 18:04:33 +02001336static unsigned int dell_m4_2_pin_configs[10] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001337 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1338 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1339 0x40f000f0, 0x044413b0,
1340};
1341
Matthew Ranostaye035b842007-11-06 11:53:55 +01001342static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1343 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001344 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1345 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001346};
1347
1348static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1349 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001350 [STAC_DELL_M4_1] = "dell-m4-1",
1351 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001352};
1353
1354static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1355 /* SigmaTel reference board */
1356 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1357 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001358 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1359 "unknown Dell", STAC_DELL_M4_1),
1360 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1361 "unknown Dell", STAC_DELL_M4_1),
1362 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1363 "unknown Dell", STAC_DELL_M4_1),
1364 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1365 "unknown Dell", STAC_DELL_M4_1),
1366 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1367 "unknown Dell", STAC_DELL_M4_1),
1368 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1369 "unknown Dell", STAC_DELL_M4_1),
1370 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1371 "unknown Dell", STAC_DELL_M4_1),
1372 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1373 "unknown Dell", STAC_DELL_M4_2),
1374 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1375 "unknown Dell", STAC_DELL_M4_2),
1376 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1377 "unknown Dell", STAC_DELL_M4_2),
1378 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1379 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001380 {} /* terminator */
1381};
1382
Matt Porter403d1942005-11-29 15:00:51 +01001383static unsigned int ref922x_pin_configs[10] = {
1384 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1385 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001386 0x40000100, 0x40000100,
1387};
1388
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001389/*
1390 STAC 922X pin configs for
1391 102801A7
1392 102801AB
1393 102801A9
1394 102801D1
1395 102801D2
1396*/
1397static unsigned int dell_922x_d81_pin_configs[10] = {
1398 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1399 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1400 0x01813122, 0x400001f2,
1401};
1402
1403/*
1404 STAC 922X pin configs for
1405 102801AC
1406 102801D0
1407*/
1408static unsigned int dell_922x_d82_pin_configs[10] = {
1409 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1410 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1411 0x01813122, 0x400001f1,
1412};
1413
1414/*
1415 STAC 922X pin configs for
1416 102801BF
1417*/
1418static unsigned int dell_922x_m81_pin_configs[10] = {
1419 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1420 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1421 0x40C003f1, 0x405003f0,
1422};
1423
1424/*
1425 STAC 9221 A1 pin configs for
1426 102801D7 (Dell XPS M1210)
1427*/
1428static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001429 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1430 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001431 0x508003f3, 0x405003f4,
1432};
1433
Matt Porter403d1942005-11-29 15:00:51 +01001434static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001435 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001436 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1437 0x02a19120, 0x40000100,
1438};
1439
1440static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001441 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1442 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001443 0x02a19320, 0x40000100,
1444};
1445
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001446static unsigned int intel_mac_v1_pin_configs[10] = {
1447 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1448 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001449 0x400000fc, 0x400000fb,
1450};
1451
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001452static unsigned int intel_mac_v2_pin_configs[10] = {
1453 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1454 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001455 0x400000fc, 0x400000fb,
1456};
1457
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001458static unsigned int intel_mac_v3_pin_configs[10] = {
1459 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1460 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1461 0x400000fc, 0x400000fb,
1462};
1463
1464static unsigned int intel_mac_v4_pin_configs[10] = {
1465 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1466 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1467 0x400000fc, 0x400000fb,
1468};
1469
1470static unsigned int intel_mac_v5_pin_configs[10] = {
1471 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1472 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1473 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001474};
1475
Takashi Iwai76c08822007-06-19 12:17:42 +02001476
Takashi Iwai19039bd2006-06-28 15:52:16 +02001477static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001478 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001479 [STAC_D945GTP3] = d945gtp3_pin_configs,
1480 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001481 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1482 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1483 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1484 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1485 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001486 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001487 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1488 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1489 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1490 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1491 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1492 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001493 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1494 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1495 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1496 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001497};
1498
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001499static const char *stac922x_models[STAC_922X_MODELS] = {
1500 [STAC_D945_REF] = "ref",
1501 [STAC_D945GTP5] = "5stack",
1502 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001503 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1504 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1505 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1506 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1507 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001508 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001509 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001510 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001511 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1512 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001513 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001514 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001515 [STAC_922X_DELL_D81] = "dell-d81",
1516 [STAC_922X_DELL_D82] = "dell-d82",
1517 [STAC_922X_DELL_M81] = "dell-m81",
1518 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001519};
1520
1521static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1522 /* SigmaTel reference board */
1523 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1524 "DFI LanParty", STAC_D945_REF),
1525 /* Intel 945G based systems */
1526 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1527 "Intel D945G", STAC_D945GTP3),
1528 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1529 "Intel D945G", STAC_D945GTP3),
1530 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1531 "Intel D945G", STAC_D945GTP3),
1532 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1533 "Intel D945G", STAC_D945GTP3),
1534 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1535 "Intel D945G", STAC_D945GTP3),
1536 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1537 "Intel D945G", STAC_D945GTP3),
1538 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1539 "Intel D945G", STAC_D945GTP3),
1540 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1541 "Intel D945G", STAC_D945GTP3),
1542 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1543 "Intel D945G", STAC_D945GTP3),
1544 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1545 "Intel D945G", STAC_D945GTP3),
1546 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1547 "Intel D945G", STAC_D945GTP3),
1548 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1549 "Intel D945G", STAC_D945GTP3),
1550 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1551 "Intel D945G", STAC_D945GTP3),
1552 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1553 "Intel D945G", STAC_D945GTP3),
1554 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1555 "Intel D945G", STAC_D945GTP3),
1556 /* Intel D945G 5-stack systems */
1557 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1558 "Intel D945G", STAC_D945GTP5),
1559 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1560 "Intel D945G", STAC_D945GTP5),
1561 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1562 "Intel D945G", STAC_D945GTP5),
1563 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1564 "Intel D945G", STAC_D945GTP5),
1565 /* Intel 945P based systems */
1566 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1567 "Intel D945P", STAC_D945GTP3),
1568 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1569 "Intel D945P", STAC_D945GTP3),
1570 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1571 "Intel D945P", STAC_D945GTP3),
1572 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1573 "Intel D945P", STAC_D945GTP3),
1574 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1575 "Intel D945P", STAC_D945GTP3),
1576 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1577 "Intel D945P", STAC_D945GTP5),
1578 /* other systems */
1579 /* Apple Mac Mini (early 2006) */
1580 SND_PCI_QUIRK(0x8384, 0x7680,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001581 "Mac Mini", STAC_INTEL_MAC_V3),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001582 /* Dell systems */
1583 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1584 "unknown Dell", STAC_922X_DELL_D81),
1585 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1586 "unknown Dell", STAC_922X_DELL_D81),
1587 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1588 "unknown Dell", STAC_922X_DELL_D81),
1589 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1590 "unknown Dell", STAC_922X_DELL_D82),
1591 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1592 "unknown Dell", STAC_922X_DELL_M81),
1593 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1594 "unknown Dell", STAC_922X_DELL_D82),
1595 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1596 "unknown Dell", STAC_922X_DELL_D81),
1597 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1598 "unknown Dell", STAC_922X_DELL_D81),
1599 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1600 "Dell XPS M1210", STAC_922X_DELL_M82),
Matt Porter403d1942005-11-29 15:00:51 +01001601 {} /* terminator */
1602};
1603
Matt Porter3cc08dc2006-01-23 15:27:49 +01001604static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02001605 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1606 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1607 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1608 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01001609};
1610
Tobin Davis93ed1502006-09-01 21:03:12 +02001611static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02001612 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1613 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1614 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1615 0x40000100, 0x40000100
1616};
1617
Tobin Davis93ed1502006-09-01 21:03:12 +02001618static unsigned int d965_5st_pin_configs[14] = {
1619 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1620 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1621 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1622 0x40000100, 0x40000100
1623};
1624
Tobin Davis4ff076e2007-08-07 11:48:12 +02001625static unsigned int dell_3st_pin_configs[14] = {
1626 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1627 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001628 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02001629 0x40c003fc, 0x40000100
1630};
1631
Tobin Davis93ed1502006-09-01 21:03:12 +02001632static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001633 [STAC_D965_REF] = ref927x_pin_configs,
1634 [STAC_D965_3ST] = d965_3st_pin_configs,
1635 [STAC_D965_5ST] = d965_5st_pin_configs,
1636 [STAC_DELL_3ST] = dell_3st_pin_configs,
1637 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01001638};
1639
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001640static const char *stac927x_models[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001641 [STAC_D965_REF] = "ref",
1642 [STAC_D965_3ST] = "3stack",
1643 [STAC_D965_5ST] = "5stack",
1644 [STAC_DELL_3ST] = "dell-3stack",
1645 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001646};
1647
1648static struct snd_pci_quirk stac927x_cfg_tbl[] = {
1649 /* SigmaTel reference board */
1650 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1651 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02001652 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001653 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
1654 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02001655 /* 965 based 3 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001656 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
1657 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
1658 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
1659 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
1660 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
1661 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
1662 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
1663 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
1664 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
1665 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
1666 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
1667 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
1668 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
1669 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
1670 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
1671 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02001672 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001673 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001674 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02001675 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
1676 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001677 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01001678 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
1679 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001680 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell ", STAC_DELL_BIOS),
1681 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
1682 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
1683 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
1684 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
1685 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02001686 /* 965 based 5 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001687 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
1688 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
1689 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
1690 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
1691 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
1692 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
1693 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
1694 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
1695 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01001696 {} /* terminator */
1697};
1698
Matt Porterf3302a52006-07-31 12:49:34 +02001699static unsigned int ref9205_pin_configs[12] = {
1700 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001701 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02001702 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02001703};
1704
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001705/*
1706 STAC 9205 pin configs for
1707 102801F1
1708 102801F2
1709 102801FC
1710 102801FD
1711 10280204
1712 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01001713 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001714*/
1715static unsigned int dell_9205_m42_pin_configs[12] = {
1716 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
1717 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
1718 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
1719};
1720
1721/*
1722 STAC 9205 pin configs for
1723 102801F9
1724 102801FA
1725 102801FE
1726 102801FF (Dell Precision M4300)
1727 10280206
1728 10280200
1729 10280201
1730*/
1731static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001732 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
1733 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
1734 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
1735};
1736
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001737static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001738 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
1739 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
1740 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
1741};
1742
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001743static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001744 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001745 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
1746 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
1747 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Matt Porterf3302a52006-07-31 12:49:34 +02001748};
1749
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001750static const char *stac9205_models[STAC_9205_MODELS] = {
1751 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001752 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001753 [STAC_9205_DELL_M43] = "dell-m43",
1754 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001755};
1756
1757static struct snd_pci_quirk stac9205_cfg_tbl[] = {
1758 /* SigmaTel reference board */
1759 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1760 "DFI LanParty", STAC_9205_REF),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001761 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
1762 "unknown Dell", STAC_9205_DELL_M42),
1763 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
1764 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001765 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02001766 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001767 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
1768 "Dell Precision", STAC_9205_DELL_M43),
1769 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
1770 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001771 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
1772 "unknown Dell", STAC_9205_DELL_M42),
1773 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
1774 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001775 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
1776 "Dell Precision", STAC_9205_DELL_M43),
1777 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001778 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001779 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
1780 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02001781 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
1782 "Dell Precision", STAC_9205_DELL_M43),
1783 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
1784 "Dell Precision", STAC_9205_DELL_M43),
1785 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
1786 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001787 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
1788 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01001789 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
1790 "Dell Vostro 1500", STAC_9205_DELL_M42),
Matt Porterf3302a52006-07-31 12:49:34 +02001791 {} /* terminator */
1792};
1793
Richard Fish11b44bb2006-08-23 18:31:34 +02001794static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
1795{
1796 int i;
1797 struct sigmatel_spec *spec = codec->spec;
1798
1799 if (! spec->bios_pin_configs) {
1800 spec->bios_pin_configs = kcalloc(spec->num_pins,
1801 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
1802 if (! spec->bios_pin_configs)
1803 return -ENOMEM;
1804 }
1805
1806 for (i = 0; i < spec->num_pins; i++) {
1807 hda_nid_t nid = spec->pin_nids[i];
1808 unsigned int pin_cfg;
1809
1810 pin_cfg = snd_hda_codec_read(codec, nid, 0,
1811 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
1812 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
1813 nid, pin_cfg);
1814 spec->bios_pin_configs[i] = pin_cfg;
1815 }
1816
1817 return 0;
1818}
1819
Matthew Ranostay87d48362007-07-17 11:52:24 +02001820static void stac92xx_set_config_reg(struct hda_codec *codec,
1821 hda_nid_t pin_nid, unsigned int pin_config)
1822{
1823 int i;
1824 snd_hda_codec_write(codec, pin_nid, 0,
1825 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
1826 pin_config & 0x000000ff);
1827 snd_hda_codec_write(codec, pin_nid, 0,
1828 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
1829 (pin_config & 0x0000ff00) >> 8);
1830 snd_hda_codec_write(codec, pin_nid, 0,
1831 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
1832 (pin_config & 0x00ff0000) >> 16);
1833 snd_hda_codec_write(codec, pin_nid, 0,
1834 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
1835 pin_config >> 24);
1836 i = snd_hda_codec_read(codec, pin_nid, 0,
1837 AC_VERB_GET_CONFIG_DEFAULT,
1838 0x00);
1839 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
1840 pin_nid, i);
1841}
1842
Matt2f2f4252005-04-13 14:45:30 +02001843static void stac92xx_set_config_regs(struct hda_codec *codec)
1844{
1845 int i;
1846 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02001847
Matthew Ranostay87d48362007-07-17 11:52:24 +02001848 if (!spec->pin_configs)
1849 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02001850
Matthew Ranostay87d48362007-07-17 11:52:24 +02001851 for (i = 0; i < spec->num_pins; i++)
1852 stac92xx_set_config_reg(codec, spec->pin_nids[i],
1853 spec->pin_configs[i]);
Matt2f2f4252005-04-13 14:45:30 +02001854}
Matt2f2f4252005-04-13 14:45:30 +02001855
Matt2f2f4252005-04-13 14:45:30 +02001856/*
1857 * Analog playback callbacks
1858 */
1859static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
1860 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001861 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02001862{
1863 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01001864 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
1865 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02001866}
1867
1868static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1869 struct hda_codec *codec,
1870 unsigned int stream_tag,
1871 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001872 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02001873{
1874 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01001875 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02001876}
1877
1878static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1879 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001880 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02001881{
1882 struct sigmatel_spec *spec = codec->spec;
1883 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1884}
1885
1886/*
Mattdabbed62005-06-14 10:19:34 +02001887 * Digital playback callbacks
1888 */
1889static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1890 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001891 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02001892{
1893 struct sigmatel_spec *spec = codec->spec;
1894 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1895}
1896
1897static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1898 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001899 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02001900{
1901 struct sigmatel_spec *spec = codec->spec;
1902 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1903}
1904
Takashi Iwai6b97eb42007-04-05 14:51:48 +02001905static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1906 struct hda_codec *codec,
1907 unsigned int stream_tag,
1908 unsigned int format,
1909 struct snd_pcm_substream *substream)
1910{
1911 struct sigmatel_spec *spec = codec->spec;
1912 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
1913 stream_tag, format, substream);
1914}
1915
Mattdabbed62005-06-14 10:19:34 +02001916
1917/*
Matt2f2f4252005-04-13 14:45:30 +02001918 * Analog capture callbacks
1919 */
1920static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1921 struct hda_codec *codec,
1922 unsigned int stream_tag,
1923 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001924 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02001925{
1926 struct sigmatel_spec *spec = codec->spec;
1927
1928 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1929 stream_tag, 0, format);
1930 return 0;
1931}
1932
1933static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1934 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001935 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02001936{
1937 struct sigmatel_spec *spec = codec->spec;
1938
Takashi Iwai888afa12008-03-18 09:57:50 +01001939 snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
Matt2f2f4252005-04-13 14:45:30 +02001940 return 0;
1941}
1942
Mattdabbed62005-06-14 10:19:34 +02001943static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
1944 .substreams = 1,
1945 .channels_min = 2,
1946 .channels_max = 2,
1947 /* NID is set in stac92xx_build_pcms */
1948 .ops = {
1949 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02001950 .close = stac92xx_dig_playback_pcm_close,
1951 .prepare = stac92xx_dig_playback_pcm_prepare
Mattdabbed62005-06-14 10:19:34 +02001952 },
1953};
1954
1955static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
1956 .substreams = 1,
1957 .channels_min = 2,
1958 .channels_max = 2,
1959 /* NID is set in stac92xx_build_pcms */
1960};
1961
Matt2f2f4252005-04-13 14:45:30 +02001962static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
1963 .substreams = 1,
1964 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02001965 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02001966 .nid = 0x02, /* NID to query formats and rates */
1967 .ops = {
1968 .open = stac92xx_playback_pcm_open,
1969 .prepare = stac92xx_playback_pcm_prepare,
1970 .cleanup = stac92xx_playback_pcm_cleanup
1971 },
1972};
1973
Matt Porter3cc08dc2006-01-23 15:27:49 +01001974static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
1975 .substreams = 1,
1976 .channels_min = 2,
1977 .channels_max = 2,
1978 .nid = 0x06, /* NID to query formats and rates */
1979 .ops = {
1980 .open = stac92xx_playback_pcm_open,
1981 .prepare = stac92xx_playback_pcm_prepare,
1982 .cleanup = stac92xx_playback_pcm_cleanup
1983 },
1984};
1985
Matt2f2f4252005-04-13 14:45:30 +02001986static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02001987 .channels_min = 2,
1988 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001989 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02001990 .ops = {
1991 .prepare = stac92xx_capture_pcm_prepare,
1992 .cleanup = stac92xx_capture_pcm_cleanup
1993 },
1994};
1995
1996static int stac92xx_build_pcms(struct hda_codec *codec)
1997{
1998 struct sigmatel_spec *spec = codec->spec;
1999 struct hda_pcm *info = spec->pcm_rec;
2000
2001 codec->num_pcms = 1;
2002 codec->pcm_info = info;
2003
Mattc7d4b2f2005-06-27 14:59:41 +02002004 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002005 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Matt2f2f4252005-04-13 14:45:30 +02002006 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002007 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002008 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002009
2010 if (spec->alt_switch) {
2011 codec->num_pcms++;
2012 info++;
2013 info->name = "STAC92xx Analog Alt";
2014 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2015 }
Matt2f2f4252005-04-13 14:45:30 +02002016
Mattdabbed62005-06-14 10:19:34 +02002017 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2018 codec->num_pcms++;
2019 info++;
2020 info->name = "STAC92xx Digital";
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002021 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Mattdabbed62005-06-14 10:19:34 +02002022 if (spec->multiout.dig_out_nid) {
2023 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2024 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2025 }
2026 if (spec->dig_in_nid) {
2027 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2028 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2029 }
2030 }
2031
Matt2f2f4252005-04-13 14:45:30 +02002032 return 0;
2033}
2034
Takashi Iwaic960a032006-03-23 17:06:28 +01002035static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2036{
2037 unsigned int pincap = snd_hda_param_read(codec, nid,
2038 AC_PAR_PIN_CAP);
2039 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2040 if (pincap & AC_PINCAP_VREF_100)
2041 return AC_PINCTL_VREF_100;
2042 if (pincap & AC_PINCAP_VREF_80)
2043 return AC_PINCTL_VREF_80;
2044 if (pincap & AC_PINCAP_VREF_50)
2045 return AC_PINCTL_VREF_50;
2046 if (pincap & AC_PINCAP_VREF_GRD)
2047 return AC_PINCTL_VREF_GRD;
2048 return 0;
2049}
2050
Matt Porter403d1942005-11-29 15:00:51 +01002051static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2052
2053{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002054 snd_hda_codec_write_cache(codec, nid, 0,
2055 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002056}
2057
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002058#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2059
2060static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2061 struct snd_ctl_elem_value *ucontrol)
2062{
2063 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2064 struct sigmatel_spec *spec = codec->spec;
2065
2066 ucontrol->value.integer.value[0] = spec->hp_switch;
2067 return 0;
2068}
2069
2070static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2071 struct snd_ctl_elem_value *ucontrol)
2072{
2073 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2074 struct sigmatel_spec *spec = codec->spec;
2075
2076 spec->hp_switch = ucontrol->value.integer.value[0];
2077
2078 /* check to be sure that the ports are upto date with
2079 * switch changes
2080 */
2081 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2082
2083 return 1;
2084}
2085
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002086#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002087
2088static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2089{
2090 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2091 struct sigmatel_spec *spec = codec->spec;
2092 int io_idx = kcontrol-> private_value & 0xff;
2093
2094 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2095 return 0;
2096}
2097
2098static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2099{
2100 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2101 struct sigmatel_spec *spec = codec->spec;
2102 hda_nid_t nid = kcontrol->private_value >> 8;
2103 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002104 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002105
2106 spec->io_switch[io_idx] = val;
2107
2108 if (val)
2109 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002110 else {
2111 unsigned int pinctl = AC_PINCTL_IN_EN;
2112 if (io_idx) /* set VREF for mic */
2113 pinctl |= stac92xx_get_vref(codec, nid);
2114 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2115 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002116
2117 /* check the auto-mute again: we need to mute/unmute the speaker
2118 * appropriately according to the pin direction
2119 */
2120 if (spec->hp_detect)
2121 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2122
Matt Porter403d1942005-11-29 15:00:51 +01002123 return 1;
2124}
2125
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002126#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2127
2128static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2129 struct snd_ctl_elem_value *ucontrol)
2130{
2131 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2132 struct sigmatel_spec *spec = codec->spec;
2133
2134 ucontrol->value.integer.value[0] = spec->clfe_swap;
2135 return 0;
2136}
2137
2138static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2139 struct snd_ctl_elem_value *ucontrol)
2140{
2141 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2142 struct sigmatel_spec *spec = codec->spec;
2143 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002144 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002145
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002146 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002147 return 0;
2148
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002149 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002150
2151 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2152 spec->clfe_swap ? 0x4 : 0x0);
2153
2154 return 1;
2155}
2156
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002157#define STAC_CODEC_HP_SWITCH(xname) \
2158 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2159 .name = xname, \
2160 .index = 0, \
2161 .info = stac92xx_hp_switch_info, \
2162 .get = stac92xx_hp_switch_get, \
2163 .put = stac92xx_hp_switch_put, \
2164 }
2165
Matt Porter403d1942005-11-29 15:00:51 +01002166#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2167 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2168 .name = xname, \
2169 .index = 0, \
2170 .info = stac92xx_io_switch_info, \
2171 .get = stac92xx_io_switch_get, \
2172 .put = stac92xx_io_switch_put, \
2173 .private_value = xpval, \
2174 }
2175
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002176#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2177 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2178 .name = xname, \
2179 .index = 0, \
2180 .info = stac92xx_clfe_switch_info, \
2181 .get = stac92xx_clfe_switch_get, \
2182 .put = stac92xx_clfe_switch_put, \
2183 .private_value = xpval, \
2184 }
Matt Porter403d1942005-11-29 15:00:51 +01002185
Mattc7d4b2f2005-06-27 14:59:41 +02002186enum {
2187 STAC_CTL_WIDGET_VOL,
2188 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002189 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002190 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002191 STAC_CTL_WIDGET_IO_SWITCH,
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002192 STAC_CTL_WIDGET_CLFE_SWITCH
Mattc7d4b2f2005-06-27 14:59:41 +02002193};
2194
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002195static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002196 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2197 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002198 STAC_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002199 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002200 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002201 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002202};
2203
2204/* add dynamic controls */
2205static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val)
2206{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002207 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002208
2209 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2210 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2211
2212 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2213 if (! knew)
2214 return -ENOMEM;
2215 if (spec->kctl_alloc) {
2216 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2217 kfree(spec->kctl_alloc);
2218 }
2219 spec->kctl_alloc = knew;
2220 spec->num_kctl_alloc = num;
2221 }
2222
2223 knew = &spec->kctl_alloc[spec->num_kctl_used];
2224 *knew = stac92xx_control_templates[type];
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002225 knew->name = kstrdup(name, GFP_KERNEL);
Mattc7d4b2f2005-06-27 14:59:41 +02002226 if (! knew->name)
2227 return -ENOMEM;
2228 knew->private_value = val;
2229 spec->num_kctl_used++;
2230 return 0;
2231}
2232
Matt Porter403d1942005-11-29 15:00:51 +01002233/* flag inputs as additional dynamic lineouts */
2234static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2235{
2236 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002237 unsigned int wcaps, wtype;
2238 int i, num_dacs = 0;
2239
2240 /* use the wcaps cache to count all DACs available for line-outs */
2241 for (i = 0; i < codec->num_nodes; i++) {
2242 wcaps = codec->wcaps[i];
2243 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002244
Steve Longerbeam7b043892007-05-03 20:50:03 +02002245 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2246 num_dacs++;
2247 }
Matt Porter403d1942005-11-29 15:00:51 +01002248
Steve Longerbeam7b043892007-05-03 20:50:03 +02002249 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2250
Matt Porter403d1942005-11-29 15:00:51 +01002251 switch (cfg->line_outs) {
2252 case 3:
2253 /* add line-in as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002254 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002255 cfg->line_out_pins[cfg->line_outs] =
2256 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002257 spec->line_switch = 1;
2258 cfg->line_outs++;
2259 }
2260 break;
2261 case 2:
2262 /* add line-in as clfe and mic as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002263 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002264 cfg->line_out_pins[cfg->line_outs] =
2265 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002266 spec->line_switch = 1;
2267 cfg->line_outs++;
2268 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002269 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002270 cfg->line_out_pins[cfg->line_outs] =
2271 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002272 spec->mic_switch = 1;
2273 cfg->line_outs++;
2274 }
2275 break;
2276 case 1:
2277 /* add line-in as surr and mic as clfe */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002278 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002279 cfg->line_out_pins[cfg->line_outs] =
2280 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002281 spec->line_switch = 1;
2282 cfg->line_outs++;
2283 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002284 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002285 cfg->line_out_pins[cfg->line_outs] =
2286 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002287 spec->mic_switch = 1;
2288 cfg->line_outs++;
2289 }
2290 break;
2291 }
2292
2293 return 0;
2294}
2295
Steve Longerbeam7b043892007-05-03 20:50:03 +02002296
2297static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2298{
2299 int i;
2300
2301 for (i = 0; i < spec->multiout.num_dacs; i++) {
2302 if (spec->multiout.dac_nids[i] == nid)
2303 return 1;
2304 }
2305
2306 return 0;
2307}
2308
Matt Porter3cc08dc2006-01-23 15:27:49 +01002309/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02002310 * Fill in the dac_nids table from the parsed pin configuration
2311 * This function only works when every pin in line_out_pins[]
2312 * contains atleast one DAC in its connection list. Some 92xx
2313 * codecs are not connected directly to a DAC, such as the 9200
2314 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002315 */
Takashi Iwai19039bd2006-06-28 15:52:16 +02002316static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaidf802952007-07-02 19:18:00 +02002317 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002318{
2319 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002320 int i, j, conn_len = 0;
2321 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2322 unsigned int wcaps, wtype;
2323
Mattc7d4b2f2005-06-27 14:59:41 +02002324 for (i = 0; i < cfg->line_outs; i++) {
2325 nid = cfg->line_out_pins[i];
Steve Longerbeam7b043892007-05-03 20:50:03 +02002326 conn_len = snd_hda_get_connections(codec, nid, conn,
2327 HDA_MAX_CONNECTIONS);
2328 for (j = 0; j < conn_len; j++) {
2329 wcaps = snd_hda_param_read(codec, conn[j],
2330 AC_PAR_AUDIO_WIDGET_CAP);
2331 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002332 if (wtype != AC_WID_AUD_OUT ||
2333 (wcaps & AC_WCAP_DIGITAL))
2334 continue;
2335 /* conn[j] is a DAC routed to this line-out */
2336 if (!is_in_dac_nids(spec, conn[j]))
2337 break;
2338 }
2339
2340 if (j == conn_len) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002341 if (spec->multiout.num_dacs > 0) {
2342 /* we have already working output pins,
2343 * so let's drop the broken ones again
2344 */
2345 cfg->line_outs = spec->multiout.num_dacs;
2346 break;
2347 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002348 /* error out, no available DAC found */
2349 snd_printk(KERN_ERR
2350 "%s: No available DAC for pin 0x%x\n",
2351 __func__, nid);
2352 return -ENODEV;
2353 }
2354
2355 spec->multiout.dac_nids[i] = conn[j];
2356 spec->multiout.num_dacs++;
2357 if (conn_len > 1) {
2358 /* select this DAC in the pin's input mux */
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002359 snd_hda_codec_write_cache(codec, nid, 0,
2360 AC_VERB_SET_CONNECT_SEL, j);
Steve Longerbeam7b043892007-05-03 20:50:03 +02002361
2362 }
Mattc7d4b2f2005-06-27 14:59:41 +02002363 }
2364
Steve Longerbeam7b043892007-05-03 20:50:03 +02002365 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2366 spec->multiout.num_dacs,
2367 spec->multiout.dac_nids[0],
2368 spec->multiout.dac_nids[1],
2369 spec->multiout.dac_nids[2],
2370 spec->multiout.dac_nids[3],
2371 spec->multiout.dac_nids[4]);
Mattc7d4b2f2005-06-27 14:59:41 +02002372 return 0;
2373}
2374
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002375/* create volume control/switch for the given prefx type */
2376static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2377{
2378 char name[32];
2379 int err;
2380
2381 sprintf(name, "%s Playback Volume", pfx);
2382 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2383 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2384 if (err < 0)
2385 return err;
2386 sprintf(name, "%s Playback Switch", pfx);
2387 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2388 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2389 if (err < 0)
2390 return err;
2391 return 0;
2392}
2393
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002394static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2395{
2396 if (!spec->multiout.hp_nid)
2397 spec->multiout.hp_nid = nid;
2398 else if (spec->multiout.num_dacs > 4) {
2399 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2400 return 1;
2401 } else {
2402 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2403 spec->multiout.num_dacs++;
2404 }
2405 return 0;
2406}
2407
2408static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2409{
2410 if (is_in_dac_nids(spec, nid))
2411 return 1;
2412 if (spec->multiout.hp_nid == nid)
2413 return 1;
2414 return 0;
2415}
2416
Mattc7d4b2f2005-06-27 14:59:41 +02002417/* add playback controls from the parsed DAC table */
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002418static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
Takashi Iwai19039bd2006-06-28 15:52:16 +02002419 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002420{
Takashi Iwai19039bd2006-06-28 15:52:16 +02002421 static const char *chname[4] = {
2422 "Front", "Surround", NULL /*CLFE*/, "Side"
2423 };
Mattc7d4b2f2005-06-27 14:59:41 +02002424 hda_nid_t nid;
2425 int i, err;
2426
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002427 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002428 unsigned int wid_caps, pincap;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002429
2430
Takashi Iwai40ac8c42008-02-29 14:16:17 +01002431 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
Matt Porter403d1942005-11-29 15:00:51 +01002432 if (!spec->multiout.dac_nids[i])
Mattc7d4b2f2005-06-27 14:59:41 +02002433 continue;
2434
2435 nid = spec->multiout.dac_nids[i];
2436
2437 if (i == 2) {
2438 /* Center/LFE */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002439 err = create_controls(spec, "Center", nid, 1);
2440 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002441 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002442 err = create_controls(spec, "LFE", nid, 2);
2443 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002444 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002445
2446 wid_caps = get_wcaps(codec, nid);
2447
2448 if (wid_caps & AC_WCAP_LR_SWAP) {
2449 err = stac92xx_add_control(spec,
2450 STAC_CTL_WIDGET_CLFE_SWITCH,
2451 "Swap Center/LFE Playback Switch", nid);
2452
2453 if (err < 0)
2454 return err;
2455 }
2456
Mattc7d4b2f2005-06-27 14:59:41 +02002457 } else {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002458 err = create_controls(spec, chname[i], nid, 3);
2459 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002460 return err;
2461 }
2462 }
2463
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002464 if (cfg->hp_outs > 1) {
2465 err = stac92xx_add_control(spec,
2466 STAC_CTL_WIDGET_HP_SWITCH,
2467 "Headphone as Line Out Switch", 0);
2468 if (err < 0)
2469 return err;
2470 }
2471
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002472 if (spec->line_switch) {
2473 nid = cfg->input_pins[AUTO_PIN_LINE];
2474 pincap = snd_hda_param_read(codec, nid,
2475 AC_PAR_PIN_CAP);
2476 if (pincap & AC_PINCAP_OUT) {
2477 err = stac92xx_add_control(spec,
2478 STAC_CTL_WIDGET_IO_SWITCH,
2479 "Line In as Output Switch", nid << 8);
2480 if (err < 0)
2481 return err;
2482 }
2483 }
Matt Porter403d1942005-11-29 15:00:51 +01002484
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002485 if (spec->mic_switch) {
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002486 unsigned int def_conf;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002487 unsigned int mic_pin = AUTO_PIN_MIC;
2488again:
2489 nid = cfg->input_pins[mic_pin];
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002490 def_conf = snd_hda_codec_read(codec, nid, 0,
2491 AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002492 /* some laptops have an internal analog microphone
2493 * which can't be used as a output */
2494 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2495 pincap = snd_hda_param_read(codec, nid,
2496 AC_PAR_PIN_CAP);
2497 if (pincap & AC_PINCAP_OUT) {
2498 err = stac92xx_add_control(spec,
2499 STAC_CTL_WIDGET_IO_SWITCH,
2500 "Mic as Output Switch", (nid << 8) | 1);
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002501 nid = snd_hda_codec_read(codec, nid, 0,
2502 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2503 if (!check_in_dac_nids(spec, nid))
2504 add_spec_dacs(spec, nid);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002505 if (err < 0)
2506 return err;
2507 }
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002508 } else if (mic_pin == AUTO_PIN_MIC) {
2509 mic_pin = AUTO_PIN_FRONT_MIC;
2510 goto again;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002511 }
2512 }
Matt Porter403d1942005-11-29 15:00:51 +01002513
Mattc7d4b2f2005-06-27 14:59:41 +02002514 return 0;
2515}
2516
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002517/* add playback controls for Speaker and HP outputs */
2518static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2519 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002520{
2521 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02002522 hda_nid_t nid;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002523 int i, old_num_dacs, err;
Mattc7d4b2f2005-06-27 14:59:41 +02002524
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002525 old_num_dacs = spec->multiout.num_dacs;
2526 for (i = 0; i < cfg->hp_outs; i++) {
2527 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2528 if (wid_caps & AC_WCAP_UNSOL_CAP)
2529 spec->hp_detect = 1;
2530 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2531 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2532 if (check_in_dac_nids(spec, nid))
2533 nid = 0;
2534 if (! nid)
Mattc7d4b2f2005-06-27 14:59:41 +02002535 continue;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002536 add_spec_dacs(spec, nid);
2537 }
2538 for (i = 0; i < cfg->speaker_outs; i++) {
Steve Longerbeam7b043892007-05-03 20:50:03 +02002539 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002540 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2541 if (check_in_dac_nids(spec, nid))
2542 nid = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002543 if (! nid)
2544 continue;
2545 add_spec_dacs(spec, nid);
Mattc7d4b2f2005-06-27 14:59:41 +02002546 }
Matthew Ranostay1b290a52007-07-12 15:17:34 +02002547 for (i = 0; i < cfg->line_outs; i++) {
2548 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2549 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2550 if (check_in_dac_nids(spec, nid))
2551 nid = 0;
2552 if (! nid)
2553 continue;
2554 add_spec_dacs(spec, nid);
2555 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002556 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2557 static const char *pfxs[] = {
2558 "Speaker", "External Speaker", "Speaker2",
2559 };
2560 err = create_controls(spec, pfxs[i - old_num_dacs],
2561 spec->multiout.dac_nids[i], 3);
2562 if (err < 0)
2563 return err;
2564 }
2565 if (spec->multiout.hp_nid) {
Takashi Iwai2626a262008-03-14 09:18:32 +01002566 err = create_controls(spec, "Headphone",
2567 spec->multiout.hp_nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002568 if (err < 0)
2569 return err;
2570 }
Mattc7d4b2f2005-06-27 14:59:41 +02002571
2572 return 0;
2573}
2574
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002575/* labels for mono mux outputs */
2576static const char *stac92xx_mono_labels[3] = {
2577 "DAC0", "DAC1", "Mixer"
2578};
2579
2580/* create mono mux for mono out on capable codecs */
2581static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
2582{
2583 struct sigmatel_spec *spec = codec->spec;
2584 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
2585 int i, num_cons;
2586 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
2587
2588 num_cons = snd_hda_get_connections(codec,
2589 spec->mono_nid,
2590 con_lst,
2591 HDA_MAX_NUM_INPUTS);
2592 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
2593 return -EINVAL;
2594
2595 for (i = 0; i < num_cons; i++) {
2596 mono_mux->items[mono_mux->num_items].label =
2597 stac92xx_mono_labels[i];
2598 mono_mux->items[mono_mux->num_items].index = i;
2599 mono_mux->num_items++;
2600 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01002601
2602 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
2603 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002604}
2605
Matt Porter8b657272006-10-26 17:12:59 +02002606/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01002607static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02002608 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
2609 "Digital Mic 3", "Digital Mic 4"
2610};
2611
2612/* create playback/capture controls for input pins on dmic capable codecs */
2613static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
2614 const struct auto_pin_cfg *cfg)
2615{
2616 struct sigmatel_spec *spec = codec->spec;
2617 struct hda_input_mux *dimux = &spec->private_dimux;
2618 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002619 int err, i, j;
2620 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02002621
2622 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
2623 dimux->items[dimux->num_items].index = 0;
2624 dimux->num_items++;
2625
2626 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002627 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02002628 int index;
2629 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002630 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02002631 unsigned int def_conf;
2632
2633 def_conf = snd_hda_codec_read(codec,
2634 spec->dmic_nids[i],
2635 0,
2636 AC_VERB_GET_CONFIG_DEFAULT,
2637 0);
2638 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
2639 continue;
2640
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002641 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02002642 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01002643 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02002644 con_lst,
2645 HDA_MAX_NUM_INPUTS);
2646 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002647 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02002648 index = j;
2649 goto found;
2650 }
2651 continue;
2652found:
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002653 wcaps = get_wcaps(codec, nid);
2654
2655 if (wcaps & AC_WCAP_OUT_AMP) {
2656 sprintf(name, "%s Capture Volume",
2657 stac92xx_dmic_labels[dimux->num_items]);
2658
2659 err = stac92xx_add_control(spec,
2660 STAC_CTL_WIDGET_VOL,
2661 name,
2662 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
2663 if (err < 0)
2664 return err;
2665 }
2666
Matt Porter8b657272006-10-26 17:12:59 +02002667 dimux->items[dimux->num_items].label =
2668 stac92xx_dmic_labels[dimux->num_items];
2669 dimux->items[dimux->num_items].index = index;
2670 dimux->num_items++;
2671 }
2672
2673 return 0;
2674}
2675
Mattc7d4b2f2005-06-27 14:59:41 +02002676/* create playback/capture controls for input pins */
2677static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
2678{
2679 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02002680 struct hda_input_mux *imux = &spec->private_imux;
2681 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
2682 int i, j, k;
2683
2684 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02002685 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02002686
Takashi Iwai314634b2006-09-21 11:56:18 +02002687 if (!cfg->input_pins[i])
2688 continue;
2689 index = -1;
2690 for (j = 0; j < spec->num_muxes; j++) {
2691 int num_cons;
2692 num_cons = snd_hda_get_connections(codec,
2693 spec->mux_nids[j],
2694 con_lst,
2695 HDA_MAX_NUM_INPUTS);
2696 for (k = 0; k < num_cons; k++)
2697 if (con_lst[k] == cfg->input_pins[i]) {
2698 index = k;
2699 goto found;
2700 }
Mattc7d4b2f2005-06-27 14:59:41 +02002701 }
Takashi Iwai314634b2006-09-21 11:56:18 +02002702 continue;
2703 found:
2704 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2705 imux->items[imux->num_items].index = index;
2706 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02002707 }
2708
Steve Longerbeam7b043892007-05-03 20:50:03 +02002709 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02002710 /*
2711 * Set the current input for the muxes.
2712 * The STAC9221 has two input muxes with identical source
2713 * NID lists. Hopefully this won't get confused.
2714 */
2715 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002716 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
2717 AC_VERB_SET_CONNECT_SEL,
2718 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02002719 }
2720 }
2721
Mattc7d4b2f2005-06-27 14:59:41 +02002722 return 0;
2723}
2724
Mattc7d4b2f2005-06-27 14:59:41 +02002725static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
2726{
2727 struct sigmatel_spec *spec = codec->spec;
2728 int i;
2729
2730 for (i = 0; i < spec->autocfg.line_outs; i++) {
2731 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2732 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2733 }
2734}
2735
2736static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
2737{
2738 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002739 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02002740
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002741 for (i = 0; i < spec->autocfg.hp_outs; i++) {
2742 hda_nid_t pin;
2743 pin = spec->autocfg.hp_pins[i];
2744 if (pin) /* connect to front */
2745 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
2746 }
2747 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
2748 hda_nid_t pin;
2749 pin = spec->autocfg.speaker_pins[i];
2750 if (pin) /* connect to front */
2751 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
2752 }
Mattc7d4b2f2005-06-27 14:59:41 +02002753}
2754
Matt Porter3cc08dc2006-01-23 15:27:49 +01002755static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
Mattc7d4b2f2005-06-27 14:59:41 +02002756{
2757 struct sigmatel_spec *spec = codec->spec;
2758 int err;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01002759 int hp_speaker_swap = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02002760
Matt Porter8b657272006-10-26 17:12:59 +02002761 if ((err = snd_hda_parse_pin_def_config(codec,
2762 &spec->autocfg,
2763 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002764 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01002765 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01002766 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02002767
Jiang Zhebcecd9b2007-11-12 12:57:03 +01002768 /* If we have no real line-out pin and multiple hp-outs, HPs should
2769 * be set up as multi-channel outputs.
2770 */
2771 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
2772 spec->autocfg.hp_outs > 1) {
2773 /* Copy hp_outs to line_outs, backup line_outs in
2774 * speaker_outs so that the following routines can handle
2775 * HP pins as primary outputs.
2776 */
2777 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
2778 sizeof(spec->autocfg.line_out_pins));
2779 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
2780 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
2781 sizeof(spec->autocfg.hp_pins));
2782 spec->autocfg.line_outs = spec->autocfg.hp_outs;
2783 hp_speaker_swap = 1;
2784 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01002785 if (spec->autocfg.mono_out_pin) {
2786 int dir = (get_wcaps(codec, spec->autocfg.mono_out_pin)
2787 & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
2788 u32 caps = query_amp_caps(codec,
2789 spec->autocfg.mono_out_pin, dir);
2790 hda_nid_t conn_list[1];
2791
2792 /* get the mixer node and then the mono mux if it exists */
2793 if (snd_hda_get_connections(codec,
2794 spec->autocfg.mono_out_pin, conn_list, 1) &&
2795 snd_hda_get_connections(codec, conn_list[0],
2796 conn_list, 1)) {
2797
2798 int wcaps = get_wcaps(codec, conn_list[0]);
2799 int wid_type = (wcaps & AC_WCAP_TYPE)
2800 >> AC_WCAP_TYPE_SHIFT;
2801 /* LR swap check, some stac925x have a mux that
2802 * changes the DACs output path instead of the
2803 * mono-mux path.
2804 */
2805 if (wid_type == AC_WID_AUD_SEL &&
2806 !(wcaps & AC_WCAP_LR_SWAP))
2807 spec->mono_nid = conn_list[0];
2808 }
2809 /* all mono outs have a least a mute/unmute switch */
2810 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
2811 "Mono Playback Switch",
2812 HDA_COMPOSE_AMP_VAL(spec->autocfg.mono_out_pin,
2813 1, 0, dir));
2814 if (err < 0)
2815 return err;
2816 /* check to see if there is volume support for the amp */
2817 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
2818 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
2819 "Mono Playback Volume",
2820 HDA_COMPOSE_AMP_VAL(spec->autocfg.mono_out_pin,
2821 1, 0, dir));
2822 if (err < 0)
2823 return err;
2824 }
2825
2826 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
2827 AC_PINCTL_OUT_EN);
2828 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01002829
Matt Porter403d1942005-11-29 15:00:51 +01002830 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
2831 return err;
Takashi Iwai19039bd2006-06-28 15:52:16 +02002832 if (spec->multiout.num_dacs == 0)
2833 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
2834 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02002835
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002836 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
2837
2838 if (err < 0)
2839 return err;
2840
Jiang Zhebcecd9b2007-11-12 12:57:03 +01002841 if (hp_speaker_swap == 1) {
2842 /* Restore the hp_outs and line_outs */
2843 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
2844 sizeof(spec->autocfg.line_out_pins));
2845 spec->autocfg.hp_outs = spec->autocfg.line_outs;
2846 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
2847 sizeof(spec->autocfg.speaker_pins));
2848 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
2849 memset(spec->autocfg.speaker_pins, 0,
2850 sizeof(spec->autocfg.speaker_pins));
2851 spec->autocfg.speaker_outs = 0;
2852 }
2853
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002854 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
2855
2856 if (err < 0)
2857 return err;
2858
2859 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
2860
2861 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002862 return err;
2863
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002864 if (spec->mono_nid > 0) {
2865 err = stac92xx_auto_create_mono_output_ctls(codec);
2866 if (err < 0)
2867 return err;
2868 }
2869
Matt Porter8b657272006-10-26 17:12:59 +02002870 if (spec->num_dmics > 0)
2871 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
2872 &spec->autocfg)) < 0)
2873 return err;
2874
Mattc7d4b2f2005-06-27 14:59:41 +02002875 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01002876 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02002877 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02002878
Takashi Iwai82bc9552006-03-21 11:24:42 +01002879 if (spec->autocfg.dig_out_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01002880 spec->multiout.dig_out_nid = dig_out;
Takashi Iwai82bc9552006-03-21 11:24:42 +01002881 if (spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01002882 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02002883
2884 if (spec->kctl_alloc)
2885 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2886
2887 spec->input_mux = &spec->private_imux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01002888 if (!spec->dinput_mux)
2889 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002890 spec->mono_mux = &spec->private_mono_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02002891
2892 return 1;
2893}
2894
Takashi Iwai82bc9552006-03-21 11:24:42 +01002895/* add playback controls for HP output */
2896static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
2897 struct auto_pin_cfg *cfg)
2898{
2899 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002900 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01002901 unsigned int wid_caps;
2902
2903 if (! pin)
2904 return 0;
2905
2906 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02002907 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01002908 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01002909
2910 return 0;
2911}
2912
Richard Fish160ea0d2006-09-06 13:58:25 +02002913/* add playback controls for LFE output */
2914static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
2915 struct auto_pin_cfg *cfg)
2916{
2917 struct sigmatel_spec *spec = codec->spec;
2918 int err;
2919 hda_nid_t lfe_pin = 0x0;
2920 int i;
2921
2922 /*
2923 * search speaker outs and line outs for a mono speaker pin
2924 * with an amp. If one is found, add LFE controls
2925 * for it.
2926 */
2927 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
2928 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01002929 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02002930 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
2931 if (wcaps == AC_WCAP_OUT_AMP)
2932 /* found a mono speaker with an amp, must be lfe */
2933 lfe_pin = pin;
2934 }
2935
2936 /* if speaker_outs is 0, then speakers may be in line_outs */
2937 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
2938 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
2939 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01002940 unsigned int defcfg;
Harvey Harrison8b551782008-02-29 11:56:48 +01002941 defcfg = snd_hda_codec_read(codec, pin, 0,
Richard Fish160ea0d2006-09-06 13:58:25 +02002942 AC_VERB_GET_CONFIG_DEFAULT,
2943 0x00);
Harvey Harrison8b551782008-02-29 11:56:48 +01002944 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01002945 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02002946 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
2947 if (wcaps == AC_WCAP_OUT_AMP)
2948 /* found a mono speaker with an amp,
2949 must be lfe */
2950 lfe_pin = pin;
2951 }
2952 }
2953 }
2954
2955 if (lfe_pin) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002956 err = create_controls(spec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02002957 if (err < 0)
2958 return err;
2959 }
2960
2961 return 0;
2962}
2963
Mattc7d4b2f2005-06-27 14:59:41 +02002964static int stac9200_parse_auto_config(struct hda_codec *codec)
2965{
2966 struct sigmatel_spec *spec = codec->spec;
2967 int err;
2968
Kailang Yangdf694da2005-12-05 19:42:22 +01002969 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002970 return err;
2971
2972 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
2973 return err;
2974
Takashi Iwai82bc9552006-03-21 11:24:42 +01002975 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
2976 return err;
2977
Richard Fish160ea0d2006-09-06 13:58:25 +02002978 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
2979 return err;
2980
Takashi Iwai82bc9552006-03-21 11:24:42 +01002981 if (spec->autocfg.dig_out_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02002982 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01002983 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02002984 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02002985
2986 if (spec->kctl_alloc)
2987 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2988
2989 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02002990 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02002991
2992 return 1;
2993}
2994
Sam Revitch62fe78e2006-05-10 15:09:17 +02002995/*
2996 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
2997 * funky external mute control using GPIO pins.
2998 */
2999
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003000static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003001 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003002{
3003 unsigned int gpiostate, gpiomask, gpiodir;
3004
3005 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3006 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003007 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003008
3009 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3010 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003011 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003012
3013 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3014 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003015 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003016
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003017 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003018 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3019
3020 snd_hda_codec_write(codec, codec->afg, 0,
3021 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003022 snd_hda_codec_read(codec, codec->afg, 0,
3023 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003024
3025 msleep(1);
3026
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003027 snd_hda_codec_read(codec, codec->afg, 0,
3028 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003029}
3030
Takashi Iwai314634b2006-09-21 11:56:18 +02003031static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3032 unsigned int event)
3033{
3034 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003035 snd_hda_codec_write_cache(codec, nid, 0,
3036 AC_VERB_SET_UNSOLICITED_ENABLE,
3037 (AC_USRSP_EN | event));
Takashi Iwai314634b2006-09-21 11:56:18 +02003038}
3039
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003040static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3041{
3042 int i;
3043 for (i = 0; i < cfg->hp_outs; i++)
3044 if (cfg->hp_pins[i] == nid)
3045 return 1; /* nid is a HP-Out */
3046
3047 return 0; /* nid is not a HP-Out */
3048};
3049
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003050static void stac92xx_power_down(struct hda_codec *codec)
3051{
3052 struct sigmatel_spec *spec = codec->spec;
3053
3054 /* power down inactive DACs */
3055 hda_nid_t *dac;
3056 for (dac = spec->dac_list; *dac; dac++)
Matthew Ranostay44510892008-02-21 07:49:31 +01003057 if (!is_in_dac_nids(spec, *dac) &&
3058 spec->multiout.hp_nid != *dac)
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003059 snd_hda_codec_write_cache(codec, *dac, 0,
3060 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3061}
3062
Mattc7d4b2f2005-06-27 14:59:41 +02003063static int stac92xx_init(struct hda_codec *codec)
3064{
3065 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003066 struct auto_pin_cfg *cfg = &spec->autocfg;
3067 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003068
Mattc7d4b2f2005-06-27 14:59:41 +02003069 snd_hda_sequence_write(codec, spec->init);
3070
Takashi Iwai82bc9552006-03-21 11:24:42 +01003071 /* set up pins */
3072 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02003073 /* Enable unsolicited responses on the HP widget */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003074 for (i = 0; i < cfg->hp_outs; i++)
Takashi Iwai314634b2006-09-21 11:56:18 +02003075 enable_pin_detect(codec, cfg->hp_pins[i],
3076 STAC_HP_EVENT);
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01003077 /* force to enable the first line-out; the others are set up
3078 * in unsol_event
3079 */
3080 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3081 AC_PINCTL_OUT_EN);
Takashi Iwaieb995a82006-09-21 14:28:21 +02003082 stac92xx_auto_init_hp_out(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003083 /* fake event to set up pins */
3084 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3085 } else {
3086 stac92xx_auto_init_multi_out(codec);
3087 stac92xx_auto_init_hp_out(codec);
3088 }
3089 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01003090 hda_nid_t nid = cfg->input_pins[i];
3091 if (nid) {
3092 unsigned int pinctl = AC_PINCTL_IN_EN;
3093 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
3094 pinctl |= stac92xx_get_vref(codec, nid);
3095 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3096 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01003097 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003098 for (i = 0; i < spec->num_dmics; i++)
3099 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3100 AC_PINCTL_IN_EN);
3101 for (i = 0; i < spec->num_pwrs; i++) {
3102 int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
3103 ? STAC_HP_EVENT : STAC_PWR_EVENT;
3104 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
3105 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003106 int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
3107 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003108 def_conf = get_defcfg_connect(def_conf);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003109 /* outputs are only ports capable of power management
3110 * any attempts on powering down a input port cause the
3111 * referenced VREF to act quirky.
3112 */
3113 if (pinctl & AC_PINCTL_IN_EN)
3114 continue;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003115 /* skip any ports that don't have jacks since presence
3116 * detection is useless */
3117 if (def_conf && def_conf != AC_JACK_PORT_FIXED)
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003118 continue;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003119 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3120 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3121 }
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003122 if (spec->dac_list)
3123 stac92xx_power_down(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003124 if (cfg->dig_out_pin)
3125 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3126 AC_PINCTL_OUT_EN);
3127 if (cfg->dig_in_pin)
3128 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3129 AC_PINCTL_IN_EN);
3130
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003131 stac_gpio_set(codec, spec->gpio_mask,
3132 spec->gpio_dir, spec->gpio_data);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003133
Mattc7d4b2f2005-06-27 14:59:41 +02003134 return 0;
3135}
3136
Matt2f2f4252005-04-13 14:45:30 +02003137static void stac92xx_free(struct hda_codec *codec)
3138{
Mattc7d4b2f2005-06-27 14:59:41 +02003139 struct sigmatel_spec *spec = codec->spec;
3140 int i;
3141
3142 if (! spec)
3143 return;
3144
3145 if (spec->kctl_alloc) {
3146 for (i = 0; i < spec->num_kctl_used; i++)
3147 kfree(spec->kctl_alloc[i].name);
3148 kfree(spec->kctl_alloc);
3149 }
3150
Richard Fish11b44bb2006-08-23 18:31:34 +02003151 if (spec->bios_pin_configs)
3152 kfree(spec->bios_pin_configs);
3153
Mattc7d4b2f2005-06-27 14:59:41 +02003154 kfree(spec);
Matt2f2f4252005-04-13 14:45:30 +02003155}
3156
Matt4e550962005-07-04 17:51:39 +02003157static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3158 unsigned int flag)
3159{
3160 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3161 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02003162
Takashi Iwaif9acba42007-05-29 18:01:06 +02003163 if (pin_ctl & AC_PINCTL_IN_EN) {
3164 /*
3165 * we need to check the current set-up direction of
3166 * shared input pins since they can be switched via
3167 * "xxx as Output" mixer switch
3168 */
3169 struct sigmatel_spec *spec = codec->spec;
3170 struct auto_pin_cfg *cfg = &spec->autocfg;
3171 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3172 spec->line_switch) ||
3173 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3174 spec->mic_switch))
3175 return;
3176 }
3177
Steve Longerbeam7b043892007-05-03 20:50:03 +02003178 /* if setting pin direction bits, clear the current
3179 direction bits first */
3180 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3181 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3182
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003183 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003184 AC_VERB_SET_PIN_WIDGET_CONTROL,
3185 pin_ctl | flag);
3186}
3187
3188static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3189 unsigned int flag)
3190{
3191 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3192 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003193 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003194 AC_VERB_SET_PIN_WIDGET_CONTROL,
3195 pin_ctl & ~flag);
3196}
3197
Jiang Zhe40c1d302007-11-12 13:05:16 +01003198static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02003199{
3200 if (!nid)
3201 return 0;
3202 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Jiang Zhe40c1d302007-11-12 13:05:16 +01003203 & (1 << 31)) {
3204 unsigned int pinctl;
3205 pinctl = snd_hda_codec_read(codec, nid, 0,
3206 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3207 if (pinctl & AC_PINCTL_IN_EN)
3208 return 0; /* mic- or line-input */
3209 else
3210 return 1; /* HP-output */
3211 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003212 return 0;
3213}
3214
3215static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
Matt4e550962005-07-04 17:51:39 +02003216{
3217 struct sigmatel_spec *spec = codec->spec;
3218 struct auto_pin_cfg *cfg = &spec->autocfg;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003219 int nid = cfg->hp_pins[cfg->hp_outs - 1];
Matt4e550962005-07-04 17:51:39 +02003220 int i, presence;
3221
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003222 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003223 if (spec->gpio_mute)
3224 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3225 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3226
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003227 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003228 if (presence)
3229 break;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003230 if (spec->hp_switch && cfg->hp_pins[i] == nid)
3231 break;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003232 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003233 }
Matt4e550962005-07-04 17:51:39 +02003234
3235 if (presence) {
3236 /* disable lineouts, enable hp */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003237 if (spec->hp_switch)
3238 stac92xx_reset_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003239 for (i = 0; i < cfg->line_outs; i++)
3240 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3241 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003242 for (i = 0; i < cfg->speaker_outs; i++)
3243 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3244 AC_PINCTL_OUT_EN);
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003245 if (spec->eapd_mask)
3246 stac_gpio_set(codec, spec->gpio_mask,
3247 spec->gpio_dir, spec->gpio_data &
3248 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003249 } else {
3250 /* enable lineouts, disable hp */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003251 if (spec->hp_switch)
3252 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003253 for (i = 0; i < cfg->line_outs; i++)
3254 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3255 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003256 for (i = 0; i < cfg->speaker_outs; i++)
3257 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3258 AC_PINCTL_OUT_EN);
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003259 if (spec->eapd_mask)
3260 stac_gpio_set(codec, spec->gpio_mask,
3261 spec->gpio_dir, spec->gpio_data |
3262 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003263 }
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003264 if (!spec->hp_switch && cfg->hp_outs > 1 && presence)
3265 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003266}
3267
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003268static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
3269{
3270 struct sigmatel_spec *spec = codec->spec;
3271 hda_nid_t nid = spec->pwr_nids[idx];
3272 int presence, val;
3273 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
3274 & 0x000000ff;
3275 presence = get_hp_pin_presence(codec, nid);
3276 idx = 1 << idx;
3277
3278 if (presence)
3279 val &= ~idx;
3280 else
3281 val |= idx;
3282
3283 /* power down unused output ports */
3284 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
3285};
3286
Takashi Iwai314634b2006-09-21 11:56:18 +02003287static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
3288{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003289 struct sigmatel_spec *spec = codec->spec;
3290 int idx = res >> 26 & 0x0f;
3291
3292 switch ((res >> 26) & 0x30) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003293 case STAC_HP_EVENT:
3294 stac92xx_hp_detect(codec, res);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003295 /* fallthru */
3296 case STAC_PWR_EVENT:
3297 if (spec->num_pwrs > 0)
3298 stac92xx_pin_sense(codec, idx);
Takashi Iwai314634b2006-09-21 11:56:18 +02003299 }
3300}
3301
Takashi Iwaicb53c622007-08-10 17:21:45 +02003302#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02003303static int stac92xx_resume(struct hda_codec *codec)
3304{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003305 struct sigmatel_spec *spec = codec->spec;
3306
Richard Fish11b44bb2006-08-23 18:31:34 +02003307 stac92xx_set_config_regs(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003308 snd_hda_sequence_write(codec, spec->init);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003309 stac_gpio_set(codec, spec->gpio_mask,
3310 spec->gpio_dir, spec->gpio_data);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003311 snd_hda_codec_resume_amp(codec);
3312 snd_hda_codec_resume_cache(codec);
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003313 /* power down inactive DACs */
3314 if (spec->dac_list)
3315 stac92xx_power_down(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003316 /* invoke unsolicited event to reset the HP state */
3317 if (spec->hp_detect)
3318 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
Mattff6fdc32005-06-27 15:06:52 +02003319 return 0;
3320}
3321#endif
3322
Matt2f2f4252005-04-13 14:45:30 +02003323static struct hda_codec_ops stac92xx_patch_ops = {
3324 .build_controls = stac92xx_build_controls,
3325 .build_pcms = stac92xx_build_pcms,
3326 .init = stac92xx_init,
3327 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02003328 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003329#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02003330 .resume = stac92xx_resume,
3331#endif
Matt2f2f4252005-04-13 14:45:30 +02003332};
3333
3334static int patch_stac9200(struct hda_codec *codec)
3335{
3336 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003337 int err;
Matt2f2f4252005-04-13 14:45:30 +02003338
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003339 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02003340 if (spec == NULL)
3341 return -ENOMEM;
3342
3343 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003344 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02003345 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003346 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
3347 stac9200_models,
3348 stac9200_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02003349 if (spec->board_config < 0) {
3350 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
3351 err = stac92xx_save_bios_config_regs(codec);
3352 if (err < 0) {
3353 stac92xx_free(codec);
3354 return err;
3355 }
3356 spec->pin_configs = spec->bios_pin_configs;
3357 } else {
Matt Porter403d1942005-11-29 15:00:51 +01003358 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
3359 stac92xx_set_config_regs(codec);
3360 }
Matt2f2f4252005-04-13 14:45:30 +02003361
3362 spec->multiout.max_channels = 2;
3363 spec->multiout.num_dacs = 1;
3364 spec->multiout.dac_nids = stac9200_dac_nids;
3365 spec->adc_nids = stac9200_adc_nids;
3366 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02003367 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02003368 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003369 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003370 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003371
Tobin Davisbf277782008-02-03 20:31:47 +01003372 if (spec->board_config == STAC_9200_GATEWAY ||
3373 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02003374 spec->init = stac9200_eapd_init;
3375 else
3376 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02003377 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02003378
Takashi Iwai117f2572008-03-18 09:53:23 +01003379 if (spec->board_config == STAC_9200_PANASONIC) {
3380 spec->gpio_mask = spec->gpio_dir = 0x09;
3381 spec->gpio_data = 0x00;
3382 }
3383
Mattc7d4b2f2005-06-27 14:59:41 +02003384 err = stac9200_parse_auto_config(codec);
3385 if (err < 0) {
3386 stac92xx_free(codec);
3387 return err;
3388 }
Matt2f2f4252005-04-13 14:45:30 +02003389
3390 codec->patch_ops = stac92xx_patch_ops;
3391
3392 return 0;
3393}
3394
Tobin Davis8e21c342007-01-08 11:04:17 +01003395static int patch_stac925x(struct hda_codec *codec)
3396{
3397 struct sigmatel_spec *spec;
3398 int err;
3399
3400 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3401 if (spec == NULL)
3402 return -ENOMEM;
3403
3404 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003405 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01003406 spec->pin_nids = stac925x_pin_nids;
3407 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
3408 stac925x_models,
3409 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01003410 again:
Tobin Davis8e21c342007-01-08 11:04:17 +01003411 if (spec->board_config < 0) {
Tobin Davis2c11f952007-05-17 09:36:34 +02003412 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
3413 "using BIOS defaults\n");
Tobin Davis8e21c342007-01-08 11:04:17 +01003414 err = stac92xx_save_bios_config_regs(codec);
3415 if (err < 0) {
3416 stac92xx_free(codec);
3417 return err;
3418 }
3419 spec->pin_configs = spec->bios_pin_configs;
3420 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
3421 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
3422 stac92xx_set_config_regs(codec);
3423 }
3424
3425 spec->multiout.max_channels = 2;
3426 spec->multiout.num_dacs = 1;
3427 spec->multiout.dac_nids = stac925x_dac_nids;
3428 spec->adc_nids = stac925x_adc_nids;
3429 spec->mux_nids = stac925x_mux_nids;
3430 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003431 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003432 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02003433 switch (codec->vendor_id) {
3434 case 0x83847632: /* STAC9202 */
3435 case 0x83847633: /* STAC9202D */
3436 case 0x83847636: /* STAC9251 */
3437 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02003438 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02003439 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01003440 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
3441 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02003442 break;
3443 default:
3444 spec->num_dmics = 0;
3445 break;
3446 }
Tobin Davis8e21c342007-01-08 11:04:17 +01003447
3448 spec->init = stac925x_core_init;
3449 spec->mixer = stac925x_mixer;
3450
3451 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01003452 if (!err) {
3453 if (spec->board_config < 0) {
3454 printk(KERN_WARNING "hda_codec: No auto-config is "
3455 "available, default to model=ref\n");
3456 spec->board_config = STAC_925x_REF;
3457 goto again;
3458 }
3459 err = -EINVAL;
3460 }
Tobin Davis8e21c342007-01-08 11:04:17 +01003461 if (err < 0) {
3462 stac92xx_free(codec);
3463 return err;
3464 }
3465
3466 codec->patch_ops = stac92xx_patch_ops;
3467
3468 return 0;
3469}
3470
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003471static struct hda_input_mux stac92hd73xx_dmux = {
3472 .num_items = 4,
3473 .items = {
3474 { "Analog Inputs", 0x0b },
3475 { "CD", 0x08 },
3476 { "Digital Mic 1", 0x09 },
3477 { "Digital Mic 2", 0x0a },
3478 }
3479};
3480
3481static int patch_stac92hd73xx(struct hda_codec *codec)
3482{
3483 struct sigmatel_spec *spec;
3484 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
3485 int err = 0;
3486
3487 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3488 if (spec == NULL)
3489 return -ENOMEM;
3490
3491 codec->spec = spec;
3492 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
3493 spec->pin_nids = stac92hd73xx_pin_nids;
3494 spec->board_config = snd_hda_check_board_config(codec,
3495 STAC_92HD73XX_MODELS,
3496 stac92hd73xx_models,
3497 stac92hd73xx_cfg_tbl);
3498again:
3499 if (spec->board_config < 0) {
3500 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3501 " STAC92HD73XX, using BIOS defaults\n");
3502 err = stac92xx_save_bios_config_regs(codec);
3503 if (err < 0) {
3504 stac92xx_free(codec);
3505 return err;
3506 }
3507 spec->pin_configs = spec->bios_pin_configs;
3508 } else {
3509 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
3510 stac92xx_set_config_regs(codec);
3511 }
3512
3513 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
3514 conn, STAC92HD73_DAC_COUNT + 2) - 1;
3515
3516 if (spec->multiout.num_dacs < 0) {
3517 printk(KERN_WARNING "hda_codec: Could not determine "
3518 "number of channels defaulting to DAC count\n");
3519 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
3520 }
3521
3522 switch (spec->multiout.num_dacs) {
3523 case 0x3: /* 6 Channel */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003524 spec->multiout.hp_nid = 0x17;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003525 spec->mixer = stac92hd73xx_6ch_mixer;
3526 spec->init = stac92hd73xx_6ch_core_init;
3527 break;
3528 case 0x4: /* 8 Channel */
3529 spec->multiout.hp_nid = 0x18;
3530 spec->mixer = stac92hd73xx_8ch_mixer;
3531 spec->init = stac92hd73xx_8ch_core_init;
3532 break;
3533 case 0x5: /* 10 Channel */
3534 spec->multiout.hp_nid = 0x19;
3535 spec->mixer = stac92hd73xx_10ch_mixer;
3536 spec->init = stac92hd73xx_10ch_core_init;
3537 };
3538
3539 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
3540 spec->aloopback_mask = 0x01;
3541 spec->aloopback_shift = 8;
3542
3543 spec->mux_nids = stac92hd73xx_mux_nids;
3544 spec->adc_nids = stac92hd73xx_adc_nids;
3545 spec->dmic_nids = stac92hd73xx_dmic_nids;
3546 spec->dmux_nids = stac92hd73xx_dmux_nids;
3547
3548 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
3549 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01003550 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003551 spec->dinput_mux = &stac92hd73xx_dmux;
3552 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003553 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003554 spec->gpio_data = 0x01;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003555
Matthew Ranostaya7662642008-02-21 07:51:14 +01003556 switch (spec->board_config) {
3557 case STAC_DELL_M6:
Matthew Ranostayd654a662008-03-14 08:46:51 +01003558 spec->init = dell_eq_core_init;
Matthew Ranostaya7662642008-02-21 07:51:14 +01003559 switch (codec->subsystem_id) {
3560 case 0x1028025e: /* Analog Mics */
3561 case 0x1028025f:
3562 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
3563 spec->num_dmics = 0;
3564 break;
Matthew Ranostayd654a662008-03-14 08:46:51 +01003565 case 0x10280271: /* Digital Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01003566 case 0x10280272:
Matthew Ranostayd654a662008-03-14 08:46:51 +01003567 spec->init = dell_m6_core_init;
3568 /* fall-through */
3569 case 0x10280254:
3570 case 0x10280255:
Matthew Ranostaya7662642008-02-21 07:51:14 +01003571 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
3572 spec->num_dmics = 1;
3573 break;
3574 case 0x10280256: /* Both */
3575 case 0x10280057:
3576 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
3577 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
3578 spec->num_dmics = 1;
3579 break;
3580 }
3581 break;
3582 default:
3583 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
3584 }
3585
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003586 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
3587 spec->pwr_nids = stac92hd73xx_pwr_nids;
3588
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003589 err = stac92xx_parse_auto_config(codec, 0x22, 0x24);
3590
3591 if (!err) {
3592 if (spec->board_config < 0) {
3593 printk(KERN_WARNING "hda_codec: No auto-config is "
3594 "available, default to model=ref\n");
3595 spec->board_config = STAC_92HD73XX_REF;
3596 goto again;
3597 }
3598 err = -EINVAL;
3599 }
3600
3601 if (err < 0) {
3602 stac92xx_free(codec);
3603 return err;
3604 }
3605
3606 codec->patch_ops = stac92xx_patch_ops;
3607
3608 return 0;
3609}
3610
Matthew Ranostaye035b842007-11-06 11:53:55 +01003611static int patch_stac92hd71bxx(struct hda_codec *codec)
3612{
3613 struct sigmatel_spec *spec;
3614 int err = 0;
3615
3616 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3617 if (spec == NULL)
3618 return -ENOMEM;
3619
3620 codec->spec = spec;
3621 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003622 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01003623 spec->pin_nids = stac92hd71bxx_pin_nids;
3624 spec->board_config = snd_hda_check_board_config(codec,
3625 STAC_92HD71BXX_MODELS,
3626 stac92hd71bxx_models,
3627 stac92hd71bxx_cfg_tbl);
3628again:
3629 if (spec->board_config < 0) {
3630 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3631 " STAC92HD71BXX, using BIOS defaults\n");
3632 err = stac92xx_save_bios_config_regs(codec);
3633 if (err < 0) {
3634 stac92xx_free(codec);
3635 return err;
3636 }
3637 spec->pin_configs = spec->bios_pin_configs;
3638 } else {
3639 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
3640 stac92xx_set_config_regs(codec);
3641 }
3642
Matthew Ranostay541eee82007-12-14 12:08:04 +01003643 switch (codec->vendor_id) {
3644 case 0x111d76b6: /* 4 Port without Analog Mixer */
3645 case 0x111d76b7:
3646 case 0x111d76b4: /* 6 Port without Analog Mixer */
3647 case 0x111d76b5:
3648 spec->mixer = stac92hd71bxx_mixer;
3649 spec->init = stac92hd71bxx_core_init;
3650 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003651 case 0x111d7608: /* 5 Port with Analog Mixer */
3652 /* no output amps */
3653 spec->num_pwrs = 0;
3654 spec->mixer = stac92hd71bxx_analog_mixer;
3655
3656 /* disable VSW */
3657 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
3658 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
3659 break;
3660 case 0x111d7603: /* 6 Port with Analog Mixer */
3661 /* no output amps */
3662 spec->num_pwrs = 0;
3663 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01003664 default:
3665 spec->mixer = stac92hd71bxx_analog_mixer;
3666 spec->init = stac92hd71bxx_analog_core_init;
3667 }
3668
3669 spec->aloopback_mask = 0x20;
3670 spec->aloopback_shift = 0;
3671
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003672 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003673 spec->gpio_mask = 0x01;
3674 spec->gpio_dir = 0x01;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003675 spec->gpio_data = 0x01;
Matthew Ranostaye035b842007-11-06 11:53:55 +01003676
Matthew Ranostaye035b842007-11-06 11:53:55 +01003677 spec->mux_nids = stac92hd71bxx_mux_nids;
3678 spec->adc_nids = stac92hd71bxx_adc_nids;
3679 spec->dmic_nids = stac92hd71bxx_dmic_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003680 spec->dmux_nids = stac92hd71bxx_dmux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003681 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01003682
3683 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
3684 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
3685 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
Takashi Iwai1697055e2007-12-18 18:05:52 +01003686 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01003687
Takashi Iwaiaea7bb02008-02-25 18:26:41 +01003688 spec->multiout.num_dacs = 1;
Matthew Ranostaye035b842007-11-06 11:53:55 +01003689 spec->multiout.hp_nid = 0x11;
3690 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
3691
3692 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
3693 if (!err) {
3694 if (spec->board_config < 0) {
3695 printk(KERN_WARNING "hda_codec: No auto-config is "
3696 "available, default to model=ref\n");
3697 spec->board_config = STAC_92HD71BXX_REF;
3698 goto again;
3699 }
3700 err = -EINVAL;
3701 }
3702
3703 if (err < 0) {
3704 stac92xx_free(codec);
3705 return err;
3706 }
3707
3708 codec->patch_ops = stac92xx_patch_ops;
3709
3710 return 0;
3711};
3712
Matt2f2f4252005-04-13 14:45:30 +02003713static int patch_stac922x(struct hda_codec *codec)
3714{
3715 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003716 int err;
Matt2f2f4252005-04-13 14:45:30 +02003717
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003718 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02003719 if (spec == NULL)
3720 return -ENOMEM;
3721
3722 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003723 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02003724 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003725 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
3726 stac922x_models,
3727 stac922x_cfg_tbl);
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02003728 if (spec->board_config == STAC_INTEL_MAC_V3) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003729 spec->gpio_mask = spec->gpio_dir = 0x03;
3730 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01003731 /* Intel Macs have all same PCI SSID, so we need to check
3732 * codec SSID to distinguish the exact models
3733 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01003734 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01003735 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02003736
3737 case 0x106b0800:
3738 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02003739 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02003740 case 0x106b0600:
3741 case 0x106b0700:
3742 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01003743 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02003744 case 0x106b0e00:
3745 case 0x106b0f00:
3746 case 0x106b1600:
3747 case 0x106b1700:
3748 case 0x106b0200:
3749 case 0x106b1e00:
3750 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01003751 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02003752 case 0x106b1a00:
3753 case 0x00000100:
3754 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02003755 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02003756 case 0x106b0a00:
3757 case 0x106b2200:
3758 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02003759 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01003760 }
3761 }
3762
Takashi Iwai9e507ab2007-02-08 17:50:10 +01003763 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02003764 if (spec->board_config < 0) {
3765 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
3766 "using BIOS defaults\n");
3767 err = stac92xx_save_bios_config_regs(codec);
3768 if (err < 0) {
3769 stac92xx_free(codec);
3770 return err;
3771 }
3772 spec->pin_configs = spec->bios_pin_configs;
3773 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
Matt Porter403d1942005-11-29 15:00:51 +01003774 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
3775 stac92xx_set_config_regs(codec);
3776 }
Matt2f2f4252005-04-13 14:45:30 +02003777
Matt2f2f4252005-04-13 14:45:30 +02003778 spec->adc_nids = stac922x_adc_nids;
3779 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01003780 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003781 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02003782 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003783 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003784
3785 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02003786 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02003787
3788 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003789
Matt Porter3cc08dc2006-01-23 15:27:49 +01003790 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01003791 if (!err) {
3792 if (spec->board_config < 0) {
3793 printk(KERN_WARNING "hda_codec: No auto-config is "
3794 "available, default to model=ref\n");
3795 spec->board_config = STAC_D945_REF;
3796 goto again;
3797 }
3798 err = -EINVAL;
3799 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01003800 if (err < 0) {
3801 stac92xx_free(codec);
3802 return err;
3803 }
3804
3805 codec->patch_ops = stac92xx_patch_ops;
3806
Takashi Iwai807a46362007-05-29 19:01:37 +02003807 /* Fix Mux capture level; max to 2 */
3808 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
3809 (0 << AC_AMPCAP_OFFSET_SHIFT) |
3810 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
3811 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
3812 (0 << AC_AMPCAP_MUTE_SHIFT));
3813
Matt Porter3cc08dc2006-01-23 15:27:49 +01003814 return 0;
3815}
3816
3817static int patch_stac927x(struct hda_codec *codec)
3818{
3819 struct sigmatel_spec *spec;
3820 int err;
3821
3822 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3823 if (spec == NULL)
3824 return -ENOMEM;
3825
3826 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003827 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02003828 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003829 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
3830 stac927x_models,
3831 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01003832 again:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003833 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
3834 if (spec->board_config < 0)
3835 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3836 "STAC927x, using BIOS defaults\n");
Richard Fish11b44bb2006-08-23 18:31:34 +02003837 err = stac92xx_save_bios_config_regs(codec);
3838 if (err < 0) {
3839 stac92xx_free(codec);
3840 return err;
3841 }
3842 spec->pin_configs = spec->bios_pin_configs;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003843 } else {
Matt Porter3cc08dc2006-01-23 15:27:49 +01003844 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
3845 stac92xx_set_config_regs(codec);
3846 }
3847
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003848 spec->adc_nids = stac927x_adc_nids;
3849 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
3850 spec->mux_nids = stac927x_mux_nids;
3851 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003852 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003853 spec->multiout.dac_nids = spec->dac_nids;
3854
Tobin Davis81d3dbd2006-08-22 19:44:45 +02003855 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02003856 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003857 case STAC_D965_5ST:
3858 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003859 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003860 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003861 spec->num_dmics = 0;
3862
Tobin Davis93ed1502006-09-01 21:03:12 +02003863 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003864 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02003865 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003866 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02003867 switch (codec->subsystem_id) {
3868 case 0x10280209:
3869 case 0x1028022e:
3870 /* correct the device field to SPDIF out */
3871 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
3872 break;
3873 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01003874 /* configure the analog microphone on some laptops */
3875 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01003876 /* correct the front output jack as a hp out */
Matthew Ranostay7989fba2008-02-21 07:50:12 +01003877 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01003878 /* correct the front input jack as a mic */
3879 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
3880 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003881 case STAC_DELL_3ST:
3882 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003883 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003884 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003885 spec->dmic_nids = stac927x_dmic_nids;
3886 spec->num_dmics = STAC927X_NUM_DMICS;
3887
Tobin Davis93ed1502006-09-01 21:03:12 +02003888 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003889 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003890 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01003891 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02003892 break;
3893 default:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003894 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003895 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003896 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003897 spec->num_dmics = 0;
3898
Tobin Davis81d3dbd2006-08-22 19:44:45 +02003899 spec->init = stac927x_core_init;
3900 spec->mixer = stac927x_mixer;
3901 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01003902
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003903 spec->num_pwrs = 0;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003904 spec->aloopback_mask = 0x40;
3905 spec->aloopback_shift = 0;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003906
Matt Porter3cc08dc2006-01-23 15:27:49 +01003907 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01003908 if (!err) {
3909 if (spec->board_config < 0) {
3910 printk(KERN_WARNING "hda_codec: No auto-config is "
3911 "available, default to model=ref\n");
3912 spec->board_config = STAC_D965_REF;
3913 goto again;
3914 }
3915 err = -EINVAL;
3916 }
Mattc7d4b2f2005-06-27 14:59:41 +02003917 if (err < 0) {
3918 stac92xx_free(codec);
3919 return err;
3920 }
Matt2f2f4252005-04-13 14:45:30 +02003921
3922 codec->patch_ops = stac92xx_patch_ops;
3923
Takashi Iwai52987652008-01-16 16:09:47 +01003924 /*
3925 * !!FIXME!!
3926 * The STAC927x seem to require fairly long delays for certain
3927 * command sequences. With too short delays (even if the answer
3928 * is set to RIRB properly), it results in the silence output
3929 * on some hardwares like Dell.
3930 *
3931 * The below flag enables the longer delay (see get_response
3932 * in hda_intel.c).
3933 */
3934 codec->bus->needs_damn_long_delay = 1;
3935
Matt2f2f4252005-04-13 14:45:30 +02003936 return 0;
3937}
3938
Matt Porterf3302a52006-07-31 12:49:34 +02003939static int patch_stac9205(struct hda_codec *codec)
3940{
3941 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02003942 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02003943
3944 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3945 if (spec == NULL)
3946 return -ENOMEM;
3947
3948 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003949 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02003950 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003951 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
3952 stac9205_models,
3953 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01003954 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02003955 if (spec->board_config < 0) {
3956 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
3957 err = stac92xx_save_bios_config_regs(codec);
3958 if (err < 0) {
3959 stac92xx_free(codec);
3960 return err;
3961 }
3962 spec->pin_configs = spec->bios_pin_configs;
3963 } else {
Matt Porterf3302a52006-07-31 12:49:34 +02003964 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
3965 stac92xx_set_config_regs(codec);
3966 }
3967
3968 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003969 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02003970 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01003971 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02003972 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02003973 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003974 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01003975 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003976 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02003977
3978 spec->init = stac9205_core_init;
3979 spec->mixer = stac9205_mixer;
3980
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003981 spec->aloopback_mask = 0x40;
3982 spec->aloopback_shift = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02003983 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02003984
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003985 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003986 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02003987 /* Enable SPDIF in/out */
3988 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
3989 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01003990
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003991 /* Enable unsol response for GPIO4/Dock HP connection */
3992 snd_hda_codec_write(codec, codec->afg, 0,
3993 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
3994 snd_hda_codec_write_cache(codec, codec->afg, 0,
3995 AC_VERB_SET_UNSOLICITED_ENABLE,
3996 (AC_USRSP_EN | STAC_HP_EVENT));
3997
3998 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003999 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004000 spec->gpio_mask = 0x1b;
4001 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01004002 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004003 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02004004 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004005 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004006 break;
4007 default:
4008 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004009 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004010 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004011 break;
4012 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02004013
Matt Porterf3302a52006-07-31 12:49:34 +02004014 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004015 if (!err) {
4016 if (spec->board_config < 0) {
4017 printk(KERN_WARNING "hda_codec: No auto-config is "
4018 "available, default to model=ref\n");
4019 spec->board_config = STAC_9205_REF;
4020 goto again;
4021 }
4022 err = -EINVAL;
4023 }
Matt Porterf3302a52006-07-31 12:49:34 +02004024 if (err < 0) {
4025 stac92xx_free(codec);
4026 return err;
4027 }
4028
4029 codec->patch_ops = stac92xx_patch_ops;
4030
4031 return 0;
4032}
4033
Matt2f2f4252005-04-13 14:45:30 +02004034/*
Guillaume Munch6d859062006-08-22 17:15:47 +02004035 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01004036 */
4037
Guillaume Munch99ccc562006-08-16 19:35:12 +02004038/* static config for Sony VAIO FE550G and Sony VAIO AR */
Takashi Iwaidb064e52006-03-16 16:04:58 +01004039static hda_nid_t vaio_dacs[] = { 0x2 };
4040#define VAIO_HP_DAC 0x5
4041static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
4042static hda_nid_t vaio_mux_nids[] = { 0x15 };
4043
4044static struct hda_input_mux vaio_mux = {
Takashi Iwaia3a2f422007-10-11 11:21:21 +02004045 .num_items = 3,
Takashi Iwaidb064e52006-03-16 16:04:58 +01004046 .items = {
Takashi Iwaid7737812006-04-25 13:05:43 +02004047 /* { "HP", 0x0 }, */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004048 { "Mic Jack", 0x1 },
4049 { "Internal Mic", 0x2 },
Takashi Iwaidb064e52006-03-16 16:04:58 +01004050 { "PCM", 0x3 },
4051 }
4052};
4053
4054static struct hda_verb vaio_init[] = {
4055 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004056 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
Takashi Iwaidb064e52006-03-16 16:04:58 +01004057 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4058 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4059 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4060 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004061 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01004062 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4063 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4064 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4065 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4066 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4067 {}
4068};
4069
Guillaume Munch6d859062006-08-22 17:15:47 +02004070static struct hda_verb vaio_ar_init[] = {
4071 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
4072 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4073 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4074 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4075/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
4076 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004077 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Guillaume Munch6d859062006-08-22 17:15:47 +02004078 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4079 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4080/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
4081 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4082 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4083 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4084 {}
4085};
4086
Takashi Iwaidb064e52006-03-16 16:04:58 +01004087/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02004088static struct hda_bind_ctls vaio_bind_master_vol = {
4089 .ops = &snd_hda_bind_vol,
4090 .values = {
4091 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4092 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4093 0
4094 },
4095};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004096
4097/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02004098static struct hda_bind_ctls vaio_bind_master_sw = {
4099 .ops = &snd_hda_bind_sw,
4100 .values = {
4101 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4102 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4103 0,
4104 },
4105};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004106
4107static struct snd_kcontrol_new vaio_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02004108 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4109 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Takashi Iwaidb064e52006-03-16 16:04:58 +01004110 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4111 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4112 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4113 {
4114 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4115 .name = "Capture Source",
4116 .count = 1,
4117 .info = stac92xx_mux_enum_info,
4118 .get = stac92xx_mux_enum_get,
4119 .put = stac92xx_mux_enum_put,
4120 },
4121 {}
4122};
4123
Guillaume Munch6d859062006-08-22 17:15:47 +02004124static struct snd_kcontrol_new vaio_ar_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02004125 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4126 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Guillaume Munch6d859062006-08-22 17:15:47 +02004127 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4128 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4129 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4130 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
4131 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
4132 {
4133 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4134 .name = "Capture Source",
4135 .count = 1,
4136 .info = stac92xx_mux_enum_info,
4137 .get = stac92xx_mux_enum_get,
4138 .put = stac92xx_mux_enum_put,
4139 },
4140 {}
4141};
4142
4143static struct hda_codec_ops stac9872_patch_ops = {
Takashi Iwaidb064e52006-03-16 16:04:58 +01004144 .build_controls = stac92xx_build_controls,
4145 .build_pcms = stac92xx_build_pcms,
4146 .init = stac92xx_init,
4147 .free = stac92xx_free,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004148#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaidb064e52006-03-16 16:04:58 +01004149 .resume = stac92xx_resume,
4150#endif
4151};
4152
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004153static int stac9872_vaio_init(struct hda_codec *codec)
4154{
4155 int err;
4156
4157 err = stac92xx_init(codec);
4158 if (err < 0)
4159 return err;
4160 if (codec->patch_ops.unsol_event)
4161 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
4162 return 0;
4163}
4164
4165static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
4166{
Jiang Zhe40c1d302007-11-12 13:05:16 +01004167 if (get_hp_pin_presence(codec, 0x0a)) {
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004168 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4169 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4170 } else {
4171 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4172 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4173 }
4174}
4175
4176static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
4177{
4178 switch (res >> 26) {
4179 case STAC_HP_EVENT:
4180 stac9872_vaio_hp_detect(codec, res);
4181 break;
4182 }
4183}
4184
4185static struct hda_codec_ops stac9872_vaio_patch_ops = {
4186 .build_controls = stac92xx_build_controls,
4187 .build_pcms = stac92xx_build_pcms,
4188 .init = stac9872_vaio_init,
4189 .free = stac92xx_free,
4190 .unsol_event = stac9872_vaio_unsol_event,
4191#ifdef CONFIG_PM
4192 .resume = stac92xx_resume,
4193#endif
4194};
4195
Guillaume Munch6d859062006-08-22 17:15:47 +02004196enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
4197 CXD9872RD_VAIO,
4198 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
4199 STAC9872AK_VAIO,
4200 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
4201 STAC9872K_VAIO,
4202 /* AR Series. id=0x83847664 and subsys=104D1300 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004203 CXD9872AKD_VAIO,
4204 STAC_9872_MODELS,
4205};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004206
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004207static const char *stac9872_models[STAC_9872_MODELS] = {
4208 [CXD9872RD_VAIO] = "vaio",
4209 [CXD9872AKD_VAIO] = "vaio-ar",
4210};
4211
4212static struct snd_pci_quirk stac9872_cfg_tbl[] = {
4213 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
4214 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
4215 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
Tobin Davis68e22542007-03-12 11:36:39 +01004216 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
Takashi Iwaidb064e52006-03-16 16:04:58 +01004217 {}
4218};
4219
Guillaume Munch6d859062006-08-22 17:15:47 +02004220static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01004221{
4222 struct sigmatel_spec *spec;
4223 int board_config;
4224
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004225 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
4226 stac9872_models,
4227 stac9872_cfg_tbl);
Takashi Iwaidb064e52006-03-16 16:04:58 +01004228 if (board_config < 0)
4229 /* unknown config, let generic-parser do its job... */
4230 return snd_hda_parse_generic_codec(codec);
4231
4232 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4233 if (spec == NULL)
4234 return -ENOMEM;
4235
4236 codec->spec = spec;
4237 switch (board_config) {
Guillaume Munch6d859062006-08-22 17:15:47 +02004238 case CXD9872RD_VAIO:
4239 case STAC9872AK_VAIO:
4240 case STAC9872K_VAIO:
Takashi Iwaidb064e52006-03-16 16:04:58 +01004241 spec->mixer = vaio_mixer;
4242 spec->init = vaio_init;
4243 spec->multiout.max_channels = 2;
4244 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
4245 spec->multiout.dac_nids = vaio_dacs;
4246 spec->multiout.hp_nid = VAIO_HP_DAC;
4247 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
4248 spec->adc_nids = vaio_adcs;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004249 spec->num_pwrs = 0;
Takashi Iwaidb064e52006-03-16 16:04:58 +01004250 spec->input_mux = &vaio_mux;
4251 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004252 codec->patch_ops = stac9872_vaio_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01004253 break;
Guillaume Munch6d859062006-08-22 17:15:47 +02004254
4255 case CXD9872AKD_VAIO:
4256 spec->mixer = vaio_ar_mixer;
4257 spec->init = vaio_ar_init;
4258 spec->multiout.max_channels = 2;
4259 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
4260 spec->multiout.dac_nids = vaio_dacs;
4261 spec->multiout.hp_nid = VAIO_HP_DAC;
4262 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004263 spec->num_pwrs = 0;
Guillaume Munch6d859062006-08-22 17:15:47 +02004264 spec->adc_nids = vaio_adcs;
4265 spec->input_mux = &vaio_mux;
4266 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004267 codec->patch_ops = stac9872_patch_ops;
Guillaume Munch6d859062006-08-22 17:15:47 +02004268 break;
Takashi Iwaidb064e52006-03-16 16:04:58 +01004269 }
4270
Takashi Iwaidb064e52006-03-16 16:04:58 +01004271 return 0;
4272}
4273
4274
4275/*
Matt2f2f4252005-04-13 14:45:30 +02004276 * patch entries
4277 */
4278struct hda_codec_preset snd_hda_preset_sigmatel[] = {
4279 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
4280 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
4281 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
4282 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
4283 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
4284 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
4285 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02004286 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
4287 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
4288 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
4289 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
4290 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
4291 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01004292 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
4293 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
4294 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
4295 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
4296 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
4297 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
4298 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
4299 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
4300 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
4301 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01004302 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
4303 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
4304 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
4305 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
4306 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
4307 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02004308 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
4309 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02004310 /* The following does not take into account .id=0x83847661 when subsys =
4311 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
4312 * currently not fully supported.
4313 */
4314 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
4315 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
4316 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02004317 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
4318 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
4319 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
4320 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
4321 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
4322 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
4323 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
4324 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004325 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
4326 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01004327 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
4328 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004329 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01004330 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
4331 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
4332 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
4333 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
4334 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
4335 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
4336 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
4337 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02004338 {} /* terminator */
4339};