blob: fac6b3ca5fe25b680dc7ff49cc0eede7158a5b9d [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"
Matthew Ranostay1cd22242008-07-18 18:20:52 +020036#include "hda_beep.h"
Matt2f2f4252005-04-13 14:45:30 +020037
Matt4e550962005-07-04 17:51:39 +020038#define NUM_CONTROL_ALLOC 32
Matthew Ranostaya64135a2008-01-10 16:55:06 +010039#define STAC_PWR_EVENT 0x20
40#define STAC_HP_EVENT 0x30
Matt4e550962005-07-04 17:51:39 +020041
Takashi Iwaif5fcc132006-11-24 17:07:44 +010042enum {
43 STAC_REF,
Tobin Davisbf277782008-02-03 20:31:47 +010044 STAC_9200_OQO,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020045 STAC_9200_DELL_D21,
46 STAC_9200_DELL_D22,
47 STAC_9200_DELL_D23,
48 STAC_9200_DELL_M21,
49 STAC_9200_DELL_M22,
50 STAC_9200_DELL_M23,
51 STAC_9200_DELL_M24,
52 STAC_9200_DELL_M25,
53 STAC_9200_DELL_M26,
54 STAC_9200_DELL_M27,
Takashi Iwai1194b5b2007-10-10 10:04:26 +020055 STAC_9200_GATEWAY,
Takashi Iwai117f2572008-03-18 09:53:23 +010056 STAC_9200_PANASONIC,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010057 STAC_9200_MODELS
58};
59
60enum {
61 STAC_9205_REF,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020062 STAC_9205_DELL_M42,
Tobin Davisae0a8ed2007-08-13 15:50:29 +020063 STAC_9205_DELL_M43,
64 STAC_9205_DELL_M44,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010065 STAC_9205_MODELS
66};
67
68enum {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010069 STAC_92HD73XX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010070 STAC_DELL_M6,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010071 STAC_92HD73XX_MODELS
72};
73
74enum {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020075 STAC_92HD83XXX_REF,
76 STAC_92HD83XXX_MODELS
77};
78
79enum {
Matthew Ranostaye035b842007-11-06 11:53:55 +010080 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010081 STAC_DELL_M4_1,
82 STAC_DELL_M4_2,
Matthew Ranostaye035b842007-11-06 11:53:55 +010083 STAC_92HD71BXX_MODELS
84};
85
86enum {
Tobin Davis8e21c342007-01-08 11:04:17 +010087 STAC_925x_REF,
88 STAC_M2_2,
89 STAC_MA6,
Tobin Davis2c11f952007-05-17 09:36:34 +020090 STAC_PA6,
Tobin Davis8e21c342007-01-08 11:04:17 +010091 STAC_925x_MODELS
92};
93
94enum {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010095 STAC_D945_REF,
96 STAC_D945GTP3,
97 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +020098 STAC_INTEL_MAC_V1,
99 STAC_INTEL_MAC_V2,
100 STAC_INTEL_MAC_V3,
101 STAC_INTEL_MAC_V4,
102 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800103 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
104 * is given, one of the above models will be
105 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200106 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100107 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100108 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100109 STAC_MACBOOK_PRO_V1,
110 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200111 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200112 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300113 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200114 STAC_922X_DELL_D81,
115 STAC_922X_DELL_D82,
116 STAC_922X_DELL_M81,
117 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100118 STAC_922X_MODELS
119};
120
121enum {
122 STAC_D965_REF,
123 STAC_D965_3ST,
124 STAC_D965_5ST,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200125 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100126 STAC_DELL_BIOS,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100127 STAC_927X_MODELS
128};
Matt Porter403d1942005-11-29 15:00:51 +0100129
Matt2f2f4252005-04-13 14:45:30 +0200130struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100131 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200132 unsigned int num_mixers;
133
Matt Porter403d1942005-11-29 15:00:51 +0100134 int board_config;
Mattc7d4b2f2005-06-27 14:59:41 +0200135 unsigned int surr_switch: 1;
Matt Porter403d1942005-11-29 15:00:51 +0100136 unsigned int line_switch: 1;
137 unsigned int mic_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100138 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100139 unsigned int hp_detect: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200140
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100141 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200142 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100143 unsigned int gpio_mask;
144 unsigned int gpio_dir;
145 unsigned int gpio_data;
146 unsigned int gpio_mute;
147
148 /* analog loopback */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100149 unsigned char aloopback_mask;
150 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200151
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100152 /* power management */
153 unsigned int num_pwrs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200154 unsigned int *pwr_mapping;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100155 hda_nid_t *pwr_nids;
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100156 hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100157
Matt2f2f4252005-04-13 14:45:30 +0200158 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100159 struct hda_input_mux *mono_mux;
160 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200161 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100162 hda_nid_t dac_nids[5];
Matt2f2f4252005-04-13 14:45:30 +0200163
164 /* capture */
165 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200166 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200167 hda_nid_t *mux_nids;
168 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200169 hda_nid_t *dmic_nids;
170 unsigned int num_dmics;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100171 hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100172 unsigned int num_dmuxes;
Mattdabbed62005-06-14 10:19:34 +0200173 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100174 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200175 hda_nid_t anabeep_nid;
176 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200177
Matt2f2f4252005-04-13 14:45:30 +0200178 /* pin widgets */
179 hda_nid_t *pin_nids;
180 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200181 unsigned int *pin_configs;
Richard Fish11b44bb2006-08-23 18:31:34 +0200182 unsigned int *bios_pin_configs;
Matt2f2f4252005-04-13 14:45:30 +0200183
184 /* codec specific stuff */
185 struct hda_verb *init;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100186 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200187
188 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200189 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100190 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200191 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100192 unsigned int cur_mux[3];
Matt2f2f4252005-04-13 14:45:30 +0200193
Matt Porter403d1942005-11-29 15:00:51 +0100194 /* i/o switches */
195 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200196 unsigned int clfe_swap;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +0200197 unsigned int hp_switch;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200198 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200199
Mattc7d4b2f2005-06-27 14:59:41 +0200200 struct hda_pcm pcm_rec[2]; /* PCM information */
201
202 /* dynamic controls and input_mux */
203 struct auto_pin_cfg autocfg;
204 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100205 struct snd_kcontrol_new *kctl_alloc;
Matt Porter8b657272006-10-26 17:12:59 +0200206 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200207 struct hda_input_mux private_imux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100208 struct hda_input_mux private_mono_mux;
Matt2f2f4252005-04-13 14:45:30 +0200209};
210
211static hda_nid_t stac9200_adc_nids[1] = {
212 0x03,
213};
214
215static hda_nid_t stac9200_mux_nids[1] = {
216 0x0c,
217};
218
219static hda_nid_t stac9200_dac_nids[1] = {
220 0x02,
221};
222
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100223static hda_nid_t stac92hd73xx_pwr_nids[8] = {
224 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
225 0x0f, 0x10, 0x11
226};
227
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100228static hda_nid_t stac92hd73xx_adc_nids[2] = {
229 0x1a, 0x1b
230};
231
232#define STAC92HD73XX_NUM_DMICS 2
233static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
234 0x13, 0x14, 0
235};
236
237#define STAC92HD73_DAC_COUNT 5
238static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
239 0x15, 0x16, 0x17, 0x18, 0x19,
240};
241
242static hda_nid_t stac92hd73xx_mux_nids[4] = {
243 0x28, 0x29, 0x2a, 0x2b,
244};
245
246static hda_nid_t stac92hd73xx_dmux_nids[2] = {
247 0x20, 0x21,
248};
249
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200250#define STAC92HD83XXX_NUM_DMICS 2
251static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
252 0x11, 0x12, 0
253};
254
255#define STAC92HD81_DAC_COUNT 2
256#define STAC92HD83_DAC_COUNT 3
257static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = {
258 0x13, 0x14, 0x22,
259};
260
261static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
262 0x17, 0x18,
263};
264
265static hda_nid_t stac92hd83xxx_adc_nids[2] = {
266 0x15, 0x16,
267};
268
269static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
270 0xa, 0xb, 0xd, 0xe,
271};
272
273static unsigned int stac92hd83xxx_pwr_mapping[4] = {
274 0x03, 0x0c, 0x10, 0x40,
275};
276
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100277static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
278 0x0a, 0x0d, 0x0f
279};
280
Matthew Ranostaye035b842007-11-06 11:53:55 +0100281static hda_nid_t stac92hd71bxx_adc_nids[2] = {
282 0x12, 0x13,
283};
284
285static hda_nid_t stac92hd71bxx_mux_nids[2] = {
286 0x1a, 0x1b
287};
288
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100289static hda_nid_t stac92hd71bxx_dmux_nids[1] = {
290 0x1c,
291};
292
Takashi Iwaiaea7bb02008-02-25 18:26:41 +0100293static hda_nid_t stac92hd71bxx_dac_nids[1] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100294 0x10, /*0x11, */
295};
296
297#define STAC92HD71BXX_NUM_DMICS 2
298static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
299 0x18, 0x19, 0
300};
301
Tobin Davis8e21c342007-01-08 11:04:17 +0100302static hda_nid_t stac925x_adc_nids[1] = {
303 0x03,
304};
305
306static hda_nid_t stac925x_mux_nids[1] = {
307 0x0f,
308};
309
310static hda_nid_t stac925x_dac_nids[1] = {
311 0x02,
312};
313
Takashi Iwaif6e98522007-10-16 14:27:04 +0200314#define STAC925X_NUM_DMICS 1
315static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
316 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200317};
318
Takashi Iwai1697055e2007-12-18 18:05:52 +0100319static hda_nid_t stac925x_dmux_nids[1] = {
320 0x14,
321};
322
Matt2f2f4252005-04-13 14:45:30 +0200323static hda_nid_t stac922x_adc_nids[2] = {
324 0x06, 0x07,
325};
326
327static hda_nid_t stac922x_mux_nids[2] = {
328 0x12, 0x13,
329};
330
Matt Porter3cc08dc2006-01-23 15:27:49 +0100331static hda_nid_t stac927x_adc_nids[3] = {
332 0x07, 0x08, 0x09
333};
334
335static hda_nid_t stac927x_mux_nids[3] = {
336 0x15, 0x16, 0x17
337};
338
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100339static hda_nid_t stac927x_dac_nids[6] = {
340 0x02, 0x03, 0x04, 0x05, 0x06, 0
341};
342
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100343static hda_nid_t stac927x_dmux_nids[1] = {
344 0x1b,
345};
346
Matthew Ranostay7f168592007-10-18 17:38:17 +0200347#define STAC927X_NUM_DMICS 2
348static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
349 0x13, 0x14, 0
350};
351
Matt Porterf3302a52006-07-31 12:49:34 +0200352static hda_nid_t stac9205_adc_nids[2] = {
353 0x12, 0x13
354};
355
356static hda_nid_t stac9205_mux_nids[2] = {
357 0x19, 0x1a
358};
359
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100360static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100361 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100362};
363
Takashi Iwaif6e98522007-10-16 14:27:04 +0200364#define STAC9205_NUM_DMICS 2
365static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
366 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200367};
368
Mattc7d4b2f2005-06-27 14:59:41 +0200369static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200370 0x08, 0x09, 0x0d, 0x0e,
371 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200372};
373
Tobin Davis8e21c342007-01-08 11:04:17 +0100374static hda_nid_t stac925x_pin_nids[8] = {
375 0x07, 0x08, 0x0a, 0x0b,
376 0x0c, 0x0d, 0x10, 0x11,
377};
378
Matt2f2f4252005-04-13 14:45:30 +0200379static hda_nid_t stac922x_pin_nids[10] = {
380 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
381 0x0f, 0x10, 0x11, 0x15, 0x1b,
382};
383
Matthew Ranostaya7662642008-02-21 07:51:14 +0100384static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100385 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
386 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostaya7662642008-02-21 07:51:14 +0100387 0x14, 0x1e, 0x22
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100388};
389
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200390static hda_nid_t stac92hd83xxx_pin_nids[14] = {
391 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
392 0x0f, 0x10, 0x11, 0x12, 0x13,
393 0x1d, 0x1e, 0x1f, 0x20
394};
Matthew Ranostaye035b842007-11-06 11:53:55 +0100395static hda_nid_t stac92hd71bxx_pin_nids[10] = {
396 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
397 0x0f, 0x14, 0x18, 0x19, 0x1e,
398};
399
Matt Porter3cc08dc2006-01-23 15:27:49 +0100400static hda_nid_t stac927x_pin_nids[14] = {
401 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
402 0x0f, 0x10, 0x11, 0x12, 0x13,
403 0x14, 0x21, 0x22, 0x23,
404};
405
Matt Porterf3302a52006-07-31 12:49:34 +0200406static hda_nid_t stac9205_pin_nids[12] = {
407 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
408 0x0f, 0x14, 0x16, 0x17, 0x18,
409 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200410};
411
Matt Porter8b657272006-10-26 17:12:59 +0200412static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
413 struct snd_ctl_elem_info *uinfo)
414{
415 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
416 struct sigmatel_spec *spec = codec->spec;
417 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
418}
419
420static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
421 struct snd_ctl_elem_value *ucontrol)
422{
423 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
424 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100425 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200426
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100427 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200428 return 0;
429}
430
431static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
432 struct snd_ctl_elem_value *ucontrol)
433{
434 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
435 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100436 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200437
438 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100439 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200440}
441
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100442static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200443{
444 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
445 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200446 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200447}
448
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100449static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200450{
451 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
452 struct sigmatel_spec *spec = codec->spec;
453 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
454
455 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
456 return 0;
457}
458
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100459static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200460{
461 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
462 struct sigmatel_spec *spec = codec->spec;
463 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
464
Mattc7d4b2f2005-06-27 14:59:41 +0200465 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200466 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
467}
468
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100469static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
470 struct snd_ctl_elem_info *uinfo)
471{
472 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
473 struct sigmatel_spec *spec = codec->spec;
474 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
475}
476
477static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
478 struct snd_ctl_elem_value *ucontrol)
479{
480 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
481 struct sigmatel_spec *spec = codec->spec;
482
483 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
484 return 0;
485}
486
487static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
488 struct snd_ctl_elem_value *ucontrol)
489{
490 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
491 struct sigmatel_spec *spec = codec->spec;
492
493 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
494 spec->mono_nid, &spec->cur_mmux);
495}
496
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200497#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
498
499static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
500 struct snd_ctl_elem_value *ucontrol)
501{
502 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100503 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200504 struct sigmatel_spec *spec = codec->spec;
505
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100506 ucontrol->value.integer.value[0] = !!(spec->aloopback &
507 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200508 return 0;
509}
510
511static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
512 struct snd_ctl_elem_value *ucontrol)
513{
514 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
515 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100516 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200517 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100518 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200519
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100520 idx_val = spec->aloopback_mask << idx;
521 if (ucontrol->value.integer.value[0])
522 val = spec->aloopback | idx_val;
523 else
524 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100525 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200526 return 0;
527
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100528 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200529
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100530 /* Only return the bits defined by the shift value of the
531 * first two bytes of the mask
532 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200533 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100534 kcontrol->private_value & 0xFFFF, 0x0);
535 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200536
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100537 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200538 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100539 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200540 } else {
541 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100542 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200543 }
544
545 snd_hda_codec_write_cache(codec, codec->afg, 0,
546 kcontrol->private_value >> 16, dac_mode);
547
548 return 1;
549}
550
Mattc7d4b2f2005-06-27 14:59:41 +0200551static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200552 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200553 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200554 {}
555};
556
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200557static struct hda_verb stac9200_eapd_init[] = {
558 /* set dac0mux for dac converter */
559 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
560 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
561 {}
562};
563
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100564static struct hda_verb stac92hd73xx_6ch_core_init[] = {
565 /* set master volume and direct control */
566 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
567 /* setup audio connections */
568 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
569 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
570 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
571 /* setup adcs to point to mixer */
572 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
573 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100574 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
575 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
576 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
577 /* setup import muxs */
578 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
579 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
580 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
581 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
582 {}
583};
584
Matthew Ranostayd654a662008-03-14 08:46:51 +0100585static struct hda_verb dell_eq_core_init[] = {
586 /* set master volume to max value without distortion
587 * and direct control */
588 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
589 /* setup audio connections */
590 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
591 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
592 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
593 /* setup adcs to point to mixer */
594 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
595 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
596 /* setup import muxs */
597 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
598 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
599 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
600 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
601 {}
602};
603
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100604static struct hda_verb dell_m6_core_init[] = {
Matthew Ranostay20f5f952008-09-01 08:17:56 +0200605 /* set master volume to max value without distortion
606 * and direct control */
607 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100608 /* setup audio connections */
Matthew Ranostay7747ecc2008-03-10 11:30:04 +0100609 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
610 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100611 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
612 /* setup adcs to point to mixer */
613 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
614 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
615 /* setup import muxs */
616 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
617 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
618 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
619 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
620 {}
621};
622
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100623static struct hda_verb stac92hd73xx_8ch_core_init[] = {
624 /* set master volume and direct control */
625 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
626 /* setup audio connections */
627 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
628 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
629 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
630 /* connect hp ports to dac3 */
631 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
632 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
633 /* setup adcs to point to mixer */
634 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
635 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100636 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
637 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
638 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
639 /* setup import muxs */
640 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
641 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
642 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
643 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
644 {}
645};
646
647static struct hda_verb stac92hd73xx_10ch_core_init[] = {
648 /* set master volume and direct control */
649 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
650 /* setup audio connections */
651 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
652 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
653 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
654 /* dac3 is connected to import3 mux */
655 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
656 /* connect hp ports to dac4 */
657 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
658 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
659 /* setup adcs to point to mixer */
660 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
661 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100662 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
663 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
664 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
665 /* setup import muxs */
666 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
667 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
668 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
669 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
670 {}
671};
672
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200673static struct hda_verb stac92hd83xxx_core_init[] = {
674 /* start of config #1 */
675 { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3},
676
677 /* start of config #2 */
678 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
679 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
680 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
681
682 /* power state controls amps */
683 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
684};
685
Matthew Ranostaye035b842007-11-06 11:53:55 +0100686static struct hda_verb stac92hd71bxx_core_init[] = {
687 /* set master volume and direct control */
688 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
689 /* connect headphone jack to dac1 */
690 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100691 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
692 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
693 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
694 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
695 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100696};
697
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200698#define HD_DISABLE_PORTF 3
Matthew Ranostay541eee82007-12-14 12:08:04 +0100699static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200700 /* start of config #1 */
701
702 /* connect port 0f to audio mixer */
703 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
704 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
705 /* unmute right and left channels for node 0x0f */
706 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
707 /* start of config #2 */
708
Matthew Ranostay541eee82007-12-14 12:08:04 +0100709 /* set master volume and direct control */
710 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
711 /* connect headphone jack to dac1 */
712 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200713 /* connect port 0d to audio mixer */
Matthew Ranostay9b359472007-11-07 13:03:12 +0100714 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostay9b359472007-11-07 13:03:12 +0100715 /* unmute dac0 input in audio mixer */
716 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200717 /* unmute right and left channels for nodes 0x0a, 0xd */
Matthew Ranostaye035b842007-11-06 11:53:55 +0100718 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
719 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100720 {}
721};
722
Tobin Davis8e21c342007-01-08 11:04:17 +0100723static struct hda_verb stac925x_core_init[] = {
724 /* set dac0mux for dac converter */
725 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
726 {}
727};
728
Mattc7d4b2f2005-06-27 14:59:41 +0200729static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200730 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200731 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200732 {}
733};
734
Tobin Davis93ed1502006-09-01 21:03:12 +0200735static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200736 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200737 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200738 /* unmute node 0x1b */
739 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
740 /* select node 0x03 as DAC */
741 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
742 {}
743};
744
Matt Porter3cc08dc2006-01-23 15:27:49 +0100745static struct hda_verb stac927x_core_init[] = {
746 /* set master volume and direct control */
747 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200748 /* enable analog pc beep path */
749 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100750 {}
751};
752
Matt Porterf3302a52006-07-31 12:49:34 +0200753static struct hda_verb stac9205_core_init[] = {
754 /* set master volume and direct control */
755 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200756 /* enable analog pc beep path */
757 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200758 {}
759};
760
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100761#define STAC_MONO_MUX \
762 { \
763 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
764 .name = "Mono Mux", \
765 .count = 1, \
766 .info = stac92xx_mono_mux_enum_info, \
767 .get = stac92xx_mono_mux_enum_get, \
768 .put = stac92xx_mono_mux_enum_put, \
769 }
770
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200771#define STAC_INPUT_SOURCE(cnt) \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200772 { \
773 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
774 .name = "Input Source", \
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200775 .count = cnt, \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200776 .info = stac92xx_mux_enum_info, \
777 .get = stac92xx_mux_enum_get, \
778 .put = stac92xx_mux_enum_put, \
779 }
780
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100781#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200782 { \
783 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
784 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100785 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200786 .info = stac92xx_aloopback_info, \
787 .get = stac92xx_aloopback_get, \
788 .put = stac92xx_aloopback_put, \
789 .private_value = verb_read | (verb_write << 16), \
790 }
791
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100792static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200793 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
794 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200795 STAC_INPUT_SOURCE(1),
Matt2f2f4252005-04-13 14:45:30 +0200796 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
797 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Mattc7d4b2f2005-06-27 14:59:41 +0200798 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200799 { } /* end */
800};
801
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100802static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100803 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
804
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100805 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
806 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
807
808 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
809 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
810
811 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
812 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
813
814 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
815 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
816
817 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
818 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
819
820 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
821 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
822
823 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
824 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
825 { } /* end */
826};
827
828static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100829 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
830
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100831 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
832 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
833
834 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
835 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
836
837 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
838 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
839
840 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
841 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
842
843 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
844 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
845
846 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
847 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
848
849 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
850 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
851 { } /* end */
852};
853
854static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100855 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
856
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100857 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
858 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
859
860 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
861 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
862
863 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
864 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
865
866 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
867 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
868
869 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
870 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
871
872 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
873 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
874
875 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
876 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
877 { } /* end */
878};
879
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200880
881static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
882 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
883 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
884
885 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
886 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
887
888 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT),
889 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
890
891 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
892 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
893
894 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
895 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
896
897 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
898 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
899
900 /*
901 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
902 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
903 */
904 { } /* end */
905};
906
Matthew Ranostay541eee82007-12-14 12:08:04 +0100907static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100908 STAC_INPUT_SOURCE(2),
Matthew Ranostaye035b842007-11-06 11:53:55 +0100909
Matthew Ranostay9b359472007-11-07 13:03:12 +0100910 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
911 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
912 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT),
913
914 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
915 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
916 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
917
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200918 /* analog pc-beep replaced with digital beep support */
919 /*
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +0200920 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
921 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200922 */
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +0200923
Matthew Ranostay9b359472007-11-07 13:03:12 +0100924 HDA_CODEC_MUTE("Analog Loopback 1", 0x17, 0x3, HDA_INPUT),
925 HDA_CODEC_MUTE("Analog Loopback 2", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +0100926 { } /* end */
927};
928
Matthew Ranostay541eee82007-12-14 12:08:04 +0100929static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +0100930 STAC_INPUT_SOURCE(2),
931 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
932
Matthew Ranostay541eee82007-12-14 12:08:04 +0100933 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
934 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
935 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT),
936
937 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
938 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
939 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
940 { } /* end */
941};
942
Tobin Davis8e21c342007-01-08 11:04:17 +0100943static struct snd_kcontrol_new stac925x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200944 STAC_INPUT_SOURCE(1),
Tobin Davis8e21c342007-01-08 11:04:17 +0100945 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +0200946 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +0100947 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0f, 0, HDA_OUTPUT),
948 { } /* end */
949};
950
Takashi Iwaid1d985f2006-11-23 19:27:12 +0100951static struct snd_kcontrol_new stac9205_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200952 STAC_INPUT_SOURCE(2),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100953 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200954
955 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
956 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
957 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x19, 0x0, HDA_OUTPUT),
958
959 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
960 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
961 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x1A, 0x0, HDA_OUTPUT),
962
963 { } /* end */
964};
965
966/* This needs to be generated dynamically based on sequence */
967static struct snd_kcontrol_new stac922x_mixer[] = {
968 STAC_INPUT_SOURCE(2),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200969 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
970 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
971 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x12, 0x0, HDA_OUTPUT),
972
973 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
974 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
975 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x13, 0x0, HDA_OUTPUT),
976 { } /* end */
977};
978
979
980static struct snd_kcontrol_new stac927x_mixer[] = {
981 STAC_INPUT_SOURCE(3),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100982 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200983
984 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
985 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
986 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x15, 0x0, HDA_OUTPUT),
987
988 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
989 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
990 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x16, 0x0, HDA_OUTPUT),
991
992 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
993 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
994 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x2, 0x17, 0x0, HDA_OUTPUT),
Matt Porterf3302a52006-07-31 12:49:34 +0200995 { } /* end */
996};
997
Takashi Iwai1697055e2007-12-18 18:05:52 +0100998static struct snd_kcontrol_new stac_dmux_mixer = {
999 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1000 .name = "Digital Input Source",
1001 /* count set later */
1002 .info = stac92xx_dmux_enum_info,
1003 .get = stac92xx_dmux_enum_get,
1004 .put = stac92xx_dmux_enum_put,
1005};
1006
Takashi Iwai2134ea42008-01-10 16:53:55 +01001007static const char *slave_vols[] = {
1008 "Front Playback Volume",
1009 "Surround Playback Volume",
1010 "Center Playback Volume",
1011 "LFE Playback Volume",
1012 "Side Playback Volume",
1013 "Headphone Playback Volume",
1014 "Headphone Playback Volume",
1015 "Speaker Playback Volume",
1016 "External Speaker Playback Volume",
1017 "Speaker2 Playback Volume",
1018 NULL
1019};
1020
1021static const char *slave_sws[] = {
1022 "Front Playback Switch",
1023 "Surround Playback Switch",
1024 "Center Playback Switch",
1025 "LFE Playback Switch",
1026 "Side Playback Switch",
1027 "Headphone Playback Switch",
1028 "Headphone Playback Switch",
1029 "Speaker Playback Switch",
1030 "External Speaker Playback Switch",
1031 "Speaker2 Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001032 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001033 NULL
1034};
1035
Matt2f2f4252005-04-13 14:45:30 +02001036static int stac92xx_build_controls(struct hda_codec *codec)
1037{
1038 struct sigmatel_spec *spec = codec->spec;
1039 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001040 int i;
Matt2f2f4252005-04-13 14:45:30 +02001041
1042 err = snd_hda_add_new_ctls(codec, spec->mixer);
1043 if (err < 0)
1044 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001045
1046 for (i = 0; i < spec->num_mixers; i++) {
1047 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1048 if (err < 0)
1049 return err;
1050 }
Takashi Iwai1697055e2007-12-18 18:05:52 +01001051 if (spec->num_dmuxes > 0) {
1052 stac_dmux_mixer.count = spec->num_dmuxes;
1053 err = snd_ctl_add(codec->bus->card,
1054 snd_ctl_new1(&stac_dmux_mixer, codec));
1055 if (err < 0)
1056 return err;
1057 }
Mattc7d4b2f2005-06-27 14:59:41 +02001058
Mattdabbed62005-06-14 10:19:34 +02001059 if (spec->multiout.dig_out_nid) {
1060 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1061 if (err < 0)
1062 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001063 err = snd_hda_create_spdif_share_sw(codec,
1064 &spec->multiout);
1065 if (err < 0)
1066 return err;
1067 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001068 }
1069 if (spec->dig_in_nid) {
1070 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1071 if (err < 0)
1072 return err;
1073 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001074
1075 /* if we have no master control, let's create it */
1076 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001077 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001078 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001079 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001080 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001081 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001082 if (err < 0)
1083 return err;
1084 }
1085 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1086 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1087 NULL, slave_sws);
1088 if (err < 0)
1089 return err;
1090 }
1091
Mattdabbed62005-06-14 10:19:34 +02001092 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001093}
1094
Matt Porter403d1942005-11-29 15:00:51 +01001095static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001096 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001097 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1098};
1099
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001100/*
1101 STAC 9200 pin configs for
1102 102801A8
1103 102801DE
1104 102801E8
1105*/
1106static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001107 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1108 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001109};
1110
1111/*
1112 STAC 9200 pin configs for
1113 102801C0
1114 102801C1
1115*/
1116static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001117 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1118 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001119};
1120
1121/*
1122 STAC 9200 pin configs for
1123 102801C4 (Dell Dimension E310)
1124 102801C5
1125 102801C7
1126 102801D9
1127 102801DA
1128 102801E3
1129*/
1130static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001131 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1132 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001133};
1134
1135
1136/*
1137 STAC 9200-32 pin configs for
1138 102801B5 (Dell Inspiron 630m)
1139 102801D8 (Dell Inspiron 640m)
1140*/
1141static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001142 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1143 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001144};
1145
1146/*
1147 STAC 9200-32 pin configs for
1148 102801C2 (Dell Latitude D620)
1149 102801C8
1150 102801CC (Dell Latitude D820)
1151 102801D4
1152 102801D6
1153*/
1154static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001155 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1156 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001157};
1158
1159/*
1160 STAC 9200-32 pin configs for
1161 102801CE (Dell XPS M1710)
1162 102801CF (Dell Precision M90)
1163*/
1164static unsigned int dell9200_m23_pin_configs[8] = {
1165 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1166 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1167};
1168
1169/*
1170 STAC 9200-32 pin configs for
1171 102801C9
1172 102801CA
1173 102801CB (Dell Latitude 120L)
1174 102801D3
1175*/
1176static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001177 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1178 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001179};
1180
1181/*
1182 STAC 9200-32 pin configs for
1183 102801BD (Dell Inspiron E1505n)
1184 102801EE
1185 102801EF
1186*/
1187static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001188 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1189 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001190};
1191
1192/*
1193 STAC 9200-32 pin configs for
1194 102801F5 (Dell Inspiron 1501)
1195 102801F6
1196*/
1197static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001198 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1199 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001200};
1201
1202/*
1203 STAC 9200-32
1204 102801CD (Dell Inspiron E1705/9400)
1205*/
1206static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001207 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1208 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001209};
1210
Tobin Davisbf277782008-02-03 20:31:47 +01001211static unsigned int oqo9200_pin_configs[8] = {
1212 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1213 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1214};
1215
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001216
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001217static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1218 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001219 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001220 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1221 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1222 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1223 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1224 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1225 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1226 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1227 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1228 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1229 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001230 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001231};
1232
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001233static const char *stac9200_models[STAC_9200_MODELS] = {
1234 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001235 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001236 [STAC_9200_DELL_D21] = "dell-d21",
1237 [STAC_9200_DELL_D22] = "dell-d22",
1238 [STAC_9200_DELL_D23] = "dell-d23",
1239 [STAC_9200_DELL_M21] = "dell-m21",
1240 [STAC_9200_DELL_M22] = "dell-m22",
1241 [STAC_9200_DELL_M23] = "dell-m23",
1242 [STAC_9200_DELL_M24] = "dell-m24",
1243 [STAC_9200_DELL_M25] = "dell-m25",
1244 [STAC_9200_DELL_M26] = "dell-m26",
1245 [STAC_9200_DELL_M27] = "dell-m27",
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001246 [STAC_9200_GATEWAY] = "gateway",
Takashi Iwai117f2572008-03-18 09:53:23 +01001247 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001248};
1249
1250static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1251 /* SigmaTel reference board */
1252 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1253 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001254 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001255 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1256 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001257 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001258 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1259 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1260 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1261 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1262 "unknown Dell", STAC_9200_DELL_D22),
1263 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1264 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001265 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001266 "Dell Latitude D620", STAC_9200_DELL_M22),
1267 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1268 "unknown Dell", STAC_9200_DELL_D23),
1269 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1270 "unknown Dell", STAC_9200_DELL_D23),
1271 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1272 "unknown Dell", STAC_9200_DELL_M22),
1273 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1274 "unknown Dell", STAC_9200_DELL_M24),
1275 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1276 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001277 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001278 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001279 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001280 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001281 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001282 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001283 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001284 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001285 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001286 "Dell Precision M90", STAC_9200_DELL_M23),
1287 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1288 "unknown Dell", STAC_9200_DELL_M22),
1289 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1290 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001291 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001292 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001293 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001294 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1295 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1296 "unknown Dell", STAC_9200_DELL_D23),
1297 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1298 "unknown Dell", STAC_9200_DELL_D23),
1299 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1300 "unknown Dell", STAC_9200_DELL_D21),
1301 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1302 "unknown Dell", STAC_9200_DELL_D23),
1303 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1304 "unknown Dell", STAC_9200_DELL_D21),
1305 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1306 "unknown Dell", STAC_9200_DELL_M25),
1307 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1308 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001309 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001310 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1311 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1312 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001313 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001314 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001315 /* Gateway machines needs EAPD to be set on resume */
1316 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1317 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1318 STAC_9200_GATEWAY),
1319 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1320 STAC_9200_GATEWAY),
Tobin Davisbf277782008-02-03 20:31:47 +01001321 /* OQO Mobile */
1322 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001323 {} /* terminator */
1324};
1325
Tobin Davis8e21c342007-01-08 11:04:17 +01001326static unsigned int ref925x_pin_configs[8] = {
1327 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001328 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001329};
1330
1331static unsigned int stac925x_MA6_pin_configs[8] = {
1332 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1333 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1334};
1335
Tobin Davis2c11f952007-05-17 09:36:34 +02001336static unsigned int stac925x_PA6_pin_configs[8] = {
1337 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1338 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1339};
1340
Tobin Davis8e21c342007-01-08 11:04:17 +01001341static unsigned int stac925xM2_2_pin_configs[8] = {
Steve Longerbeam7353e142007-05-29 14:36:17 +02001342 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1343 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001344};
1345
1346static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1347 [STAC_REF] = ref925x_pin_configs,
1348 [STAC_M2_2] = stac925xM2_2_pin_configs,
1349 [STAC_MA6] = stac925x_MA6_pin_configs,
Tobin Davis2c11f952007-05-17 09:36:34 +02001350 [STAC_PA6] = stac925x_PA6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001351};
1352
1353static const char *stac925x_models[STAC_925x_MODELS] = {
1354 [STAC_REF] = "ref",
1355 [STAC_M2_2] = "m2-2",
1356 [STAC_MA6] = "m6",
Tobin Davis2c11f952007-05-17 09:36:34 +02001357 [STAC_PA6] = "pa6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001358};
1359
1360static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1361 /* SigmaTel reference board */
1362 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001363 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Tobin Davis8e21c342007-01-08 11:04:17 +01001364 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1365 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1366 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
Tobin Davis2c11f952007-05-17 09:36:34 +02001367 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
Tobin Davis8e21c342007-01-08 11:04:17 +01001368 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1369 {} /* terminator */
1370};
1371
Matthew Ranostaya7662642008-02-21 07:51:14 +01001372static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001373 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1374 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1375 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001376 0x01452050,
1377};
1378
1379static unsigned int dell_m6_pin_configs[13] = {
1380 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001381 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001382 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1383 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001384};
1385
1386static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001387 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1388 [STAC_DELL_M6] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001389};
1390
1391static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1392 [STAC_92HD73XX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001393 [STAC_DELL_M6] = "dell-m6",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001394};
1395
1396static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1397 /* SigmaTel reference board */
1398 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001399 "DFI LanParty", STAC_92HD73XX_REF),
1400 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1401 "unknown Dell", STAC_DELL_M6),
1402 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1403 "unknown Dell", STAC_DELL_M6),
1404 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1405 "unknown Dell", STAC_DELL_M6),
1406 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1407 "unknown Dell", STAC_DELL_M6),
1408 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1409 "unknown Dell", STAC_DELL_M6),
1410 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1411 "unknown Dell", STAC_DELL_M6),
1412 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1413 "unknown Dell", STAC_DELL_M6),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001414 {} /* terminator */
1415};
1416
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001417static unsigned int ref92hd83xxx_pin_configs[14] = {
1418 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1419 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1420 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1421 0x01451160, 0x98560170,
1422};
1423
1424static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1425 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1426};
1427
1428static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1429 [STAC_92HD83XXX_REF] = "ref",
1430};
1431
1432static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1433 /* SigmaTel reference board */
1434 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1435 "DFI LanParty", STAC_92HD71BXX_REF),
1436};
1437
Matthew Ranostaye035b842007-11-06 11:53:55 +01001438static unsigned int ref92hd71bxx_pin_configs[10] = {
1439 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostayb22b4822008-01-22 12:32:30 +01001440 0x0181302e, 0x01114010, 0x01019020, 0x90a000f0,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001441 0x90a000f0, 0x01452050,
1442};
1443
Matthew Ranostayaafc4412008-06-13 18:04:33 +02001444static unsigned int dell_m4_1_pin_configs[10] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001445 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001446 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001447 0x40f000f0, 0x4f0000f0,
1448};
1449
Matthew Ranostayaafc4412008-06-13 18:04:33 +02001450static unsigned int dell_m4_2_pin_configs[10] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001451 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1452 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1453 0x40f000f0, 0x044413b0,
1454};
1455
Matthew Ranostaye035b842007-11-06 11:53:55 +01001456static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1457 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001458 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1459 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001460};
1461
1462static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1463 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001464 [STAC_DELL_M4_1] = "dell-m4-1",
1465 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001466};
1467
1468static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1469 /* SigmaTel reference board */
1470 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1471 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001472 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1473 "unknown Dell", STAC_DELL_M4_1),
1474 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1475 "unknown Dell", STAC_DELL_M4_1),
1476 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1477 "unknown Dell", STAC_DELL_M4_1),
1478 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1479 "unknown Dell", STAC_DELL_M4_1),
1480 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1481 "unknown Dell", STAC_DELL_M4_1),
1482 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1483 "unknown Dell", STAC_DELL_M4_1),
1484 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1485 "unknown Dell", STAC_DELL_M4_1),
1486 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1487 "unknown Dell", STAC_DELL_M4_2),
1488 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1489 "unknown Dell", STAC_DELL_M4_2),
1490 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1491 "unknown Dell", STAC_DELL_M4_2),
1492 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1493 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001494 {} /* terminator */
1495};
1496
Matt Porter403d1942005-11-29 15:00:51 +01001497static unsigned int ref922x_pin_configs[10] = {
1498 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1499 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001500 0x40000100, 0x40000100,
1501};
1502
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001503/*
1504 STAC 922X pin configs for
1505 102801A7
1506 102801AB
1507 102801A9
1508 102801D1
1509 102801D2
1510*/
1511static unsigned int dell_922x_d81_pin_configs[10] = {
1512 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1513 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1514 0x01813122, 0x400001f2,
1515};
1516
1517/*
1518 STAC 922X pin configs for
1519 102801AC
1520 102801D0
1521*/
1522static unsigned int dell_922x_d82_pin_configs[10] = {
1523 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1524 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1525 0x01813122, 0x400001f1,
1526};
1527
1528/*
1529 STAC 922X pin configs for
1530 102801BF
1531*/
1532static unsigned int dell_922x_m81_pin_configs[10] = {
1533 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1534 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1535 0x40C003f1, 0x405003f0,
1536};
1537
1538/*
1539 STAC 9221 A1 pin configs for
1540 102801D7 (Dell XPS M1210)
1541*/
1542static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001543 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1544 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001545 0x508003f3, 0x405003f4,
1546};
1547
Matt Porter403d1942005-11-29 15:00:51 +01001548static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001549 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001550 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1551 0x02a19120, 0x40000100,
1552};
1553
1554static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001555 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1556 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001557 0x02a19320, 0x40000100,
1558};
1559
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001560static unsigned int intel_mac_v1_pin_configs[10] = {
1561 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1562 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001563 0x400000fc, 0x400000fb,
1564};
1565
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001566static unsigned int intel_mac_v2_pin_configs[10] = {
1567 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1568 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001569 0x400000fc, 0x400000fb,
1570};
1571
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001572static unsigned int intel_mac_v3_pin_configs[10] = {
1573 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1574 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1575 0x400000fc, 0x400000fb,
1576};
1577
1578static unsigned int intel_mac_v4_pin_configs[10] = {
1579 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1580 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1581 0x400000fc, 0x400000fb,
1582};
1583
1584static unsigned int intel_mac_v5_pin_configs[10] = {
1585 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1586 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1587 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001588};
1589
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001590static unsigned int ecs202_pin_configs[10] = {
1591 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1592 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1593 0x9037012e, 0x40e000f2,
1594};
Takashi Iwai76c08822007-06-19 12:17:42 +02001595
Takashi Iwai19039bd2006-06-28 15:52:16 +02001596static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001597 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001598 [STAC_D945GTP3] = d945gtp3_pin_configs,
1599 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001600 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1601 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1602 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1603 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1604 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001605 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001606 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001607 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1608 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1609 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1610 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1611 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1612 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001613 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001614 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1615 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1616 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1617 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001618};
1619
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001620static const char *stac922x_models[STAC_922X_MODELS] = {
1621 [STAC_D945_REF] = "ref",
1622 [STAC_D945GTP5] = "5stack",
1623 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001624 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1625 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1626 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1627 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1628 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001629 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001630 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001631 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001632 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001633 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1634 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001635 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001636 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001637 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001638 [STAC_922X_DELL_D81] = "dell-d81",
1639 [STAC_922X_DELL_D82] = "dell-d82",
1640 [STAC_922X_DELL_M81] = "dell-m81",
1641 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001642};
1643
1644static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1645 /* SigmaTel reference board */
1646 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1647 "DFI LanParty", STAC_D945_REF),
1648 /* Intel 945G based systems */
1649 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1650 "Intel D945G", STAC_D945GTP3),
1651 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1652 "Intel D945G", STAC_D945GTP3),
1653 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1654 "Intel D945G", STAC_D945GTP3),
1655 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1656 "Intel D945G", STAC_D945GTP3),
1657 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1658 "Intel D945G", STAC_D945GTP3),
1659 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1660 "Intel D945G", STAC_D945GTP3),
1661 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1662 "Intel D945G", STAC_D945GTP3),
1663 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1664 "Intel D945G", STAC_D945GTP3),
1665 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1666 "Intel D945G", STAC_D945GTP3),
1667 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1668 "Intel D945G", STAC_D945GTP3),
1669 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1670 "Intel D945G", STAC_D945GTP3),
1671 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1672 "Intel D945G", STAC_D945GTP3),
1673 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1674 "Intel D945G", STAC_D945GTP3),
1675 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1676 "Intel D945G", STAC_D945GTP3),
1677 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1678 "Intel D945G", STAC_D945GTP3),
1679 /* Intel D945G 5-stack systems */
1680 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1681 "Intel D945G", STAC_D945GTP5),
1682 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1683 "Intel D945G", STAC_D945GTP5),
1684 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1685 "Intel D945G", STAC_D945GTP5),
1686 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1687 "Intel D945G", STAC_D945GTP5),
1688 /* Intel 945P based systems */
1689 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1690 "Intel D945P", STAC_D945GTP3),
1691 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1692 "Intel D945P", STAC_D945GTP3),
1693 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1694 "Intel D945P", STAC_D945GTP3),
1695 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1696 "Intel D945P", STAC_D945GTP3),
1697 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1698 "Intel D945P", STAC_D945GTP3),
1699 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1700 "Intel D945P", STAC_D945GTP5),
1701 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08001702 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001703 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001704 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001705 /* Dell systems */
1706 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1707 "unknown Dell", STAC_922X_DELL_D81),
1708 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1709 "unknown Dell", STAC_922X_DELL_D81),
1710 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1711 "unknown Dell", STAC_922X_DELL_D81),
1712 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1713 "unknown Dell", STAC_922X_DELL_D82),
1714 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1715 "unknown Dell", STAC_922X_DELL_M81),
1716 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1717 "unknown Dell", STAC_922X_DELL_D82),
1718 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1719 "unknown Dell", STAC_922X_DELL_D81),
1720 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1721 "unknown Dell", STAC_922X_DELL_D81),
1722 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1723 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001724 /* ECS/PC Chips boards */
1725 SND_PCI_QUIRK(0x1019, 0x2144,
1726 "ECS/PC chips", STAC_ECS_202),
1727 SND_PCI_QUIRK(0x1019, 0x2608,
1728 "ECS/PC chips", STAC_ECS_202),
1729 SND_PCI_QUIRK(0x1019, 0x2633,
1730 "ECS/PC chips P17G/1333", STAC_ECS_202),
1731 SND_PCI_QUIRK(0x1019, 0x2811,
1732 "ECS/PC chips", STAC_ECS_202),
1733 SND_PCI_QUIRK(0x1019, 0x2812,
1734 "ECS/PC chips", STAC_ECS_202),
1735 SND_PCI_QUIRK(0x1019, 0x2813,
1736 "ECS/PC chips", STAC_ECS_202),
1737 SND_PCI_QUIRK(0x1019, 0x2814,
1738 "ECS/PC chips", STAC_ECS_202),
1739 SND_PCI_QUIRK(0x1019, 0x2815,
1740 "ECS/PC chips", STAC_ECS_202),
1741 SND_PCI_QUIRK(0x1019, 0x2816,
1742 "ECS/PC chips", STAC_ECS_202),
1743 SND_PCI_QUIRK(0x1019, 0x2817,
1744 "ECS/PC chips", STAC_ECS_202),
1745 SND_PCI_QUIRK(0x1019, 0x2818,
1746 "ECS/PC chips", STAC_ECS_202),
1747 SND_PCI_QUIRK(0x1019, 0x2819,
1748 "ECS/PC chips", STAC_ECS_202),
1749 SND_PCI_QUIRK(0x1019, 0x2820,
1750 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01001751 {} /* terminator */
1752};
1753
Matt Porter3cc08dc2006-01-23 15:27:49 +01001754static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02001755 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1756 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1757 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1758 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01001759};
1760
Tobin Davis93ed1502006-09-01 21:03:12 +02001761static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02001762 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1763 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1764 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1765 0x40000100, 0x40000100
1766};
1767
Tobin Davis93ed1502006-09-01 21:03:12 +02001768static unsigned int d965_5st_pin_configs[14] = {
1769 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1770 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1771 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1772 0x40000100, 0x40000100
1773};
1774
Tobin Davis4ff076e2007-08-07 11:48:12 +02001775static unsigned int dell_3st_pin_configs[14] = {
1776 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1777 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001778 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02001779 0x40c003fc, 0x40000100
1780};
1781
Tobin Davis93ed1502006-09-01 21:03:12 +02001782static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001783 [STAC_D965_REF] = ref927x_pin_configs,
1784 [STAC_D965_3ST] = d965_3st_pin_configs,
1785 [STAC_D965_5ST] = d965_5st_pin_configs,
1786 [STAC_DELL_3ST] = dell_3st_pin_configs,
1787 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01001788};
1789
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001790static const char *stac927x_models[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001791 [STAC_D965_REF] = "ref",
1792 [STAC_D965_3ST] = "3stack",
1793 [STAC_D965_5ST] = "5stack",
1794 [STAC_DELL_3ST] = "dell-3stack",
1795 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001796};
1797
1798static struct snd_pci_quirk stac927x_cfg_tbl[] = {
1799 /* SigmaTel reference board */
1800 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1801 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02001802 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001803 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
1804 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02001805 /* 965 based 3 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001806 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
1807 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
1808 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
1809 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
1810 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
1811 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
1812 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
1813 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
1814 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
1815 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
1816 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
1817 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
1818 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
1819 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
1820 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
1821 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02001822 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001823 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001824 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02001825 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
1826 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001827 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01001828 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
1829 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001830 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02001831 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001832 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
1833 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
1834 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
1835 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02001836 /* 965 based 5 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001837 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
1838 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
1839 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
1840 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
1841 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
1842 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
1843 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
1844 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
1845 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01001846 {} /* terminator */
1847};
1848
Matt Porterf3302a52006-07-31 12:49:34 +02001849static unsigned int ref9205_pin_configs[12] = {
1850 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001851 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02001852 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02001853};
1854
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001855/*
1856 STAC 9205 pin configs for
1857 102801F1
1858 102801F2
1859 102801FC
1860 102801FD
1861 10280204
1862 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01001863 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001864*/
1865static unsigned int dell_9205_m42_pin_configs[12] = {
1866 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
1867 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
1868 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
1869};
1870
1871/*
1872 STAC 9205 pin configs for
1873 102801F9
1874 102801FA
1875 102801FE
1876 102801FF (Dell Precision M4300)
1877 10280206
1878 10280200
1879 10280201
1880*/
1881static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001882 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
1883 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
1884 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
1885};
1886
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001887static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001888 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
1889 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
1890 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
1891};
1892
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001893static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001894 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001895 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
1896 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
1897 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Matt Porterf3302a52006-07-31 12:49:34 +02001898};
1899
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001900static const char *stac9205_models[STAC_9205_MODELS] = {
1901 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001902 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001903 [STAC_9205_DELL_M43] = "dell-m43",
1904 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001905};
1906
1907static struct snd_pci_quirk stac9205_cfg_tbl[] = {
1908 /* SigmaTel reference board */
1909 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1910 "DFI LanParty", STAC_9205_REF),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001911 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
1912 "unknown Dell", STAC_9205_DELL_M42),
1913 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
1914 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001915 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02001916 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001917 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
1918 "Dell Precision", STAC_9205_DELL_M43),
1919 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
1920 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001921 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
1922 "unknown Dell", STAC_9205_DELL_M42),
1923 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
1924 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001925 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
1926 "Dell Precision", STAC_9205_DELL_M43),
1927 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001928 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001929 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
1930 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02001931 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
1932 "Dell Precision", STAC_9205_DELL_M43),
1933 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
1934 "Dell Precision", STAC_9205_DELL_M43),
1935 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
1936 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001937 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
1938 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01001939 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
1940 "Dell Vostro 1500", STAC_9205_DELL_M42),
Matt Porterf3302a52006-07-31 12:49:34 +02001941 {} /* terminator */
1942};
1943
Richard Fish11b44bb2006-08-23 18:31:34 +02001944static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
1945{
1946 int i;
1947 struct sigmatel_spec *spec = codec->spec;
1948
1949 if (! spec->bios_pin_configs) {
1950 spec->bios_pin_configs = kcalloc(spec->num_pins,
1951 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
1952 if (! spec->bios_pin_configs)
1953 return -ENOMEM;
1954 }
1955
1956 for (i = 0; i < spec->num_pins; i++) {
1957 hda_nid_t nid = spec->pin_nids[i];
1958 unsigned int pin_cfg;
1959
1960 pin_cfg = snd_hda_codec_read(codec, nid, 0,
1961 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
1962 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
1963 nid, pin_cfg);
1964 spec->bios_pin_configs[i] = pin_cfg;
1965 }
1966
1967 return 0;
1968}
1969
Matthew Ranostay87d48362007-07-17 11:52:24 +02001970static void stac92xx_set_config_reg(struct hda_codec *codec,
1971 hda_nid_t pin_nid, unsigned int pin_config)
1972{
1973 int i;
1974 snd_hda_codec_write(codec, pin_nid, 0,
1975 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
1976 pin_config & 0x000000ff);
1977 snd_hda_codec_write(codec, pin_nid, 0,
1978 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
1979 (pin_config & 0x0000ff00) >> 8);
1980 snd_hda_codec_write(codec, pin_nid, 0,
1981 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
1982 (pin_config & 0x00ff0000) >> 16);
1983 snd_hda_codec_write(codec, pin_nid, 0,
1984 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
1985 pin_config >> 24);
1986 i = snd_hda_codec_read(codec, pin_nid, 0,
1987 AC_VERB_GET_CONFIG_DEFAULT,
1988 0x00);
1989 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
1990 pin_nid, i);
1991}
1992
Matt2f2f4252005-04-13 14:45:30 +02001993static void stac92xx_set_config_regs(struct hda_codec *codec)
1994{
1995 int i;
1996 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02001997
Matthew Ranostay87d48362007-07-17 11:52:24 +02001998 if (!spec->pin_configs)
1999 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002000
Matthew Ranostay87d48362007-07-17 11:52:24 +02002001 for (i = 0; i < spec->num_pins; i++)
2002 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2003 spec->pin_configs[i]);
Matt2f2f4252005-04-13 14:45:30 +02002004}
Matt2f2f4252005-04-13 14:45:30 +02002005
Matt2f2f4252005-04-13 14:45:30 +02002006/*
2007 * Analog playback callbacks
2008 */
2009static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2010 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002011 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002012{
2013 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01002014 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2015 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002016}
2017
2018static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2019 struct hda_codec *codec,
2020 unsigned int stream_tag,
2021 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002022 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002023{
2024 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002025 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002026}
2027
2028static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2029 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002030 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002031{
2032 struct sigmatel_spec *spec = codec->spec;
2033 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2034}
2035
2036/*
Mattdabbed62005-06-14 10:19:34 +02002037 * Digital playback callbacks
2038 */
2039static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2040 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002041 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002042{
2043 struct sigmatel_spec *spec = codec->spec;
2044 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2045}
2046
2047static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2048 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002049 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002050{
2051 struct sigmatel_spec *spec = codec->spec;
2052 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2053}
2054
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002055static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2056 struct hda_codec *codec,
2057 unsigned int stream_tag,
2058 unsigned int format,
2059 struct snd_pcm_substream *substream)
2060{
2061 struct sigmatel_spec *spec = codec->spec;
2062 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2063 stream_tag, format, substream);
2064}
2065
Mattdabbed62005-06-14 10:19:34 +02002066
2067/*
Matt2f2f4252005-04-13 14:45:30 +02002068 * Analog capture callbacks
2069 */
2070static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2071 struct hda_codec *codec,
2072 unsigned int stream_tag,
2073 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002074 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002075{
2076 struct sigmatel_spec *spec = codec->spec;
2077
2078 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2079 stream_tag, 0, format);
2080 return 0;
2081}
2082
2083static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2084 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002085 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002086{
2087 struct sigmatel_spec *spec = codec->spec;
2088
Takashi Iwai888afa12008-03-18 09:57:50 +01002089 snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
Matt2f2f4252005-04-13 14:45:30 +02002090 return 0;
2091}
2092
Mattdabbed62005-06-14 10:19:34 +02002093static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2094 .substreams = 1,
2095 .channels_min = 2,
2096 .channels_max = 2,
2097 /* NID is set in stac92xx_build_pcms */
2098 .ops = {
2099 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002100 .close = stac92xx_dig_playback_pcm_close,
2101 .prepare = stac92xx_dig_playback_pcm_prepare
Mattdabbed62005-06-14 10:19:34 +02002102 },
2103};
2104
2105static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2106 .substreams = 1,
2107 .channels_min = 2,
2108 .channels_max = 2,
2109 /* NID is set in stac92xx_build_pcms */
2110};
2111
Matt2f2f4252005-04-13 14:45:30 +02002112static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2113 .substreams = 1,
2114 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002115 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002116 .nid = 0x02, /* NID to query formats and rates */
2117 .ops = {
2118 .open = stac92xx_playback_pcm_open,
2119 .prepare = stac92xx_playback_pcm_prepare,
2120 .cleanup = stac92xx_playback_pcm_cleanup
2121 },
2122};
2123
Matt Porter3cc08dc2006-01-23 15:27:49 +01002124static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2125 .substreams = 1,
2126 .channels_min = 2,
2127 .channels_max = 2,
2128 .nid = 0x06, /* NID to query formats and rates */
2129 .ops = {
2130 .open = stac92xx_playback_pcm_open,
2131 .prepare = stac92xx_playback_pcm_prepare,
2132 .cleanup = stac92xx_playback_pcm_cleanup
2133 },
2134};
2135
Matt2f2f4252005-04-13 14:45:30 +02002136static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002137 .channels_min = 2,
2138 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002139 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002140 .ops = {
2141 .prepare = stac92xx_capture_pcm_prepare,
2142 .cleanup = stac92xx_capture_pcm_cleanup
2143 },
2144};
2145
2146static int stac92xx_build_pcms(struct hda_codec *codec)
2147{
2148 struct sigmatel_spec *spec = codec->spec;
2149 struct hda_pcm *info = spec->pcm_rec;
2150
2151 codec->num_pcms = 1;
2152 codec->pcm_info = info;
2153
Mattc7d4b2f2005-06-27 14:59:41 +02002154 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002155 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Matt2f2f4252005-04-13 14:45:30 +02002156 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002157 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002158 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002159
2160 if (spec->alt_switch) {
2161 codec->num_pcms++;
2162 info++;
2163 info->name = "STAC92xx Analog Alt";
2164 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2165 }
Matt2f2f4252005-04-13 14:45:30 +02002166
Mattdabbed62005-06-14 10:19:34 +02002167 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2168 codec->num_pcms++;
2169 info++;
2170 info->name = "STAC92xx Digital";
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002171 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Mattdabbed62005-06-14 10:19:34 +02002172 if (spec->multiout.dig_out_nid) {
2173 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2174 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2175 }
2176 if (spec->dig_in_nid) {
2177 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2178 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2179 }
2180 }
2181
Matt2f2f4252005-04-13 14:45:30 +02002182 return 0;
2183}
2184
Takashi Iwaic960a032006-03-23 17:06:28 +01002185static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2186{
2187 unsigned int pincap = snd_hda_param_read(codec, nid,
2188 AC_PAR_PIN_CAP);
2189 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2190 if (pincap & AC_PINCAP_VREF_100)
2191 return AC_PINCTL_VREF_100;
2192 if (pincap & AC_PINCAP_VREF_80)
2193 return AC_PINCTL_VREF_80;
2194 if (pincap & AC_PINCAP_VREF_50)
2195 return AC_PINCTL_VREF_50;
2196 if (pincap & AC_PINCAP_VREF_GRD)
2197 return AC_PINCTL_VREF_GRD;
2198 return 0;
2199}
2200
Matt Porter403d1942005-11-29 15:00:51 +01002201static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2202
2203{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002204 snd_hda_codec_write_cache(codec, nid, 0,
2205 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002206}
2207
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002208#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2209
2210static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2211 struct snd_ctl_elem_value *ucontrol)
2212{
2213 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2214 struct sigmatel_spec *spec = codec->spec;
2215
2216 ucontrol->value.integer.value[0] = spec->hp_switch;
2217 return 0;
2218}
2219
2220static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2221 struct snd_ctl_elem_value *ucontrol)
2222{
2223 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2224 struct sigmatel_spec *spec = codec->spec;
2225
2226 spec->hp_switch = ucontrol->value.integer.value[0];
2227
2228 /* check to be sure that the ports are upto date with
2229 * switch changes
2230 */
2231 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2232
2233 return 1;
2234}
2235
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002236#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002237
2238static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2239{
2240 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2241 struct sigmatel_spec *spec = codec->spec;
2242 int io_idx = kcontrol-> private_value & 0xff;
2243
2244 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2245 return 0;
2246}
2247
2248static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2249{
2250 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2251 struct sigmatel_spec *spec = codec->spec;
2252 hda_nid_t nid = kcontrol->private_value >> 8;
2253 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002254 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002255
2256 spec->io_switch[io_idx] = val;
2257
2258 if (val)
2259 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002260 else {
2261 unsigned int pinctl = AC_PINCTL_IN_EN;
2262 if (io_idx) /* set VREF for mic */
2263 pinctl |= stac92xx_get_vref(codec, nid);
2264 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2265 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002266
2267 /* check the auto-mute again: we need to mute/unmute the speaker
2268 * appropriately according to the pin direction
2269 */
2270 if (spec->hp_detect)
2271 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2272
Matt Porter403d1942005-11-29 15:00:51 +01002273 return 1;
2274}
2275
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002276#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2277
2278static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2279 struct snd_ctl_elem_value *ucontrol)
2280{
2281 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2282 struct sigmatel_spec *spec = codec->spec;
2283
2284 ucontrol->value.integer.value[0] = spec->clfe_swap;
2285 return 0;
2286}
2287
2288static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2289 struct snd_ctl_elem_value *ucontrol)
2290{
2291 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2292 struct sigmatel_spec *spec = codec->spec;
2293 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002294 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002295
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002296 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002297 return 0;
2298
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002299 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002300
2301 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2302 spec->clfe_swap ? 0x4 : 0x0);
2303
2304 return 1;
2305}
2306
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002307#define STAC_CODEC_HP_SWITCH(xname) \
2308 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2309 .name = xname, \
2310 .index = 0, \
2311 .info = stac92xx_hp_switch_info, \
2312 .get = stac92xx_hp_switch_get, \
2313 .put = stac92xx_hp_switch_put, \
2314 }
2315
Matt Porter403d1942005-11-29 15:00:51 +01002316#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2317 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2318 .name = xname, \
2319 .index = 0, \
2320 .info = stac92xx_io_switch_info, \
2321 .get = stac92xx_io_switch_get, \
2322 .put = stac92xx_io_switch_put, \
2323 .private_value = xpval, \
2324 }
2325
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002326#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2327 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2328 .name = xname, \
2329 .index = 0, \
2330 .info = stac92xx_clfe_switch_info, \
2331 .get = stac92xx_clfe_switch_get, \
2332 .put = stac92xx_clfe_switch_put, \
2333 .private_value = xpval, \
2334 }
Matt Porter403d1942005-11-29 15:00:51 +01002335
Mattc7d4b2f2005-06-27 14:59:41 +02002336enum {
2337 STAC_CTL_WIDGET_VOL,
2338 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002339 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002340 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002341 STAC_CTL_WIDGET_IO_SWITCH,
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002342 STAC_CTL_WIDGET_CLFE_SWITCH
Mattc7d4b2f2005-06-27 14:59:41 +02002343};
2344
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002345static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002346 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2347 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002348 STAC_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002349 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002350 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002351 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002352};
2353
2354/* add dynamic controls */
2355static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val)
2356{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002357 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002358
2359 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2360 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2361
2362 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2363 if (! knew)
2364 return -ENOMEM;
2365 if (spec->kctl_alloc) {
2366 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2367 kfree(spec->kctl_alloc);
2368 }
2369 spec->kctl_alloc = knew;
2370 spec->num_kctl_alloc = num;
2371 }
2372
2373 knew = &spec->kctl_alloc[spec->num_kctl_used];
2374 *knew = stac92xx_control_templates[type];
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002375 knew->name = kstrdup(name, GFP_KERNEL);
Mattc7d4b2f2005-06-27 14:59:41 +02002376 if (! knew->name)
2377 return -ENOMEM;
2378 knew->private_value = val;
2379 spec->num_kctl_used++;
2380 return 0;
2381}
2382
Matt Porter403d1942005-11-29 15:00:51 +01002383/* flag inputs as additional dynamic lineouts */
2384static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2385{
2386 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002387 unsigned int wcaps, wtype;
2388 int i, num_dacs = 0;
2389
2390 /* use the wcaps cache to count all DACs available for line-outs */
2391 for (i = 0; i < codec->num_nodes; i++) {
2392 wcaps = codec->wcaps[i];
2393 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002394
Steve Longerbeam7b043892007-05-03 20:50:03 +02002395 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2396 num_dacs++;
2397 }
Matt Porter403d1942005-11-29 15:00:51 +01002398
Steve Longerbeam7b043892007-05-03 20:50:03 +02002399 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2400
Matt Porter403d1942005-11-29 15:00:51 +01002401 switch (cfg->line_outs) {
2402 case 3:
2403 /* add line-in as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002404 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002405 cfg->line_out_pins[cfg->line_outs] =
2406 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002407 spec->line_switch = 1;
2408 cfg->line_outs++;
2409 }
2410 break;
2411 case 2:
2412 /* add line-in as clfe and mic as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002413 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002414 cfg->line_out_pins[cfg->line_outs] =
2415 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002416 spec->line_switch = 1;
2417 cfg->line_outs++;
2418 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002419 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002420 cfg->line_out_pins[cfg->line_outs] =
2421 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002422 spec->mic_switch = 1;
2423 cfg->line_outs++;
2424 }
2425 break;
2426 case 1:
2427 /* add line-in as surr and mic as clfe */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002428 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002429 cfg->line_out_pins[cfg->line_outs] =
2430 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002431 spec->line_switch = 1;
2432 cfg->line_outs++;
2433 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002434 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002435 cfg->line_out_pins[cfg->line_outs] =
2436 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002437 spec->mic_switch = 1;
2438 cfg->line_outs++;
2439 }
2440 break;
2441 }
2442
2443 return 0;
2444}
2445
Steve Longerbeam7b043892007-05-03 20:50:03 +02002446
2447static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2448{
2449 int i;
2450
2451 for (i = 0; i < spec->multiout.num_dacs; i++) {
2452 if (spec->multiout.dac_nids[i] == nid)
2453 return 1;
2454 }
2455
2456 return 0;
2457}
2458
Matt Porter3cc08dc2006-01-23 15:27:49 +01002459/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02002460 * Fill in the dac_nids table from the parsed pin configuration
2461 * This function only works when every pin in line_out_pins[]
2462 * contains atleast one DAC in its connection list. Some 92xx
2463 * codecs are not connected directly to a DAC, such as the 9200
2464 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002465 */
Takashi Iwai19039bd2006-06-28 15:52:16 +02002466static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaidf802952007-07-02 19:18:00 +02002467 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002468{
2469 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002470 int i, j, conn_len = 0;
2471 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2472 unsigned int wcaps, wtype;
2473
Mattc7d4b2f2005-06-27 14:59:41 +02002474 for (i = 0; i < cfg->line_outs; i++) {
2475 nid = cfg->line_out_pins[i];
Steve Longerbeam7b043892007-05-03 20:50:03 +02002476 conn_len = snd_hda_get_connections(codec, nid, conn,
2477 HDA_MAX_CONNECTIONS);
2478 for (j = 0; j < conn_len; j++) {
2479 wcaps = snd_hda_param_read(codec, conn[j],
2480 AC_PAR_AUDIO_WIDGET_CAP);
2481 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002482 if (wtype != AC_WID_AUD_OUT ||
2483 (wcaps & AC_WCAP_DIGITAL))
2484 continue;
2485 /* conn[j] is a DAC routed to this line-out */
2486 if (!is_in_dac_nids(spec, conn[j]))
2487 break;
2488 }
2489
2490 if (j == conn_len) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002491 if (spec->multiout.num_dacs > 0) {
2492 /* we have already working output pins,
2493 * so let's drop the broken ones again
2494 */
2495 cfg->line_outs = spec->multiout.num_dacs;
2496 break;
2497 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002498 /* error out, no available DAC found */
2499 snd_printk(KERN_ERR
2500 "%s: No available DAC for pin 0x%x\n",
2501 __func__, nid);
2502 return -ENODEV;
2503 }
2504
2505 spec->multiout.dac_nids[i] = conn[j];
2506 spec->multiout.num_dacs++;
2507 if (conn_len > 1) {
2508 /* select this DAC in the pin's input mux */
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002509 snd_hda_codec_write_cache(codec, nid, 0,
2510 AC_VERB_SET_CONNECT_SEL, j);
Steve Longerbeam7b043892007-05-03 20:50:03 +02002511
2512 }
Mattc7d4b2f2005-06-27 14:59:41 +02002513 }
2514
Steve Longerbeam7b043892007-05-03 20:50:03 +02002515 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2516 spec->multiout.num_dacs,
2517 spec->multiout.dac_nids[0],
2518 spec->multiout.dac_nids[1],
2519 spec->multiout.dac_nids[2],
2520 spec->multiout.dac_nids[3],
2521 spec->multiout.dac_nids[4]);
Mattc7d4b2f2005-06-27 14:59:41 +02002522 return 0;
2523}
2524
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002525/* create volume control/switch for the given prefx type */
2526static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2527{
2528 char name[32];
2529 int err;
2530
2531 sprintf(name, "%s Playback Volume", pfx);
2532 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2533 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2534 if (err < 0)
2535 return err;
2536 sprintf(name, "%s Playback Switch", pfx);
2537 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2538 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2539 if (err < 0)
2540 return err;
2541 return 0;
2542}
2543
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002544static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2545{
2546 if (!spec->multiout.hp_nid)
2547 spec->multiout.hp_nid = nid;
2548 else if (spec->multiout.num_dacs > 4) {
2549 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2550 return 1;
2551 } else {
2552 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2553 spec->multiout.num_dacs++;
2554 }
2555 return 0;
2556}
2557
2558static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2559{
2560 if (is_in_dac_nids(spec, nid))
2561 return 1;
2562 if (spec->multiout.hp_nid == nid)
2563 return 1;
2564 return 0;
2565}
2566
Mattc7d4b2f2005-06-27 14:59:41 +02002567/* add playback controls from the parsed DAC table */
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002568static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
Takashi Iwai19039bd2006-06-28 15:52:16 +02002569 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002570{
Takashi Iwai19039bd2006-06-28 15:52:16 +02002571 static const char *chname[4] = {
2572 "Front", "Surround", NULL /*CLFE*/, "Side"
2573 };
Mattc7d4b2f2005-06-27 14:59:41 +02002574 hda_nid_t nid;
2575 int i, err;
2576
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002577 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002578 unsigned int wid_caps, pincap;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002579
2580
Takashi Iwai40ac8c42008-02-29 14:16:17 +01002581 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
Matt Porter403d1942005-11-29 15:00:51 +01002582 if (!spec->multiout.dac_nids[i])
Mattc7d4b2f2005-06-27 14:59:41 +02002583 continue;
2584
2585 nid = spec->multiout.dac_nids[i];
2586
2587 if (i == 2) {
2588 /* Center/LFE */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002589 err = create_controls(spec, "Center", nid, 1);
2590 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002591 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002592 err = create_controls(spec, "LFE", nid, 2);
2593 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002594 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002595
2596 wid_caps = get_wcaps(codec, nid);
2597
2598 if (wid_caps & AC_WCAP_LR_SWAP) {
2599 err = stac92xx_add_control(spec,
2600 STAC_CTL_WIDGET_CLFE_SWITCH,
2601 "Swap Center/LFE Playback Switch", nid);
2602
2603 if (err < 0)
2604 return err;
2605 }
2606
Mattc7d4b2f2005-06-27 14:59:41 +02002607 } else {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002608 err = create_controls(spec, chname[i], nid, 3);
2609 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002610 return err;
2611 }
2612 }
2613
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002614 if (cfg->hp_outs > 1) {
2615 err = stac92xx_add_control(spec,
2616 STAC_CTL_WIDGET_HP_SWITCH,
2617 "Headphone as Line Out Switch", 0);
2618 if (err < 0)
2619 return err;
2620 }
2621
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002622 if (spec->line_switch) {
2623 nid = cfg->input_pins[AUTO_PIN_LINE];
2624 pincap = snd_hda_param_read(codec, nid,
2625 AC_PAR_PIN_CAP);
2626 if (pincap & AC_PINCAP_OUT) {
2627 err = stac92xx_add_control(spec,
2628 STAC_CTL_WIDGET_IO_SWITCH,
2629 "Line In as Output Switch", nid << 8);
2630 if (err < 0)
2631 return err;
2632 }
2633 }
Matt Porter403d1942005-11-29 15:00:51 +01002634
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002635 if (spec->mic_switch) {
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002636 unsigned int def_conf;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002637 unsigned int mic_pin = AUTO_PIN_MIC;
2638again:
2639 nid = cfg->input_pins[mic_pin];
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002640 def_conf = snd_hda_codec_read(codec, nid, 0,
2641 AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002642 /* some laptops have an internal analog microphone
2643 * which can't be used as a output */
2644 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2645 pincap = snd_hda_param_read(codec, nid,
2646 AC_PAR_PIN_CAP);
2647 if (pincap & AC_PINCAP_OUT) {
2648 err = stac92xx_add_control(spec,
2649 STAC_CTL_WIDGET_IO_SWITCH,
2650 "Mic as Output Switch", (nid << 8) | 1);
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002651 nid = snd_hda_codec_read(codec, nid, 0,
2652 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2653 if (!check_in_dac_nids(spec, nid))
2654 add_spec_dacs(spec, nid);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002655 if (err < 0)
2656 return err;
2657 }
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002658 } else if (mic_pin == AUTO_PIN_MIC) {
2659 mic_pin = AUTO_PIN_FRONT_MIC;
2660 goto again;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002661 }
2662 }
Matt Porter403d1942005-11-29 15:00:51 +01002663
Mattc7d4b2f2005-06-27 14:59:41 +02002664 return 0;
2665}
2666
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002667/* add playback controls for Speaker and HP outputs */
2668static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2669 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002670{
2671 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02002672 hda_nid_t nid;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002673 int i, old_num_dacs, err;
Mattc7d4b2f2005-06-27 14:59:41 +02002674
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002675 old_num_dacs = spec->multiout.num_dacs;
2676 for (i = 0; i < cfg->hp_outs; i++) {
2677 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2678 if (wid_caps & AC_WCAP_UNSOL_CAP)
2679 spec->hp_detect = 1;
2680 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2681 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2682 if (check_in_dac_nids(spec, nid))
2683 nid = 0;
2684 if (! nid)
Mattc7d4b2f2005-06-27 14:59:41 +02002685 continue;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002686 add_spec_dacs(spec, nid);
2687 }
2688 for (i = 0; i < cfg->speaker_outs; i++) {
Steve Longerbeam7b043892007-05-03 20:50:03 +02002689 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002690 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2691 if (check_in_dac_nids(spec, nid))
2692 nid = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002693 if (! nid)
2694 continue;
2695 add_spec_dacs(spec, nid);
Mattc7d4b2f2005-06-27 14:59:41 +02002696 }
Matthew Ranostay1b290a52007-07-12 15:17:34 +02002697 for (i = 0; i < cfg->line_outs; i++) {
2698 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2699 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2700 if (check_in_dac_nids(spec, nid))
2701 nid = 0;
2702 if (! nid)
2703 continue;
2704 add_spec_dacs(spec, nid);
2705 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002706 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2707 static const char *pfxs[] = {
2708 "Speaker", "External Speaker", "Speaker2",
2709 };
2710 err = create_controls(spec, pfxs[i - old_num_dacs],
2711 spec->multiout.dac_nids[i], 3);
2712 if (err < 0)
2713 return err;
2714 }
2715 if (spec->multiout.hp_nid) {
Takashi Iwai2626a262008-03-14 09:18:32 +01002716 err = create_controls(spec, "Headphone",
2717 spec->multiout.hp_nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002718 if (err < 0)
2719 return err;
2720 }
Mattc7d4b2f2005-06-27 14:59:41 +02002721
2722 return 0;
2723}
2724
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002725/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002726static const char *stac92xx_mono_labels[4] = {
2727 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002728};
2729
2730/* create mono mux for mono out on capable codecs */
2731static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
2732{
2733 struct sigmatel_spec *spec = codec->spec;
2734 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
2735 int i, num_cons;
2736 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
2737
2738 num_cons = snd_hda_get_connections(codec,
2739 spec->mono_nid,
2740 con_lst,
2741 HDA_MAX_NUM_INPUTS);
2742 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
2743 return -EINVAL;
2744
2745 for (i = 0; i < num_cons; i++) {
2746 mono_mux->items[mono_mux->num_items].label =
2747 stac92xx_mono_labels[i];
2748 mono_mux->items[mono_mux->num_items].index = i;
2749 mono_mux->num_items++;
2750 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01002751
2752 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
2753 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002754}
2755
Matthew Ranostay1cd22242008-07-18 18:20:52 +02002756/* create PC beep volume controls */
2757static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
2758 hda_nid_t nid)
2759{
2760 struct sigmatel_spec *spec = codec->spec;
2761 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
2762 int err;
2763
2764 /* check for mute support for the the amp */
2765 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
2766 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
2767 "PC Beep Playback Switch",
2768 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
2769 if (err < 0)
2770 return err;
2771 }
2772
2773 /* check to see if there is volume support for the amp */
2774 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
2775 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
2776 "PC Beep Playback Volume",
2777 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
2778 if (err < 0)
2779 return err;
2780 }
2781 return 0;
2782}
2783
Matt Porter8b657272006-10-26 17:12:59 +02002784/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01002785static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02002786 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
2787 "Digital Mic 3", "Digital Mic 4"
2788};
2789
2790/* create playback/capture controls for input pins on dmic capable codecs */
2791static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
2792 const struct auto_pin_cfg *cfg)
2793{
2794 struct sigmatel_spec *spec = codec->spec;
2795 struct hda_input_mux *dimux = &spec->private_dimux;
2796 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002797 int err, i, j;
2798 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02002799
2800 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
2801 dimux->items[dimux->num_items].index = 0;
2802 dimux->num_items++;
2803
2804 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002805 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02002806 int index;
2807 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002808 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02002809 unsigned int def_conf;
2810
2811 def_conf = snd_hda_codec_read(codec,
2812 spec->dmic_nids[i],
2813 0,
2814 AC_VERB_GET_CONFIG_DEFAULT,
2815 0);
2816 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
2817 continue;
2818
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002819 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02002820 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01002821 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02002822 con_lst,
2823 HDA_MAX_NUM_INPUTS);
2824 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002825 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02002826 index = j;
2827 goto found;
2828 }
2829 continue;
2830found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002831 wcaps = get_wcaps(codec, nid) &
2832 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002833
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002834 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002835 sprintf(name, "%s Capture Volume",
2836 stac92xx_dmic_labels[dimux->num_items]);
2837
2838 err = stac92xx_add_control(spec,
2839 STAC_CTL_WIDGET_VOL,
2840 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002841 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
2842 (wcaps & AC_WCAP_OUT_AMP) ?
2843 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002844 if (err < 0)
2845 return err;
2846 }
2847
Matt Porter8b657272006-10-26 17:12:59 +02002848 dimux->items[dimux->num_items].label =
2849 stac92xx_dmic_labels[dimux->num_items];
2850 dimux->items[dimux->num_items].index = index;
2851 dimux->num_items++;
2852 }
2853
2854 return 0;
2855}
2856
Mattc7d4b2f2005-06-27 14:59:41 +02002857/* create playback/capture controls for input pins */
2858static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
2859{
2860 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02002861 struct hda_input_mux *imux = &spec->private_imux;
2862 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
2863 int i, j, k;
2864
2865 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02002866 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02002867
Takashi Iwai314634b2006-09-21 11:56:18 +02002868 if (!cfg->input_pins[i])
2869 continue;
2870 index = -1;
2871 for (j = 0; j < spec->num_muxes; j++) {
2872 int num_cons;
2873 num_cons = snd_hda_get_connections(codec,
2874 spec->mux_nids[j],
2875 con_lst,
2876 HDA_MAX_NUM_INPUTS);
2877 for (k = 0; k < num_cons; k++)
2878 if (con_lst[k] == cfg->input_pins[i]) {
2879 index = k;
2880 goto found;
2881 }
Mattc7d4b2f2005-06-27 14:59:41 +02002882 }
Takashi Iwai314634b2006-09-21 11:56:18 +02002883 continue;
2884 found:
2885 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2886 imux->items[imux->num_items].index = index;
2887 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02002888 }
2889
Steve Longerbeam7b043892007-05-03 20:50:03 +02002890 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02002891 /*
2892 * Set the current input for the muxes.
2893 * The STAC9221 has two input muxes with identical source
2894 * NID lists. Hopefully this won't get confused.
2895 */
2896 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002897 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
2898 AC_VERB_SET_CONNECT_SEL,
2899 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02002900 }
2901 }
2902
Mattc7d4b2f2005-06-27 14:59:41 +02002903 return 0;
2904}
2905
Mattc7d4b2f2005-06-27 14:59:41 +02002906static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
2907{
2908 struct sigmatel_spec *spec = codec->spec;
2909 int i;
2910
2911 for (i = 0; i < spec->autocfg.line_outs; i++) {
2912 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2913 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2914 }
2915}
2916
2917static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
2918{
2919 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002920 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02002921
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002922 for (i = 0; i < spec->autocfg.hp_outs; i++) {
2923 hda_nid_t pin;
2924 pin = spec->autocfg.hp_pins[i];
2925 if (pin) /* connect to front */
2926 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
2927 }
2928 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
2929 hda_nid_t pin;
2930 pin = spec->autocfg.speaker_pins[i];
2931 if (pin) /* connect to front */
2932 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
2933 }
Mattc7d4b2f2005-06-27 14:59:41 +02002934}
2935
Matt Porter3cc08dc2006-01-23 15:27:49 +01002936static 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 +02002937{
2938 struct sigmatel_spec *spec = codec->spec;
2939 int err;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01002940 int hp_speaker_swap = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02002941
Matt Porter8b657272006-10-26 17:12:59 +02002942 if ((err = snd_hda_parse_pin_def_config(codec,
2943 &spec->autocfg,
2944 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002945 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01002946 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01002947 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02002948
Jiang Zhebcecd9b2007-11-12 12:57:03 +01002949 /* If we have no real line-out pin and multiple hp-outs, HPs should
2950 * be set up as multi-channel outputs.
2951 */
2952 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
2953 spec->autocfg.hp_outs > 1) {
2954 /* Copy hp_outs to line_outs, backup line_outs in
2955 * speaker_outs so that the following routines can handle
2956 * HP pins as primary outputs.
2957 */
2958 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
2959 sizeof(spec->autocfg.line_out_pins));
2960 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
2961 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
2962 sizeof(spec->autocfg.hp_pins));
2963 spec->autocfg.line_outs = spec->autocfg.hp_outs;
2964 hp_speaker_swap = 1;
2965 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01002966 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002967 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
2968 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01002969 u32 caps = query_amp_caps(codec,
2970 spec->autocfg.mono_out_pin, dir);
2971 hda_nid_t conn_list[1];
2972
2973 /* get the mixer node and then the mono mux if it exists */
2974 if (snd_hda_get_connections(codec,
2975 spec->autocfg.mono_out_pin, conn_list, 1) &&
2976 snd_hda_get_connections(codec, conn_list[0],
2977 conn_list, 1)) {
2978
2979 int wcaps = get_wcaps(codec, conn_list[0]);
2980 int wid_type = (wcaps & AC_WCAP_TYPE)
2981 >> AC_WCAP_TYPE_SHIFT;
2982 /* LR swap check, some stac925x have a mux that
2983 * changes the DACs output path instead of the
2984 * mono-mux path.
2985 */
2986 if (wid_type == AC_WID_AUD_SEL &&
2987 !(wcaps & AC_WCAP_LR_SWAP))
2988 spec->mono_nid = conn_list[0];
2989 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002990 if (dir) {
2991 hda_nid_t nid = spec->autocfg.mono_out_pin;
2992
2993 /* most mono outs have a least a mute/unmute switch */
2994 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
2995 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
2996 "Mono Playback Switch",
2997 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01002998 if (err < 0)
2999 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003000 /* check for volume support for the amp */
3001 if ((caps & AC_AMPCAP_NUM_STEPS)
3002 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3003 err = stac92xx_add_control(spec,
3004 STAC_CTL_WIDGET_VOL,
3005 "Mono Playback Volume",
3006 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3007 if (err < 0)
3008 return err;
3009 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003010 }
3011
3012 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3013 AC_PINCTL_OUT_EN);
3014 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003015
Matt Porter403d1942005-11-29 15:00:51 +01003016 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
3017 return err;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003018 if (spec->multiout.num_dacs == 0)
3019 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
3020 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003021
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003022 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
3023
3024 if (err < 0)
3025 return err;
3026
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003027 /* setup analog beep controls */
3028 if (spec->anabeep_nid > 0) {
3029 err = stac92xx_auto_create_beep_ctls(codec,
3030 spec->anabeep_nid);
3031 if (err < 0)
3032 return err;
3033 }
3034
3035 /* setup digital beep controls and input device */
3036#ifdef CONFIG_SND_HDA_INPUT_BEEP
3037 if (spec->digbeep_nid > 0) {
3038 hda_nid_t nid = spec->digbeep_nid;
3039
3040 err = stac92xx_auto_create_beep_ctls(codec, nid);
3041 if (err < 0)
3042 return err;
3043 err = snd_hda_attach_beep_device(codec, nid);
3044 if (err < 0)
3045 return err;
3046 }
3047#endif
3048
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003049 if (hp_speaker_swap == 1) {
3050 /* Restore the hp_outs and line_outs */
3051 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3052 sizeof(spec->autocfg.line_out_pins));
3053 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3054 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
3055 sizeof(spec->autocfg.speaker_pins));
3056 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
3057 memset(spec->autocfg.speaker_pins, 0,
3058 sizeof(spec->autocfg.speaker_pins));
3059 spec->autocfg.speaker_outs = 0;
3060 }
3061
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003062 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3063
3064 if (err < 0)
3065 return err;
3066
3067 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3068
3069 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003070 return err;
3071
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003072 if (spec->mono_nid > 0) {
3073 err = stac92xx_auto_create_mono_output_ctls(codec);
3074 if (err < 0)
3075 return err;
3076 }
3077
Matt Porter8b657272006-10-26 17:12:59 +02003078 if (spec->num_dmics > 0)
3079 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3080 &spec->autocfg)) < 0)
3081 return err;
3082
Mattc7d4b2f2005-06-27 14:59:41 +02003083 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003084 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003085 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003086
Takashi Iwai82bc9552006-03-21 11:24:42 +01003087 if (spec->autocfg.dig_out_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003088 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003089 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003090 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003091
3092 if (spec->kctl_alloc)
3093 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3094
3095 spec->input_mux = &spec->private_imux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003096 if (!spec->dinput_mux)
3097 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003098 spec->mono_mux = &spec->private_mono_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003099
3100 return 1;
3101}
3102
Takashi Iwai82bc9552006-03-21 11:24:42 +01003103/* add playback controls for HP output */
3104static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3105 struct auto_pin_cfg *cfg)
3106{
3107 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003108 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003109 unsigned int wid_caps;
3110
3111 if (! pin)
3112 return 0;
3113
3114 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003115 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003116 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003117
3118 return 0;
3119}
3120
Richard Fish160ea0d2006-09-06 13:58:25 +02003121/* add playback controls for LFE output */
3122static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3123 struct auto_pin_cfg *cfg)
3124{
3125 struct sigmatel_spec *spec = codec->spec;
3126 int err;
3127 hda_nid_t lfe_pin = 0x0;
3128 int i;
3129
3130 /*
3131 * search speaker outs and line outs for a mono speaker pin
3132 * with an amp. If one is found, add LFE controls
3133 * for it.
3134 */
3135 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3136 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003137 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003138 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3139 if (wcaps == AC_WCAP_OUT_AMP)
3140 /* found a mono speaker with an amp, must be lfe */
3141 lfe_pin = pin;
3142 }
3143
3144 /* if speaker_outs is 0, then speakers may be in line_outs */
3145 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3146 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3147 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003148 unsigned int defcfg;
Harvey Harrison8b551782008-02-29 11:56:48 +01003149 defcfg = snd_hda_codec_read(codec, pin, 0,
Richard Fish160ea0d2006-09-06 13:58:25 +02003150 AC_VERB_GET_CONFIG_DEFAULT,
3151 0x00);
Harvey Harrison8b551782008-02-29 11:56:48 +01003152 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003153 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003154 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3155 if (wcaps == AC_WCAP_OUT_AMP)
3156 /* found a mono speaker with an amp,
3157 must be lfe */
3158 lfe_pin = pin;
3159 }
3160 }
3161 }
3162
3163 if (lfe_pin) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003164 err = create_controls(spec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003165 if (err < 0)
3166 return err;
3167 }
3168
3169 return 0;
3170}
3171
Mattc7d4b2f2005-06-27 14:59:41 +02003172static int stac9200_parse_auto_config(struct hda_codec *codec)
3173{
3174 struct sigmatel_spec *spec = codec->spec;
3175 int err;
3176
Kailang Yangdf694da2005-12-05 19:42:22 +01003177 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003178 return err;
3179
3180 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3181 return err;
3182
Takashi Iwai82bc9552006-03-21 11:24:42 +01003183 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3184 return err;
3185
Richard Fish160ea0d2006-09-06 13:58:25 +02003186 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3187 return err;
3188
Takashi Iwai82bc9552006-03-21 11:24:42 +01003189 if (spec->autocfg.dig_out_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003190 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003191 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003192 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003193
3194 if (spec->kctl_alloc)
3195 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3196
3197 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003198 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003199
3200 return 1;
3201}
3202
Sam Revitch62fe78e2006-05-10 15:09:17 +02003203/*
3204 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3205 * funky external mute control using GPIO pins.
3206 */
3207
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003208static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003209 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003210{
3211 unsigned int gpiostate, gpiomask, gpiodir;
3212
3213 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3214 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003215 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003216
3217 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3218 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003219 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003220
3221 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3222 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003223 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003224
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003225 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003226 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3227
3228 snd_hda_codec_write(codec, codec->afg, 0,
3229 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003230 snd_hda_codec_read(codec, codec->afg, 0,
3231 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003232
3233 msleep(1);
3234
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003235 snd_hda_codec_read(codec, codec->afg, 0,
3236 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003237}
3238
Takashi Iwai314634b2006-09-21 11:56:18 +02003239static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3240 unsigned int event)
3241{
3242 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003243 snd_hda_codec_write_cache(codec, nid, 0,
3244 AC_VERB_SET_UNSOLICITED_ENABLE,
3245 (AC_USRSP_EN | event));
Takashi Iwai314634b2006-09-21 11:56:18 +02003246}
3247
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003248static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3249{
3250 int i;
3251 for (i = 0; i < cfg->hp_outs; i++)
3252 if (cfg->hp_pins[i] == nid)
3253 return 1; /* nid is a HP-Out */
3254
3255 return 0; /* nid is not a HP-Out */
3256};
3257
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003258static void stac92xx_power_down(struct hda_codec *codec)
3259{
3260 struct sigmatel_spec *spec = codec->spec;
3261
3262 /* power down inactive DACs */
3263 hda_nid_t *dac;
3264 for (dac = spec->dac_list; *dac; dac++)
Matthew Ranostay44510892008-02-21 07:49:31 +01003265 if (!is_in_dac_nids(spec, *dac) &&
3266 spec->multiout.hp_nid != *dac)
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003267 snd_hda_codec_write_cache(codec, *dac, 0,
3268 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3269}
3270
Mattc7d4b2f2005-06-27 14:59:41 +02003271static int stac92xx_init(struct hda_codec *codec)
3272{
3273 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003274 struct auto_pin_cfg *cfg = &spec->autocfg;
3275 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003276
Mattc7d4b2f2005-06-27 14:59:41 +02003277 snd_hda_sequence_write(codec, spec->init);
3278
Takashi Iwai82bc9552006-03-21 11:24:42 +01003279 /* set up pins */
3280 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02003281 /* Enable unsolicited responses on the HP widget */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003282 for (i = 0; i < cfg->hp_outs; i++)
Takashi Iwai314634b2006-09-21 11:56:18 +02003283 enable_pin_detect(codec, cfg->hp_pins[i],
3284 STAC_HP_EVENT);
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01003285 /* force to enable the first line-out; the others are set up
3286 * in unsol_event
3287 */
3288 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3289 AC_PINCTL_OUT_EN);
Takashi Iwaieb995a82006-09-21 14:28:21 +02003290 stac92xx_auto_init_hp_out(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003291 /* fake event to set up pins */
3292 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3293 } else {
3294 stac92xx_auto_init_multi_out(codec);
3295 stac92xx_auto_init_hp_out(codec);
3296 }
3297 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01003298 hda_nid_t nid = cfg->input_pins[i];
3299 if (nid) {
3300 unsigned int pinctl = AC_PINCTL_IN_EN;
3301 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
3302 pinctl |= stac92xx_get_vref(codec, nid);
3303 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3304 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01003305 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003306 for (i = 0; i < spec->num_dmics; i++)
3307 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3308 AC_PINCTL_IN_EN);
3309 for (i = 0; i < spec->num_pwrs; i++) {
3310 int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
3311 ? STAC_HP_EVENT : STAC_PWR_EVENT;
3312 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
3313 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003314 int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
3315 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003316 def_conf = get_defcfg_connect(def_conf);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003317 /* outputs are only ports capable of power management
3318 * any attempts on powering down a input port cause the
3319 * referenced VREF to act quirky.
3320 */
3321 if (pinctl & AC_PINCTL_IN_EN)
3322 continue;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003323 /* skip any ports that don't have jacks since presence
3324 * detection is useless */
3325 if (def_conf && def_conf != AC_JACK_PORT_FIXED)
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003326 continue;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003327 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3328 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3329 }
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003330 if (spec->dac_list)
3331 stac92xx_power_down(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003332 if (cfg->dig_out_pin)
3333 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3334 AC_PINCTL_OUT_EN);
3335 if (cfg->dig_in_pin)
3336 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3337 AC_PINCTL_IN_EN);
3338
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003339 stac_gpio_set(codec, spec->gpio_mask,
3340 spec->gpio_dir, spec->gpio_data);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003341
Mattc7d4b2f2005-06-27 14:59:41 +02003342 return 0;
3343}
3344
Matt2f2f4252005-04-13 14:45:30 +02003345static void stac92xx_free(struct hda_codec *codec)
3346{
Mattc7d4b2f2005-06-27 14:59:41 +02003347 struct sigmatel_spec *spec = codec->spec;
3348 int i;
3349
3350 if (! spec)
3351 return;
3352
3353 if (spec->kctl_alloc) {
3354 for (i = 0; i < spec->num_kctl_used; i++)
3355 kfree(spec->kctl_alloc[i].name);
3356 kfree(spec->kctl_alloc);
3357 }
3358
Richard Fish11b44bb2006-08-23 18:31:34 +02003359 if (spec->bios_pin_configs)
3360 kfree(spec->bios_pin_configs);
3361
Mattc7d4b2f2005-06-27 14:59:41 +02003362 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003363 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02003364}
3365
Matt4e550962005-07-04 17:51:39 +02003366static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3367 unsigned int flag)
3368{
3369 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3370 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02003371
Takashi Iwaif9acba42007-05-29 18:01:06 +02003372 if (pin_ctl & AC_PINCTL_IN_EN) {
3373 /*
3374 * we need to check the current set-up direction of
3375 * shared input pins since they can be switched via
3376 * "xxx as Output" mixer switch
3377 */
3378 struct sigmatel_spec *spec = codec->spec;
3379 struct auto_pin_cfg *cfg = &spec->autocfg;
3380 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3381 spec->line_switch) ||
3382 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3383 spec->mic_switch))
3384 return;
3385 }
3386
Steve Longerbeam7b043892007-05-03 20:50:03 +02003387 /* if setting pin direction bits, clear the current
3388 direction bits first */
3389 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3390 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3391
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003392 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003393 AC_VERB_SET_PIN_WIDGET_CONTROL,
3394 pin_ctl | flag);
3395}
3396
3397static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3398 unsigned int flag)
3399{
3400 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3401 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003402 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003403 AC_VERB_SET_PIN_WIDGET_CONTROL,
3404 pin_ctl & ~flag);
3405}
3406
Jiang Zhe40c1d302007-11-12 13:05:16 +01003407static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02003408{
3409 if (!nid)
3410 return 0;
3411 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Jiang Zhe40c1d302007-11-12 13:05:16 +01003412 & (1 << 31)) {
3413 unsigned int pinctl;
3414 pinctl = snd_hda_codec_read(codec, nid, 0,
3415 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3416 if (pinctl & AC_PINCTL_IN_EN)
3417 return 0; /* mic- or line-input */
3418 else
3419 return 1; /* HP-output */
3420 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003421 return 0;
3422}
3423
3424static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
Matt4e550962005-07-04 17:51:39 +02003425{
3426 struct sigmatel_spec *spec = codec->spec;
3427 struct auto_pin_cfg *cfg = &spec->autocfg;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003428 int nid = cfg->hp_pins[cfg->hp_outs - 1];
Matt4e550962005-07-04 17:51:39 +02003429 int i, presence;
3430
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003431 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003432 if (spec->gpio_mute)
3433 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3434 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3435
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003436 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003437 if (presence)
3438 break;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003439 if (spec->hp_switch && cfg->hp_pins[i] == nid)
3440 break;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003441 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003442 }
Matt4e550962005-07-04 17:51:39 +02003443
3444 if (presence) {
3445 /* disable lineouts, enable hp */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003446 if (spec->hp_switch)
3447 stac92xx_reset_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003448 for (i = 0; i < cfg->line_outs; i++)
3449 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3450 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003451 for (i = 0; i < cfg->speaker_outs; i++)
3452 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3453 AC_PINCTL_OUT_EN);
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003454 if (spec->eapd_mask)
3455 stac_gpio_set(codec, spec->gpio_mask,
3456 spec->gpio_dir, spec->gpio_data &
3457 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003458 } else {
3459 /* enable lineouts, disable hp */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003460 if (spec->hp_switch)
3461 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003462 for (i = 0; i < cfg->line_outs; i++)
3463 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3464 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003465 for (i = 0; i < cfg->speaker_outs; i++)
3466 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3467 AC_PINCTL_OUT_EN);
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003468 if (spec->eapd_mask)
3469 stac_gpio_set(codec, spec->gpio_mask,
3470 spec->gpio_dir, spec->gpio_data |
3471 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003472 }
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003473 if (!spec->hp_switch && cfg->hp_outs > 1 && presence)
3474 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003475}
3476
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003477static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
3478{
3479 struct sigmatel_spec *spec = codec->spec;
3480 hda_nid_t nid = spec->pwr_nids[idx];
3481 int presence, val;
3482 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
3483 & 0x000000ff;
3484 presence = get_hp_pin_presence(codec, nid);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003485
3486 /* several codecs have two power down bits */
3487 if (spec->pwr_mapping)
3488 idx = spec->pwr_mapping[idx];
3489 else
3490 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003491
3492 if (presence)
3493 val &= ~idx;
3494 else
3495 val |= idx;
3496
3497 /* power down unused output ports */
3498 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
3499};
3500
Takashi Iwai314634b2006-09-21 11:56:18 +02003501static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
3502{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003503 struct sigmatel_spec *spec = codec->spec;
3504 int idx = res >> 26 & 0x0f;
3505
3506 switch ((res >> 26) & 0x30) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003507 case STAC_HP_EVENT:
3508 stac92xx_hp_detect(codec, res);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003509 /* fallthru */
3510 case STAC_PWR_EVENT:
3511 if (spec->num_pwrs > 0)
3512 stac92xx_pin_sense(codec, idx);
Takashi Iwai314634b2006-09-21 11:56:18 +02003513 }
3514}
3515
Takashi Iwaicb53c622007-08-10 17:21:45 +02003516#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02003517static int stac92xx_resume(struct hda_codec *codec)
3518{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003519 struct sigmatel_spec *spec = codec->spec;
3520
Richard Fish11b44bb2006-08-23 18:31:34 +02003521 stac92xx_set_config_regs(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003522 snd_hda_sequence_write(codec, spec->init);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003523 stac_gpio_set(codec, spec->gpio_mask,
3524 spec->gpio_dir, spec->gpio_data);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003525 snd_hda_codec_resume_amp(codec);
3526 snd_hda_codec_resume_cache(codec);
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003527 /* power down inactive DACs */
3528 if (spec->dac_list)
3529 stac92xx_power_down(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003530 /* invoke unsolicited event to reset the HP state */
3531 if (spec->hp_detect)
3532 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
Mattff6fdc32005-06-27 15:06:52 +02003533 return 0;
3534}
3535#endif
3536
Matt2f2f4252005-04-13 14:45:30 +02003537static struct hda_codec_ops stac92xx_patch_ops = {
3538 .build_controls = stac92xx_build_controls,
3539 .build_pcms = stac92xx_build_pcms,
3540 .init = stac92xx_init,
3541 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02003542 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003543#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02003544 .resume = stac92xx_resume,
3545#endif
Matt2f2f4252005-04-13 14:45:30 +02003546};
3547
3548static int patch_stac9200(struct hda_codec *codec)
3549{
3550 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003551 int err;
Matt2f2f4252005-04-13 14:45:30 +02003552
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003553 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02003554 if (spec == NULL)
3555 return -ENOMEM;
3556
3557 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003558 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02003559 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003560 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
3561 stac9200_models,
3562 stac9200_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02003563 if (spec->board_config < 0) {
3564 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
3565 err = stac92xx_save_bios_config_regs(codec);
3566 if (err < 0) {
3567 stac92xx_free(codec);
3568 return err;
3569 }
3570 spec->pin_configs = spec->bios_pin_configs;
3571 } else {
Matt Porter403d1942005-11-29 15:00:51 +01003572 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
3573 stac92xx_set_config_regs(codec);
3574 }
Matt2f2f4252005-04-13 14:45:30 +02003575
3576 spec->multiout.max_channels = 2;
3577 spec->multiout.num_dacs = 1;
3578 spec->multiout.dac_nids = stac9200_dac_nids;
3579 spec->adc_nids = stac9200_adc_nids;
3580 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02003581 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02003582 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003583 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003584 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003585
Tobin Davisbf277782008-02-03 20:31:47 +01003586 if (spec->board_config == STAC_9200_GATEWAY ||
3587 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02003588 spec->init = stac9200_eapd_init;
3589 else
3590 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02003591 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02003592
Takashi Iwai117f2572008-03-18 09:53:23 +01003593 if (spec->board_config == STAC_9200_PANASONIC) {
3594 spec->gpio_mask = spec->gpio_dir = 0x09;
3595 spec->gpio_data = 0x00;
3596 }
3597
Mattc7d4b2f2005-06-27 14:59:41 +02003598 err = stac9200_parse_auto_config(codec);
3599 if (err < 0) {
3600 stac92xx_free(codec);
3601 return err;
3602 }
Matt2f2f4252005-04-13 14:45:30 +02003603
3604 codec->patch_ops = stac92xx_patch_ops;
3605
3606 return 0;
3607}
3608
Tobin Davis8e21c342007-01-08 11:04:17 +01003609static int patch_stac925x(struct hda_codec *codec)
3610{
3611 struct sigmatel_spec *spec;
3612 int err;
3613
3614 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3615 if (spec == NULL)
3616 return -ENOMEM;
3617
3618 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003619 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01003620 spec->pin_nids = stac925x_pin_nids;
3621 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
3622 stac925x_models,
3623 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01003624 again:
Tobin Davis8e21c342007-01-08 11:04:17 +01003625 if (spec->board_config < 0) {
Tobin Davis2c11f952007-05-17 09:36:34 +02003626 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
3627 "using BIOS defaults\n");
Tobin Davis8e21c342007-01-08 11:04:17 +01003628 err = stac92xx_save_bios_config_regs(codec);
3629 if (err < 0) {
3630 stac92xx_free(codec);
3631 return err;
3632 }
3633 spec->pin_configs = spec->bios_pin_configs;
3634 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
3635 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
3636 stac92xx_set_config_regs(codec);
3637 }
3638
3639 spec->multiout.max_channels = 2;
3640 spec->multiout.num_dacs = 1;
3641 spec->multiout.dac_nids = stac925x_dac_nids;
3642 spec->adc_nids = stac925x_adc_nids;
3643 spec->mux_nids = stac925x_mux_nids;
3644 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003645 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003646 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02003647 switch (codec->vendor_id) {
3648 case 0x83847632: /* STAC9202 */
3649 case 0x83847633: /* STAC9202D */
3650 case 0x83847636: /* STAC9251 */
3651 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02003652 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02003653 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01003654 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
3655 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02003656 break;
3657 default:
3658 spec->num_dmics = 0;
3659 break;
3660 }
Tobin Davis8e21c342007-01-08 11:04:17 +01003661
3662 spec->init = stac925x_core_init;
3663 spec->mixer = stac925x_mixer;
3664
3665 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01003666 if (!err) {
3667 if (spec->board_config < 0) {
3668 printk(KERN_WARNING "hda_codec: No auto-config is "
3669 "available, default to model=ref\n");
3670 spec->board_config = STAC_925x_REF;
3671 goto again;
3672 }
3673 err = -EINVAL;
3674 }
Tobin Davis8e21c342007-01-08 11:04:17 +01003675 if (err < 0) {
3676 stac92xx_free(codec);
3677 return err;
3678 }
3679
3680 codec->patch_ops = stac92xx_patch_ops;
3681
3682 return 0;
3683}
3684
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003685static struct hda_input_mux stac92hd73xx_dmux = {
3686 .num_items = 4,
3687 .items = {
3688 { "Analog Inputs", 0x0b },
3689 { "CD", 0x08 },
3690 { "Digital Mic 1", 0x09 },
3691 { "Digital Mic 2", 0x0a },
3692 }
3693};
3694
3695static int patch_stac92hd73xx(struct hda_codec *codec)
3696{
3697 struct sigmatel_spec *spec;
3698 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
3699 int err = 0;
3700
3701 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3702 if (spec == NULL)
3703 return -ENOMEM;
3704
3705 codec->spec = spec;
3706 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
3707 spec->pin_nids = stac92hd73xx_pin_nids;
3708 spec->board_config = snd_hda_check_board_config(codec,
3709 STAC_92HD73XX_MODELS,
3710 stac92hd73xx_models,
3711 stac92hd73xx_cfg_tbl);
3712again:
3713 if (spec->board_config < 0) {
3714 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3715 " STAC92HD73XX, using BIOS defaults\n");
3716 err = stac92xx_save_bios_config_regs(codec);
3717 if (err < 0) {
3718 stac92xx_free(codec);
3719 return err;
3720 }
3721 spec->pin_configs = spec->bios_pin_configs;
3722 } else {
3723 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
3724 stac92xx_set_config_regs(codec);
3725 }
3726
3727 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
3728 conn, STAC92HD73_DAC_COUNT + 2) - 1;
3729
3730 if (spec->multiout.num_dacs < 0) {
3731 printk(KERN_WARNING "hda_codec: Could not determine "
3732 "number of channels defaulting to DAC count\n");
3733 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
3734 }
3735
3736 switch (spec->multiout.num_dacs) {
3737 case 0x3: /* 6 Channel */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003738 spec->multiout.hp_nid = 0x17;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003739 spec->mixer = stac92hd73xx_6ch_mixer;
3740 spec->init = stac92hd73xx_6ch_core_init;
3741 break;
3742 case 0x4: /* 8 Channel */
3743 spec->multiout.hp_nid = 0x18;
3744 spec->mixer = stac92hd73xx_8ch_mixer;
3745 spec->init = stac92hd73xx_8ch_core_init;
3746 break;
3747 case 0x5: /* 10 Channel */
3748 spec->multiout.hp_nid = 0x19;
3749 spec->mixer = stac92hd73xx_10ch_mixer;
3750 spec->init = stac92hd73xx_10ch_core_init;
3751 };
3752
3753 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
3754 spec->aloopback_mask = 0x01;
3755 spec->aloopback_shift = 8;
3756
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003757 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003758 spec->mux_nids = stac92hd73xx_mux_nids;
3759 spec->adc_nids = stac92hd73xx_adc_nids;
3760 spec->dmic_nids = stac92hd73xx_dmic_nids;
3761 spec->dmux_nids = stac92hd73xx_dmux_nids;
3762
3763 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
3764 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01003765 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003766 spec->dinput_mux = &stac92hd73xx_dmux;
3767 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003768 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003769 spec->gpio_data = 0x01;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003770
Matthew Ranostaya7662642008-02-21 07:51:14 +01003771 switch (spec->board_config) {
3772 case STAC_DELL_M6:
Matthew Ranostayd654a662008-03-14 08:46:51 +01003773 spec->init = dell_eq_core_init;
Matthew Ranostaya7662642008-02-21 07:51:14 +01003774 switch (codec->subsystem_id) {
3775 case 0x1028025e: /* Analog Mics */
3776 case 0x1028025f:
3777 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
3778 spec->num_dmics = 0;
3779 break;
Matthew Ranostayd654a662008-03-14 08:46:51 +01003780 case 0x10280271: /* Digital Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01003781 case 0x10280272:
Matthew Ranostayd654a662008-03-14 08:46:51 +01003782 spec->init = dell_m6_core_init;
3783 /* fall-through */
3784 case 0x10280254:
3785 case 0x10280255:
Matthew Ranostaya7662642008-02-21 07:51:14 +01003786 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
3787 spec->num_dmics = 1;
3788 break;
3789 case 0x10280256: /* Both */
3790 case 0x10280057:
3791 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
3792 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
3793 spec->num_dmics = 1;
3794 break;
3795 }
3796 break;
3797 default:
3798 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
3799 }
3800
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003801 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
3802 spec->pwr_nids = stac92hd73xx_pwr_nids;
3803
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003804 err = stac92xx_parse_auto_config(codec, 0x22, 0x24);
3805
3806 if (!err) {
3807 if (spec->board_config < 0) {
3808 printk(KERN_WARNING "hda_codec: No auto-config is "
3809 "available, default to model=ref\n");
3810 spec->board_config = STAC_92HD73XX_REF;
3811 goto again;
3812 }
3813 err = -EINVAL;
3814 }
3815
3816 if (err < 0) {
3817 stac92xx_free(codec);
3818 return err;
3819 }
3820
3821 codec->patch_ops = stac92xx_patch_ops;
3822
3823 return 0;
3824}
3825
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003826static struct hda_input_mux stac92hd83xxx_dmux = {
3827 .num_items = 3,
3828 .items = {
3829 { "Analog Inputs", 0x03 },
3830 { "Digital Mic 1", 0x04 },
3831 { "Digital Mic 2", 0x05 },
3832 }
3833};
3834
3835static int patch_stac92hd83xxx(struct hda_codec *codec)
3836{
3837 struct sigmatel_spec *spec;
3838 int err;
3839
3840 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3841 if (spec == NULL)
3842 return -ENOMEM;
3843
3844 codec->spec = spec;
3845 spec->mono_nid = 0x19;
3846 spec->digbeep_nid = 0x21;
3847 spec->dmic_nids = stac92hd83xxx_dmic_nids;
3848 spec->dmux_nids = stac92hd83xxx_dmux_nids;
3849 spec->adc_nids = stac92hd83xxx_adc_nids;
3850 spec->pwr_nids = stac92hd83xxx_pwr_nids;
3851 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
3852 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
3853 spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
3854
3855 spec->init = stac92hd83xxx_core_init;
3856 switch (codec->vendor_id) {
3857 case 0x111d7605:
3858 spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
3859 break;
3860 default:
3861 spec->num_pwrs--;
3862 spec->init++; /* switch to config #2 */
3863 spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
3864 }
3865
3866 spec->mixer = stac92hd83xxx_mixer;
3867 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
3868 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
3869 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
3870 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
3871 spec->dinput_mux = &stac92hd83xxx_dmux;
3872 spec->pin_nids = stac92hd83xxx_pin_nids;
3873 spec->board_config = snd_hda_check_board_config(codec,
3874 STAC_92HD83XXX_MODELS,
3875 stac92hd83xxx_models,
3876 stac92hd83xxx_cfg_tbl);
3877again:
3878 if (spec->board_config < 0) {
3879 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3880 " STAC92HD83XXX, using BIOS defaults\n");
3881 err = stac92xx_save_bios_config_regs(codec);
3882 if (err < 0) {
3883 stac92xx_free(codec);
3884 return err;
3885 }
3886 spec->pin_configs = spec->bios_pin_configs;
3887 } else {
3888 spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config];
3889 stac92xx_set_config_regs(codec);
3890 }
3891
3892 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
3893 if (!err) {
3894 if (spec->board_config < 0) {
3895 printk(KERN_WARNING "hda_codec: No auto-config is "
3896 "available, default to model=ref\n");
3897 spec->board_config = STAC_92HD83XXX_REF;
3898 goto again;
3899 }
3900 err = -EINVAL;
3901 }
3902
3903 if (err < 0) {
3904 stac92xx_free(codec);
3905 return err;
3906 }
3907
3908 codec->patch_ops = stac92xx_patch_ops;
3909
3910 return 0;
3911}
3912
3913
Matthew Ranostaye035b842007-11-06 11:53:55 +01003914static int patch_stac92hd71bxx(struct hda_codec *codec)
3915{
3916 struct sigmatel_spec *spec;
3917 int err = 0;
3918
3919 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3920 if (spec == NULL)
3921 return -ENOMEM;
3922
3923 codec->spec = spec;
3924 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003925 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01003926 spec->pin_nids = stac92hd71bxx_pin_nids;
3927 spec->board_config = snd_hda_check_board_config(codec,
3928 STAC_92HD71BXX_MODELS,
3929 stac92hd71bxx_models,
3930 stac92hd71bxx_cfg_tbl);
3931again:
3932 if (spec->board_config < 0) {
3933 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3934 " STAC92HD71BXX, using BIOS defaults\n");
3935 err = stac92xx_save_bios_config_regs(codec);
3936 if (err < 0) {
3937 stac92xx_free(codec);
3938 return err;
3939 }
3940 spec->pin_configs = spec->bios_pin_configs;
3941 } else {
3942 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
3943 stac92xx_set_config_regs(codec);
3944 }
3945
Matthew Ranostay541eee82007-12-14 12:08:04 +01003946 switch (codec->vendor_id) {
3947 case 0x111d76b6: /* 4 Port without Analog Mixer */
3948 case 0x111d76b7:
3949 case 0x111d76b4: /* 6 Port without Analog Mixer */
3950 case 0x111d76b5:
3951 spec->mixer = stac92hd71bxx_mixer;
3952 spec->init = stac92hd71bxx_core_init;
3953 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003954 case 0x111d7608: /* 5 Port with Analog Mixer */
3955 /* no output amps */
3956 spec->num_pwrs = 0;
3957 spec->mixer = stac92hd71bxx_analog_mixer;
3958
3959 /* disable VSW */
3960 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
3961 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
3962 break;
3963 case 0x111d7603: /* 6 Port with Analog Mixer */
3964 /* no output amps */
3965 spec->num_pwrs = 0;
3966 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01003967 default:
3968 spec->mixer = stac92hd71bxx_analog_mixer;
3969 spec->init = stac92hd71bxx_analog_core_init;
3970 }
3971
3972 spec->aloopback_mask = 0x20;
3973 spec->aloopback_shift = 0;
3974
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003975 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003976 spec->gpio_mask = 0x01;
3977 spec->gpio_dir = 0x01;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003978 spec->gpio_data = 0x01;
Matthew Ranostaye035b842007-11-06 11:53:55 +01003979
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003980 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01003981 spec->mux_nids = stac92hd71bxx_mux_nids;
3982 spec->adc_nids = stac92hd71bxx_adc_nids;
3983 spec->dmic_nids = stac92hd71bxx_dmic_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003984 spec->dmux_nids = stac92hd71bxx_dmux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003985 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01003986
3987 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
3988 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
3989 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
Takashi Iwai1697055e2007-12-18 18:05:52 +01003990 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01003991
Takashi Iwaiaea7bb02008-02-25 18:26:41 +01003992 spec->multiout.num_dacs = 1;
Matthew Ranostaye035b842007-11-06 11:53:55 +01003993 spec->multiout.hp_nid = 0x11;
3994 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
3995
3996 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
3997 if (!err) {
3998 if (spec->board_config < 0) {
3999 printk(KERN_WARNING "hda_codec: No auto-config is "
4000 "available, default to model=ref\n");
4001 spec->board_config = STAC_92HD71BXX_REF;
4002 goto again;
4003 }
4004 err = -EINVAL;
4005 }
4006
4007 if (err < 0) {
4008 stac92xx_free(codec);
4009 return err;
4010 }
4011
4012 codec->patch_ops = stac92xx_patch_ops;
4013
4014 return 0;
4015};
4016
Matt2f2f4252005-04-13 14:45:30 +02004017static int patch_stac922x(struct hda_codec *codec)
4018{
4019 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004020 int err;
Matt2f2f4252005-04-13 14:45:30 +02004021
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004022 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004023 if (spec == NULL)
4024 return -ENOMEM;
4025
4026 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004027 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004028 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004029 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
4030 stac922x_models,
4031 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08004032 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004033 spec->gpio_mask = spec->gpio_dir = 0x03;
4034 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004035 /* Intel Macs have all same PCI SSID, so we need to check
4036 * codec SSID to distinguish the exact models
4037 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004038 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004039 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004040
4041 case 0x106b0800:
4042 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02004043 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004044 case 0x106b0600:
4045 case 0x106b0700:
4046 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004047 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004048 case 0x106b0e00:
4049 case 0x106b0f00:
4050 case 0x106b1600:
4051 case 0x106b1700:
4052 case 0x106b0200:
4053 case 0x106b1e00:
4054 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004055 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004056 case 0x106b1a00:
4057 case 0x00000100:
4058 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02004059 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004060 case 0x106b0a00:
4061 case 0x106b2200:
4062 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02004063 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08004064 default:
4065 spec->board_config = STAC_INTEL_MAC_V3;
4066 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004067 }
4068 }
4069
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004070 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004071 if (spec->board_config < 0) {
4072 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
4073 "using BIOS defaults\n");
4074 err = stac92xx_save_bios_config_regs(codec);
4075 if (err < 0) {
4076 stac92xx_free(codec);
4077 return err;
4078 }
4079 spec->pin_configs = spec->bios_pin_configs;
4080 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
Matt Porter403d1942005-11-29 15:00:51 +01004081 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
4082 stac92xx_set_config_regs(codec);
4083 }
Matt2f2f4252005-04-13 14:45:30 +02004084
Matt2f2f4252005-04-13 14:45:30 +02004085 spec->adc_nids = stac922x_adc_nids;
4086 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004087 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004088 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004089 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004090 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004091
4092 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004093 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004094
4095 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02004096
Matt Porter3cc08dc2006-01-23 15:27:49 +01004097 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004098 if (!err) {
4099 if (spec->board_config < 0) {
4100 printk(KERN_WARNING "hda_codec: No auto-config is "
4101 "available, default to model=ref\n");
4102 spec->board_config = STAC_D945_REF;
4103 goto again;
4104 }
4105 err = -EINVAL;
4106 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004107 if (err < 0) {
4108 stac92xx_free(codec);
4109 return err;
4110 }
4111
4112 codec->patch_ops = stac92xx_patch_ops;
4113
Takashi Iwai807a46362007-05-29 19:01:37 +02004114 /* Fix Mux capture level; max to 2 */
4115 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
4116 (0 << AC_AMPCAP_OFFSET_SHIFT) |
4117 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4118 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4119 (0 << AC_AMPCAP_MUTE_SHIFT));
4120
Matt Porter3cc08dc2006-01-23 15:27:49 +01004121 return 0;
4122}
4123
4124static int patch_stac927x(struct hda_codec *codec)
4125{
4126 struct sigmatel_spec *spec;
4127 int err;
4128
4129 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4130 if (spec == NULL)
4131 return -ENOMEM;
4132
4133 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004134 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004135 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004136 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
4137 stac927x_models,
4138 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004139 again:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004140 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
4141 if (spec->board_config < 0)
4142 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4143 "STAC927x, using BIOS defaults\n");
Richard Fish11b44bb2006-08-23 18:31:34 +02004144 err = stac92xx_save_bios_config_regs(codec);
4145 if (err < 0) {
4146 stac92xx_free(codec);
4147 return err;
4148 }
4149 spec->pin_configs = spec->bios_pin_configs;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004150 } else {
Matt Porter3cc08dc2006-01-23 15:27:49 +01004151 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
4152 stac92xx_set_config_regs(codec);
4153 }
4154
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004155 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004156 spec->adc_nids = stac927x_adc_nids;
4157 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
4158 spec->mux_nids = stac927x_mux_nids;
4159 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004160 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004161 spec->multiout.dac_nids = spec->dac_nids;
4162
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004163 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02004164 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004165 case STAC_D965_5ST:
4166 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004167 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004168 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004169 spec->num_dmics = 0;
4170
Tobin Davis93ed1502006-09-01 21:03:12 +02004171 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004172 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004173 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004174 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02004175 switch (codec->subsystem_id) {
4176 case 0x10280209:
4177 case 0x1028022e:
4178 /* correct the device field to SPDIF out */
4179 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
4180 break;
4181 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01004182 /* configure the analog microphone on some laptops */
4183 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01004184 /* correct the front output jack as a hp out */
Matthew Ranostay7989fba2008-02-21 07:50:12 +01004185 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01004186 /* correct the front input jack as a mic */
4187 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
4188 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004189 case STAC_DELL_3ST:
4190 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004191 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004192 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004193 spec->dmic_nids = stac927x_dmic_nids;
4194 spec->num_dmics = STAC927X_NUM_DMICS;
4195
Tobin Davis93ed1502006-09-01 21:03:12 +02004196 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004197 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004198 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004199 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004200 break;
4201 default:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004202 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004203 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004204 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004205 spec->num_dmics = 0;
4206
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004207 spec->init = stac927x_core_init;
4208 spec->mixer = stac927x_mixer;
4209 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004210
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004211 spec->num_pwrs = 0;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004212 spec->aloopback_mask = 0x40;
4213 spec->aloopback_shift = 0;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004214
Matt Porter3cc08dc2006-01-23 15:27:49 +01004215 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004216 if (!err) {
4217 if (spec->board_config < 0) {
4218 printk(KERN_WARNING "hda_codec: No auto-config is "
4219 "available, default to model=ref\n");
4220 spec->board_config = STAC_D965_REF;
4221 goto again;
4222 }
4223 err = -EINVAL;
4224 }
Mattc7d4b2f2005-06-27 14:59:41 +02004225 if (err < 0) {
4226 stac92xx_free(codec);
4227 return err;
4228 }
Matt2f2f4252005-04-13 14:45:30 +02004229
4230 codec->patch_ops = stac92xx_patch_ops;
4231
Takashi Iwai52987652008-01-16 16:09:47 +01004232 /*
4233 * !!FIXME!!
4234 * The STAC927x seem to require fairly long delays for certain
4235 * command sequences. With too short delays (even if the answer
4236 * is set to RIRB properly), it results in the silence output
4237 * on some hardwares like Dell.
4238 *
4239 * The below flag enables the longer delay (see get_response
4240 * in hda_intel.c).
4241 */
4242 codec->bus->needs_damn_long_delay = 1;
4243
Matt2f2f4252005-04-13 14:45:30 +02004244 return 0;
4245}
4246
Matt Porterf3302a52006-07-31 12:49:34 +02004247static int patch_stac9205(struct hda_codec *codec)
4248{
4249 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02004250 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02004251
4252 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4253 if (spec == NULL)
4254 return -ENOMEM;
4255
4256 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004257 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004258 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004259 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
4260 stac9205_models,
4261 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004262 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004263 if (spec->board_config < 0) {
4264 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
4265 err = stac92xx_save_bios_config_regs(codec);
4266 if (err < 0) {
4267 stac92xx_free(codec);
4268 return err;
4269 }
4270 spec->pin_configs = spec->bios_pin_configs;
4271 } else {
Matt Porterf3302a52006-07-31 12:49:34 +02004272 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
4273 stac92xx_set_config_regs(codec);
4274 }
4275
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004276 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02004277 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004278 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02004279 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004280 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004281 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02004282 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004283 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004284 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004285 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02004286
4287 spec->init = stac9205_core_init;
4288 spec->mixer = stac9205_mixer;
4289
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004290 spec->aloopback_mask = 0x40;
4291 spec->aloopback_shift = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02004292 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02004293
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004294 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004295 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02004296 /* Enable SPDIF in/out */
4297 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
4298 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01004299
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004300 /* Enable unsol response for GPIO4/Dock HP connection */
4301 snd_hda_codec_write(codec, codec->afg, 0,
4302 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4303 snd_hda_codec_write_cache(codec, codec->afg, 0,
4304 AC_VERB_SET_UNSOLICITED_ENABLE,
4305 (AC_USRSP_EN | STAC_HP_EVENT));
4306
4307 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004308 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004309 spec->gpio_mask = 0x1b;
4310 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01004311 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004312 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02004313 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004314 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004315 break;
4316 default:
4317 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004318 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004319 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004320 break;
4321 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02004322
Matt Porterf3302a52006-07-31 12:49:34 +02004323 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004324 if (!err) {
4325 if (spec->board_config < 0) {
4326 printk(KERN_WARNING "hda_codec: No auto-config is "
4327 "available, default to model=ref\n");
4328 spec->board_config = STAC_9205_REF;
4329 goto again;
4330 }
4331 err = -EINVAL;
4332 }
Matt Porterf3302a52006-07-31 12:49:34 +02004333 if (err < 0) {
4334 stac92xx_free(codec);
4335 return err;
4336 }
4337
4338 codec->patch_ops = stac92xx_patch_ops;
4339
4340 return 0;
4341}
4342
Matt2f2f4252005-04-13 14:45:30 +02004343/*
Guillaume Munch6d859062006-08-22 17:15:47 +02004344 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01004345 */
4346
Guillaume Munch99ccc562006-08-16 19:35:12 +02004347/* static config for Sony VAIO FE550G and Sony VAIO AR */
Takashi Iwaidb064e52006-03-16 16:04:58 +01004348static hda_nid_t vaio_dacs[] = { 0x2 };
4349#define VAIO_HP_DAC 0x5
4350static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
4351static hda_nid_t vaio_mux_nids[] = { 0x15 };
4352
4353static struct hda_input_mux vaio_mux = {
Takashi Iwaia3a2f422007-10-11 11:21:21 +02004354 .num_items = 3,
Takashi Iwaidb064e52006-03-16 16:04:58 +01004355 .items = {
Takashi Iwaid7737812006-04-25 13:05:43 +02004356 /* { "HP", 0x0 }, */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004357 { "Mic Jack", 0x1 },
4358 { "Internal Mic", 0x2 },
Takashi Iwaidb064e52006-03-16 16:04:58 +01004359 { "PCM", 0x3 },
4360 }
4361};
4362
4363static struct hda_verb vaio_init[] = {
4364 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004365 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
Takashi Iwaidb064e52006-03-16 16:04:58 +01004366 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4367 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4368 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4369 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004370 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01004371 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4372 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4373 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4374 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4375 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4376 {}
4377};
4378
Guillaume Munch6d859062006-08-22 17:15:47 +02004379static struct hda_verb vaio_ar_init[] = {
4380 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
4381 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4382 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4383 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4384/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
4385 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004386 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Guillaume Munch6d859062006-08-22 17:15:47 +02004387 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4388 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4389/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
4390 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4391 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4392 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4393 {}
4394};
4395
Takashi Iwaidb064e52006-03-16 16:04:58 +01004396/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02004397static struct hda_bind_ctls vaio_bind_master_vol = {
4398 .ops = &snd_hda_bind_vol,
4399 .values = {
4400 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4401 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4402 0
4403 },
4404};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004405
4406/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02004407static struct hda_bind_ctls vaio_bind_master_sw = {
4408 .ops = &snd_hda_bind_sw,
4409 .values = {
4410 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4411 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4412 0,
4413 },
4414};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004415
4416static struct snd_kcontrol_new vaio_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02004417 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4418 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Takashi Iwaidb064e52006-03-16 16:04:58 +01004419 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4420 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4421 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4422 {
4423 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4424 .name = "Capture Source",
4425 .count = 1,
4426 .info = stac92xx_mux_enum_info,
4427 .get = stac92xx_mux_enum_get,
4428 .put = stac92xx_mux_enum_put,
4429 },
4430 {}
4431};
4432
Guillaume Munch6d859062006-08-22 17:15:47 +02004433static struct snd_kcontrol_new vaio_ar_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02004434 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4435 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Guillaume Munch6d859062006-08-22 17:15:47 +02004436 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4437 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4438 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4439 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
4440 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
4441 {
4442 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4443 .name = "Capture Source",
4444 .count = 1,
4445 .info = stac92xx_mux_enum_info,
4446 .get = stac92xx_mux_enum_get,
4447 .put = stac92xx_mux_enum_put,
4448 },
4449 {}
4450};
4451
4452static struct hda_codec_ops stac9872_patch_ops = {
Takashi Iwaidb064e52006-03-16 16:04:58 +01004453 .build_controls = stac92xx_build_controls,
4454 .build_pcms = stac92xx_build_pcms,
4455 .init = stac92xx_init,
4456 .free = stac92xx_free,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004457#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaidb064e52006-03-16 16:04:58 +01004458 .resume = stac92xx_resume,
4459#endif
4460};
4461
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004462static int stac9872_vaio_init(struct hda_codec *codec)
4463{
4464 int err;
4465
4466 err = stac92xx_init(codec);
4467 if (err < 0)
4468 return err;
4469 if (codec->patch_ops.unsol_event)
4470 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
4471 return 0;
4472}
4473
4474static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
4475{
Jiang Zhe40c1d302007-11-12 13:05:16 +01004476 if (get_hp_pin_presence(codec, 0x0a)) {
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004477 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4478 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4479 } else {
4480 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4481 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4482 }
4483}
4484
4485static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
4486{
4487 switch (res >> 26) {
4488 case STAC_HP_EVENT:
4489 stac9872_vaio_hp_detect(codec, res);
4490 break;
4491 }
4492}
4493
4494static struct hda_codec_ops stac9872_vaio_patch_ops = {
4495 .build_controls = stac92xx_build_controls,
4496 .build_pcms = stac92xx_build_pcms,
4497 .init = stac9872_vaio_init,
4498 .free = stac92xx_free,
4499 .unsol_event = stac9872_vaio_unsol_event,
4500#ifdef CONFIG_PM
4501 .resume = stac92xx_resume,
4502#endif
4503};
4504
Guillaume Munch6d859062006-08-22 17:15:47 +02004505enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
4506 CXD9872RD_VAIO,
4507 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
4508 STAC9872AK_VAIO,
4509 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
4510 STAC9872K_VAIO,
4511 /* AR Series. id=0x83847664 and subsys=104D1300 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004512 CXD9872AKD_VAIO,
4513 STAC_9872_MODELS,
4514};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004515
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004516static const char *stac9872_models[STAC_9872_MODELS] = {
4517 [CXD9872RD_VAIO] = "vaio",
4518 [CXD9872AKD_VAIO] = "vaio-ar",
4519};
4520
4521static struct snd_pci_quirk stac9872_cfg_tbl[] = {
4522 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
4523 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
4524 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
Tobin Davis68e22542007-03-12 11:36:39 +01004525 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
Takashi Iwaidb064e52006-03-16 16:04:58 +01004526 {}
4527};
4528
Guillaume Munch6d859062006-08-22 17:15:47 +02004529static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01004530{
4531 struct sigmatel_spec *spec;
4532 int board_config;
4533
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004534 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
4535 stac9872_models,
4536 stac9872_cfg_tbl);
Takashi Iwaidb064e52006-03-16 16:04:58 +01004537 if (board_config < 0)
4538 /* unknown config, let generic-parser do its job... */
4539 return snd_hda_parse_generic_codec(codec);
4540
4541 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4542 if (spec == NULL)
4543 return -ENOMEM;
4544
4545 codec->spec = spec;
4546 switch (board_config) {
Guillaume Munch6d859062006-08-22 17:15:47 +02004547 case CXD9872RD_VAIO:
4548 case STAC9872AK_VAIO:
4549 case STAC9872K_VAIO:
Takashi Iwaidb064e52006-03-16 16:04:58 +01004550 spec->mixer = vaio_mixer;
4551 spec->init = vaio_init;
4552 spec->multiout.max_channels = 2;
4553 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
4554 spec->multiout.dac_nids = vaio_dacs;
4555 spec->multiout.hp_nid = VAIO_HP_DAC;
4556 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
4557 spec->adc_nids = vaio_adcs;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004558 spec->num_pwrs = 0;
Takashi Iwaidb064e52006-03-16 16:04:58 +01004559 spec->input_mux = &vaio_mux;
4560 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004561 codec->patch_ops = stac9872_vaio_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01004562 break;
Guillaume Munch6d859062006-08-22 17:15:47 +02004563
4564 case CXD9872AKD_VAIO:
4565 spec->mixer = vaio_ar_mixer;
4566 spec->init = vaio_ar_init;
4567 spec->multiout.max_channels = 2;
4568 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
4569 spec->multiout.dac_nids = vaio_dacs;
4570 spec->multiout.hp_nid = VAIO_HP_DAC;
4571 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004572 spec->num_pwrs = 0;
Guillaume Munch6d859062006-08-22 17:15:47 +02004573 spec->adc_nids = vaio_adcs;
4574 spec->input_mux = &vaio_mux;
4575 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004576 codec->patch_ops = stac9872_patch_ops;
Guillaume Munch6d859062006-08-22 17:15:47 +02004577 break;
Takashi Iwaidb064e52006-03-16 16:04:58 +01004578 }
4579
Takashi Iwaidb064e52006-03-16 16:04:58 +01004580 return 0;
4581}
4582
4583
4584/*
Matt2f2f4252005-04-13 14:45:30 +02004585 * patch entries
4586 */
4587struct hda_codec_preset snd_hda_preset_sigmatel[] = {
4588 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
4589 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
4590 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
4591 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
4592 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
4593 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
4594 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02004595 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
4596 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
4597 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
4598 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
4599 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
4600 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01004601 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
4602 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
4603 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
4604 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
4605 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
4606 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
4607 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
4608 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
4609 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
4610 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01004611 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
4612 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
4613 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
4614 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
4615 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
4616 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02004617 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
4618 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02004619 /* The following does not take into account .id=0x83847661 when subsys =
4620 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
4621 * currently not fully supported.
4622 */
4623 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
4624 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
4625 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02004626 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
4627 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
4628 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
4629 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
4630 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
4631 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
4632 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
4633 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004634 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004635 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
4636 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004637 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01004638 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
4639 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004640 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01004641 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
4642 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
4643 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
4644 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
4645 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
4646 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
4647 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
4648 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02004649 {} /* terminator */
4650};