blob: 75112e4b7965d6ab6d0717ba3d5fbad2bf81ecd9 [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),
Matt2f2f4252005-04-13 14:45:30 +0200798 { } /* end */
799};
800
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100801static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100802 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
803
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100804 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
805 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
806
807 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
808 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
809
810 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
811 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
812
813 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
814 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
815
816 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
817 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
818
819 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
820 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
821
822 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
823 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
824 { } /* end */
825};
826
827static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100828 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
829
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100830 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
831 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
832
833 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
834 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
835
836 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
837 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
838
839 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
840 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
841
842 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
843 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
844
845 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
846 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
847
848 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
849 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
850 { } /* end */
851};
852
853static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100854 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
855
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100856 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
857 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
858
859 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
860 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
861
862 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
863 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
864
865 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
866 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
867
868 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
869 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
870
871 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
872 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
873
874 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
875 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
876 { } /* end */
877};
878
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200879
880static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
881 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
882 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
883
884 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
885 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
886
887 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT),
888 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
889
890 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
891 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
892
893 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
894 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
895
896 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
897 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
898
899 /*
900 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
901 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
902 */
903 { } /* end */
904};
905
Matthew Ranostay541eee82007-12-14 12:08:04 +0100906static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100907 STAC_INPUT_SOURCE(2),
Matthew Ranostaye035b842007-11-06 11:53:55 +0100908
Matthew Ranostay9b359472007-11-07 13:03:12 +0100909 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
910 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay9b359472007-11-07 13:03:12 +0100911
912 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
913 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200914 /* analog pc-beep replaced with digital beep support */
915 /*
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +0200916 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
917 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200918 */
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +0200919
Matthew Ranostay9b359472007-11-07 13:03:12 +0100920 HDA_CODEC_MUTE("Analog Loopback 1", 0x17, 0x3, HDA_INPUT),
921 HDA_CODEC_MUTE("Analog Loopback 2", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +0100922 { } /* end */
923};
924
Matthew Ranostay541eee82007-12-14 12:08:04 +0100925static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +0100926 STAC_INPUT_SOURCE(2),
927 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
928
Matthew Ranostay541eee82007-12-14 12:08:04 +0100929 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
930 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +0100931
932 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
933 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +0100934 { } /* end */
935};
936
Tobin Davis8e21c342007-01-08 11:04:17 +0100937static struct snd_kcontrol_new stac925x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200938 STAC_INPUT_SOURCE(1),
Tobin Davis8e21c342007-01-08 11:04:17 +0100939 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +0200940 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +0100941 { } /* end */
942};
943
Takashi Iwaid1d985f2006-11-23 19:27:12 +0100944static struct snd_kcontrol_new stac9205_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200945 STAC_INPUT_SOURCE(2),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100946 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200947
948 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
949 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200950
951 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
952 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200953 { } /* end */
954};
955
956/* This needs to be generated dynamically based on sequence */
957static struct snd_kcontrol_new stac922x_mixer[] = {
958 STAC_INPUT_SOURCE(2),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200959 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
960 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200961
962 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
963 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200964 { } /* end */
965};
966
967
968static struct snd_kcontrol_new stac927x_mixer[] = {
969 STAC_INPUT_SOURCE(3),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100970 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200971
972 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
973 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200974
975 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
976 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200977
978 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
979 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
Matt Porterf3302a52006-07-31 12:49:34 +0200980 { } /* end */
981};
982
Takashi Iwai1697055e2007-12-18 18:05:52 +0100983static struct snd_kcontrol_new stac_dmux_mixer = {
984 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
985 .name = "Digital Input Source",
986 /* count set later */
987 .info = stac92xx_dmux_enum_info,
988 .get = stac92xx_dmux_enum_get,
989 .put = stac92xx_dmux_enum_put,
990};
991
Takashi Iwai2134ea42008-01-10 16:53:55 +0100992static const char *slave_vols[] = {
993 "Front Playback Volume",
994 "Surround Playback Volume",
995 "Center Playback Volume",
996 "LFE Playback Volume",
997 "Side Playback Volume",
998 "Headphone Playback Volume",
999 "Headphone Playback Volume",
1000 "Speaker Playback Volume",
1001 "External Speaker Playback Volume",
1002 "Speaker2 Playback Volume",
1003 NULL
1004};
1005
1006static const char *slave_sws[] = {
1007 "Front Playback Switch",
1008 "Surround Playback Switch",
1009 "Center Playback Switch",
1010 "LFE Playback Switch",
1011 "Side Playback Switch",
1012 "Headphone Playback Switch",
1013 "Headphone Playback Switch",
1014 "Speaker Playback Switch",
1015 "External Speaker Playback Switch",
1016 "Speaker2 Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001017 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001018 NULL
1019};
1020
Matt2f2f4252005-04-13 14:45:30 +02001021static int stac92xx_build_controls(struct hda_codec *codec)
1022{
1023 struct sigmatel_spec *spec = codec->spec;
1024 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001025 int i;
Matt2f2f4252005-04-13 14:45:30 +02001026
1027 err = snd_hda_add_new_ctls(codec, spec->mixer);
1028 if (err < 0)
1029 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001030
1031 for (i = 0; i < spec->num_mixers; i++) {
1032 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1033 if (err < 0)
1034 return err;
1035 }
Takashi Iwai1697055e2007-12-18 18:05:52 +01001036 if (spec->num_dmuxes > 0) {
1037 stac_dmux_mixer.count = spec->num_dmuxes;
1038 err = snd_ctl_add(codec->bus->card,
1039 snd_ctl_new1(&stac_dmux_mixer, codec));
1040 if (err < 0)
1041 return err;
1042 }
Mattc7d4b2f2005-06-27 14:59:41 +02001043
Mattdabbed62005-06-14 10:19:34 +02001044 if (spec->multiout.dig_out_nid) {
1045 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1046 if (err < 0)
1047 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001048 err = snd_hda_create_spdif_share_sw(codec,
1049 &spec->multiout);
1050 if (err < 0)
1051 return err;
1052 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001053 }
1054 if (spec->dig_in_nid) {
1055 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1056 if (err < 0)
1057 return err;
1058 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001059
1060 /* if we have no master control, let's create it */
1061 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001062 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001063 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001064 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001065 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001066 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001067 if (err < 0)
1068 return err;
1069 }
1070 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1071 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1072 NULL, slave_sws);
1073 if (err < 0)
1074 return err;
1075 }
1076
Mattdabbed62005-06-14 10:19:34 +02001077 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001078}
1079
Matt Porter403d1942005-11-29 15:00:51 +01001080static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001081 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001082 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1083};
1084
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001085/*
1086 STAC 9200 pin configs for
1087 102801A8
1088 102801DE
1089 102801E8
1090*/
1091static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001092 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1093 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001094};
1095
1096/*
1097 STAC 9200 pin configs for
1098 102801C0
1099 102801C1
1100*/
1101static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001102 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1103 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001104};
1105
1106/*
1107 STAC 9200 pin configs for
1108 102801C4 (Dell Dimension E310)
1109 102801C5
1110 102801C7
1111 102801D9
1112 102801DA
1113 102801E3
1114*/
1115static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001116 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1117 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001118};
1119
1120
1121/*
1122 STAC 9200-32 pin configs for
1123 102801B5 (Dell Inspiron 630m)
1124 102801D8 (Dell Inspiron 640m)
1125*/
1126static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001127 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1128 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001129};
1130
1131/*
1132 STAC 9200-32 pin configs for
1133 102801C2 (Dell Latitude D620)
1134 102801C8
1135 102801CC (Dell Latitude D820)
1136 102801D4
1137 102801D6
1138*/
1139static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001140 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1141 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001142};
1143
1144/*
1145 STAC 9200-32 pin configs for
1146 102801CE (Dell XPS M1710)
1147 102801CF (Dell Precision M90)
1148*/
1149static unsigned int dell9200_m23_pin_configs[8] = {
1150 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1151 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1152};
1153
1154/*
1155 STAC 9200-32 pin configs for
1156 102801C9
1157 102801CA
1158 102801CB (Dell Latitude 120L)
1159 102801D3
1160*/
1161static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001162 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1163 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001164};
1165
1166/*
1167 STAC 9200-32 pin configs for
1168 102801BD (Dell Inspiron E1505n)
1169 102801EE
1170 102801EF
1171*/
1172static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001173 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1174 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001175};
1176
1177/*
1178 STAC 9200-32 pin configs for
1179 102801F5 (Dell Inspiron 1501)
1180 102801F6
1181*/
1182static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001183 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1184 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001185};
1186
1187/*
1188 STAC 9200-32
1189 102801CD (Dell Inspiron E1705/9400)
1190*/
1191static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001192 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1193 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001194};
1195
Tobin Davisbf277782008-02-03 20:31:47 +01001196static unsigned int oqo9200_pin_configs[8] = {
1197 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1198 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1199};
1200
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001201
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001202static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1203 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001204 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001205 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1206 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1207 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1208 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1209 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1210 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1211 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1212 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1213 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1214 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001215 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001216};
1217
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001218static const char *stac9200_models[STAC_9200_MODELS] = {
1219 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001220 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001221 [STAC_9200_DELL_D21] = "dell-d21",
1222 [STAC_9200_DELL_D22] = "dell-d22",
1223 [STAC_9200_DELL_D23] = "dell-d23",
1224 [STAC_9200_DELL_M21] = "dell-m21",
1225 [STAC_9200_DELL_M22] = "dell-m22",
1226 [STAC_9200_DELL_M23] = "dell-m23",
1227 [STAC_9200_DELL_M24] = "dell-m24",
1228 [STAC_9200_DELL_M25] = "dell-m25",
1229 [STAC_9200_DELL_M26] = "dell-m26",
1230 [STAC_9200_DELL_M27] = "dell-m27",
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001231 [STAC_9200_GATEWAY] = "gateway",
Takashi Iwai117f2572008-03-18 09:53:23 +01001232 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001233};
1234
1235static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1236 /* SigmaTel reference board */
1237 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1238 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001239 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001240 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1241 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001242 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001243 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1244 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1245 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1246 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1247 "unknown Dell", STAC_9200_DELL_D22),
1248 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1249 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001250 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001251 "Dell Latitude D620", STAC_9200_DELL_M22),
1252 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1253 "unknown Dell", STAC_9200_DELL_D23),
1254 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1255 "unknown Dell", STAC_9200_DELL_D23),
1256 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1257 "unknown Dell", STAC_9200_DELL_M22),
1258 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1259 "unknown Dell", STAC_9200_DELL_M24),
1260 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1261 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001262 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001263 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001264 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001265 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001266 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001267 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001268 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001269 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001270 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001271 "Dell Precision M90", STAC_9200_DELL_M23),
1272 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1273 "unknown Dell", STAC_9200_DELL_M22),
1274 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1275 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001276 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001277 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001278 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001279 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1280 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1281 "unknown Dell", STAC_9200_DELL_D23),
1282 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1283 "unknown Dell", STAC_9200_DELL_D23),
1284 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1285 "unknown Dell", STAC_9200_DELL_D21),
1286 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1287 "unknown Dell", STAC_9200_DELL_D23),
1288 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1289 "unknown Dell", STAC_9200_DELL_D21),
1290 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1291 "unknown Dell", STAC_9200_DELL_M25),
1292 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1293 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001294 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001295 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1296 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1297 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001298 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001299 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001300 /* Gateway machines needs EAPD to be set on resume */
1301 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1302 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1303 STAC_9200_GATEWAY),
1304 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1305 STAC_9200_GATEWAY),
Tobin Davisbf277782008-02-03 20:31:47 +01001306 /* OQO Mobile */
1307 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001308 {} /* terminator */
1309};
1310
Tobin Davis8e21c342007-01-08 11:04:17 +01001311static unsigned int ref925x_pin_configs[8] = {
1312 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001313 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001314};
1315
1316static unsigned int stac925x_MA6_pin_configs[8] = {
1317 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1318 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1319};
1320
Tobin Davis2c11f952007-05-17 09:36:34 +02001321static unsigned int stac925x_PA6_pin_configs[8] = {
1322 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1323 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1324};
1325
Tobin Davis8e21c342007-01-08 11:04:17 +01001326static unsigned int stac925xM2_2_pin_configs[8] = {
Steve Longerbeam7353e142007-05-29 14:36:17 +02001327 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1328 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001329};
1330
1331static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1332 [STAC_REF] = ref925x_pin_configs,
1333 [STAC_M2_2] = stac925xM2_2_pin_configs,
1334 [STAC_MA6] = stac925x_MA6_pin_configs,
Tobin Davis2c11f952007-05-17 09:36:34 +02001335 [STAC_PA6] = stac925x_PA6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001336};
1337
1338static const char *stac925x_models[STAC_925x_MODELS] = {
1339 [STAC_REF] = "ref",
1340 [STAC_M2_2] = "m2-2",
1341 [STAC_MA6] = "m6",
Tobin Davis2c11f952007-05-17 09:36:34 +02001342 [STAC_PA6] = "pa6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001343};
1344
1345static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1346 /* SigmaTel reference board */
1347 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001348 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Tobin Davis8e21c342007-01-08 11:04:17 +01001349 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1350 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1351 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
Tobin Davis2c11f952007-05-17 09:36:34 +02001352 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
Tobin Davis8e21c342007-01-08 11:04:17 +01001353 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1354 {} /* terminator */
1355};
1356
Matthew Ranostaya7662642008-02-21 07:51:14 +01001357static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001358 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1359 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1360 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001361 0x01452050,
1362};
1363
1364static unsigned int dell_m6_pin_configs[13] = {
1365 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001366 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001367 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1368 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001369};
1370
1371static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001372 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1373 [STAC_DELL_M6] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001374};
1375
1376static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1377 [STAC_92HD73XX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001378 [STAC_DELL_M6] = "dell-m6",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001379};
1380
1381static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1382 /* SigmaTel reference board */
1383 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001384 "DFI LanParty", STAC_92HD73XX_REF),
1385 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1386 "unknown Dell", STAC_DELL_M6),
1387 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1388 "unknown Dell", STAC_DELL_M6),
1389 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1390 "unknown Dell", STAC_DELL_M6),
1391 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1392 "unknown Dell", STAC_DELL_M6),
1393 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1394 "unknown Dell", STAC_DELL_M6),
1395 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1396 "unknown Dell", STAC_DELL_M6),
1397 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1398 "unknown Dell", STAC_DELL_M6),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001399 {} /* terminator */
1400};
1401
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001402static unsigned int ref92hd83xxx_pin_configs[14] = {
1403 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1404 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1405 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1406 0x01451160, 0x98560170,
1407};
1408
1409static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1410 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1411};
1412
1413static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1414 [STAC_92HD83XXX_REF] = "ref",
1415};
1416
1417static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1418 /* SigmaTel reference board */
1419 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1420 "DFI LanParty", STAC_92HD71BXX_REF),
1421};
1422
Matthew Ranostaye035b842007-11-06 11:53:55 +01001423static unsigned int ref92hd71bxx_pin_configs[10] = {
1424 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostayb22b4822008-01-22 12:32:30 +01001425 0x0181302e, 0x01114010, 0x01019020, 0x90a000f0,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001426 0x90a000f0, 0x01452050,
1427};
1428
Matthew Ranostayaafc4412008-06-13 18:04:33 +02001429static unsigned int dell_m4_1_pin_configs[10] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001430 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001431 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001432 0x40f000f0, 0x4f0000f0,
1433};
1434
Matthew Ranostayaafc4412008-06-13 18:04:33 +02001435static unsigned int dell_m4_2_pin_configs[10] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001436 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1437 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1438 0x40f000f0, 0x044413b0,
1439};
1440
Matthew Ranostaye035b842007-11-06 11:53:55 +01001441static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1442 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001443 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1444 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001445};
1446
1447static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1448 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001449 [STAC_DELL_M4_1] = "dell-m4-1",
1450 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001451};
1452
1453static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1454 /* SigmaTel reference board */
1455 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1456 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001457 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1458 "unknown Dell", STAC_DELL_M4_1),
1459 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1460 "unknown Dell", STAC_DELL_M4_1),
1461 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1462 "unknown Dell", STAC_DELL_M4_1),
1463 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1464 "unknown Dell", STAC_DELL_M4_1),
1465 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1466 "unknown Dell", STAC_DELL_M4_1),
1467 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1468 "unknown Dell", STAC_DELL_M4_1),
1469 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1470 "unknown Dell", STAC_DELL_M4_1),
1471 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1472 "unknown Dell", STAC_DELL_M4_2),
1473 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1474 "unknown Dell", STAC_DELL_M4_2),
1475 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1476 "unknown Dell", STAC_DELL_M4_2),
1477 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1478 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001479 {} /* terminator */
1480};
1481
Matt Porter403d1942005-11-29 15:00:51 +01001482static unsigned int ref922x_pin_configs[10] = {
1483 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1484 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001485 0x40000100, 0x40000100,
1486};
1487
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001488/*
1489 STAC 922X pin configs for
1490 102801A7
1491 102801AB
1492 102801A9
1493 102801D1
1494 102801D2
1495*/
1496static unsigned int dell_922x_d81_pin_configs[10] = {
1497 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1498 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1499 0x01813122, 0x400001f2,
1500};
1501
1502/*
1503 STAC 922X pin configs for
1504 102801AC
1505 102801D0
1506*/
1507static unsigned int dell_922x_d82_pin_configs[10] = {
1508 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1509 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1510 0x01813122, 0x400001f1,
1511};
1512
1513/*
1514 STAC 922X pin configs for
1515 102801BF
1516*/
1517static unsigned int dell_922x_m81_pin_configs[10] = {
1518 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1519 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1520 0x40C003f1, 0x405003f0,
1521};
1522
1523/*
1524 STAC 9221 A1 pin configs for
1525 102801D7 (Dell XPS M1210)
1526*/
1527static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001528 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1529 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001530 0x508003f3, 0x405003f4,
1531};
1532
Matt Porter403d1942005-11-29 15:00:51 +01001533static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001534 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001535 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1536 0x02a19120, 0x40000100,
1537};
1538
1539static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001540 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1541 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001542 0x02a19320, 0x40000100,
1543};
1544
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001545static unsigned int intel_mac_v1_pin_configs[10] = {
1546 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1547 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001548 0x400000fc, 0x400000fb,
1549};
1550
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001551static unsigned int intel_mac_v2_pin_configs[10] = {
1552 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1553 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001554 0x400000fc, 0x400000fb,
1555};
1556
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001557static unsigned int intel_mac_v3_pin_configs[10] = {
1558 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1559 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1560 0x400000fc, 0x400000fb,
1561};
1562
1563static unsigned int intel_mac_v4_pin_configs[10] = {
1564 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1565 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1566 0x400000fc, 0x400000fb,
1567};
1568
1569static unsigned int intel_mac_v5_pin_configs[10] = {
1570 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1571 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1572 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001573};
1574
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001575static unsigned int ecs202_pin_configs[10] = {
1576 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1577 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1578 0x9037012e, 0x40e000f2,
1579};
Takashi Iwai76c08822007-06-19 12:17:42 +02001580
Takashi Iwai19039bd2006-06-28 15:52:16 +02001581static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001582 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001583 [STAC_D945GTP3] = d945gtp3_pin_configs,
1584 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001585 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1586 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1587 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1588 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1589 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001590 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001591 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001592 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1593 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1594 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1595 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1596 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1597 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001598 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001599 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1600 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1601 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1602 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001603};
1604
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001605static const char *stac922x_models[STAC_922X_MODELS] = {
1606 [STAC_D945_REF] = "ref",
1607 [STAC_D945GTP5] = "5stack",
1608 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001609 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1610 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1611 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1612 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1613 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001614 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001615 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001616 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001617 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001618 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1619 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001620 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001621 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001622 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001623 [STAC_922X_DELL_D81] = "dell-d81",
1624 [STAC_922X_DELL_D82] = "dell-d82",
1625 [STAC_922X_DELL_M81] = "dell-m81",
1626 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001627};
1628
1629static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1630 /* SigmaTel reference board */
1631 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1632 "DFI LanParty", STAC_D945_REF),
1633 /* Intel 945G based systems */
1634 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1635 "Intel D945G", STAC_D945GTP3),
1636 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1637 "Intel D945G", STAC_D945GTP3),
1638 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1639 "Intel D945G", STAC_D945GTP3),
1640 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1641 "Intel D945G", STAC_D945GTP3),
1642 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1643 "Intel D945G", STAC_D945GTP3),
1644 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1645 "Intel D945G", STAC_D945GTP3),
1646 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1647 "Intel D945G", STAC_D945GTP3),
1648 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1649 "Intel D945G", STAC_D945GTP3),
1650 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1651 "Intel D945G", STAC_D945GTP3),
1652 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1653 "Intel D945G", STAC_D945GTP3),
1654 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1655 "Intel D945G", STAC_D945GTP3),
1656 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1657 "Intel D945G", STAC_D945GTP3),
1658 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1659 "Intel D945G", STAC_D945GTP3),
1660 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1661 "Intel D945G", STAC_D945GTP3),
1662 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1663 "Intel D945G", STAC_D945GTP3),
1664 /* Intel D945G 5-stack systems */
1665 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1666 "Intel D945G", STAC_D945GTP5),
1667 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1668 "Intel D945G", STAC_D945GTP5),
1669 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1670 "Intel D945G", STAC_D945GTP5),
1671 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1672 "Intel D945G", STAC_D945GTP5),
1673 /* Intel 945P based systems */
1674 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1675 "Intel D945P", STAC_D945GTP3),
1676 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1677 "Intel D945P", STAC_D945GTP3),
1678 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1679 "Intel D945P", STAC_D945GTP3),
1680 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1681 "Intel D945P", STAC_D945GTP3),
1682 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1683 "Intel D945P", STAC_D945GTP3),
1684 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1685 "Intel D945P", STAC_D945GTP5),
1686 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08001687 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001688 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001689 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001690 /* Dell systems */
1691 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1692 "unknown Dell", STAC_922X_DELL_D81),
1693 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1694 "unknown Dell", STAC_922X_DELL_D81),
1695 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1696 "unknown Dell", STAC_922X_DELL_D81),
1697 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1698 "unknown Dell", STAC_922X_DELL_D82),
1699 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1700 "unknown Dell", STAC_922X_DELL_M81),
1701 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1702 "unknown Dell", STAC_922X_DELL_D82),
1703 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1704 "unknown Dell", STAC_922X_DELL_D81),
1705 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1706 "unknown Dell", STAC_922X_DELL_D81),
1707 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1708 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001709 /* ECS/PC Chips boards */
1710 SND_PCI_QUIRK(0x1019, 0x2144,
1711 "ECS/PC chips", STAC_ECS_202),
1712 SND_PCI_QUIRK(0x1019, 0x2608,
1713 "ECS/PC chips", STAC_ECS_202),
1714 SND_PCI_QUIRK(0x1019, 0x2633,
1715 "ECS/PC chips P17G/1333", STAC_ECS_202),
1716 SND_PCI_QUIRK(0x1019, 0x2811,
1717 "ECS/PC chips", STAC_ECS_202),
1718 SND_PCI_QUIRK(0x1019, 0x2812,
1719 "ECS/PC chips", STAC_ECS_202),
1720 SND_PCI_QUIRK(0x1019, 0x2813,
1721 "ECS/PC chips", STAC_ECS_202),
1722 SND_PCI_QUIRK(0x1019, 0x2814,
1723 "ECS/PC chips", STAC_ECS_202),
1724 SND_PCI_QUIRK(0x1019, 0x2815,
1725 "ECS/PC chips", STAC_ECS_202),
1726 SND_PCI_QUIRK(0x1019, 0x2816,
1727 "ECS/PC chips", STAC_ECS_202),
1728 SND_PCI_QUIRK(0x1019, 0x2817,
1729 "ECS/PC chips", STAC_ECS_202),
1730 SND_PCI_QUIRK(0x1019, 0x2818,
1731 "ECS/PC chips", STAC_ECS_202),
1732 SND_PCI_QUIRK(0x1019, 0x2819,
1733 "ECS/PC chips", STAC_ECS_202),
1734 SND_PCI_QUIRK(0x1019, 0x2820,
1735 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01001736 {} /* terminator */
1737};
1738
Matt Porter3cc08dc2006-01-23 15:27:49 +01001739static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02001740 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1741 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1742 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1743 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01001744};
1745
Tobin Davis93ed1502006-09-01 21:03:12 +02001746static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02001747 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1748 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1749 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1750 0x40000100, 0x40000100
1751};
1752
Tobin Davis93ed1502006-09-01 21:03:12 +02001753static unsigned int d965_5st_pin_configs[14] = {
1754 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1755 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1756 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1757 0x40000100, 0x40000100
1758};
1759
Tobin Davis4ff076e2007-08-07 11:48:12 +02001760static unsigned int dell_3st_pin_configs[14] = {
1761 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1762 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001763 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02001764 0x40c003fc, 0x40000100
1765};
1766
Tobin Davis93ed1502006-09-01 21:03:12 +02001767static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001768 [STAC_D965_REF] = ref927x_pin_configs,
1769 [STAC_D965_3ST] = d965_3st_pin_configs,
1770 [STAC_D965_5ST] = d965_5st_pin_configs,
1771 [STAC_DELL_3ST] = dell_3st_pin_configs,
1772 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01001773};
1774
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001775static const char *stac927x_models[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001776 [STAC_D965_REF] = "ref",
1777 [STAC_D965_3ST] = "3stack",
1778 [STAC_D965_5ST] = "5stack",
1779 [STAC_DELL_3ST] = "dell-3stack",
1780 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001781};
1782
1783static struct snd_pci_quirk stac927x_cfg_tbl[] = {
1784 /* SigmaTel reference board */
1785 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1786 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02001787 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001788 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
1789 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02001790 /* 965 based 3 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001791 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
1792 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
1793 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
1794 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
1795 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
1796 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
1797 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
1798 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
1799 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
1800 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
1801 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
1802 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
1803 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
1804 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
1805 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
1806 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02001807 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001808 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001809 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02001810 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
1811 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001812 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01001813 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
1814 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001815 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02001816 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001817 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
1818 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
1819 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
1820 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02001821 /* 965 based 5 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001822 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
1823 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
1824 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
1825 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
1826 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
1827 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
1828 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
1829 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
1830 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01001831 {} /* terminator */
1832};
1833
Matt Porterf3302a52006-07-31 12:49:34 +02001834static unsigned int ref9205_pin_configs[12] = {
1835 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001836 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02001837 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02001838};
1839
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001840/*
1841 STAC 9205 pin configs for
1842 102801F1
1843 102801F2
1844 102801FC
1845 102801FD
1846 10280204
1847 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01001848 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001849*/
1850static unsigned int dell_9205_m42_pin_configs[12] = {
1851 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
1852 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
1853 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
1854};
1855
1856/*
1857 STAC 9205 pin configs for
1858 102801F9
1859 102801FA
1860 102801FE
1861 102801FF (Dell Precision M4300)
1862 10280206
1863 10280200
1864 10280201
1865*/
1866static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001867 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
1868 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
1869 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
1870};
1871
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001872static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001873 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
1874 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
1875 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
1876};
1877
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001878static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001879 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001880 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
1881 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
1882 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Matt Porterf3302a52006-07-31 12:49:34 +02001883};
1884
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001885static const char *stac9205_models[STAC_9205_MODELS] = {
1886 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001887 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001888 [STAC_9205_DELL_M43] = "dell-m43",
1889 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001890};
1891
1892static struct snd_pci_quirk stac9205_cfg_tbl[] = {
1893 /* SigmaTel reference board */
1894 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1895 "DFI LanParty", STAC_9205_REF),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001896 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
1897 "unknown Dell", STAC_9205_DELL_M42),
1898 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
1899 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001900 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02001901 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001902 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
1903 "Dell Precision", STAC_9205_DELL_M43),
1904 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
1905 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001906 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
1907 "unknown Dell", STAC_9205_DELL_M42),
1908 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
1909 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001910 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
1911 "Dell Precision", STAC_9205_DELL_M43),
1912 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001913 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001914 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
1915 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02001916 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
1917 "Dell Precision", STAC_9205_DELL_M43),
1918 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
1919 "Dell Precision", STAC_9205_DELL_M43),
1920 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
1921 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001922 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
1923 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01001924 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
1925 "Dell Vostro 1500", STAC_9205_DELL_M42),
Matt Porterf3302a52006-07-31 12:49:34 +02001926 {} /* terminator */
1927};
1928
Richard Fish11b44bb2006-08-23 18:31:34 +02001929static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
1930{
1931 int i;
1932 struct sigmatel_spec *spec = codec->spec;
1933
1934 if (! spec->bios_pin_configs) {
1935 spec->bios_pin_configs = kcalloc(spec->num_pins,
1936 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
1937 if (! spec->bios_pin_configs)
1938 return -ENOMEM;
1939 }
1940
1941 for (i = 0; i < spec->num_pins; i++) {
1942 hda_nid_t nid = spec->pin_nids[i];
1943 unsigned int pin_cfg;
1944
1945 pin_cfg = snd_hda_codec_read(codec, nid, 0,
1946 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
1947 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
1948 nid, pin_cfg);
1949 spec->bios_pin_configs[i] = pin_cfg;
1950 }
1951
1952 return 0;
1953}
1954
Matthew Ranostay87d48362007-07-17 11:52:24 +02001955static void stac92xx_set_config_reg(struct hda_codec *codec,
1956 hda_nid_t pin_nid, unsigned int pin_config)
1957{
1958 int i;
1959 snd_hda_codec_write(codec, pin_nid, 0,
1960 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
1961 pin_config & 0x000000ff);
1962 snd_hda_codec_write(codec, pin_nid, 0,
1963 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
1964 (pin_config & 0x0000ff00) >> 8);
1965 snd_hda_codec_write(codec, pin_nid, 0,
1966 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
1967 (pin_config & 0x00ff0000) >> 16);
1968 snd_hda_codec_write(codec, pin_nid, 0,
1969 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
1970 pin_config >> 24);
1971 i = snd_hda_codec_read(codec, pin_nid, 0,
1972 AC_VERB_GET_CONFIG_DEFAULT,
1973 0x00);
1974 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
1975 pin_nid, i);
1976}
1977
Matt2f2f4252005-04-13 14:45:30 +02001978static void stac92xx_set_config_regs(struct hda_codec *codec)
1979{
1980 int i;
1981 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02001982
Matthew Ranostay87d48362007-07-17 11:52:24 +02001983 if (!spec->pin_configs)
1984 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02001985
Matthew Ranostay87d48362007-07-17 11:52:24 +02001986 for (i = 0; i < spec->num_pins; i++)
1987 stac92xx_set_config_reg(codec, spec->pin_nids[i],
1988 spec->pin_configs[i]);
Matt2f2f4252005-04-13 14:45:30 +02001989}
Matt2f2f4252005-04-13 14:45:30 +02001990
Matt2f2f4252005-04-13 14:45:30 +02001991/*
1992 * Analog playback callbacks
1993 */
1994static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
1995 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001996 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02001997{
1998 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01001999 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2000 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002001}
2002
2003static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2004 struct hda_codec *codec,
2005 unsigned int stream_tag,
2006 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002007 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002008{
2009 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002010 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002011}
2012
2013static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2014 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002015 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002016{
2017 struct sigmatel_spec *spec = codec->spec;
2018 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2019}
2020
2021/*
Mattdabbed62005-06-14 10:19:34 +02002022 * Digital playback callbacks
2023 */
2024static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2025 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002026 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002027{
2028 struct sigmatel_spec *spec = codec->spec;
2029 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2030}
2031
2032static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2033 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002034 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002035{
2036 struct sigmatel_spec *spec = codec->spec;
2037 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2038}
2039
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002040static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2041 struct hda_codec *codec,
2042 unsigned int stream_tag,
2043 unsigned int format,
2044 struct snd_pcm_substream *substream)
2045{
2046 struct sigmatel_spec *spec = codec->spec;
2047 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2048 stream_tag, format, substream);
2049}
2050
Mattdabbed62005-06-14 10:19:34 +02002051
2052/*
Matt2f2f4252005-04-13 14:45:30 +02002053 * Analog capture callbacks
2054 */
2055static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2056 struct hda_codec *codec,
2057 unsigned int stream_tag,
2058 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002059 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002060{
2061 struct sigmatel_spec *spec = codec->spec;
2062
2063 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2064 stream_tag, 0, format);
2065 return 0;
2066}
2067
2068static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2069 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002070 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002071{
2072 struct sigmatel_spec *spec = codec->spec;
2073
Takashi Iwai888afa12008-03-18 09:57:50 +01002074 snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
Matt2f2f4252005-04-13 14:45:30 +02002075 return 0;
2076}
2077
Mattdabbed62005-06-14 10:19:34 +02002078static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2079 .substreams = 1,
2080 .channels_min = 2,
2081 .channels_max = 2,
2082 /* NID is set in stac92xx_build_pcms */
2083 .ops = {
2084 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002085 .close = stac92xx_dig_playback_pcm_close,
2086 .prepare = stac92xx_dig_playback_pcm_prepare
Mattdabbed62005-06-14 10:19:34 +02002087 },
2088};
2089
2090static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2091 .substreams = 1,
2092 .channels_min = 2,
2093 .channels_max = 2,
2094 /* NID is set in stac92xx_build_pcms */
2095};
2096
Matt2f2f4252005-04-13 14:45:30 +02002097static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2098 .substreams = 1,
2099 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002100 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002101 .nid = 0x02, /* NID to query formats and rates */
2102 .ops = {
2103 .open = stac92xx_playback_pcm_open,
2104 .prepare = stac92xx_playback_pcm_prepare,
2105 .cleanup = stac92xx_playback_pcm_cleanup
2106 },
2107};
2108
Matt Porter3cc08dc2006-01-23 15:27:49 +01002109static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2110 .substreams = 1,
2111 .channels_min = 2,
2112 .channels_max = 2,
2113 .nid = 0x06, /* NID to query formats and rates */
2114 .ops = {
2115 .open = stac92xx_playback_pcm_open,
2116 .prepare = stac92xx_playback_pcm_prepare,
2117 .cleanup = stac92xx_playback_pcm_cleanup
2118 },
2119};
2120
Matt2f2f4252005-04-13 14:45:30 +02002121static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002122 .channels_min = 2,
2123 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002124 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002125 .ops = {
2126 .prepare = stac92xx_capture_pcm_prepare,
2127 .cleanup = stac92xx_capture_pcm_cleanup
2128 },
2129};
2130
2131static int stac92xx_build_pcms(struct hda_codec *codec)
2132{
2133 struct sigmatel_spec *spec = codec->spec;
2134 struct hda_pcm *info = spec->pcm_rec;
2135
2136 codec->num_pcms = 1;
2137 codec->pcm_info = info;
2138
Mattc7d4b2f2005-06-27 14:59:41 +02002139 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002140 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Matt2f2f4252005-04-13 14:45:30 +02002141 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002142 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002143 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002144
2145 if (spec->alt_switch) {
2146 codec->num_pcms++;
2147 info++;
2148 info->name = "STAC92xx Analog Alt";
2149 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2150 }
Matt2f2f4252005-04-13 14:45:30 +02002151
Mattdabbed62005-06-14 10:19:34 +02002152 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2153 codec->num_pcms++;
2154 info++;
2155 info->name = "STAC92xx Digital";
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002156 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Mattdabbed62005-06-14 10:19:34 +02002157 if (spec->multiout.dig_out_nid) {
2158 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2159 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2160 }
2161 if (spec->dig_in_nid) {
2162 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2163 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2164 }
2165 }
2166
Matt2f2f4252005-04-13 14:45:30 +02002167 return 0;
2168}
2169
Takashi Iwaic960a032006-03-23 17:06:28 +01002170static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2171{
2172 unsigned int pincap = snd_hda_param_read(codec, nid,
2173 AC_PAR_PIN_CAP);
2174 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2175 if (pincap & AC_PINCAP_VREF_100)
2176 return AC_PINCTL_VREF_100;
2177 if (pincap & AC_PINCAP_VREF_80)
2178 return AC_PINCTL_VREF_80;
2179 if (pincap & AC_PINCAP_VREF_50)
2180 return AC_PINCTL_VREF_50;
2181 if (pincap & AC_PINCAP_VREF_GRD)
2182 return AC_PINCTL_VREF_GRD;
2183 return 0;
2184}
2185
Matt Porter403d1942005-11-29 15:00:51 +01002186static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2187
2188{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002189 snd_hda_codec_write_cache(codec, nid, 0,
2190 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002191}
2192
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002193#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2194
2195static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2196 struct snd_ctl_elem_value *ucontrol)
2197{
2198 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2199 struct sigmatel_spec *spec = codec->spec;
2200
2201 ucontrol->value.integer.value[0] = spec->hp_switch;
2202 return 0;
2203}
2204
2205static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2206 struct snd_ctl_elem_value *ucontrol)
2207{
2208 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2209 struct sigmatel_spec *spec = codec->spec;
2210
2211 spec->hp_switch = ucontrol->value.integer.value[0];
2212
2213 /* check to be sure that the ports are upto date with
2214 * switch changes
2215 */
2216 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2217
2218 return 1;
2219}
2220
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002221#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002222
2223static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2224{
2225 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2226 struct sigmatel_spec *spec = codec->spec;
2227 int io_idx = kcontrol-> private_value & 0xff;
2228
2229 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2230 return 0;
2231}
2232
2233static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2234{
2235 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2236 struct sigmatel_spec *spec = codec->spec;
2237 hda_nid_t nid = kcontrol->private_value >> 8;
2238 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002239 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002240
2241 spec->io_switch[io_idx] = val;
2242
2243 if (val)
2244 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002245 else {
2246 unsigned int pinctl = AC_PINCTL_IN_EN;
2247 if (io_idx) /* set VREF for mic */
2248 pinctl |= stac92xx_get_vref(codec, nid);
2249 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2250 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002251
2252 /* check the auto-mute again: we need to mute/unmute the speaker
2253 * appropriately according to the pin direction
2254 */
2255 if (spec->hp_detect)
2256 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2257
Matt Porter403d1942005-11-29 15:00:51 +01002258 return 1;
2259}
2260
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002261#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2262
2263static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2264 struct snd_ctl_elem_value *ucontrol)
2265{
2266 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2267 struct sigmatel_spec *spec = codec->spec;
2268
2269 ucontrol->value.integer.value[0] = spec->clfe_swap;
2270 return 0;
2271}
2272
2273static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2274 struct snd_ctl_elem_value *ucontrol)
2275{
2276 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2277 struct sigmatel_spec *spec = codec->spec;
2278 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002279 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002280
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002281 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002282 return 0;
2283
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002284 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002285
2286 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2287 spec->clfe_swap ? 0x4 : 0x0);
2288
2289 return 1;
2290}
2291
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002292#define STAC_CODEC_HP_SWITCH(xname) \
2293 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2294 .name = xname, \
2295 .index = 0, \
2296 .info = stac92xx_hp_switch_info, \
2297 .get = stac92xx_hp_switch_get, \
2298 .put = stac92xx_hp_switch_put, \
2299 }
2300
Matt Porter403d1942005-11-29 15:00:51 +01002301#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2302 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2303 .name = xname, \
2304 .index = 0, \
2305 .info = stac92xx_io_switch_info, \
2306 .get = stac92xx_io_switch_get, \
2307 .put = stac92xx_io_switch_put, \
2308 .private_value = xpval, \
2309 }
2310
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002311#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2312 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2313 .name = xname, \
2314 .index = 0, \
2315 .info = stac92xx_clfe_switch_info, \
2316 .get = stac92xx_clfe_switch_get, \
2317 .put = stac92xx_clfe_switch_put, \
2318 .private_value = xpval, \
2319 }
Matt Porter403d1942005-11-29 15:00:51 +01002320
Mattc7d4b2f2005-06-27 14:59:41 +02002321enum {
2322 STAC_CTL_WIDGET_VOL,
2323 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002324 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002325 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002326 STAC_CTL_WIDGET_IO_SWITCH,
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002327 STAC_CTL_WIDGET_CLFE_SWITCH
Mattc7d4b2f2005-06-27 14:59:41 +02002328};
2329
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002330static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002331 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2332 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002333 STAC_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002334 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002335 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002336 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002337};
2338
2339/* add dynamic controls */
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002340static int stac92xx_add_control_idx(struct sigmatel_spec *spec, int type,
2341 int idx, const char *name, unsigned long val)
Mattc7d4b2f2005-06-27 14:59:41 +02002342{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002343 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002344
2345 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2346 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2347
2348 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2349 if (! knew)
2350 return -ENOMEM;
2351 if (spec->kctl_alloc) {
2352 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2353 kfree(spec->kctl_alloc);
2354 }
2355 spec->kctl_alloc = knew;
2356 spec->num_kctl_alloc = num;
2357 }
2358
2359 knew = &spec->kctl_alloc[spec->num_kctl_used];
2360 *knew = stac92xx_control_templates[type];
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002361 knew->index = idx;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002362 knew->name = kstrdup(name, GFP_KERNEL);
Mattc7d4b2f2005-06-27 14:59:41 +02002363 if (! knew->name)
2364 return -ENOMEM;
2365 knew->private_value = val;
2366 spec->num_kctl_used++;
2367 return 0;
2368}
2369
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002370
2371/* add dynamic controls */
2372static int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2373 const char *name, unsigned long val)
2374{
2375 return stac92xx_add_control_idx(spec, type, 0, name, val);
2376}
2377
Matt Porter403d1942005-11-29 15:00:51 +01002378/* flag inputs as additional dynamic lineouts */
2379static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2380{
2381 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002382 unsigned int wcaps, wtype;
2383 int i, num_dacs = 0;
2384
2385 /* use the wcaps cache to count all DACs available for line-outs */
2386 for (i = 0; i < codec->num_nodes; i++) {
2387 wcaps = codec->wcaps[i];
2388 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002389
Steve Longerbeam7b043892007-05-03 20:50:03 +02002390 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2391 num_dacs++;
2392 }
Matt Porter403d1942005-11-29 15:00:51 +01002393
Steve Longerbeam7b043892007-05-03 20:50:03 +02002394 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2395
Matt Porter403d1942005-11-29 15:00:51 +01002396 switch (cfg->line_outs) {
2397 case 3:
2398 /* add line-in as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002399 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002400 cfg->line_out_pins[cfg->line_outs] =
2401 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002402 spec->line_switch = 1;
2403 cfg->line_outs++;
2404 }
2405 break;
2406 case 2:
2407 /* add line-in as clfe and mic as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002408 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002409 cfg->line_out_pins[cfg->line_outs] =
2410 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002411 spec->line_switch = 1;
2412 cfg->line_outs++;
2413 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002414 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002415 cfg->line_out_pins[cfg->line_outs] =
2416 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002417 spec->mic_switch = 1;
2418 cfg->line_outs++;
2419 }
2420 break;
2421 case 1:
2422 /* add line-in as surr and mic as clfe */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002423 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002424 cfg->line_out_pins[cfg->line_outs] =
2425 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002426 spec->line_switch = 1;
2427 cfg->line_outs++;
2428 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002429 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002430 cfg->line_out_pins[cfg->line_outs] =
2431 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002432 spec->mic_switch = 1;
2433 cfg->line_outs++;
2434 }
2435 break;
2436 }
2437
2438 return 0;
2439}
2440
Steve Longerbeam7b043892007-05-03 20:50:03 +02002441
2442static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2443{
2444 int i;
2445
2446 for (i = 0; i < spec->multiout.num_dacs; i++) {
2447 if (spec->multiout.dac_nids[i] == nid)
2448 return 1;
2449 }
2450
2451 return 0;
2452}
2453
Matt Porter3cc08dc2006-01-23 15:27:49 +01002454/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02002455 * Fill in the dac_nids table from the parsed pin configuration
2456 * This function only works when every pin in line_out_pins[]
2457 * contains atleast one DAC in its connection list. Some 92xx
2458 * codecs are not connected directly to a DAC, such as the 9200
2459 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002460 */
Takashi Iwai19039bd2006-06-28 15:52:16 +02002461static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaidf802952007-07-02 19:18:00 +02002462 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002463{
2464 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002465 int i, j, conn_len = 0;
2466 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2467 unsigned int wcaps, wtype;
2468
Mattc7d4b2f2005-06-27 14:59:41 +02002469 for (i = 0; i < cfg->line_outs; i++) {
2470 nid = cfg->line_out_pins[i];
Steve Longerbeam7b043892007-05-03 20:50:03 +02002471 conn_len = snd_hda_get_connections(codec, nid, conn,
2472 HDA_MAX_CONNECTIONS);
2473 for (j = 0; j < conn_len; j++) {
2474 wcaps = snd_hda_param_read(codec, conn[j],
2475 AC_PAR_AUDIO_WIDGET_CAP);
2476 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002477 if (wtype != AC_WID_AUD_OUT ||
2478 (wcaps & AC_WCAP_DIGITAL))
2479 continue;
2480 /* conn[j] is a DAC routed to this line-out */
2481 if (!is_in_dac_nids(spec, conn[j]))
2482 break;
2483 }
2484
2485 if (j == conn_len) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002486 if (spec->multiout.num_dacs > 0) {
2487 /* we have already working output pins,
2488 * so let's drop the broken ones again
2489 */
2490 cfg->line_outs = spec->multiout.num_dacs;
2491 break;
2492 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002493 /* error out, no available DAC found */
2494 snd_printk(KERN_ERR
2495 "%s: No available DAC for pin 0x%x\n",
2496 __func__, nid);
2497 return -ENODEV;
2498 }
2499
2500 spec->multiout.dac_nids[i] = conn[j];
2501 spec->multiout.num_dacs++;
2502 if (conn_len > 1) {
2503 /* select this DAC in the pin's input mux */
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002504 snd_hda_codec_write_cache(codec, nid, 0,
2505 AC_VERB_SET_CONNECT_SEL, j);
Steve Longerbeam7b043892007-05-03 20:50:03 +02002506
2507 }
Mattc7d4b2f2005-06-27 14:59:41 +02002508 }
2509
Steve Longerbeam7b043892007-05-03 20:50:03 +02002510 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2511 spec->multiout.num_dacs,
2512 spec->multiout.dac_nids[0],
2513 spec->multiout.dac_nids[1],
2514 spec->multiout.dac_nids[2],
2515 spec->multiout.dac_nids[3],
2516 spec->multiout.dac_nids[4]);
Mattc7d4b2f2005-06-27 14:59:41 +02002517 return 0;
2518}
2519
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002520/* create volume control/switch for the given prefx type */
2521static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2522{
2523 char name[32];
2524 int err;
2525
2526 sprintf(name, "%s Playback Volume", pfx);
2527 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2528 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2529 if (err < 0)
2530 return err;
2531 sprintf(name, "%s Playback Switch", pfx);
2532 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2533 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2534 if (err < 0)
2535 return err;
2536 return 0;
2537}
2538
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002539static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2540{
2541 if (!spec->multiout.hp_nid)
2542 spec->multiout.hp_nid = nid;
2543 else if (spec->multiout.num_dacs > 4) {
2544 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2545 return 1;
2546 } else {
2547 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2548 spec->multiout.num_dacs++;
2549 }
2550 return 0;
2551}
2552
2553static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2554{
2555 if (is_in_dac_nids(spec, nid))
2556 return 1;
2557 if (spec->multiout.hp_nid == nid)
2558 return 1;
2559 return 0;
2560}
2561
Mattc7d4b2f2005-06-27 14:59:41 +02002562/* add playback controls from the parsed DAC table */
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002563static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
Takashi Iwai19039bd2006-06-28 15:52:16 +02002564 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002565{
Takashi Iwai19039bd2006-06-28 15:52:16 +02002566 static const char *chname[4] = {
2567 "Front", "Surround", NULL /*CLFE*/, "Side"
2568 };
Mattc7d4b2f2005-06-27 14:59:41 +02002569 hda_nid_t nid;
2570 int i, err;
2571
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002572 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002573 unsigned int wid_caps, pincap;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002574
2575
Takashi Iwai40ac8c42008-02-29 14:16:17 +01002576 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
Matt Porter403d1942005-11-29 15:00:51 +01002577 if (!spec->multiout.dac_nids[i])
Mattc7d4b2f2005-06-27 14:59:41 +02002578 continue;
2579
2580 nid = spec->multiout.dac_nids[i];
2581
2582 if (i == 2) {
2583 /* Center/LFE */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002584 err = create_controls(spec, "Center", nid, 1);
2585 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002586 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002587 err = create_controls(spec, "LFE", nid, 2);
2588 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002589 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002590
2591 wid_caps = get_wcaps(codec, nid);
2592
2593 if (wid_caps & AC_WCAP_LR_SWAP) {
2594 err = stac92xx_add_control(spec,
2595 STAC_CTL_WIDGET_CLFE_SWITCH,
2596 "Swap Center/LFE Playback Switch", nid);
2597
2598 if (err < 0)
2599 return err;
2600 }
2601
Mattc7d4b2f2005-06-27 14:59:41 +02002602 } else {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002603 err = create_controls(spec, chname[i], nid, 3);
2604 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002605 return err;
2606 }
2607 }
2608
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002609 if (cfg->hp_outs > 1) {
2610 err = stac92xx_add_control(spec,
2611 STAC_CTL_WIDGET_HP_SWITCH,
2612 "Headphone as Line Out Switch", 0);
2613 if (err < 0)
2614 return err;
2615 }
2616
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002617 if (spec->line_switch) {
2618 nid = cfg->input_pins[AUTO_PIN_LINE];
2619 pincap = snd_hda_param_read(codec, nid,
2620 AC_PAR_PIN_CAP);
2621 if (pincap & AC_PINCAP_OUT) {
2622 err = stac92xx_add_control(spec,
2623 STAC_CTL_WIDGET_IO_SWITCH,
2624 "Line In as Output Switch", nid << 8);
2625 if (err < 0)
2626 return err;
2627 }
2628 }
Matt Porter403d1942005-11-29 15:00:51 +01002629
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002630 if (spec->mic_switch) {
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002631 unsigned int def_conf;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002632 unsigned int mic_pin = AUTO_PIN_MIC;
2633again:
2634 nid = cfg->input_pins[mic_pin];
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002635 def_conf = snd_hda_codec_read(codec, nid, 0,
2636 AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002637 /* some laptops have an internal analog microphone
2638 * which can't be used as a output */
2639 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2640 pincap = snd_hda_param_read(codec, nid,
2641 AC_PAR_PIN_CAP);
2642 if (pincap & AC_PINCAP_OUT) {
2643 err = stac92xx_add_control(spec,
2644 STAC_CTL_WIDGET_IO_SWITCH,
2645 "Mic as Output Switch", (nid << 8) | 1);
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002646 nid = snd_hda_codec_read(codec, nid, 0,
2647 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2648 if (!check_in_dac_nids(spec, nid))
2649 add_spec_dacs(spec, nid);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002650 if (err < 0)
2651 return err;
2652 }
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002653 } else if (mic_pin == AUTO_PIN_MIC) {
2654 mic_pin = AUTO_PIN_FRONT_MIC;
2655 goto again;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002656 }
2657 }
Matt Porter403d1942005-11-29 15:00:51 +01002658
Mattc7d4b2f2005-06-27 14:59:41 +02002659 return 0;
2660}
2661
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002662/* add playback controls for Speaker and HP outputs */
2663static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2664 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002665{
2666 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02002667 hda_nid_t nid;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002668 int i, old_num_dacs, err;
Mattc7d4b2f2005-06-27 14:59:41 +02002669
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002670 old_num_dacs = spec->multiout.num_dacs;
2671 for (i = 0; i < cfg->hp_outs; i++) {
2672 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2673 if (wid_caps & AC_WCAP_UNSOL_CAP)
2674 spec->hp_detect = 1;
2675 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2676 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2677 if (check_in_dac_nids(spec, nid))
2678 nid = 0;
2679 if (! nid)
Mattc7d4b2f2005-06-27 14:59:41 +02002680 continue;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002681 add_spec_dacs(spec, nid);
2682 }
2683 for (i = 0; i < cfg->speaker_outs; i++) {
Steve Longerbeam7b043892007-05-03 20:50:03 +02002684 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002685 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2686 if (check_in_dac_nids(spec, nid))
2687 nid = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002688 if (! nid)
2689 continue;
2690 add_spec_dacs(spec, nid);
Mattc7d4b2f2005-06-27 14:59:41 +02002691 }
Matthew Ranostay1b290a52007-07-12 15:17:34 +02002692 for (i = 0; i < cfg->line_outs; i++) {
2693 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2694 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2695 if (check_in_dac_nids(spec, nid))
2696 nid = 0;
2697 if (! nid)
2698 continue;
2699 add_spec_dacs(spec, nid);
2700 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002701 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2702 static const char *pfxs[] = {
2703 "Speaker", "External Speaker", "Speaker2",
2704 };
2705 err = create_controls(spec, pfxs[i - old_num_dacs],
2706 spec->multiout.dac_nids[i], 3);
2707 if (err < 0)
2708 return err;
2709 }
2710 if (spec->multiout.hp_nid) {
Takashi Iwai2626a262008-03-14 09:18:32 +01002711 err = create_controls(spec, "Headphone",
2712 spec->multiout.hp_nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002713 if (err < 0)
2714 return err;
2715 }
Mattc7d4b2f2005-06-27 14:59:41 +02002716
2717 return 0;
2718}
2719
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002720/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002721static const char *stac92xx_mono_labels[4] = {
2722 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002723};
2724
2725/* create mono mux for mono out on capable codecs */
2726static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
2727{
2728 struct sigmatel_spec *spec = codec->spec;
2729 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
2730 int i, num_cons;
2731 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
2732
2733 num_cons = snd_hda_get_connections(codec,
2734 spec->mono_nid,
2735 con_lst,
2736 HDA_MAX_NUM_INPUTS);
2737 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
2738 return -EINVAL;
2739
2740 for (i = 0; i < num_cons; i++) {
2741 mono_mux->items[mono_mux->num_items].label =
2742 stac92xx_mono_labels[i];
2743 mono_mux->items[mono_mux->num_items].index = i;
2744 mono_mux->num_items++;
2745 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01002746
2747 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
2748 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002749}
2750
Matthew Ranostay1cd22242008-07-18 18:20:52 +02002751/* create PC beep volume controls */
2752static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
2753 hda_nid_t nid)
2754{
2755 struct sigmatel_spec *spec = codec->spec;
2756 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
2757 int err;
2758
2759 /* check for mute support for the the amp */
2760 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
2761 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
2762 "PC Beep Playback Switch",
2763 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
2764 if (err < 0)
2765 return err;
2766 }
2767
2768 /* check to see if there is volume support for the amp */
2769 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
2770 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
2771 "PC Beep Playback Volume",
2772 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
2773 if (err < 0)
2774 return err;
2775 }
2776 return 0;
2777}
2778
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002779static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
2780{
2781 struct sigmatel_spec *spec = codec->spec;
2782 int wcaps, nid, i, err = 0;
2783
2784 for (i = 0; i < spec->num_muxes; i++) {
2785 nid = spec->mux_nids[i];
2786 wcaps = get_wcaps(codec, nid);
2787
2788 if (wcaps & AC_WCAP_OUT_AMP) {
2789 err = stac92xx_add_control_idx(spec,
2790 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
2791 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
2792 if (err < 0)
2793 return err;
2794 }
2795 }
2796 return 0;
2797};
2798
Matt Porter8b657272006-10-26 17:12:59 +02002799/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01002800static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02002801 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
2802 "Digital Mic 3", "Digital Mic 4"
2803};
2804
2805/* create playback/capture controls for input pins on dmic capable codecs */
2806static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
2807 const struct auto_pin_cfg *cfg)
2808{
2809 struct sigmatel_spec *spec = codec->spec;
2810 struct hda_input_mux *dimux = &spec->private_dimux;
2811 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002812 int err, i, j;
2813 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02002814
2815 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
2816 dimux->items[dimux->num_items].index = 0;
2817 dimux->num_items++;
2818
2819 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002820 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02002821 int index;
2822 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002823 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02002824 unsigned int def_conf;
2825
2826 def_conf = snd_hda_codec_read(codec,
2827 spec->dmic_nids[i],
2828 0,
2829 AC_VERB_GET_CONFIG_DEFAULT,
2830 0);
2831 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
2832 continue;
2833
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002834 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02002835 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01002836 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02002837 con_lst,
2838 HDA_MAX_NUM_INPUTS);
2839 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002840 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02002841 index = j;
2842 goto found;
2843 }
2844 continue;
2845found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002846 wcaps = get_wcaps(codec, nid) &
2847 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002848
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002849 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002850 sprintf(name, "%s Capture Volume",
2851 stac92xx_dmic_labels[dimux->num_items]);
2852
2853 err = stac92xx_add_control(spec,
2854 STAC_CTL_WIDGET_VOL,
2855 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002856 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
2857 (wcaps & AC_WCAP_OUT_AMP) ?
2858 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002859 if (err < 0)
2860 return err;
2861 }
2862
Matt Porter8b657272006-10-26 17:12:59 +02002863 dimux->items[dimux->num_items].label =
2864 stac92xx_dmic_labels[dimux->num_items];
2865 dimux->items[dimux->num_items].index = index;
2866 dimux->num_items++;
2867 }
2868
2869 return 0;
2870}
2871
Mattc7d4b2f2005-06-27 14:59:41 +02002872/* create playback/capture controls for input pins */
2873static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
2874{
2875 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02002876 struct hda_input_mux *imux = &spec->private_imux;
2877 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
2878 int i, j, k;
2879
2880 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02002881 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02002882
Takashi Iwai314634b2006-09-21 11:56:18 +02002883 if (!cfg->input_pins[i])
2884 continue;
2885 index = -1;
2886 for (j = 0; j < spec->num_muxes; j++) {
2887 int num_cons;
2888 num_cons = snd_hda_get_connections(codec,
2889 spec->mux_nids[j],
2890 con_lst,
2891 HDA_MAX_NUM_INPUTS);
2892 for (k = 0; k < num_cons; k++)
2893 if (con_lst[k] == cfg->input_pins[i]) {
2894 index = k;
2895 goto found;
2896 }
Mattc7d4b2f2005-06-27 14:59:41 +02002897 }
Takashi Iwai314634b2006-09-21 11:56:18 +02002898 continue;
2899 found:
2900 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2901 imux->items[imux->num_items].index = index;
2902 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02002903 }
2904
Steve Longerbeam7b043892007-05-03 20:50:03 +02002905 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02002906 /*
2907 * Set the current input for the muxes.
2908 * The STAC9221 has two input muxes with identical source
2909 * NID lists. Hopefully this won't get confused.
2910 */
2911 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002912 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
2913 AC_VERB_SET_CONNECT_SEL,
2914 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02002915 }
2916 }
2917
Mattc7d4b2f2005-06-27 14:59:41 +02002918 return 0;
2919}
2920
Mattc7d4b2f2005-06-27 14:59:41 +02002921static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
2922{
2923 struct sigmatel_spec *spec = codec->spec;
2924 int i;
2925
2926 for (i = 0; i < spec->autocfg.line_outs; i++) {
2927 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2928 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2929 }
2930}
2931
2932static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
2933{
2934 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002935 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02002936
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002937 for (i = 0; i < spec->autocfg.hp_outs; i++) {
2938 hda_nid_t pin;
2939 pin = spec->autocfg.hp_pins[i];
2940 if (pin) /* connect to front */
2941 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
2942 }
2943 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
2944 hda_nid_t pin;
2945 pin = spec->autocfg.speaker_pins[i];
2946 if (pin) /* connect to front */
2947 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
2948 }
Mattc7d4b2f2005-06-27 14:59:41 +02002949}
2950
Matt Porter3cc08dc2006-01-23 15:27:49 +01002951static 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 +02002952{
2953 struct sigmatel_spec *spec = codec->spec;
2954 int err;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01002955 int hp_speaker_swap = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02002956
Matt Porter8b657272006-10-26 17:12:59 +02002957 if ((err = snd_hda_parse_pin_def_config(codec,
2958 &spec->autocfg,
2959 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002960 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01002961 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01002962 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02002963
Jiang Zhebcecd9b2007-11-12 12:57:03 +01002964 /* If we have no real line-out pin and multiple hp-outs, HPs should
2965 * be set up as multi-channel outputs.
2966 */
2967 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
2968 spec->autocfg.hp_outs > 1) {
2969 /* Copy hp_outs to line_outs, backup line_outs in
2970 * speaker_outs so that the following routines can handle
2971 * HP pins as primary outputs.
2972 */
2973 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
2974 sizeof(spec->autocfg.line_out_pins));
2975 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
2976 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
2977 sizeof(spec->autocfg.hp_pins));
2978 spec->autocfg.line_outs = spec->autocfg.hp_outs;
2979 hp_speaker_swap = 1;
2980 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01002981 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002982 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
2983 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01002984 u32 caps = query_amp_caps(codec,
2985 spec->autocfg.mono_out_pin, dir);
2986 hda_nid_t conn_list[1];
2987
2988 /* get the mixer node and then the mono mux if it exists */
2989 if (snd_hda_get_connections(codec,
2990 spec->autocfg.mono_out_pin, conn_list, 1) &&
2991 snd_hda_get_connections(codec, conn_list[0],
2992 conn_list, 1)) {
2993
2994 int wcaps = get_wcaps(codec, conn_list[0]);
2995 int wid_type = (wcaps & AC_WCAP_TYPE)
2996 >> AC_WCAP_TYPE_SHIFT;
2997 /* LR swap check, some stac925x have a mux that
2998 * changes the DACs output path instead of the
2999 * mono-mux path.
3000 */
3001 if (wid_type == AC_WID_AUD_SEL &&
3002 !(wcaps & AC_WCAP_LR_SWAP))
3003 spec->mono_nid = conn_list[0];
3004 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003005 if (dir) {
3006 hda_nid_t nid = spec->autocfg.mono_out_pin;
3007
3008 /* most mono outs have a least a mute/unmute switch */
3009 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3010 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3011 "Mono Playback Switch",
3012 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003013 if (err < 0)
3014 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003015 /* check for volume support for the amp */
3016 if ((caps & AC_AMPCAP_NUM_STEPS)
3017 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3018 err = stac92xx_add_control(spec,
3019 STAC_CTL_WIDGET_VOL,
3020 "Mono Playback Volume",
3021 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3022 if (err < 0)
3023 return err;
3024 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003025 }
3026
3027 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3028 AC_PINCTL_OUT_EN);
3029 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003030
Matt Porter403d1942005-11-29 15:00:51 +01003031 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
3032 return err;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003033 if (spec->multiout.num_dacs == 0)
3034 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
3035 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003036
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003037 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
3038
3039 if (err < 0)
3040 return err;
3041
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003042 /* setup analog beep controls */
3043 if (spec->anabeep_nid > 0) {
3044 err = stac92xx_auto_create_beep_ctls(codec,
3045 spec->anabeep_nid);
3046 if (err < 0)
3047 return err;
3048 }
3049
3050 /* setup digital beep controls and input device */
3051#ifdef CONFIG_SND_HDA_INPUT_BEEP
3052 if (spec->digbeep_nid > 0) {
3053 hda_nid_t nid = spec->digbeep_nid;
3054
3055 err = stac92xx_auto_create_beep_ctls(codec, nid);
3056 if (err < 0)
3057 return err;
3058 err = snd_hda_attach_beep_device(codec, nid);
3059 if (err < 0)
3060 return err;
3061 }
3062#endif
3063
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003064 if (hp_speaker_swap == 1) {
3065 /* Restore the hp_outs and line_outs */
3066 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3067 sizeof(spec->autocfg.line_out_pins));
3068 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3069 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
3070 sizeof(spec->autocfg.speaker_pins));
3071 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
3072 memset(spec->autocfg.speaker_pins, 0,
3073 sizeof(spec->autocfg.speaker_pins));
3074 spec->autocfg.speaker_outs = 0;
3075 }
3076
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003077 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3078
3079 if (err < 0)
3080 return err;
3081
3082 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3083
3084 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003085 return err;
3086
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003087 if (spec->mono_nid > 0) {
3088 err = stac92xx_auto_create_mono_output_ctls(codec);
3089 if (err < 0)
3090 return err;
3091 }
3092
Matt Porter8b657272006-10-26 17:12:59 +02003093 if (spec->num_dmics > 0)
3094 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3095 &spec->autocfg)) < 0)
3096 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003097 if (spec->num_muxes > 0) {
3098 err = stac92xx_auto_create_mux_input_ctls(codec);
3099 if (err < 0)
3100 return err;
3101 }
Matt Porter8b657272006-10-26 17:12:59 +02003102
Mattc7d4b2f2005-06-27 14:59:41 +02003103 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003104 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003105 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003106
Takashi Iwai82bc9552006-03-21 11:24:42 +01003107 if (spec->autocfg.dig_out_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003108 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003109 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003110 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003111
3112 if (spec->kctl_alloc)
3113 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3114
3115 spec->input_mux = &spec->private_imux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003116 if (!spec->dinput_mux)
3117 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003118 spec->mono_mux = &spec->private_mono_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003119
3120 return 1;
3121}
3122
Takashi Iwai82bc9552006-03-21 11:24:42 +01003123/* add playback controls for HP output */
3124static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3125 struct auto_pin_cfg *cfg)
3126{
3127 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003128 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003129 unsigned int wid_caps;
3130
3131 if (! pin)
3132 return 0;
3133
3134 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003135 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003136 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003137
3138 return 0;
3139}
3140
Richard Fish160ea0d2006-09-06 13:58:25 +02003141/* add playback controls for LFE output */
3142static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3143 struct auto_pin_cfg *cfg)
3144{
3145 struct sigmatel_spec *spec = codec->spec;
3146 int err;
3147 hda_nid_t lfe_pin = 0x0;
3148 int i;
3149
3150 /*
3151 * search speaker outs and line outs for a mono speaker pin
3152 * with an amp. If one is found, add LFE controls
3153 * for it.
3154 */
3155 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3156 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003157 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003158 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3159 if (wcaps == AC_WCAP_OUT_AMP)
3160 /* found a mono speaker with an amp, must be lfe */
3161 lfe_pin = pin;
3162 }
3163
3164 /* if speaker_outs is 0, then speakers may be in line_outs */
3165 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3166 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3167 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003168 unsigned int defcfg;
Harvey Harrison8b551782008-02-29 11:56:48 +01003169 defcfg = snd_hda_codec_read(codec, pin, 0,
Richard Fish160ea0d2006-09-06 13:58:25 +02003170 AC_VERB_GET_CONFIG_DEFAULT,
3171 0x00);
Harvey Harrison8b551782008-02-29 11:56:48 +01003172 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003173 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003174 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3175 if (wcaps == AC_WCAP_OUT_AMP)
3176 /* found a mono speaker with an amp,
3177 must be lfe */
3178 lfe_pin = pin;
3179 }
3180 }
3181 }
3182
3183 if (lfe_pin) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003184 err = create_controls(spec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003185 if (err < 0)
3186 return err;
3187 }
3188
3189 return 0;
3190}
3191
Mattc7d4b2f2005-06-27 14:59:41 +02003192static int stac9200_parse_auto_config(struct hda_codec *codec)
3193{
3194 struct sigmatel_spec *spec = codec->spec;
3195 int err;
3196
Kailang Yangdf694da2005-12-05 19:42:22 +01003197 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003198 return err;
3199
3200 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3201 return err;
3202
Takashi Iwai82bc9552006-03-21 11:24:42 +01003203 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3204 return err;
3205
Richard Fish160ea0d2006-09-06 13:58:25 +02003206 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3207 return err;
3208
Takashi Iwai82bc9552006-03-21 11:24:42 +01003209 if (spec->autocfg.dig_out_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003210 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003211 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003212 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003213
3214 if (spec->kctl_alloc)
3215 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3216
3217 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003218 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003219
3220 return 1;
3221}
3222
Sam Revitch62fe78e2006-05-10 15:09:17 +02003223/*
3224 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3225 * funky external mute control using GPIO pins.
3226 */
3227
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003228static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003229 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003230{
3231 unsigned int gpiostate, gpiomask, gpiodir;
3232
3233 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3234 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003235 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003236
3237 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3238 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003239 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003240
3241 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3242 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003243 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003244
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003245 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003246 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3247
3248 snd_hda_codec_write(codec, codec->afg, 0,
3249 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003250 snd_hda_codec_read(codec, codec->afg, 0,
3251 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003252
3253 msleep(1);
3254
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003255 snd_hda_codec_read(codec, codec->afg, 0,
3256 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003257}
3258
Takashi Iwai314634b2006-09-21 11:56:18 +02003259static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3260 unsigned int event)
3261{
3262 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003263 snd_hda_codec_write_cache(codec, nid, 0,
3264 AC_VERB_SET_UNSOLICITED_ENABLE,
3265 (AC_USRSP_EN | event));
Takashi Iwai314634b2006-09-21 11:56:18 +02003266}
3267
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003268static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3269{
3270 int i;
3271 for (i = 0; i < cfg->hp_outs; i++)
3272 if (cfg->hp_pins[i] == nid)
3273 return 1; /* nid is a HP-Out */
3274
3275 return 0; /* nid is not a HP-Out */
3276};
3277
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003278static void stac92xx_power_down(struct hda_codec *codec)
3279{
3280 struct sigmatel_spec *spec = codec->spec;
3281
3282 /* power down inactive DACs */
3283 hda_nid_t *dac;
3284 for (dac = spec->dac_list; *dac; dac++)
Matthew Ranostay44510892008-02-21 07:49:31 +01003285 if (!is_in_dac_nids(spec, *dac) &&
3286 spec->multiout.hp_nid != *dac)
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003287 snd_hda_codec_write_cache(codec, *dac, 0,
3288 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3289}
3290
Mattc7d4b2f2005-06-27 14:59:41 +02003291static int stac92xx_init(struct hda_codec *codec)
3292{
3293 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003294 struct auto_pin_cfg *cfg = &spec->autocfg;
3295 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003296
Mattc7d4b2f2005-06-27 14:59:41 +02003297 snd_hda_sequence_write(codec, spec->init);
3298
Takashi Iwai82bc9552006-03-21 11:24:42 +01003299 /* set up pins */
3300 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02003301 /* Enable unsolicited responses on the HP widget */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003302 for (i = 0; i < cfg->hp_outs; i++)
Takashi Iwai314634b2006-09-21 11:56:18 +02003303 enable_pin_detect(codec, cfg->hp_pins[i],
3304 STAC_HP_EVENT);
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01003305 /* force to enable the first line-out; the others are set up
3306 * in unsol_event
3307 */
3308 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3309 AC_PINCTL_OUT_EN);
Takashi Iwaieb995a82006-09-21 14:28:21 +02003310 stac92xx_auto_init_hp_out(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003311 /* fake event to set up pins */
3312 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3313 } else {
3314 stac92xx_auto_init_multi_out(codec);
3315 stac92xx_auto_init_hp_out(codec);
3316 }
3317 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01003318 hda_nid_t nid = cfg->input_pins[i];
3319 if (nid) {
3320 unsigned int pinctl = AC_PINCTL_IN_EN;
3321 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
3322 pinctl |= stac92xx_get_vref(codec, nid);
3323 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3324 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01003325 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003326 for (i = 0; i < spec->num_dmics; i++)
3327 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3328 AC_PINCTL_IN_EN);
3329 for (i = 0; i < spec->num_pwrs; i++) {
3330 int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
3331 ? STAC_HP_EVENT : STAC_PWR_EVENT;
3332 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
3333 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003334 int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
3335 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003336 def_conf = get_defcfg_connect(def_conf);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003337 /* outputs are only ports capable of power management
3338 * any attempts on powering down a input port cause the
3339 * referenced VREF to act quirky.
3340 */
3341 if (pinctl & AC_PINCTL_IN_EN)
3342 continue;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003343 /* skip any ports that don't have jacks since presence
3344 * detection is useless */
3345 if (def_conf && def_conf != AC_JACK_PORT_FIXED)
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003346 continue;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003347 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3348 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3349 }
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003350 if (spec->dac_list)
3351 stac92xx_power_down(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003352 if (cfg->dig_out_pin)
3353 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3354 AC_PINCTL_OUT_EN);
3355 if (cfg->dig_in_pin)
3356 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3357 AC_PINCTL_IN_EN);
3358
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003359 stac_gpio_set(codec, spec->gpio_mask,
3360 spec->gpio_dir, spec->gpio_data);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003361
Mattc7d4b2f2005-06-27 14:59:41 +02003362 return 0;
3363}
3364
Matt2f2f4252005-04-13 14:45:30 +02003365static void stac92xx_free(struct hda_codec *codec)
3366{
Mattc7d4b2f2005-06-27 14:59:41 +02003367 struct sigmatel_spec *spec = codec->spec;
3368 int i;
3369
3370 if (! spec)
3371 return;
3372
3373 if (spec->kctl_alloc) {
3374 for (i = 0; i < spec->num_kctl_used; i++)
3375 kfree(spec->kctl_alloc[i].name);
3376 kfree(spec->kctl_alloc);
3377 }
3378
Richard Fish11b44bb2006-08-23 18:31:34 +02003379 if (spec->bios_pin_configs)
3380 kfree(spec->bios_pin_configs);
3381
Mattc7d4b2f2005-06-27 14:59:41 +02003382 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003383 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02003384}
3385
Matt4e550962005-07-04 17:51:39 +02003386static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3387 unsigned int flag)
3388{
3389 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3390 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02003391
Takashi Iwaif9acba42007-05-29 18:01:06 +02003392 if (pin_ctl & AC_PINCTL_IN_EN) {
3393 /*
3394 * we need to check the current set-up direction of
3395 * shared input pins since they can be switched via
3396 * "xxx as Output" mixer switch
3397 */
3398 struct sigmatel_spec *spec = codec->spec;
3399 struct auto_pin_cfg *cfg = &spec->autocfg;
3400 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3401 spec->line_switch) ||
3402 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3403 spec->mic_switch))
3404 return;
3405 }
3406
Steve Longerbeam7b043892007-05-03 20:50:03 +02003407 /* if setting pin direction bits, clear the current
3408 direction bits first */
3409 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3410 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3411
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003412 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003413 AC_VERB_SET_PIN_WIDGET_CONTROL,
3414 pin_ctl | flag);
3415}
3416
3417static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3418 unsigned int flag)
3419{
3420 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3421 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003422 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003423 AC_VERB_SET_PIN_WIDGET_CONTROL,
3424 pin_ctl & ~flag);
3425}
3426
Jiang Zhe40c1d302007-11-12 13:05:16 +01003427static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02003428{
3429 if (!nid)
3430 return 0;
3431 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Jiang Zhe40c1d302007-11-12 13:05:16 +01003432 & (1 << 31)) {
3433 unsigned int pinctl;
3434 pinctl = snd_hda_codec_read(codec, nid, 0,
3435 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3436 if (pinctl & AC_PINCTL_IN_EN)
3437 return 0; /* mic- or line-input */
3438 else
3439 return 1; /* HP-output */
3440 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003441 return 0;
3442}
3443
3444static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
Matt4e550962005-07-04 17:51:39 +02003445{
3446 struct sigmatel_spec *spec = codec->spec;
3447 struct auto_pin_cfg *cfg = &spec->autocfg;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003448 int nid = cfg->hp_pins[cfg->hp_outs - 1];
Matt4e550962005-07-04 17:51:39 +02003449 int i, presence;
3450
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003451 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003452 if (spec->gpio_mute)
3453 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3454 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3455
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003456 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003457 if (presence)
3458 break;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003459 if (spec->hp_switch && cfg->hp_pins[i] == nid)
3460 break;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003461 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003462 }
Matt4e550962005-07-04 17:51:39 +02003463
3464 if (presence) {
3465 /* disable lineouts, enable hp */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003466 if (spec->hp_switch)
3467 stac92xx_reset_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003468 for (i = 0; i < cfg->line_outs; i++)
3469 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3470 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003471 for (i = 0; i < cfg->speaker_outs; i++)
3472 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3473 AC_PINCTL_OUT_EN);
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003474 if (spec->eapd_mask)
3475 stac_gpio_set(codec, spec->gpio_mask,
3476 spec->gpio_dir, spec->gpio_data &
3477 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003478 } else {
3479 /* enable lineouts, disable hp */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003480 if (spec->hp_switch)
3481 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003482 for (i = 0; i < cfg->line_outs; i++)
3483 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3484 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003485 for (i = 0; i < cfg->speaker_outs; i++)
3486 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3487 AC_PINCTL_OUT_EN);
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003488 if (spec->eapd_mask)
3489 stac_gpio_set(codec, spec->gpio_mask,
3490 spec->gpio_dir, spec->gpio_data |
3491 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003492 }
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003493 if (!spec->hp_switch && cfg->hp_outs > 1 && presence)
3494 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003495}
3496
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003497static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
3498{
3499 struct sigmatel_spec *spec = codec->spec;
3500 hda_nid_t nid = spec->pwr_nids[idx];
3501 int presence, val;
3502 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
3503 & 0x000000ff;
3504 presence = get_hp_pin_presence(codec, nid);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003505
3506 /* several codecs have two power down bits */
3507 if (spec->pwr_mapping)
3508 idx = spec->pwr_mapping[idx];
3509 else
3510 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003511
3512 if (presence)
3513 val &= ~idx;
3514 else
3515 val |= idx;
3516
3517 /* power down unused output ports */
3518 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
3519};
3520
Takashi Iwai314634b2006-09-21 11:56:18 +02003521static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
3522{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003523 struct sigmatel_spec *spec = codec->spec;
3524 int idx = res >> 26 & 0x0f;
3525
3526 switch ((res >> 26) & 0x30) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003527 case STAC_HP_EVENT:
3528 stac92xx_hp_detect(codec, res);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003529 /* fallthru */
3530 case STAC_PWR_EVENT:
3531 if (spec->num_pwrs > 0)
3532 stac92xx_pin_sense(codec, idx);
Takashi Iwai314634b2006-09-21 11:56:18 +02003533 }
3534}
3535
Takashi Iwaicb53c622007-08-10 17:21:45 +02003536#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02003537static int stac92xx_resume(struct hda_codec *codec)
3538{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003539 struct sigmatel_spec *spec = codec->spec;
3540
Richard Fish11b44bb2006-08-23 18:31:34 +02003541 stac92xx_set_config_regs(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003542 snd_hda_sequence_write(codec, spec->init);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003543 stac_gpio_set(codec, spec->gpio_mask,
3544 spec->gpio_dir, spec->gpio_data);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003545 snd_hda_codec_resume_amp(codec);
3546 snd_hda_codec_resume_cache(codec);
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003547 /* power down inactive DACs */
3548 if (spec->dac_list)
3549 stac92xx_power_down(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003550 /* invoke unsolicited event to reset the HP state */
3551 if (spec->hp_detect)
3552 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
Mattff6fdc32005-06-27 15:06:52 +02003553 return 0;
3554}
3555#endif
3556
Matt2f2f4252005-04-13 14:45:30 +02003557static struct hda_codec_ops stac92xx_patch_ops = {
3558 .build_controls = stac92xx_build_controls,
3559 .build_pcms = stac92xx_build_pcms,
3560 .init = stac92xx_init,
3561 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02003562 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003563#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02003564 .resume = stac92xx_resume,
3565#endif
Matt2f2f4252005-04-13 14:45:30 +02003566};
3567
3568static int patch_stac9200(struct hda_codec *codec)
3569{
3570 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003571 int err;
Matt2f2f4252005-04-13 14:45:30 +02003572
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003573 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02003574 if (spec == NULL)
3575 return -ENOMEM;
3576
3577 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003578 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02003579 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003580 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
3581 stac9200_models,
3582 stac9200_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02003583 if (spec->board_config < 0) {
3584 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
3585 err = stac92xx_save_bios_config_regs(codec);
3586 if (err < 0) {
3587 stac92xx_free(codec);
3588 return err;
3589 }
3590 spec->pin_configs = spec->bios_pin_configs;
3591 } else {
Matt Porter403d1942005-11-29 15:00:51 +01003592 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
3593 stac92xx_set_config_regs(codec);
3594 }
Matt2f2f4252005-04-13 14:45:30 +02003595
3596 spec->multiout.max_channels = 2;
3597 spec->multiout.num_dacs = 1;
3598 spec->multiout.dac_nids = stac9200_dac_nids;
3599 spec->adc_nids = stac9200_adc_nids;
3600 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02003601 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02003602 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003603 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003604 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003605
Tobin Davisbf277782008-02-03 20:31:47 +01003606 if (spec->board_config == STAC_9200_GATEWAY ||
3607 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02003608 spec->init = stac9200_eapd_init;
3609 else
3610 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02003611 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02003612
Takashi Iwai117f2572008-03-18 09:53:23 +01003613 if (spec->board_config == STAC_9200_PANASONIC) {
3614 spec->gpio_mask = spec->gpio_dir = 0x09;
3615 spec->gpio_data = 0x00;
3616 }
3617
Mattc7d4b2f2005-06-27 14:59:41 +02003618 err = stac9200_parse_auto_config(codec);
3619 if (err < 0) {
3620 stac92xx_free(codec);
3621 return err;
3622 }
Matt2f2f4252005-04-13 14:45:30 +02003623
3624 codec->patch_ops = stac92xx_patch_ops;
3625
3626 return 0;
3627}
3628
Tobin Davis8e21c342007-01-08 11:04:17 +01003629static int patch_stac925x(struct hda_codec *codec)
3630{
3631 struct sigmatel_spec *spec;
3632 int err;
3633
3634 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3635 if (spec == NULL)
3636 return -ENOMEM;
3637
3638 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003639 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01003640 spec->pin_nids = stac925x_pin_nids;
3641 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
3642 stac925x_models,
3643 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01003644 again:
Tobin Davis8e21c342007-01-08 11:04:17 +01003645 if (spec->board_config < 0) {
Tobin Davis2c11f952007-05-17 09:36:34 +02003646 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
3647 "using BIOS defaults\n");
Tobin Davis8e21c342007-01-08 11:04:17 +01003648 err = stac92xx_save_bios_config_regs(codec);
3649 if (err < 0) {
3650 stac92xx_free(codec);
3651 return err;
3652 }
3653 spec->pin_configs = spec->bios_pin_configs;
3654 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
3655 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
3656 stac92xx_set_config_regs(codec);
3657 }
3658
3659 spec->multiout.max_channels = 2;
3660 spec->multiout.num_dacs = 1;
3661 spec->multiout.dac_nids = stac925x_dac_nids;
3662 spec->adc_nids = stac925x_adc_nids;
3663 spec->mux_nids = stac925x_mux_nids;
3664 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003665 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003666 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02003667 switch (codec->vendor_id) {
3668 case 0x83847632: /* STAC9202 */
3669 case 0x83847633: /* STAC9202D */
3670 case 0x83847636: /* STAC9251 */
3671 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02003672 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02003673 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01003674 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
3675 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02003676 break;
3677 default:
3678 spec->num_dmics = 0;
3679 break;
3680 }
Tobin Davis8e21c342007-01-08 11:04:17 +01003681
3682 spec->init = stac925x_core_init;
3683 spec->mixer = stac925x_mixer;
3684
3685 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01003686 if (!err) {
3687 if (spec->board_config < 0) {
3688 printk(KERN_WARNING "hda_codec: No auto-config is "
3689 "available, default to model=ref\n");
3690 spec->board_config = STAC_925x_REF;
3691 goto again;
3692 }
3693 err = -EINVAL;
3694 }
Tobin Davis8e21c342007-01-08 11:04:17 +01003695 if (err < 0) {
3696 stac92xx_free(codec);
3697 return err;
3698 }
3699
3700 codec->patch_ops = stac92xx_patch_ops;
3701
3702 return 0;
3703}
3704
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003705static struct hda_input_mux stac92hd73xx_dmux = {
3706 .num_items = 4,
3707 .items = {
3708 { "Analog Inputs", 0x0b },
3709 { "CD", 0x08 },
3710 { "Digital Mic 1", 0x09 },
3711 { "Digital Mic 2", 0x0a },
3712 }
3713};
3714
3715static int patch_stac92hd73xx(struct hda_codec *codec)
3716{
3717 struct sigmatel_spec *spec;
3718 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
3719 int err = 0;
3720
3721 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3722 if (spec == NULL)
3723 return -ENOMEM;
3724
3725 codec->spec = spec;
3726 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
3727 spec->pin_nids = stac92hd73xx_pin_nids;
3728 spec->board_config = snd_hda_check_board_config(codec,
3729 STAC_92HD73XX_MODELS,
3730 stac92hd73xx_models,
3731 stac92hd73xx_cfg_tbl);
3732again:
3733 if (spec->board_config < 0) {
3734 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3735 " STAC92HD73XX, using BIOS defaults\n");
3736 err = stac92xx_save_bios_config_regs(codec);
3737 if (err < 0) {
3738 stac92xx_free(codec);
3739 return err;
3740 }
3741 spec->pin_configs = spec->bios_pin_configs;
3742 } else {
3743 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
3744 stac92xx_set_config_regs(codec);
3745 }
3746
3747 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
3748 conn, STAC92HD73_DAC_COUNT + 2) - 1;
3749
3750 if (spec->multiout.num_dacs < 0) {
3751 printk(KERN_WARNING "hda_codec: Could not determine "
3752 "number of channels defaulting to DAC count\n");
3753 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
3754 }
3755
3756 switch (spec->multiout.num_dacs) {
3757 case 0x3: /* 6 Channel */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003758 spec->multiout.hp_nid = 0x17;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003759 spec->mixer = stac92hd73xx_6ch_mixer;
3760 spec->init = stac92hd73xx_6ch_core_init;
3761 break;
3762 case 0x4: /* 8 Channel */
3763 spec->multiout.hp_nid = 0x18;
3764 spec->mixer = stac92hd73xx_8ch_mixer;
3765 spec->init = stac92hd73xx_8ch_core_init;
3766 break;
3767 case 0x5: /* 10 Channel */
3768 spec->multiout.hp_nid = 0x19;
3769 spec->mixer = stac92hd73xx_10ch_mixer;
3770 spec->init = stac92hd73xx_10ch_core_init;
3771 };
3772
3773 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
3774 spec->aloopback_mask = 0x01;
3775 spec->aloopback_shift = 8;
3776
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003777 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003778 spec->mux_nids = stac92hd73xx_mux_nids;
3779 spec->adc_nids = stac92hd73xx_adc_nids;
3780 spec->dmic_nids = stac92hd73xx_dmic_nids;
3781 spec->dmux_nids = stac92hd73xx_dmux_nids;
3782
3783 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
3784 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01003785 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003786 spec->dinput_mux = &stac92hd73xx_dmux;
3787 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003788 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003789 spec->gpio_data = 0x01;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003790
Matthew Ranostaya7662642008-02-21 07:51:14 +01003791 switch (spec->board_config) {
3792 case STAC_DELL_M6:
Matthew Ranostayd654a662008-03-14 08:46:51 +01003793 spec->init = dell_eq_core_init;
Matthew Ranostaya7662642008-02-21 07:51:14 +01003794 switch (codec->subsystem_id) {
3795 case 0x1028025e: /* Analog Mics */
3796 case 0x1028025f:
3797 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
3798 spec->num_dmics = 0;
3799 break;
Matthew Ranostayd654a662008-03-14 08:46:51 +01003800 case 0x10280271: /* Digital Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01003801 case 0x10280272:
Matthew Ranostayd654a662008-03-14 08:46:51 +01003802 spec->init = dell_m6_core_init;
3803 /* fall-through */
3804 case 0x10280254:
3805 case 0x10280255:
Matthew Ranostaya7662642008-02-21 07:51:14 +01003806 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
3807 spec->num_dmics = 1;
3808 break;
3809 case 0x10280256: /* Both */
3810 case 0x10280057:
3811 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
3812 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
3813 spec->num_dmics = 1;
3814 break;
3815 }
3816 break;
3817 default:
3818 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
3819 }
3820
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003821 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
3822 spec->pwr_nids = stac92hd73xx_pwr_nids;
3823
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003824 err = stac92xx_parse_auto_config(codec, 0x22, 0x24);
3825
3826 if (!err) {
3827 if (spec->board_config < 0) {
3828 printk(KERN_WARNING "hda_codec: No auto-config is "
3829 "available, default to model=ref\n");
3830 spec->board_config = STAC_92HD73XX_REF;
3831 goto again;
3832 }
3833 err = -EINVAL;
3834 }
3835
3836 if (err < 0) {
3837 stac92xx_free(codec);
3838 return err;
3839 }
3840
3841 codec->patch_ops = stac92xx_patch_ops;
3842
3843 return 0;
3844}
3845
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003846static struct hda_input_mux stac92hd83xxx_dmux = {
3847 .num_items = 3,
3848 .items = {
3849 { "Analog Inputs", 0x03 },
3850 { "Digital Mic 1", 0x04 },
3851 { "Digital Mic 2", 0x05 },
3852 }
3853};
3854
3855static int patch_stac92hd83xxx(struct hda_codec *codec)
3856{
3857 struct sigmatel_spec *spec;
3858 int err;
3859
3860 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3861 if (spec == NULL)
3862 return -ENOMEM;
3863
3864 codec->spec = spec;
3865 spec->mono_nid = 0x19;
3866 spec->digbeep_nid = 0x21;
3867 spec->dmic_nids = stac92hd83xxx_dmic_nids;
3868 spec->dmux_nids = stac92hd83xxx_dmux_nids;
3869 spec->adc_nids = stac92hd83xxx_adc_nids;
3870 spec->pwr_nids = stac92hd83xxx_pwr_nids;
3871 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
3872 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
3873 spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
3874
3875 spec->init = stac92hd83xxx_core_init;
3876 switch (codec->vendor_id) {
3877 case 0x111d7605:
3878 spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
3879 break;
3880 default:
3881 spec->num_pwrs--;
3882 spec->init++; /* switch to config #2 */
3883 spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
3884 }
3885
3886 spec->mixer = stac92hd83xxx_mixer;
3887 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
3888 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
3889 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
3890 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
3891 spec->dinput_mux = &stac92hd83xxx_dmux;
3892 spec->pin_nids = stac92hd83xxx_pin_nids;
3893 spec->board_config = snd_hda_check_board_config(codec,
3894 STAC_92HD83XXX_MODELS,
3895 stac92hd83xxx_models,
3896 stac92hd83xxx_cfg_tbl);
3897again:
3898 if (spec->board_config < 0) {
3899 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3900 " STAC92HD83XXX, using BIOS defaults\n");
3901 err = stac92xx_save_bios_config_regs(codec);
3902 if (err < 0) {
3903 stac92xx_free(codec);
3904 return err;
3905 }
3906 spec->pin_configs = spec->bios_pin_configs;
3907 } else {
3908 spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config];
3909 stac92xx_set_config_regs(codec);
3910 }
3911
3912 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
3913 if (!err) {
3914 if (spec->board_config < 0) {
3915 printk(KERN_WARNING "hda_codec: No auto-config is "
3916 "available, default to model=ref\n");
3917 spec->board_config = STAC_92HD83XXX_REF;
3918 goto again;
3919 }
3920 err = -EINVAL;
3921 }
3922
3923 if (err < 0) {
3924 stac92xx_free(codec);
3925 return err;
3926 }
3927
3928 codec->patch_ops = stac92xx_patch_ops;
3929
3930 return 0;
3931}
3932
3933
Matthew Ranostaye035b842007-11-06 11:53:55 +01003934static int patch_stac92hd71bxx(struct hda_codec *codec)
3935{
3936 struct sigmatel_spec *spec;
3937 int err = 0;
3938
3939 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3940 if (spec == NULL)
3941 return -ENOMEM;
3942
3943 codec->spec = spec;
3944 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003945 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01003946 spec->pin_nids = stac92hd71bxx_pin_nids;
3947 spec->board_config = snd_hda_check_board_config(codec,
3948 STAC_92HD71BXX_MODELS,
3949 stac92hd71bxx_models,
3950 stac92hd71bxx_cfg_tbl);
3951again:
3952 if (spec->board_config < 0) {
3953 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3954 " STAC92HD71BXX, using BIOS defaults\n");
3955 err = stac92xx_save_bios_config_regs(codec);
3956 if (err < 0) {
3957 stac92xx_free(codec);
3958 return err;
3959 }
3960 spec->pin_configs = spec->bios_pin_configs;
3961 } else {
3962 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
3963 stac92xx_set_config_regs(codec);
3964 }
3965
Matthew Ranostay541eee82007-12-14 12:08:04 +01003966 switch (codec->vendor_id) {
3967 case 0x111d76b6: /* 4 Port without Analog Mixer */
3968 case 0x111d76b7:
3969 case 0x111d76b4: /* 6 Port without Analog Mixer */
3970 case 0x111d76b5:
3971 spec->mixer = stac92hd71bxx_mixer;
3972 spec->init = stac92hd71bxx_core_init;
3973 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003974 case 0x111d7608: /* 5 Port with Analog Mixer */
3975 /* no output amps */
3976 spec->num_pwrs = 0;
3977 spec->mixer = stac92hd71bxx_analog_mixer;
3978
3979 /* disable VSW */
3980 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
3981 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
3982 break;
3983 case 0x111d7603: /* 6 Port with Analog Mixer */
3984 /* no output amps */
3985 spec->num_pwrs = 0;
3986 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01003987 default:
3988 spec->mixer = stac92hd71bxx_analog_mixer;
3989 spec->init = stac92hd71bxx_analog_core_init;
3990 }
3991
3992 spec->aloopback_mask = 0x20;
3993 spec->aloopback_shift = 0;
3994
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003995 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003996 spec->gpio_mask = 0x01;
3997 spec->gpio_dir = 0x01;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003998 spec->gpio_data = 0x01;
Matthew Ranostaye035b842007-11-06 11:53:55 +01003999
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004000 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004001 spec->mux_nids = stac92hd71bxx_mux_nids;
4002 spec->adc_nids = stac92hd71bxx_adc_nids;
4003 spec->dmic_nids = stac92hd71bxx_dmic_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004004 spec->dmux_nids = stac92hd71bxx_dmux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004005 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004006
4007 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
4008 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
4009 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004010 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004011
Takashi Iwaiaea7bb02008-02-25 18:26:41 +01004012 spec->multiout.num_dacs = 1;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004013 spec->multiout.hp_nid = 0x11;
4014 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
4015
4016 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
4017 if (!err) {
4018 if (spec->board_config < 0) {
4019 printk(KERN_WARNING "hda_codec: No auto-config is "
4020 "available, default to model=ref\n");
4021 spec->board_config = STAC_92HD71BXX_REF;
4022 goto again;
4023 }
4024 err = -EINVAL;
4025 }
4026
4027 if (err < 0) {
4028 stac92xx_free(codec);
4029 return err;
4030 }
4031
4032 codec->patch_ops = stac92xx_patch_ops;
4033
4034 return 0;
4035};
4036
Matt2f2f4252005-04-13 14:45:30 +02004037static int patch_stac922x(struct hda_codec *codec)
4038{
4039 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004040 int err;
Matt2f2f4252005-04-13 14:45:30 +02004041
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004042 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004043 if (spec == NULL)
4044 return -ENOMEM;
4045
4046 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004047 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004048 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004049 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
4050 stac922x_models,
4051 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08004052 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004053 spec->gpio_mask = spec->gpio_dir = 0x03;
4054 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004055 /* Intel Macs have all same PCI SSID, so we need to check
4056 * codec SSID to distinguish the exact models
4057 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004058 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004059 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004060
4061 case 0x106b0800:
4062 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02004063 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004064 case 0x106b0600:
4065 case 0x106b0700:
4066 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004067 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004068 case 0x106b0e00:
4069 case 0x106b0f00:
4070 case 0x106b1600:
4071 case 0x106b1700:
4072 case 0x106b0200:
4073 case 0x106b1e00:
4074 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004075 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004076 case 0x106b1a00:
4077 case 0x00000100:
4078 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02004079 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004080 case 0x106b0a00:
4081 case 0x106b2200:
4082 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02004083 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08004084 default:
4085 spec->board_config = STAC_INTEL_MAC_V3;
4086 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004087 }
4088 }
4089
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004090 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004091 if (spec->board_config < 0) {
4092 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
4093 "using BIOS defaults\n");
4094 err = stac92xx_save_bios_config_regs(codec);
4095 if (err < 0) {
4096 stac92xx_free(codec);
4097 return err;
4098 }
4099 spec->pin_configs = spec->bios_pin_configs;
4100 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
Matt Porter403d1942005-11-29 15:00:51 +01004101 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
4102 stac92xx_set_config_regs(codec);
4103 }
Matt2f2f4252005-04-13 14:45:30 +02004104
Matt2f2f4252005-04-13 14:45:30 +02004105 spec->adc_nids = stac922x_adc_nids;
4106 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004107 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004108 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004109 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004110 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004111
4112 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004113 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004114
4115 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02004116
Matt Porter3cc08dc2006-01-23 15:27:49 +01004117 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004118 if (!err) {
4119 if (spec->board_config < 0) {
4120 printk(KERN_WARNING "hda_codec: No auto-config is "
4121 "available, default to model=ref\n");
4122 spec->board_config = STAC_D945_REF;
4123 goto again;
4124 }
4125 err = -EINVAL;
4126 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004127 if (err < 0) {
4128 stac92xx_free(codec);
4129 return err;
4130 }
4131
4132 codec->patch_ops = stac92xx_patch_ops;
4133
Takashi Iwai807a46362007-05-29 19:01:37 +02004134 /* Fix Mux capture level; max to 2 */
4135 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
4136 (0 << AC_AMPCAP_OFFSET_SHIFT) |
4137 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4138 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4139 (0 << AC_AMPCAP_MUTE_SHIFT));
4140
Matt Porter3cc08dc2006-01-23 15:27:49 +01004141 return 0;
4142}
4143
4144static int patch_stac927x(struct hda_codec *codec)
4145{
4146 struct sigmatel_spec *spec;
4147 int err;
4148
4149 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4150 if (spec == NULL)
4151 return -ENOMEM;
4152
4153 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004154 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004155 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004156 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
4157 stac927x_models,
4158 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004159 again:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004160 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
4161 if (spec->board_config < 0)
4162 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4163 "STAC927x, using BIOS defaults\n");
Richard Fish11b44bb2006-08-23 18:31:34 +02004164 err = stac92xx_save_bios_config_regs(codec);
4165 if (err < 0) {
4166 stac92xx_free(codec);
4167 return err;
4168 }
4169 spec->pin_configs = spec->bios_pin_configs;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004170 } else {
Matt Porter3cc08dc2006-01-23 15:27:49 +01004171 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
4172 stac92xx_set_config_regs(codec);
4173 }
4174
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004175 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004176 spec->adc_nids = stac927x_adc_nids;
4177 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
4178 spec->mux_nids = stac927x_mux_nids;
4179 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004180 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004181 spec->multiout.dac_nids = spec->dac_nids;
4182
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004183 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02004184 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004185 case STAC_D965_5ST:
4186 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004187 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004188 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004189 spec->num_dmics = 0;
4190
Tobin Davis93ed1502006-09-01 21:03:12 +02004191 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004192 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004193 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004194 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02004195 switch (codec->subsystem_id) {
4196 case 0x10280209:
4197 case 0x1028022e:
4198 /* correct the device field to SPDIF out */
4199 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
4200 break;
4201 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01004202 /* configure the analog microphone on some laptops */
4203 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01004204 /* correct the front output jack as a hp out */
Matthew Ranostay7989fba2008-02-21 07:50:12 +01004205 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01004206 /* correct the front input jack as a mic */
4207 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
4208 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004209 case STAC_DELL_3ST:
4210 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004211 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004212 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004213 spec->dmic_nids = stac927x_dmic_nids;
4214 spec->num_dmics = STAC927X_NUM_DMICS;
4215
Tobin Davis93ed1502006-09-01 21:03:12 +02004216 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004217 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004218 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004219 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004220 break;
4221 default:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004222 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004223 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004224 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004225 spec->num_dmics = 0;
4226
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004227 spec->init = stac927x_core_init;
4228 spec->mixer = stac927x_mixer;
4229 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004230
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004231 spec->num_pwrs = 0;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004232 spec->aloopback_mask = 0x40;
4233 spec->aloopback_shift = 0;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004234
Matt Porter3cc08dc2006-01-23 15:27:49 +01004235 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004236 if (!err) {
4237 if (spec->board_config < 0) {
4238 printk(KERN_WARNING "hda_codec: No auto-config is "
4239 "available, default to model=ref\n");
4240 spec->board_config = STAC_D965_REF;
4241 goto again;
4242 }
4243 err = -EINVAL;
4244 }
Mattc7d4b2f2005-06-27 14:59:41 +02004245 if (err < 0) {
4246 stac92xx_free(codec);
4247 return err;
4248 }
Matt2f2f4252005-04-13 14:45:30 +02004249
4250 codec->patch_ops = stac92xx_patch_ops;
4251
Takashi Iwai52987652008-01-16 16:09:47 +01004252 /*
4253 * !!FIXME!!
4254 * The STAC927x seem to require fairly long delays for certain
4255 * command sequences. With too short delays (even if the answer
4256 * is set to RIRB properly), it results in the silence output
4257 * on some hardwares like Dell.
4258 *
4259 * The below flag enables the longer delay (see get_response
4260 * in hda_intel.c).
4261 */
4262 codec->bus->needs_damn_long_delay = 1;
4263
Matt2f2f4252005-04-13 14:45:30 +02004264 return 0;
4265}
4266
Matt Porterf3302a52006-07-31 12:49:34 +02004267static int patch_stac9205(struct hda_codec *codec)
4268{
4269 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02004270 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02004271
4272 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4273 if (spec == NULL)
4274 return -ENOMEM;
4275
4276 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004277 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004278 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004279 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
4280 stac9205_models,
4281 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004282 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004283 if (spec->board_config < 0) {
4284 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
4285 err = stac92xx_save_bios_config_regs(codec);
4286 if (err < 0) {
4287 stac92xx_free(codec);
4288 return err;
4289 }
4290 spec->pin_configs = spec->bios_pin_configs;
4291 } else {
Matt Porterf3302a52006-07-31 12:49:34 +02004292 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
4293 stac92xx_set_config_regs(codec);
4294 }
4295
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004296 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02004297 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004298 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02004299 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004300 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004301 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02004302 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004303 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004304 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004305 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02004306
4307 spec->init = stac9205_core_init;
4308 spec->mixer = stac9205_mixer;
4309
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004310 spec->aloopback_mask = 0x40;
4311 spec->aloopback_shift = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02004312 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02004313
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004314 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004315 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02004316 /* Enable SPDIF in/out */
4317 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
4318 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01004319
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004320 /* Enable unsol response for GPIO4/Dock HP connection */
4321 snd_hda_codec_write(codec, codec->afg, 0,
4322 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4323 snd_hda_codec_write_cache(codec, codec->afg, 0,
4324 AC_VERB_SET_UNSOLICITED_ENABLE,
4325 (AC_USRSP_EN | STAC_HP_EVENT));
4326
4327 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004328 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004329 spec->gpio_mask = 0x1b;
4330 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01004331 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004332 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02004333 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004334 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004335 break;
4336 default:
4337 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004338 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004339 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004340 break;
4341 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02004342
Matt Porterf3302a52006-07-31 12:49:34 +02004343 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004344 if (!err) {
4345 if (spec->board_config < 0) {
4346 printk(KERN_WARNING "hda_codec: No auto-config is "
4347 "available, default to model=ref\n");
4348 spec->board_config = STAC_9205_REF;
4349 goto again;
4350 }
4351 err = -EINVAL;
4352 }
Matt Porterf3302a52006-07-31 12:49:34 +02004353 if (err < 0) {
4354 stac92xx_free(codec);
4355 return err;
4356 }
4357
4358 codec->patch_ops = stac92xx_patch_ops;
4359
4360 return 0;
4361}
4362
Matt2f2f4252005-04-13 14:45:30 +02004363/*
Guillaume Munch6d859062006-08-22 17:15:47 +02004364 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01004365 */
4366
Guillaume Munch99ccc562006-08-16 19:35:12 +02004367/* static config for Sony VAIO FE550G and Sony VAIO AR */
Takashi Iwaidb064e52006-03-16 16:04:58 +01004368static hda_nid_t vaio_dacs[] = { 0x2 };
4369#define VAIO_HP_DAC 0x5
4370static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
4371static hda_nid_t vaio_mux_nids[] = { 0x15 };
4372
4373static struct hda_input_mux vaio_mux = {
Takashi Iwaia3a2f422007-10-11 11:21:21 +02004374 .num_items = 3,
Takashi Iwaidb064e52006-03-16 16:04:58 +01004375 .items = {
Takashi Iwaid7737812006-04-25 13:05:43 +02004376 /* { "HP", 0x0 }, */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004377 { "Mic Jack", 0x1 },
4378 { "Internal Mic", 0x2 },
Takashi Iwaidb064e52006-03-16 16:04:58 +01004379 { "PCM", 0x3 },
4380 }
4381};
4382
4383static struct hda_verb vaio_init[] = {
4384 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004385 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
Takashi Iwaidb064e52006-03-16 16:04:58 +01004386 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4387 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4388 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4389 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004390 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01004391 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4392 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4393 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4394 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4395 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4396 {}
4397};
4398
Guillaume Munch6d859062006-08-22 17:15:47 +02004399static struct hda_verb vaio_ar_init[] = {
4400 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
4401 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4402 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4403 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4404/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
4405 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004406 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Guillaume Munch6d859062006-08-22 17:15:47 +02004407 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4408 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4409/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
4410 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4411 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4412 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4413 {}
4414};
4415
Takashi Iwaidb064e52006-03-16 16:04:58 +01004416/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02004417static struct hda_bind_ctls vaio_bind_master_vol = {
4418 .ops = &snd_hda_bind_vol,
4419 .values = {
4420 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4421 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4422 0
4423 },
4424};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004425
4426/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02004427static struct hda_bind_ctls vaio_bind_master_sw = {
4428 .ops = &snd_hda_bind_sw,
4429 .values = {
4430 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4431 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4432 0,
4433 },
4434};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004435
4436static struct snd_kcontrol_new vaio_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02004437 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4438 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Takashi Iwaidb064e52006-03-16 16:04:58 +01004439 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4440 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4441 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4442 {
4443 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4444 .name = "Capture Source",
4445 .count = 1,
4446 .info = stac92xx_mux_enum_info,
4447 .get = stac92xx_mux_enum_get,
4448 .put = stac92xx_mux_enum_put,
4449 },
4450 {}
4451};
4452
Guillaume Munch6d859062006-08-22 17:15:47 +02004453static struct snd_kcontrol_new vaio_ar_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02004454 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4455 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Guillaume Munch6d859062006-08-22 17:15:47 +02004456 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4457 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4458 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4459 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
4460 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
4461 {
4462 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4463 .name = "Capture Source",
4464 .count = 1,
4465 .info = stac92xx_mux_enum_info,
4466 .get = stac92xx_mux_enum_get,
4467 .put = stac92xx_mux_enum_put,
4468 },
4469 {}
4470};
4471
4472static struct hda_codec_ops stac9872_patch_ops = {
Takashi Iwaidb064e52006-03-16 16:04:58 +01004473 .build_controls = stac92xx_build_controls,
4474 .build_pcms = stac92xx_build_pcms,
4475 .init = stac92xx_init,
4476 .free = stac92xx_free,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004477#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaidb064e52006-03-16 16:04:58 +01004478 .resume = stac92xx_resume,
4479#endif
4480};
4481
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004482static int stac9872_vaio_init(struct hda_codec *codec)
4483{
4484 int err;
4485
4486 err = stac92xx_init(codec);
4487 if (err < 0)
4488 return err;
4489 if (codec->patch_ops.unsol_event)
4490 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
4491 return 0;
4492}
4493
4494static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
4495{
Jiang Zhe40c1d302007-11-12 13:05:16 +01004496 if (get_hp_pin_presence(codec, 0x0a)) {
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004497 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4498 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4499 } else {
4500 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4501 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4502 }
4503}
4504
4505static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
4506{
4507 switch (res >> 26) {
4508 case STAC_HP_EVENT:
4509 stac9872_vaio_hp_detect(codec, res);
4510 break;
4511 }
4512}
4513
4514static struct hda_codec_ops stac9872_vaio_patch_ops = {
4515 .build_controls = stac92xx_build_controls,
4516 .build_pcms = stac92xx_build_pcms,
4517 .init = stac9872_vaio_init,
4518 .free = stac92xx_free,
4519 .unsol_event = stac9872_vaio_unsol_event,
4520#ifdef CONFIG_PM
4521 .resume = stac92xx_resume,
4522#endif
4523};
4524
Guillaume Munch6d859062006-08-22 17:15:47 +02004525enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
4526 CXD9872RD_VAIO,
4527 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
4528 STAC9872AK_VAIO,
4529 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
4530 STAC9872K_VAIO,
4531 /* AR Series. id=0x83847664 and subsys=104D1300 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004532 CXD9872AKD_VAIO,
4533 STAC_9872_MODELS,
4534};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004535
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004536static const char *stac9872_models[STAC_9872_MODELS] = {
4537 [CXD9872RD_VAIO] = "vaio",
4538 [CXD9872AKD_VAIO] = "vaio-ar",
4539};
4540
4541static struct snd_pci_quirk stac9872_cfg_tbl[] = {
4542 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
4543 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
4544 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
Tobin Davis68e22542007-03-12 11:36:39 +01004545 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
Takashi Iwaidb064e52006-03-16 16:04:58 +01004546 {}
4547};
4548
Guillaume Munch6d859062006-08-22 17:15:47 +02004549static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01004550{
4551 struct sigmatel_spec *spec;
4552 int board_config;
4553
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004554 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
4555 stac9872_models,
4556 stac9872_cfg_tbl);
Takashi Iwaidb064e52006-03-16 16:04:58 +01004557 if (board_config < 0)
4558 /* unknown config, let generic-parser do its job... */
4559 return snd_hda_parse_generic_codec(codec);
4560
4561 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4562 if (spec == NULL)
4563 return -ENOMEM;
4564
4565 codec->spec = spec;
4566 switch (board_config) {
Guillaume Munch6d859062006-08-22 17:15:47 +02004567 case CXD9872RD_VAIO:
4568 case STAC9872AK_VAIO:
4569 case STAC9872K_VAIO:
Takashi Iwaidb064e52006-03-16 16:04:58 +01004570 spec->mixer = vaio_mixer;
4571 spec->init = vaio_init;
4572 spec->multiout.max_channels = 2;
4573 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
4574 spec->multiout.dac_nids = vaio_dacs;
4575 spec->multiout.hp_nid = VAIO_HP_DAC;
4576 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
4577 spec->adc_nids = vaio_adcs;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004578 spec->num_pwrs = 0;
Takashi Iwaidb064e52006-03-16 16:04:58 +01004579 spec->input_mux = &vaio_mux;
4580 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004581 codec->patch_ops = stac9872_vaio_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01004582 break;
Guillaume Munch6d859062006-08-22 17:15:47 +02004583
4584 case CXD9872AKD_VAIO:
4585 spec->mixer = vaio_ar_mixer;
4586 spec->init = vaio_ar_init;
4587 spec->multiout.max_channels = 2;
4588 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
4589 spec->multiout.dac_nids = vaio_dacs;
4590 spec->multiout.hp_nid = VAIO_HP_DAC;
4591 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004592 spec->num_pwrs = 0;
Guillaume Munch6d859062006-08-22 17:15:47 +02004593 spec->adc_nids = vaio_adcs;
4594 spec->input_mux = &vaio_mux;
4595 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004596 codec->patch_ops = stac9872_patch_ops;
Guillaume Munch6d859062006-08-22 17:15:47 +02004597 break;
Takashi Iwaidb064e52006-03-16 16:04:58 +01004598 }
4599
Takashi Iwaidb064e52006-03-16 16:04:58 +01004600 return 0;
4601}
4602
4603
4604/*
Matt2f2f4252005-04-13 14:45:30 +02004605 * patch entries
4606 */
4607struct hda_codec_preset snd_hda_preset_sigmatel[] = {
4608 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
4609 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
4610 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
4611 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
4612 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
4613 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
4614 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02004615 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
4616 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
4617 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
4618 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
4619 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
4620 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01004621 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
4622 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
4623 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
4624 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
4625 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
4626 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
4627 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
4628 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
4629 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
4630 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01004631 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
4632 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
4633 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
4634 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
4635 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
4636 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02004637 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
4638 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02004639 /* The following does not take into account .id=0x83847661 when subsys =
4640 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
4641 * currently not fully supported.
4642 */
4643 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
4644 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
4645 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02004646 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
4647 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
4648 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
4649 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
4650 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
4651 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
4652 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
4653 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004654 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004655 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
4656 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004657 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01004658 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
4659 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004660 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01004661 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
4662 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
4663 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
4664 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
4665 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
4666 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
4667 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
4668 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02004669 {} /* terminator */
4670};