blob: 23a7b2228e3c4cf63ca5e208c0fe0c80fda69b4b [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,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200113 STAC_922X_DELL_D81,
114 STAC_922X_DELL_D82,
115 STAC_922X_DELL_M81,
116 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100117 STAC_922X_MODELS
118};
119
120enum {
121 STAC_D965_REF,
122 STAC_D965_3ST,
123 STAC_D965_5ST,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200124 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100125 STAC_DELL_BIOS,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100126 STAC_927X_MODELS
127};
Matt Porter403d1942005-11-29 15:00:51 +0100128
Matt2f2f4252005-04-13 14:45:30 +0200129struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100130 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200131 unsigned int num_mixers;
132
Matt Porter403d1942005-11-29 15:00:51 +0100133 int board_config;
Mattc7d4b2f2005-06-27 14:59:41 +0200134 unsigned int surr_switch: 1;
Matt Porter403d1942005-11-29 15:00:51 +0100135 unsigned int line_switch: 1;
136 unsigned int mic_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100137 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100138 unsigned int hp_detect: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200139
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100140 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200141 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100142 unsigned int gpio_mask;
143 unsigned int gpio_dir;
144 unsigned int gpio_data;
145 unsigned int gpio_mute;
146
147 /* analog loopback */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100148 unsigned char aloopback_mask;
149 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200150
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100151 /* power management */
152 unsigned int num_pwrs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200153 unsigned int *pwr_mapping;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100154 hda_nid_t *pwr_nids;
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100155 hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100156
Matt2f2f4252005-04-13 14:45:30 +0200157 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100158 struct hda_input_mux *mono_mux;
159 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200160 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100161 hda_nid_t dac_nids[5];
Matt2f2f4252005-04-13 14:45:30 +0200162
163 /* capture */
164 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200165 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200166 hda_nid_t *mux_nids;
167 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200168 hda_nid_t *dmic_nids;
169 unsigned int num_dmics;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100170 hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100171 unsigned int num_dmuxes;
Mattdabbed62005-06-14 10:19:34 +0200172 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100173 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200174 hda_nid_t anabeep_nid;
175 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200176
Matt2f2f4252005-04-13 14:45:30 +0200177 /* pin widgets */
178 hda_nid_t *pin_nids;
179 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200180 unsigned int *pin_configs;
Richard Fish11b44bb2006-08-23 18:31:34 +0200181 unsigned int *bios_pin_configs;
Matt2f2f4252005-04-13 14:45:30 +0200182
183 /* codec specific stuff */
184 struct hda_verb *init;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100185 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200186
187 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200188 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100189 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200190 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100191 unsigned int cur_mux[3];
Matt2f2f4252005-04-13 14:45:30 +0200192
Matt Porter403d1942005-11-29 15:00:51 +0100193 /* i/o switches */
194 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200195 unsigned int clfe_swap;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +0200196 unsigned int hp_switch;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200197 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200198
Mattc7d4b2f2005-06-27 14:59:41 +0200199 struct hda_pcm pcm_rec[2]; /* PCM information */
200
201 /* dynamic controls and input_mux */
202 struct auto_pin_cfg autocfg;
203 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100204 struct snd_kcontrol_new *kctl_alloc;
Matt Porter8b657272006-10-26 17:12:59 +0200205 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200206 struct hda_input_mux private_imux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100207 struct hda_input_mux private_mono_mux;
Matt2f2f4252005-04-13 14:45:30 +0200208};
209
210static hda_nid_t stac9200_adc_nids[1] = {
211 0x03,
212};
213
214static hda_nid_t stac9200_mux_nids[1] = {
215 0x0c,
216};
217
218static hda_nid_t stac9200_dac_nids[1] = {
219 0x02,
220};
221
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100222static hda_nid_t stac92hd73xx_pwr_nids[8] = {
223 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
224 0x0f, 0x10, 0x11
225};
226
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100227static hda_nid_t stac92hd73xx_adc_nids[2] = {
228 0x1a, 0x1b
229};
230
231#define STAC92HD73XX_NUM_DMICS 2
232static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
233 0x13, 0x14, 0
234};
235
236#define STAC92HD73_DAC_COUNT 5
237static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
238 0x15, 0x16, 0x17, 0x18, 0x19,
239};
240
241static hda_nid_t stac92hd73xx_mux_nids[4] = {
242 0x28, 0x29, 0x2a, 0x2b,
243};
244
245static hda_nid_t stac92hd73xx_dmux_nids[2] = {
246 0x20, 0x21,
247};
248
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200249#define STAC92HD83XXX_NUM_DMICS 2
250static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
251 0x11, 0x12, 0
252};
253
254#define STAC92HD81_DAC_COUNT 2
255#define STAC92HD83_DAC_COUNT 3
256static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = {
257 0x13, 0x14, 0x22,
258};
259
260static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
261 0x17, 0x18,
262};
263
264static hda_nid_t stac92hd83xxx_adc_nids[2] = {
265 0x15, 0x16,
266};
267
268static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
269 0xa, 0xb, 0xd, 0xe,
270};
271
272static unsigned int stac92hd83xxx_pwr_mapping[4] = {
273 0x03, 0x0c, 0x10, 0x40,
274};
275
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100276static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
277 0x0a, 0x0d, 0x0f
278};
279
Matthew Ranostaye035b842007-11-06 11:53:55 +0100280static hda_nid_t stac92hd71bxx_adc_nids[2] = {
281 0x12, 0x13,
282};
283
284static hda_nid_t stac92hd71bxx_mux_nids[2] = {
285 0x1a, 0x1b
286};
287
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100288static hda_nid_t stac92hd71bxx_dmux_nids[1] = {
289 0x1c,
290};
291
Takashi Iwaiaea7bb02008-02-25 18:26:41 +0100292static hda_nid_t stac92hd71bxx_dac_nids[1] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100293 0x10, /*0x11, */
294};
295
296#define STAC92HD71BXX_NUM_DMICS 2
297static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
298 0x18, 0x19, 0
299};
300
Tobin Davis8e21c342007-01-08 11:04:17 +0100301static hda_nid_t stac925x_adc_nids[1] = {
302 0x03,
303};
304
305static hda_nid_t stac925x_mux_nids[1] = {
306 0x0f,
307};
308
309static hda_nid_t stac925x_dac_nids[1] = {
310 0x02,
311};
312
Takashi Iwaif6e98522007-10-16 14:27:04 +0200313#define STAC925X_NUM_DMICS 1
314static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
315 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200316};
317
Takashi Iwai1697055e2007-12-18 18:05:52 +0100318static hda_nid_t stac925x_dmux_nids[1] = {
319 0x14,
320};
321
Matt2f2f4252005-04-13 14:45:30 +0200322static hda_nid_t stac922x_adc_nids[2] = {
323 0x06, 0x07,
324};
325
326static hda_nid_t stac922x_mux_nids[2] = {
327 0x12, 0x13,
328};
329
Matt Porter3cc08dc2006-01-23 15:27:49 +0100330static hda_nid_t stac927x_adc_nids[3] = {
331 0x07, 0x08, 0x09
332};
333
334static hda_nid_t stac927x_mux_nids[3] = {
335 0x15, 0x16, 0x17
336};
337
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100338static hda_nid_t stac927x_dac_nids[6] = {
339 0x02, 0x03, 0x04, 0x05, 0x06, 0
340};
341
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100342static hda_nid_t stac927x_dmux_nids[1] = {
343 0x1b,
344};
345
Matthew Ranostay7f168592007-10-18 17:38:17 +0200346#define STAC927X_NUM_DMICS 2
347static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
348 0x13, 0x14, 0
349};
350
Matt Porterf3302a52006-07-31 12:49:34 +0200351static hda_nid_t stac9205_adc_nids[2] = {
352 0x12, 0x13
353};
354
355static hda_nid_t stac9205_mux_nids[2] = {
356 0x19, 0x1a
357};
358
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100359static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100360 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100361};
362
Takashi Iwaif6e98522007-10-16 14:27:04 +0200363#define STAC9205_NUM_DMICS 2
364static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
365 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200366};
367
Mattc7d4b2f2005-06-27 14:59:41 +0200368static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200369 0x08, 0x09, 0x0d, 0x0e,
370 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200371};
372
Tobin Davis8e21c342007-01-08 11:04:17 +0100373static hda_nid_t stac925x_pin_nids[8] = {
374 0x07, 0x08, 0x0a, 0x0b,
375 0x0c, 0x0d, 0x10, 0x11,
376};
377
Matt2f2f4252005-04-13 14:45:30 +0200378static hda_nid_t stac922x_pin_nids[10] = {
379 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
380 0x0f, 0x10, 0x11, 0x15, 0x1b,
381};
382
Matthew Ranostaya7662642008-02-21 07:51:14 +0100383static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100384 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
385 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostaya7662642008-02-21 07:51:14 +0100386 0x14, 0x1e, 0x22
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100387};
388
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200389static hda_nid_t stac92hd83xxx_pin_nids[14] = {
390 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
391 0x0f, 0x10, 0x11, 0x12, 0x13,
392 0x1d, 0x1e, 0x1f, 0x20
393};
Matthew Ranostaye035b842007-11-06 11:53:55 +0100394static hda_nid_t stac92hd71bxx_pin_nids[10] = {
395 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
396 0x0f, 0x14, 0x18, 0x19, 0x1e,
397};
398
Matt Porter3cc08dc2006-01-23 15:27:49 +0100399static hda_nid_t stac927x_pin_nids[14] = {
400 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
401 0x0f, 0x10, 0x11, 0x12, 0x13,
402 0x14, 0x21, 0x22, 0x23,
403};
404
Matt Porterf3302a52006-07-31 12:49:34 +0200405static hda_nid_t stac9205_pin_nids[12] = {
406 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
407 0x0f, 0x14, 0x16, 0x17, 0x18,
408 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200409};
410
Matt Porter8b657272006-10-26 17:12:59 +0200411static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
412 struct snd_ctl_elem_info *uinfo)
413{
414 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
415 struct sigmatel_spec *spec = codec->spec;
416 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
417}
418
419static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
420 struct snd_ctl_elem_value *ucontrol)
421{
422 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
423 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100424 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200425
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100426 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200427 return 0;
428}
429
430static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
431 struct snd_ctl_elem_value *ucontrol)
432{
433 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
434 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100435 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200436
437 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100438 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200439}
440
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100441static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200442{
443 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
444 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200445 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200446}
447
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100448static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200449{
450 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
451 struct sigmatel_spec *spec = codec->spec;
452 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
453
454 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
455 return 0;
456}
457
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100458static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200459{
460 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
461 struct sigmatel_spec *spec = codec->spec;
462 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
463
Mattc7d4b2f2005-06-27 14:59:41 +0200464 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200465 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
466}
467
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100468static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
469 struct snd_ctl_elem_info *uinfo)
470{
471 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
472 struct sigmatel_spec *spec = codec->spec;
473 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
474}
475
476static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
477 struct snd_ctl_elem_value *ucontrol)
478{
479 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
480 struct sigmatel_spec *spec = codec->spec;
481
482 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
483 return 0;
484}
485
486static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
487 struct snd_ctl_elem_value *ucontrol)
488{
489 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
490 struct sigmatel_spec *spec = codec->spec;
491
492 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
493 spec->mono_nid, &spec->cur_mmux);
494}
495
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200496#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
497
498static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
499 struct snd_ctl_elem_value *ucontrol)
500{
501 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100502 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200503 struct sigmatel_spec *spec = codec->spec;
504
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100505 ucontrol->value.integer.value[0] = !!(spec->aloopback &
506 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200507 return 0;
508}
509
510static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
511 struct snd_ctl_elem_value *ucontrol)
512{
513 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
514 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100515 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200516 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100517 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200518
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100519 idx_val = spec->aloopback_mask << idx;
520 if (ucontrol->value.integer.value[0])
521 val = spec->aloopback | idx_val;
522 else
523 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100524 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200525 return 0;
526
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100527 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200528
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100529 /* Only return the bits defined by the shift value of the
530 * first two bytes of the mask
531 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200532 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100533 kcontrol->private_value & 0xFFFF, 0x0);
534 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200535
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100536 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200537 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100538 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200539 } else {
540 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100541 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200542 }
543
544 snd_hda_codec_write_cache(codec, codec->afg, 0,
545 kcontrol->private_value >> 16, dac_mode);
546
547 return 1;
548}
549
Mattc7d4b2f2005-06-27 14:59:41 +0200550static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200551 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200552 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200553 {}
554};
555
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200556static struct hda_verb stac9200_eapd_init[] = {
557 /* set dac0mux for dac converter */
558 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
559 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
560 {}
561};
562
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100563static struct hda_verb stac92hd73xx_6ch_core_init[] = {
564 /* set master volume and direct control */
565 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
566 /* setup audio connections */
567 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
568 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
569 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
570 /* setup adcs to point to mixer */
571 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
572 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100573 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
574 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
575 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
576 /* setup import muxs */
577 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
578 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
579 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
580 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
581 {}
582};
583
Matthew Ranostayd654a662008-03-14 08:46:51 +0100584static struct hda_verb dell_eq_core_init[] = {
585 /* set master volume to max value without distortion
586 * and direct control */
587 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
588 /* setup audio connections */
589 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
590 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
591 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
592 /* setup adcs to point to mixer */
593 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
594 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
595 /* setup import muxs */
596 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
597 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
598 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
599 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
600 {}
601};
602
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100603static struct hda_verb dell_m6_core_init[] = {
Matthew Ranostay20f5f952008-09-01 08:17:56 +0200604 /* set master volume to max value without distortion
605 * and direct control */
606 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100607 /* setup audio connections */
Matthew Ranostay7747ecc2008-03-10 11:30:04 +0100608 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
609 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100610 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
611 /* setup adcs to point to mixer */
612 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
613 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
614 /* setup import muxs */
615 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
616 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
617 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
618 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
619 {}
620};
621
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100622static struct hda_verb stac92hd73xx_8ch_core_init[] = {
623 /* set master volume and direct control */
624 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
625 /* setup audio connections */
626 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
627 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
628 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
629 /* connect hp ports to dac3 */
630 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
631 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
632 /* setup adcs to point to mixer */
633 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
634 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100635 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
636 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
637 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
638 /* setup import muxs */
639 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
640 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
641 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
642 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
643 {}
644};
645
646static struct hda_verb stac92hd73xx_10ch_core_init[] = {
647 /* set master volume and direct control */
648 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
649 /* setup audio connections */
650 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
651 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
652 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
653 /* dac3 is connected to import3 mux */
654 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
655 /* connect hp ports to dac4 */
656 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
657 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
658 /* setup adcs to point to mixer */
659 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
660 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100661 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
662 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
663 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
664 /* setup import muxs */
665 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
666 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
667 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
668 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
669 {}
670};
671
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200672static struct hda_verb stac92hd83xxx_core_init[] = {
673 /* start of config #1 */
674 { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3},
675
676 /* start of config #2 */
677 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
678 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
679 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
680
681 /* power state controls amps */
682 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
683};
684
Matthew Ranostaye035b842007-11-06 11:53:55 +0100685static struct hda_verb stac92hd71bxx_core_init[] = {
686 /* set master volume and direct control */
687 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
688 /* connect headphone jack to dac1 */
689 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100690 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
691 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
692 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
693 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
694 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100695};
696
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200697#define HD_DISABLE_PORTF 3
Matthew Ranostay541eee82007-12-14 12:08:04 +0100698static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200699 /* start of config #1 */
700
701 /* connect port 0f to audio mixer */
702 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
703 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
704 /* unmute right and left channels for node 0x0f */
705 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
706 /* start of config #2 */
707
Matthew Ranostay541eee82007-12-14 12:08:04 +0100708 /* set master volume and direct control */
709 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
710 /* connect headphone jack to dac1 */
711 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200712 /* connect port 0d to audio mixer */
Matthew Ranostay9b359472007-11-07 13:03:12 +0100713 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostay9b359472007-11-07 13:03:12 +0100714 /* unmute dac0 input in audio mixer */
715 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200716 /* unmute right and left channels for nodes 0x0a, 0xd */
Matthew Ranostaye035b842007-11-06 11:53:55 +0100717 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
718 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100719 {}
720};
721
Tobin Davis8e21c342007-01-08 11:04:17 +0100722static struct hda_verb stac925x_core_init[] = {
723 /* set dac0mux for dac converter */
724 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
725 {}
726};
727
Mattc7d4b2f2005-06-27 14:59:41 +0200728static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200729 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200730 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200731 {}
732};
733
Tobin Davis93ed1502006-09-01 21:03:12 +0200734static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200735 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200736 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200737 /* unmute node 0x1b */
738 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
739 /* select node 0x03 as DAC */
740 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
741 {}
742};
743
Matt Porter3cc08dc2006-01-23 15:27:49 +0100744static struct hda_verb stac927x_core_init[] = {
745 /* set master volume and direct control */
746 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200747 /* enable analog pc beep path */
748 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100749 {}
750};
751
Matt Porterf3302a52006-07-31 12:49:34 +0200752static struct hda_verb stac9205_core_init[] = {
753 /* set master volume and direct control */
754 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200755 /* enable analog pc beep path */
756 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200757 {}
758};
759
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100760#define STAC_MONO_MUX \
761 { \
762 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
763 .name = "Mono Mux", \
764 .count = 1, \
765 .info = stac92xx_mono_mux_enum_info, \
766 .get = stac92xx_mono_mux_enum_get, \
767 .put = stac92xx_mono_mux_enum_put, \
768 }
769
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200770#define STAC_INPUT_SOURCE(cnt) \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200771 { \
772 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
773 .name = "Input Source", \
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200774 .count = cnt, \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200775 .info = stac92xx_mux_enum_info, \
776 .get = stac92xx_mux_enum_get, \
777 .put = stac92xx_mux_enum_put, \
778 }
779
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100780#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200781 { \
782 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
783 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100784 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200785 .info = stac92xx_aloopback_info, \
786 .get = stac92xx_aloopback_get, \
787 .put = stac92xx_aloopback_put, \
788 .private_value = verb_read | (verb_write << 16), \
789 }
790
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100791static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200792 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
793 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200794 STAC_INPUT_SOURCE(1),
Matt2f2f4252005-04-13 14:45:30 +0200795 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
796 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Mattc7d4b2f2005-06-27 14:59:41 +0200797 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 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),
911 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT),
912
913 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
914 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
915 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
916
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200917 /* analog pc-beep replaced with digital beep support */
918 /*
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +0200919 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
920 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200921 */
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +0200922
Matthew Ranostay9b359472007-11-07 13:03:12 +0100923 HDA_CODEC_MUTE("Analog Loopback 1", 0x17, 0x3, HDA_INPUT),
924 HDA_CODEC_MUTE("Analog Loopback 2", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +0100925 { } /* end */
926};
927
Matthew Ranostay541eee82007-12-14 12:08:04 +0100928static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +0100929 STAC_INPUT_SOURCE(2),
930 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
931
Matthew Ranostay541eee82007-12-14 12:08:04 +0100932 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
933 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
934 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT),
935
936 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
937 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
938 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
939 { } /* end */
940};
941
Tobin Davis8e21c342007-01-08 11:04:17 +0100942static struct snd_kcontrol_new stac925x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200943 STAC_INPUT_SOURCE(1),
Tobin Davis8e21c342007-01-08 11:04:17 +0100944 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +0200945 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +0100946 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0f, 0, HDA_OUTPUT),
947 { } /* end */
948};
949
Takashi Iwaid1d985f2006-11-23 19:27:12 +0100950static struct snd_kcontrol_new stac9205_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200951 STAC_INPUT_SOURCE(2),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100952 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200953
954 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
955 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
956 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x19, 0x0, HDA_OUTPUT),
957
958 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
959 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
960 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x1A, 0x0, HDA_OUTPUT),
961
962 { } /* end */
963};
964
965/* This needs to be generated dynamically based on sequence */
966static struct snd_kcontrol_new stac922x_mixer[] = {
967 STAC_INPUT_SOURCE(2),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200968 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
969 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
970 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x12, 0x0, HDA_OUTPUT),
971
972 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
973 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
974 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x13, 0x0, HDA_OUTPUT),
975 { } /* end */
976};
977
978
979static struct snd_kcontrol_new stac927x_mixer[] = {
980 STAC_INPUT_SOURCE(3),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100981 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200982
983 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
984 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
985 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x15, 0x0, HDA_OUTPUT),
986
987 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
988 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
989 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x16, 0x0, HDA_OUTPUT),
990
991 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
992 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
993 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x2, 0x17, 0x0, HDA_OUTPUT),
Matt Porterf3302a52006-07-31 12:49:34 +0200994 { } /* end */
995};
996
Takashi Iwai1697055e2007-12-18 18:05:52 +0100997static struct snd_kcontrol_new stac_dmux_mixer = {
998 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
999 .name = "Digital Input Source",
1000 /* count set later */
1001 .info = stac92xx_dmux_enum_info,
1002 .get = stac92xx_dmux_enum_get,
1003 .put = stac92xx_dmux_enum_put,
1004};
1005
Takashi Iwai2134ea42008-01-10 16:53:55 +01001006static const char *slave_vols[] = {
1007 "Front Playback Volume",
1008 "Surround Playback Volume",
1009 "Center Playback Volume",
1010 "LFE Playback Volume",
1011 "Side Playback Volume",
1012 "Headphone Playback Volume",
1013 "Headphone Playback Volume",
1014 "Speaker Playback Volume",
1015 "External Speaker Playback Volume",
1016 "Speaker2 Playback Volume",
1017 NULL
1018};
1019
1020static const char *slave_sws[] = {
1021 "Front Playback Switch",
1022 "Surround Playback Switch",
1023 "Center Playback Switch",
1024 "LFE Playback Switch",
1025 "Side Playback Switch",
1026 "Headphone Playback Switch",
1027 "Headphone Playback Switch",
1028 "Speaker Playback Switch",
1029 "External Speaker Playback Switch",
1030 "Speaker2 Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001031 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001032 NULL
1033};
1034
Matt2f2f4252005-04-13 14:45:30 +02001035static int stac92xx_build_controls(struct hda_codec *codec)
1036{
1037 struct sigmatel_spec *spec = codec->spec;
1038 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001039 int i;
Matt2f2f4252005-04-13 14:45:30 +02001040
1041 err = snd_hda_add_new_ctls(codec, spec->mixer);
1042 if (err < 0)
1043 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001044
1045 for (i = 0; i < spec->num_mixers; i++) {
1046 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1047 if (err < 0)
1048 return err;
1049 }
Takashi Iwai1697055e2007-12-18 18:05:52 +01001050 if (spec->num_dmuxes > 0) {
1051 stac_dmux_mixer.count = spec->num_dmuxes;
1052 err = snd_ctl_add(codec->bus->card,
1053 snd_ctl_new1(&stac_dmux_mixer, codec));
1054 if (err < 0)
1055 return err;
1056 }
Mattc7d4b2f2005-06-27 14:59:41 +02001057
Mattdabbed62005-06-14 10:19:34 +02001058 if (spec->multiout.dig_out_nid) {
1059 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1060 if (err < 0)
1061 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001062 err = snd_hda_create_spdif_share_sw(codec,
1063 &spec->multiout);
1064 if (err < 0)
1065 return err;
1066 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001067 }
1068 if (spec->dig_in_nid) {
1069 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1070 if (err < 0)
1071 return err;
1072 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001073
1074 /* if we have no master control, let's create it */
1075 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001076 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001077 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001078 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001079 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001080 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001081 if (err < 0)
1082 return err;
1083 }
1084 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1085 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1086 NULL, slave_sws);
1087 if (err < 0)
1088 return err;
1089 }
1090
Mattdabbed62005-06-14 10:19:34 +02001091 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001092}
1093
Matt Porter403d1942005-11-29 15:00:51 +01001094static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001095 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001096 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1097};
1098
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001099/*
1100 STAC 9200 pin configs for
1101 102801A8
1102 102801DE
1103 102801E8
1104*/
1105static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001106 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1107 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001108};
1109
1110/*
1111 STAC 9200 pin configs for
1112 102801C0
1113 102801C1
1114*/
1115static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001116 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1117 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001118};
1119
1120/*
1121 STAC 9200 pin configs for
1122 102801C4 (Dell Dimension E310)
1123 102801C5
1124 102801C7
1125 102801D9
1126 102801DA
1127 102801E3
1128*/
1129static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001130 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1131 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001132};
1133
1134
1135/*
1136 STAC 9200-32 pin configs for
1137 102801B5 (Dell Inspiron 630m)
1138 102801D8 (Dell Inspiron 640m)
1139*/
1140static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001141 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1142 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001143};
1144
1145/*
1146 STAC 9200-32 pin configs for
1147 102801C2 (Dell Latitude D620)
1148 102801C8
1149 102801CC (Dell Latitude D820)
1150 102801D4
1151 102801D6
1152*/
1153static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001154 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1155 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001156};
1157
1158/*
1159 STAC 9200-32 pin configs for
1160 102801CE (Dell XPS M1710)
1161 102801CF (Dell Precision M90)
1162*/
1163static unsigned int dell9200_m23_pin_configs[8] = {
1164 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1165 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1166};
1167
1168/*
1169 STAC 9200-32 pin configs for
1170 102801C9
1171 102801CA
1172 102801CB (Dell Latitude 120L)
1173 102801D3
1174*/
1175static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001176 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1177 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001178};
1179
1180/*
1181 STAC 9200-32 pin configs for
1182 102801BD (Dell Inspiron E1505n)
1183 102801EE
1184 102801EF
1185*/
1186static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001187 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1188 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001189};
1190
1191/*
1192 STAC 9200-32 pin configs for
1193 102801F5 (Dell Inspiron 1501)
1194 102801F6
1195*/
1196static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001197 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1198 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001199};
1200
1201/*
1202 STAC 9200-32
1203 102801CD (Dell Inspiron E1705/9400)
1204*/
1205static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001206 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1207 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001208};
1209
Tobin Davisbf277782008-02-03 20:31:47 +01001210static unsigned int oqo9200_pin_configs[8] = {
1211 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1212 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1213};
1214
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001215
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001216static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1217 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001218 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001219 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1220 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1221 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1222 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1223 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1224 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1225 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1226 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1227 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1228 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001229 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001230};
1231
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001232static const char *stac9200_models[STAC_9200_MODELS] = {
1233 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001234 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001235 [STAC_9200_DELL_D21] = "dell-d21",
1236 [STAC_9200_DELL_D22] = "dell-d22",
1237 [STAC_9200_DELL_D23] = "dell-d23",
1238 [STAC_9200_DELL_M21] = "dell-m21",
1239 [STAC_9200_DELL_M22] = "dell-m22",
1240 [STAC_9200_DELL_M23] = "dell-m23",
1241 [STAC_9200_DELL_M24] = "dell-m24",
1242 [STAC_9200_DELL_M25] = "dell-m25",
1243 [STAC_9200_DELL_M26] = "dell-m26",
1244 [STAC_9200_DELL_M27] = "dell-m27",
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001245 [STAC_9200_GATEWAY] = "gateway",
Takashi Iwai117f2572008-03-18 09:53:23 +01001246 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001247};
1248
1249static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1250 /* SigmaTel reference board */
1251 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1252 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001253 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001254 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1255 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001256 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001257 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1258 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1259 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1260 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1261 "unknown Dell", STAC_9200_DELL_D22),
1262 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1263 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001264 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001265 "Dell Latitude D620", STAC_9200_DELL_M22),
1266 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1267 "unknown Dell", STAC_9200_DELL_D23),
1268 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1269 "unknown Dell", STAC_9200_DELL_D23),
1270 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1271 "unknown Dell", STAC_9200_DELL_M22),
1272 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1273 "unknown Dell", STAC_9200_DELL_M24),
1274 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1275 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001276 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001277 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001278 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001279 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001280 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001281 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001282 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001283 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001284 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001285 "Dell Precision M90", STAC_9200_DELL_M23),
1286 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1287 "unknown Dell", STAC_9200_DELL_M22),
1288 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1289 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001290 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001291 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001292 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001293 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1294 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1295 "unknown Dell", STAC_9200_DELL_D23),
1296 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1297 "unknown Dell", STAC_9200_DELL_D23),
1298 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1299 "unknown Dell", STAC_9200_DELL_D21),
1300 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1301 "unknown Dell", STAC_9200_DELL_D23),
1302 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1303 "unknown Dell", STAC_9200_DELL_D21),
1304 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1305 "unknown Dell", STAC_9200_DELL_M25),
1306 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1307 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001308 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001309 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1310 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1311 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001312 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001313 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001314 /* Gateway machines needs EAPD to be set on resume */
1315 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1316 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1317 STAC_9200_GATEWAY),
1318 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1319 STAC_9200_GATEWAY),
Tobin Davisbf277782008-02-03 20:31:47 +01001320 /* OQO Mobile */
1321 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001322 {} /* terminator */
1323};
1324
Tobin Davis8e21c342007-01-08 11:04:17 +01001325static unsigned int ref925x_pin_configs[8] = {
1326 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001327 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001328};
1329
1330static unsigned int stac925x_MA6_pin_configs[8] = {
1331 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1332 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1333};
1334
Tobin Davis2c11f952007-05-17 09:36:34 +02001335static unsigned int stac925x_PA6_pin_configs[8] = {
1336 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1337 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1338};
1339
Tobin Davis8e21c342007-01-08 11:04:17 +01001340static unsigned int stac925xM2_2_pin_configs[8] = {
Steve Longerbeam7353e142007-05-29 14:36:17 +02001341 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1342 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001343};
1344
1345static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1346 [STAC_REF] = ref925x_pin_configs,
1347 [STAC_M2_2] = stac925xM2_2_pin_configs,
1348 [STAC_MA6] = stac925x_MA6_pin_configs,
Tobin Davis2c11f952007-05-17 09:36:34 +02001349 [STAC_PA6] = stac925x_PA6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001350};
1351
1352static const char *stac925x_models[STAC_925x_MODELS] = {
1353 [STAC_REF] = "ref",
1354 [STAC_M2_2] = "m2-2",
1355 [STAC_MA6] = "m6",
Tobin Davis2c11f952007-05-17 09:36:34 +02001356 [STAC_PA6] = "pa6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001357};
1358
1359static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1360 /* SigmaTel reference board */
1361 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001362 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Tobin Davis8e21c342007-01-08 11:04:17 +01001363 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1364 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1365 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
Tobin Davis2c11f952007-05-17 09:36:34 +02001366 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
Tobin Davis8e21c342007-01-08 11:04:17 +01001367 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1368 {} /* terminator */
1369};
1370
Matthew Ranostaya7662642008-02-21 07:51:14 +01001371static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001372 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1373 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1374 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001375 0x01452050,
1376};
1377
1378static unsigned int dell_m6_pin_configs[13] = {
1379 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001380 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001381 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1382 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001383};
1384
1385static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001386 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1387 [STAC_DELL_M6] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001388};
1389
1390static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1391 [STAC_92HD73XX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001392 [STAC_DELL_M6] = "dell-m6",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001393};
1394
1395static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1396 /* SigmaTel reference board */
1397 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001398 "DFI LanParty", STAC_92HD73XX_REF),
1399 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1400 "unknown Dell", STAC_DELL_M6),
1401 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1402 "unknown Dell", STAC_DELL_M6),
1403 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1404 "unknown Dell", STAC_DELL_M6),
1405 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1406 "unknown Dell", STAC_DELL_M6),
1407 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1408 "unknown Dell", STAC_DELL_M6),
1409 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1410 "unknown Dell", STAC_DELL_M6),
1411 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1412 "unknown Dell", STAC_DELL_M6),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001413 {} /* terminator */
1414};
1415
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001416static unsigned int ref92hd83xxx_pin_configs[14] = {
1417 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1418 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1419 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1420 0x01451160, 0x98560170,
1421};
1422
1423static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1424 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1425};
1426
1427static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1428 [STAC_92HD83XXX_REF] = "ref",
1429};
1430
1431static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1432 /* SigmaTel reference board */
1433 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1434 "DFI LanParty", STAC_92HD71BXX_REF),
1435};
1436
Matthew Ranostaye035b842007-11-06 11:53:55 +01001437static unsigned int ref92hd71bxx_pin_configs[10] = {
1438 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostayb22b4822008-01-22 12:32:30 +01001439 0x0181302e, 0x01114010, 0x01019020, 0x90a000f0,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001440 0x90a000f0, 0x01452050,
1441};
1442
Matthew Ranostayaafc4412008-06-13 18:04:33 +02001443static unsigned int dell_m4_1_pin_configs[10] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001444 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001445 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001446 0x40f000f0, 0x4f0000f0,
1447};
1448
Matthew Ranostayaafc4412008-06-13 18:04:33 +02001449static unsigned int dell_m4_2_pin_configs[10] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001450 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1451 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1452 0x40f000f0, 0x044413b0,
1453};
1454
Matthew Ranostaye035b842007-11-06 11:53:55 +01001455static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1456 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001457 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1458 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001459};
1460
1461static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1462 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001463 [STAC_DELL_M4_1] = "dell-m4-1",
1464 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001465};
1466
1467static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1468 /* SigmaTel reference board */
1469 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1470 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001471 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1472 "unknown Dell", STAC_DELL_M4_1),
1473 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1474 "unknown Dell", STAC_DELL_M4_1),
1475 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1476 "unknown Dell", STAC_DELL_M4_1),
1477 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1478 "unknown Dell", STAC_DELL_M4_1),
1479 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1480 "unknown Dell", STAC_DELL_M4_1),
1481 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1482 "unknown Dell", STAC_DELL_M4_1),
1483 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1484 "unknown Dell", STAC_DELL_M4_1),
1485 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1486 "unknown Dell", STAC_DELL_M4_2),
1487 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1488 "unknown Dell", STAC_DELL_M4_2),
1489 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1490 "unknown Dell", STAC_DELL_M4_2),
1491 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1492 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001493 {} /* terminator */
1494};
1495
Matt Porter403d1942005-11-29 15:00:51 +01001496static unsigned int ref922x_pin_configs[10] = {
1497 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1498 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001499 0x40000100, 0x40000100,
1500};
1501
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001502/*
1503 STAC 922X pin configs for
1504 102801A7
1505 102801AB
1506 102801A9
1507 102801D1
1508 102801D2
1509*/
1510static unsigned int dell_922x_d81_pin_configs[10] = {
1511 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1512 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1513 0x01813122, 0x400001f2,
1514};
1515
1516/*
1517 STAC 922X pin configs for
1518 102801AC
1519 102801D0
1520*/
1521static unsigned int dell_922x_d82_pin_configs[10] = {
1522 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1523 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1524 0x01813122, 0x400001f1,
1525};
1526
1527/*
1528 STAC 922X pin configs for
1529 102801BF
1530*/
1531static unsigned int dell_922x_m81_pin_configs[10] = {
1532 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1533 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1534 0x40C003f1, 0x405003f0,
1535};
1536
1537/*
1538 STAC 9221 A1 pin configs for
1539 102801D7 (Dell XPS M1210)
1540*/
1541static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001542 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1543 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001544 0x508003f3, 0x405003f4,
1545};
1546
Matt Porter403d1942005-11-29 15:00:51 +01001547static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001548 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001549 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1550 0x02a19120, 0x40000100,
1551};
1552
1553static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001554 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1555 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001556 0x02a19320, 0x40000100,
1557};
1558
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001559static unsigned int intel_mac_v1_pin_configs[10] = {
1560 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1561 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001562 0x400000fc, 0x400000fb,
1563};
1564
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001565static unsigned int intel_mac_v2_pin_configs[10] = {
1566 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1567 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001568 0x400000fc, 0x400000fb,
1569};
1570
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001571static unsigned int intel_mac_v3_pin_configs[10] = {
1572 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1573 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1574 0x400000fc, 0x400000fb,
1575};
1576
1577static unsigned int intel_mac_v4_pin_configs[10] = {
1578 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1579 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1580 0x400000fc, 0x400000fb,
1581};
1582
1583static unsigned int intel_mac_v5_pin_configs[10] = {
1584 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1585 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1586 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001587};
1588
Takashi Iwai76c08822007-06-19 12:17:42 +02001589
Takashi Iwai19039bd2006-06-28 15:52:16 +02001590static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001591 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001592 [STAC_D945GTP3] = d945gtp3_pin_configs,
1593 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001594 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1595 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1596 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1597 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1598 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001599 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001600 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001601 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1602 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1603 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1604 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1605 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1606 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001607 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1608 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1609 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1610 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001611};
1612
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001613static const char *stac922x_models[STAC_922X_MODELS] = {
1614 [STAC_D945_REF] = "ref",
1615 [STAC_D945GTP5] = "5stack",
1616 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001617 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1618 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1619 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1620 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1621 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001622 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001623 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001624 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001625 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001626 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1627 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001628 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001629 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001630 [STAC_922X_DELL_D81] = "dell-d81",
1631 [STAC_922X_DELL_D82] = "dell-d82",
1632 [STAC_922X_DELL_M81] = "dell-m81",
1633 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001634};
1635
1636static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1637 /* SigmaTel reference board */
1638 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1639 "DFI LanParty", STAC_D945_REF),
1640 /* Intel 945G based systems */
1641 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1642 "Intel D945G", STAC_D945GTP3),
1643 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1644 "Intel D945G", STAC_D945GTP3),
1645 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1646 "Intel D945G", STAC_D945GTP3),
1647 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1648 "Intel D945G", STAC_D945GTP3),
1649 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1650 "Intel D945G", STAC_D945GTP3),
1651 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1652 "Intel D945G", STAC_D945GTP3),
1653 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1654 "Intel D945G", STAC_D945GTP3),
1655 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1656 "Intel D945G", STAC_D945GTP3),
1657 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1658 "Intel D945G", STAC_D945GTP3),
1659 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1660 "Intel D945G", STAC_D945GTP3),
1661 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1662 "Intel D945G", STAC_D945GTP3),
1663 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1664 "Intel D945G", STAC_D945GTP3),
1665 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1666 "Intel D945G", STAC_D945GTP3),
1667 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1668 "Intel D945G", STAC_D945GTP3),
1669 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1670 "Intel D945G", STAC_D945GTP3),
1671 /* Intel D945G 5-stack systems */
1672 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1673 "Intel D945G", STAC_D945GTP5),
1674 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1675 "Intel D945G", STAC_D945GTP5),
1676 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1677 "Intel D945G", STAC_D945GTP5),
1678 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1679 "Intel D945G", STAC_D945GTP5),
1680 /* Intel 945P based systems */
1681 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1682 "Intel D945P", STAC_D945GTP3),
1683 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1684 "Intel D945P", STAC_D945GTP3),
1685 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1686 "Intel D945P", STAC_D945GTP3),
1687 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1688 "Intel D945P", STAC_D945GTP3),
1689 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1690 "Intel D945P", STAC_D945GTP3),
1691 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1692 "Intel D945P", STAC_D945GTP5),
1693 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08001694 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001695 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001696 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001697 /* Dell systems */
1698 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1699 "unknown Dell", STAC_922X_DELL_D81),
1700 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1701 "unknown Dell", STAC_922X_DELL_D81),
1702 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1703 "unknown Dell", STAC_922X_DELL_D81),
1704 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1705 "unknown Dell", STAC_922X_DELL_D82),
1706 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1707 "unknown Dell", STAC_922X_DELL_M81),
1708 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1709 "unknown Dell", STAC_922X_DELL_D82),
1710 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1711 "unknown Dell", STAC_922X_DELL_D81),
1712 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1713 "unknown Dell", STAC_922X_DELL_D81),
1714 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1715 "Dell XPS M1210", STAC_922X_DELL_M82),
Matt Porter403d1942005-11-29 15:00:51 +01001716 {} /* terminator */
1717};
1718
Matt Porter3cc08dc2006-01-23 15:27:49 +01001719static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02001720 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1721 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1722 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1723 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01001724};
1725
Tobin Davis93ed1502006-09-01 21:03:12 +02001726static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02001727 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1728 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1729 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1730 0x40000100, 0x40000100
1731};
1732
Tobin Davis93ed1502006-09-01 21:03:12 +02001733static unsigned int d965_5st_pin_configs[14] = {
1734 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1735 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1736 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1737 0x40000100, 0x40000100
1738};
1739
Tobin Davis4ff076e2007-08-07 11:48:12 +02001740static unsigned int dell_3st_pin_configs[14] = {
1741 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1742 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001743 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02001744 0x40c003fc, 0x40000100
1745};
1746
Tobin Davis93ed1502006-09-01 21:03:12 +02001747static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001748 [STAC_D965_REF] = ref927x_pin_configs,
1749 [STAC_D965_3ST] = d965_3st_pin_configs,
1750 [STAC_D965_5ST] = d965_5st_pin_configs,
1751 [STAC_DELL_3ST] = dell_3st_pin_configs,
1752 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01001753};
1754
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001755static const char *stac927x_models[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001756 [STAC_D965_REF] = "ref",
1757 [STAC_D965_3ST] = "3stack",
1758 [STAC_D965_5ST] = "5stack",
1759 [STAC_DELL_3ST] = "dell-3stack",
1760 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001761};
1762
1763static struct snd_pci_quirk stac927x_cfg_tbl[] = {
1764 /* SigmaTel reference board */
1765 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1766 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02001767 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001768 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
1769 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02001770 /* 965 based 3 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001771 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
1772 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
1773 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
1774 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
1775 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
1776 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
1777 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
1778 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
1779 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
1780 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
1781 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
1782 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
1783 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
1784 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
1785 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
1786 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02001787 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001788 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001789 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02001790 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
1791 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001792 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01001793 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
1794 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001795 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02001796 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001797 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
1798 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
1799 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
1800 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02001801 /* 965 based 5 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001802 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
1803 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
1804 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
1805 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
1806 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
1807 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
1808 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
1809 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
1810 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01001811 {} /* terminator */
1812};
1813
Matt Porterf3302a52006-07-31 12:49:34 +02001814static unsigned int ref9205_pin_configs[12] = {
1815 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001816 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02001817 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02001818};
1819
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001820/*
1821 STAC 9205 pin configs for
1822 102801F1
1823 102801F2
1824 102801FC
1825 102801FD
1826 10280204
1827 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01001828 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001829*/
1830static unsigned int dell_9205_m42_pin_configs[12] = {
1831 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
1832 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
1833 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
1834};
1835
1836/*
1837 STAC 9205 pin configs for
1838 102801F9
1839 102801FA
1840 102801FE
1841 102801FF (Dell Precision M4300)
1842 10280206
1843 10280200
1844 10280201
1845*/
1846static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001847 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
1848 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
1849 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
1850};
1851
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001852static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001853 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
1854 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
1855 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
1856};
1857
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001858static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001859 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001860 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
1861 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
1862 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Matt Porterf3302a52006-07-31 12:49:34 +02001863};
1864
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001865static const char *stac9205_models[STAC_9205_MODELS] = {
1866 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001867 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001868 [STAC_9205_DELL_M43] = "dell-m43",
1869 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001870};
1871
1872static struct snd_pci_quirk stac9205_cfg_tbl[] = {
1873 /* SigmaTel reference board */
1874 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1875 "DFI LanParty", STAC_9205_REF),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001876 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
1877 "unknown Dell", STAC_9205_DELL_M42),
1878 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
1879 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001880 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02001881 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001882 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
1883 "Dell Precision", STAC_9205_DELL_M43),
1884 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
1885 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001886 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
1887 "unknown Dell", STAC_9205_DELL_M42),
1888 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
1889 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001890 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
1891 "Dell Precision", STAC_9205_DELL_M43),
1892 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001893 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001894 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
1895 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02001896 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
1897 "Dell Precision", STAC_9205_DELL_M43),
1898 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
1899 "Dell Precision", STAC_9205_DELL_M43),
1900 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
1901 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001902 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
1903 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01001904 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
1905 "Dell Vostro 1500", STAC_9205_DELL_M42),
Matt Porterf3302a52006-07-31 12:49:34 +02001906 {} /* terminator */
1907};
1908
Richard Fish11b44bb2006-08-23 18:31:34 +02001909static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
1910{
1911 int i;
1912 struct sigmatel_spec *spec = codec->spec;
1913
1914 if (! spec->bios_pin_configs) {
1915 spec->bios_pin_configs = kcalloc(spec->num_pins,
1916 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
1917 if (! spec->bios_pin_configs)
1918 return -ENOMEM;
1919 }
1920
1921 for (i = 0; i < spec->num_pins; i++) {
1922 hda_nid_t nid = spec->pin_nids[i];
1923 unsigned int pin_cfg;
1924
1925 pin_cfg = snd_hda_codec_read(codec, nid, 0,
1926 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
1927 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
1928 nid, pin_cfg);
1929 spec->bios_pin_configs[i] = pin_cfg;
1930 }
1931
1932 return 0;
1933}
1934
Matthew Ranostay87d48362007-07-17 11:52:24 +02001935static void stac92xx_set_config_reg(struct hda_codec *codec,
1936 hda_nid_t pin_nid, unsigned int pin_config)
1937{
1938 int i;
1939 snd_hda_codec_write(codec, pin_nid, 0,
1940 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
1941 pin_config & 0x000000ff);
1942 snd_hda_codec_write(codec, pin_nid, 0,
1943 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
1944 (pin_config & 0x0000ff00) >> 8);
1945 snd_hda_codec_write(codec, pin_nid, 0,
1946 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
1947 (pin_config & 0x00ff0000) >> 16);
1948 snd_hda_codec_write(codec, pin_nid, 0,
1949 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
1950 pin_config >> 24);
1951 i = snd_hda_codec_read(codec, pin_nid, 0,
1952 AC_VERB_GET_CONFIG_DEFAULT,
1953 0x00);
1954 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
1955 pin_nid, i);
1956}
1957
Matt2f2f4252005-04-13 14:45:30 +02001958static void stac92xx_set_config_regs(struct hda_codec *codec)
1959{
1960 int i;
1961 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02001962
Matthew Ranostay87d48362007-07-17 11:52:24 +02001963 if (!spec->pin_configs)
1964 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02001965
Matthew Ranostay87d48362007-07-17 11:52:24 +02001966 for (i = 0; i < spec->num_pins; i++)
1967 stac92xx_set_config_reg(codec, spec->pin_nids[i],
1968 spec->pin_configs[i]);
Matt2f2f4252005-04-13 14:45:30 +02001969}
Matt2f2f4252005-04-13 14:45:30 +02001970
Matt2f2f4252005-04-13 14:45:30 +02001971/*
1972 * Analog playback callbacks
1973 */
1974static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
1975 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001976 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02001977{
1978 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01001979 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
1980 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02001981}
1982
1983static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1984 struct hda_codec *codec,
1985 unsigned int stream_tag,
1986 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001987 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02001988{
1989 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01001990 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02001991}
1992
1993static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1994 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001995 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02001996{
1997 struct sigmatel_spec *spec = codec->spec;
1998 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1999}
2000
2001/*
Mattdabbed62005-06-14 10:19:34 +02002002 * Digital playback callbacks
2003 */
2004static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2005 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002006 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002007{
2008 struct sigmatel_spec *spec = codec->spec;
2009 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2010}
2011
2012static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2013 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002014 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002015{
2016 struct sigmatel_spec *spec = codec->spec;
2017 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2018}
2019
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002020static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2021 struct hda_codec *codec,
2022 unsigned int stream_tag,
2023 unsigned int format,
2024 struct snd_pcm_substream *substream)
2025{
2026 struct sigmatel_spec *spec = codec->spec;
2027 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2028 stream_tag, format, substream);
2029}
2030
Mattdabbed62005-06-14 10:19:34 +02002031
2032/*
Matt2f2f4252005-04-13 14:45:30 +02002033 * Analog capture callbacks
2034 */
2035static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2036 struct hda_codec *codec,
2037 unsigned int stream_tag,
2038 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002039 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002040{
2041 struct sigmatel_spec *spec = codec->spec;
2042
2043 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2044 stream_tag, 0, format);
2045 return 0;
2046}
2047
2048static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2049 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002050 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002051{
2052 struct sigmatel_spec *spec = codec->spec;
2053
Takashi Iwai888afa12008-03-18 09:57:50 +01002054 snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
Matt2f2f4252005-04-13 14:45:30 +02002055 return 0;
2056}
2057
Mattdabbed62005-06-14 10:19:34 +02002058static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2059 .substreams = 1,
2060 .channels_min = 2,
2061 .channels_max = 2,
2062 /* NID is set in stac92xx_build_pcms */
2063 .ops = {
2064 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002065 .close = stac92xx_dig_playback_pcm_close,
2066 .prepare = stac92xx_dig_playback_pcm_prepare
Mattdabbed62005-06-14 10:19:34 +02002067 },
2068};
2069
2070static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2071 .substreams = 1,
2072 .channels_min = 2,
2073 .channels_max = 2,
2074 /* NID is set in stac92xx_build_pcms */
2075};
2076
Matt2f2f4252005-04-13 14:45:30 +02002077static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2078 .substreams = 1,
2079 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002080 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002081 .nid = 0x02, /* NID to query formats and rates */
2082 .ops = {
2083 .open = stac92xx_playback_pcm_open,
2084 .prepare = stac92xx_playback_pcm_prepare,
2085 .cleanup = stac92xx_playback_pcm_cleanup
2086 },
2087};
2088
Matt Porter3cc08dc2006-01-23 15:27:49 +01002089static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2090 .substreams = 1,
2091 .channels_min = 2,
2092 .channels_max = 2,
2093 .nid = 0x06, /* NID to query formats and rates */
2094 .ops = {
2095 .open = stac92xx_playback_pcm_open,
2096 .prepare = stac92xx_playback_pcm_prepare,
2097 .cleanup = stac92xx_playback_pcm_cleanup
2098 },
2099};
2100
Matt2f2f4252005-04-13 14:45:30 +02002101static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002102 .channels_min = 2,
2103 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002104 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002105 .ops = {
2106 .prepare = stac92xx_capture_pcm_prepare,
2107 .cleanup = stac92xx_capture_pcm_cleanup
2108 },
2109};
2110
2111static int stac92xx_build_pcms(struct hda_codec *codec)
2112{
2113 struct sigmatel_spec *spec = codec->spec;
2114 struct hda_pcm *info = spec->pcm_rec;
2115
2116 codec->num_pcms = 1;
2117 codec->pcm_info = info;
2118
Mattc7d4b2f2005-06-27 14:59:41 +02002119 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002120 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Matt2f2f4252005-04-13 14:45:30 +02002121 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002122 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002123 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002124
2125 if (spec->alt_switch) {
2126 codec->num_pcms++;
2127 info++;
2128 info->name = "STAC92xx Analog Alt";
2129 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2130 }
Matt2f2f4252005-04-13 14:45:30 +02002131
Mattdabbed62005-06-14 10:19:34 +02002132 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2133 codec->num_pcms++;
2134 info++;
2135 info->name = "STAC92xx Digital";
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002136 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Mattdabbed62005-06-14 10:19:34 +02002137 if (spec->multiout.dig_out_nid) {
2138 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2139 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2140 }
2141 if (spec->dig_in_nid) {
2142 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2143 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2144 }
2145 }
2146
Matt2f2f4252005-04-13 14:45:30 +02002147 return 0;
2148}
2149
Takashi Iwaic960a032006-03-23 17:06:28 +01002150static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2151{
2152 unsigned int pincap = snd_hda_param_read(codec, nid,
2153 AC_PAR_PIN_CAP);
2154 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2155 if (pincap & AC_PINCAP_VREF_100)
2156 return AC_PINCTL_VREF_100;
2157 if (pincap & AC_PINCAP_VREF_80)
2158 return AC_PINCTL_VREF_80;
2159 if (pincap & AC_PINCAP_VREF_50)
2160 return AC_PINCTL_VREF_50;
2161 if (pincap & AC_PINCAP_VREF_GRD)
2162 return AC_PINCTL_VREF_GRD;
2163 return 0;
2164}
2165
Matt Porter403d1942005-11-29 15:00:51 +01002166static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2167
2168{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002169 snd_hda_codec_write_cache(codec, nid, 0,
2170 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002171}
2172
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002173#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2174
2175static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2176 struct snd_ctl_elem_value *ucontrol)
2177{
2178 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2179 struct sigmatel_spec *spec = codec->spec;
2180
2181 ucontrol->value.integer.value[0] = spec->hp_switch;
2182 return 0;
2183}
2184
2185static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2186 struct snd_ctl_elem_value *ucontrol)
2187{
2188 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2189 struct sigmatel_spec *spec = codec->spec;
2190
2191 spec->hp_switch = ucontrol->value.integer.value[0];
2192
2193 /* check to be sure that the ports are upto date with
2194 * switch changes
2195 */
2196 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2197
2198 return 1;
2199}
2200
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002201#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002202
2203static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2204{
2205 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2206 struct sigmatel_spec *spec = codec->spec;
2207 int io_idx = kcontrol-> private_value & 0xff;
2208
2209 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2210 return 0;
2211}
2212
2213static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2214{
2215 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2216 struct sigmatel_spec *spec = codec->spec;
2217 hda_nid_t nid = kcontrol->private_value >> 8;
2218 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002219 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002220
2221 spec->io_switch[io_idx] = val;
2222
2223 if (val)
2224 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002225 else {
2226 unsigned int pinctl = AC_PINCTL_IN_EN;
2227 if (io_idx) /* set VREF for mic */
2228 pinctl |= stac92xx_get_vref(codec, nid);
2229 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2230 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002231
2232 /* check the auto-mute again: we need to mute/unmute the speaker
2233 * appropriately according to the pin direction
2234 */
2235 if (spec->hp_detect)
2236 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2237
Matt Porter403d1942005-11-29 15:00:51 +01002238 return 1;
2239}
2240
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002241#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2242
2243static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2244 struct snd_ctl_elem_value *ucontrol)
2245{
2246 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2247 struct sigmatel_spec *spec = codec->spec;
2248
2249 ucontrol->value.integer.value[0] = spec->clfe_swap;
2250 return 0;
2251}
2252
2253static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2254 struct snd_ctl_elem_value *ucontrol)
2255{
2256 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2257 struct sigmatel_spec *spec = codec->spec;
2258 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002259 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002260
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002261 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002262 return 0;
2263
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002264 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002265
2266 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2267 spec->clfe_swap ? 0x4 : 0x0);
2268
2269 return 1;
2270}
2271
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002272#define STAC_CODEC_HP_SWITCH(xname) \
2273 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2274 .name = xname, \
2275 .index = 0, \
2276 .info = stac92xx_hp_switch_info, \
2277 .get = stac92xx_hp_switch_get, \
2278 .put = stac92xx_hp_switch_put, \
2279 }
2280
Matt Porter403d1942005-11-29 15:00:51 +01002281#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2282 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2283 .name = xname, \
2284 .index = 0, \
2285 .info = stac92xx_io_switch_info, \
2286 .get = stac92xx_io_switch_get, \
2287 .put = stac92xx_io_switch_put, \
2288 .private_value = xpval, \
2289 }
2290
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002291#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2292 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2293 .name = xname, \
2294 .index = 0, \
2295 .info = stac92xx_clfe_switch_info, \
2296 .get = stac92xx_clfe_switch_get, \
2297 .put = stac92xx_clfe_switch_put, \
2298 .private_value = xpval, \
2299 }
Matt Porter403d1942005-11-29 15:00:51 +01002300
Mattc7d4b2f2005-06-27 14:59:41 +02002301enum {
2302 STAC_CTL_WIDGET_VOL,
2303 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002304 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002305 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002306 STAC_CTL_WIDGET_IO_SWITCH,
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002307 STAC_CTL_WIDGET_CLFE_SWITCH
Mattc7d4b2f2005-06-27 14:59:41 +02002308};
2309
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002310static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002311 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2312 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002313 STAC_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002314 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002315 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002316 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002317};
2318
2319/* add dynamic controls */
2320static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val)
2321{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002322 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002323
2324 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2325 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2326
2327 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2328 if (! knew)
2329 return -ENOMEM;
2330 if (spec->kctl_alloc) {
2331 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2332 kfree(spec->kctl_alloc);
2333 }
2334 spec->kctl_alloc = knew;
2335 spec->num_kctl_alloc = num;
2336 }
2337
2338 knew = &spec->kctl_alloc[spec->num_kctl_used];
2339 *knew = stac92xx_control_templates[type];
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002340 knew->name = kstrdup(name, GFP_KERNEL);
Mattc7d4b2f2005-06-27 14:59:41 +02002341 if (! knew->name)
2342 return -ENOMEM;
2343 knew->private_value = val;
2344 spec->num_kctl_used++;
2345 return 0;
2346}
2347
Matt Porter403d1942005-11-29 15:00:51 +01002348/* flag inputs as additional dynamic lineouts */
2349static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2350{
2351 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002352 unsigned int wcaps, wtype;
2353 int i, num_dacs = 0;
2354
2355 /* use the wcaps cache to count all DACs available for line-outs */
2356 for (i = 0; i < codec->num_nodes; i++) {
2357 wcaps = codec->wcaps[i];
2358 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002359
Steve Longerbeam7b043892007-05-03 20:50:03 +02002360 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2361 num_dacs++;
2362 }
Matt Porter403d1942005-11-29 15:00:51 +01002363
Steve Longerbeam7b043892007-05-03 20:50:03 +02002364 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2365
Matt Porter403d1942005-11-29 15:00:51 +01002366 switch (cfg->line_outs) {
2367 case 3:
2368 /* add line-in as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002369 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002370 cfg->line_out_pins[cfg->line_outs] =
2371 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002372 spec->line_switch = 1;
2373 cfg->line_outs++;
2374 }
2375 break;
2376 case 2:
2377 /* add line-in as clfe and mic as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002378 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002379 cfg->line_out_pins[cfg->line_outs] =
2380 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002381 spec->line_switch = 1;
2382 cfg->line_outs++;
2383 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002384 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002385 cfg->line_out_pins[cfg->line_outs] =
2386 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002387 spec->mic_switch = 1;
2388 cfg->line_outs++;
2389 }
2390 break;
2391 case 1:
2392 /* add line-in as surr and mic as clfe */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002393 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002394 cfg->line_out_pins[cfg->line_outs] =
2395 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002396 spec->line_switch = 1;
2397 cfg->line_outs++;
2398 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002399 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002400 cfg->line_out_pins[cfg->line_outs] =
2401 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002402 spec->mic_switch = 1;
2403 cfg->line_outs++;
2404 }
2405 break;
2406 }
2407
2408 return 0;
2409}
2410
Steve Longerbeam7b043892007-05-03 20:50:03 +02002411
2412static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2413{
2414 int i;
2415
2416 for (i = 0; i < spec->multiout.num_dacs; i++) {
2417 if (spec->multiout.dac_nids[i] == nid)
2418 return 1;
2419 }
2420
2421 return 0;
2422}
2423
Matt Porter3cc08dc2006-01-23 15:27:49 +01002424/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02002425 * Fill in the dac_nids table from the parsed pin configuration
2426 * This function only works when every pin in line_out_pins[]
2427 * contains atleast one DAC in its connection list. Some 92xx
2428 * codecs are not connected directly to a DAC, such as the 9200
2429 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002430 */
Takashi Iwai19039bd2006-06-28 15:52:16 +02002431static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaidf802952007-07-02 19:18:00 +02002432 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002433{
2434 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002435 int i, j, conn_len = 0;
2436 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2437 unsigned int wcaps, wtype;
2438
Mattc7d4b2f2005-06-27 14:59:41 +02002439 for (i = 0; i < cfg->line_outs; i++) {
2440 nid = cfg->line_out_pins[i];
Steve Longerbeam7b043892007-05-03 20:50:03 +02002441 conn_len = snd_hda_get_connections(codec, nid, conn,
2442 HDA_MAX_CONNECTIONS);
2443 for (j = 0; j < conn_len; j++) {
2444 wcaps = snd_hda_param_read(codec, conn[j],
2445 AC_PAR_AUDIO_WIDGET_CAP);
2446 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002447 if (wtype != AC_WID_AUD_OUT ||
2448 (wcaps & AC_WCAP_DIGITAL))
2449 continue;
2450 /* conn[j] is a DAC routed to this line-out */
2451 if (!is_in_dac_nids(spec, conn[j]))
2452 break;
2453 }
2454
2455 if (j == conn_len) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002456 if (spec->multiout.num_dacs > 0) {
2457 /* we have already working output pins,
2458 * so let's drop the broken ones again
2459 */
2460 cfg->line_outs = spec->multiout.num_dacs;
2461 break;
2462 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002463 /* error out, no available DAC found */
2464 snd_printk(KERN_ERR
2465 "%s: No available DAC for pin 0x%x\n",
2466 __func__, nid);
2467 return -ENODEV;
2468 }
2469
2470 spec->multiout.dac_nids[i] = conn[j];
2471 spec->multiout.num_dacs++;
2472 if (conn_len > 1) {
2473 /* select this DAC in the pin's input mux */
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002474 snd_hda_codec_write_cache(codec, nid, 0,
2475 AC_VERB_SET_CONNECT_SEL, j);
Steve Longerbeam7b043892007-05-03 20:50:03 +02002476
2477 }
Mattc7d4b2f2005-06-27 14:59:41 +02002478 }
2479
Steve Longerbeam7b043892007-05-03 20:50:03 +02002480 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2481 spec->multiout.num_dacs,
2482 spec->multiout.dac_nids[0],
2483 spec->multiout.dac_nids[1],
2484 spec->multiout.dac_nids[2],
2485 spec->multiout.dac_nids[3],
2486 spec->multiout.dac_nids[4]);
Mattc7d4b2f2005-06-27 14:59:41 +02002487 return 0;
2488}
2489
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002490/* create volume control/switch for the given prefx type */
2491static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2492{
2493 char name[32];
2494 int err;
2495
2496 sprintf(name, "%s Playback Volume", pfx);
2497 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2498 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2499 if (err < 0)
2500 return err;
2501 sprintf(name, "%s Playback Switch", pfx);
2502 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2503 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2504 if (err < 0)
2505 return err;
2506 return 0;
2507}
2508
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002509static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2510{
2511 if (!spec->multiout.hp_nid)
2512 spec->multiout.hp_nid = nid;
2513 else if (spec->multiout.num_dacs > 4) {
2514 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2515 return 1;
2516 } else {
2517 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2518 spec->multiout.num_dacs++;
2519 }
2520 return 0;
2521}
2522
2523static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2524{
2525 if (is_in_dac_nids(spec, nid))
2526 return 1;
2527 if (spec->multiout.hp_nid == nid)
2528 return 1;
2529 return 0;
2530}
2531
Mattc7d4b2f2005-06-27 14:59:41 +02002532/* add playback controls from the parsed DAC table */
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002533static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
Takashi Iwai19039bd2006-06-28 15:52:16 +02002534 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002535{
Takashi Iwai19039bd2006-06-28 15:52:16 +02002536 static const char *chname[4] = {
2537 "Front", "Surround", NULL /*CLFE*/, "Side"
2538 };
Mattc7d4b2f2005-06-27 14:59:41 +02002539 hda_nid_t nid;
2540 int i, err;
2541
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002542 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002543 unsigned int wid_caps, pincap;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002544
2545
Takashi Iwai40ac8c42008-02-29 14:16:17 +01002546 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
Matt Porter403d1942005-11-29 15:00:51 +01002547 if (!spec->multiout.dac_nids[i])
Mattc7d4b2f2005-06-27 14:59:41 +02002548 continue;
2549
2550 nid = spec->multiout.dac_nids[i];
2551
2552 if (i == 2) {
2553 /* Center/LFE */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002554 err = create_controls(spec, "Center", nid, 1);
2555 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002556 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002557 err = create_controls(spec, "LFE", nid, 2);
2558 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002559 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002560
2561 wid_caps = get_wcaps(codec, nid);
2562
2563 if (wid_caps & AC_WCAP_LR_SWAP) {
2564 err = stac92xx_add_control(spec,
2565 STAC_CTL_WIDGET_CLFE_SWITCH,
2566 "Swap Center/LFE Playback Switch", nid);
2567
2568 if (err < 0)
2569 return err;
2570 }
2571
Mattc7d4b2f2005-06-27 14:59:41 +02002572 } else {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002573 err = create_controls(spec, chname[i], nid, 3);
2574 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002575 return err;
2576 }
2577 }
2578
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002579 if (cfg->hp_outs > 1) {
2580 err = stac92xx_add_control(spec,
2581 STAC_CTL_WIDGET_HP_SWITCH,
2582 "Headphone as Line Out Switch", 0);
2583 if (err < 0)
2584 return err;
2585 }
2586
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002587 if (spec->line_switch) {
2588 nid = cfg->input_pins[AUTO_PIN_LINE];
2589 pincap = snd_hda_param_read(codec, nid,
2590 AC_PAR_PIN_CAP);
2591 if (pincap & AC_PINCAP_OUT) {
2592 err = stac92xx_add_control(spec,
2593 STAC_CTL_WIDGET_IO_SWITCH,
2594 "Line In as Output Switch", nid << 8);
2595 if (err < 0)
2596 return err;
2597 }
2598 }
Matt Porter403d1942005-11-29 15:00:51 +01002599
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002600 if (spec->mic_switch) {
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002601 unsigned int def_conf;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002602 unsigned int mic_pin = AUTO_PIN_MIC;
2603again:
2604 nid = cfg->input_pins[mic_pin];
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002605 def_conf = snd_hda_codec_read(codec, nid, 0,
2606 AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002607 /* some laptops have an internal analog microphone
2608 * which can't be used as a output */
2609 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2610 pincap = snd_hda_param_read(codec, nid,
2611 AC_PAR_PIN_CAP);
2612 if (pincap & AC_PINCAP_OUT) {
2613 err = stac92xx_add_control(spec,
2614 STAC_CTL_WIDGET_IO_SWITCH,
2615 "Mic as Output Switch", (nid << 8) | 1);
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002616 nid = snd_hda_codec_read(codec, nid, 0,
2617 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2618 if (!check_in_dac_nids(spec, nid))
2619 add_spec_dacs(spec, nid);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002620 if (err < 0)
2621 return err;
2622 }
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002623 } else if (mic_pin == AUTO_PIN_MIC) {
2624 mic_pin = AUTO_PIN_FRONT_MIC;
2625 goto again;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002626 }
2627 }
Matt Porter403d1942005-11-29 15:00:51 +01002628
Mattc7d4b2f2005-06-27 14:59:41 +02002629 return 0;
2630}
2631
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002632/* add playback controls for Speaker and HP outputs */
2633static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2634 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002635{
2636 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02002637 hda_nid_t nid;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002638 int i, old_num_dacs, err;
Mattc7d4b2f2005-06-27 14:59:41 +02002639
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002640 old_num_dacs = spec->multiout.num_dacs;
2641 for (i = 0; i < cfg->hp_outs; i++) {
2642 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2643 if (wid_caps & AC_WCAP_UNSOL_CAP)
2644 spec->hp_detect = 1;
2645 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2646 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2647 if (check_in_dac_nids(spec, nid))
2648 nid = 0;
2649 if (! nid)
Mattc7d4b2f2005-06-27 14:59:41 +02002650 continue;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002651 add_spec_dacs(spec, nid);
2652 }
2653 for (i = 0; i < cfg->speaker_outs; i++) {
Steve Longerbeam7b043892007-05-03 20:50:03 +02002654 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002655 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2656 if (check_in_dac_nids(spec, nid))
2657 nid = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002658 if (! nid)
2659 continue;
2660 add_spec_dacs(spec, nid);
Mattc7d4b2f2005-06-27 14:59:41 +02002661 }
Matthew Ranostay1b290a52007-07-12 15:17:34 +02002662 for (i = 0; i < cfg->line_outs; i++) {
2663 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2664 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2665 if (check_in_dac_nids(spec, nid))
2666 nid = 0;
2667 if (! nid)
2668 continue;
2669 add_spec_dacs(spec, nid);
2670 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002671 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2672 static const char *pfxs[] = {
2673 "Speaker", "External Speaker", "Speaker2",
2674 };
2675 err = create_controls(spec, pfxs[i - old_num_dacs],
2676 spec->multiout.dac_nids[i], 3);
2677 if (err < 0)
2678 return err;
2679 }
2680 if (spec->multiout.hp_nid) {
Takashi Iwai2626a262008-03-14 09:18:32 +01002681 err = create_controls(spec, "Headphone",
2682 spec->multiout.hp_nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002683 if (err < 0)
2684 return err;
2685 }
Mattc7d4b2f2005-06-27 14:59:41 +02002686
2687 return 0;
2688}
2689
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002690/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002691static const char *stac92xx_mono_labels[4] = {
2692 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002693};
2694
2695/* create mono mux for mono out on capable codecs */
2696static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
2697{
2698 struct sigmatel_spec *spec = codec->spec;
2699 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
2700 int i, num_cons;
2701 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
2702
2703 num_cons = snd_hda_get_connections(codec,
2704 spec->mono_nid,
2705 con_lst,
2706 HDA_MAX_NUM_INPUTS);
2707 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
2708 return -EINVAL;
2709
2710 for (i = 0; i < num_cons; i++) {
2711 mono_mux->items[mono_mux->num_items].label =
2712 stac92xx_mono_labels[i];
2713 mono_mux->items[mono_mux->num_items].index = i;
2714 mono_mux->num_items++;
2715 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01002716
2717 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
2718 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002719}
2720
Matthew Ranostay1cd22242008-07-18 18:20:52 +02002721/* create PC beep volume controls */
2722static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
2723 hda_nid_t nid)
2724{
2725 struct sigmatel_spec *spec = codec->spec;
2726 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
2727 int err;
2728
2729 /* check for mute support for the the amp */
2730 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
2731 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
2732 "PC Beep Playback Switch",
2733 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
2734 if (err < 0)
2735 return err;
2736 }
2737
2738 /* check to see if there is volume support for the amp */
2739 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
2740 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
2741 "PC Beep Playback Volume",
2742 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
2743 if (err < 0)
2744 return err;
2745 }
2746 return 0;
2747}
2748
Matt Porter8b657272006-10-26 17:12:59 +02002749/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01002750static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02002751 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
2752 "Digital Mic 3", "Digital Mic 4"
2753};
2754
2755/* create playback/capture controls for input pins on dmic capable codecs */
2756static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
2757 const struct auto_pin_cfg *cfg)
2758{
2759 struct sigmatel_spec *spec = codec->spec;
2760 struct hda_input_mux *dimux = &spec->private_dimux;
2761 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002762 int err, i, j;
2763 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02002764
2765 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
2766 dimux->items[dimux->num_items].index = 0;
2767 dimux->num_items++;
2768
2769 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002770 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02002771 int index;
2772 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002773 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02002774 unsigned int def_conf;
2775
2776 def_conf = snd_hda_codec_read(codec,
2777 spec->dmic_nids[i],
2778 0,
2779 AC_VERB_GET_CONFIG_DEFAULT,
2780 0);
2781 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
2782 continue;
2783
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002784 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02002785 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01002786 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02002787 con_lst,
2788 HDA_MAX_NUM_INPUTS);
2789 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002790 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02002791 index = j;
2792 goto found;
2793 }
2794 continue;
2795found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002796 wcaps = get_wcaps(codec, nid) &
2797 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002798
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002799 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002800 sprintf(name, "%s Capture Volume",
2801 stac92xx_dmic_labels[dimux->num_items]);
2802
2803 err = stac92xx_add_control(spec,
2804 STAC_CTL_WIDGET_VOL,
2805 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002806 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
2807 (wcaps & AC_WCAP_OUT_AMP) ?
2808 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002809 if (err < 0)
2810 return err;
2811 }
2812
Matt Porter8b657272006-10-26 17:12:59 +02002813 dimux->items[dimux->num_items].label =
2814 stac92xx_dmic_labels[dimux->num_items];
2815 dimux->items[dimux->num_items].index = index;
2816 dimux->num_items++;
2817 }
2818
2819 return 0;
2820}
2821
Mattc7d4b2f2005-06-27 14:59:41 +02002822/* create playback/capture controls for input pins */
2823static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
2824{
2825 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02002826 struct hda_input_mux *imux = &spec->private_imux;
2827 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
2828 int i, j, k;
2829
2830 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02002831 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02002832
Takashi Iwai314634b2006-09-21 11:56:18 +02002833 if (!cfg->input_pins[i])
2834 continue;
2835 index = -1;
2836 for (j = 0; j < spec->num_muxes; j++) {
2837 int num_cons;
2838 num_cons = snd_hda_get_connections(codec,
2839 spec->mux_nids[j],
2840 con_lst,
2841 HDA_MAX_NUM_INPUTS);
2842 for (k = 0; k < num_cons; k++)
2843 if (con_lst[k] == cfg->input_pins[i]) {
2844 index = k;
2845 goto found;
2846 }
Mattc7d4b2f2005-06-27 14:59:41 +02002847 }
Takashi Iwai314634b2006-09-21 11:56:18 +02002848 continue;
2849 found:
2850 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2851 imux->items[imux->num_items].index = index;
2852 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02002853 }
2854
Steve Longerbeam7b043892007-05-03 20:50:03 +02002855 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02002856 /*
2857 * Set the current input for the muxes.
2858 * The STAC9221 has two input muxes with identical source
2859 * NID lists. Hopefully this won't get confused.
2860 */
2861 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002862 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
2863 AC_VERB_SET_CONNECT_SEL,
2864 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02002865 }
2866 }
2867
Mattc7d4b2f2005-06-27 14:59:41 +02002868 return 0;
2869}
2870
Mattc7d4b2f2005-06-27 14:59:41 +02002871static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
2872{
2873 struct sigmatel_spec *spec = codec->spec;
2874 int i;
2875
2876 for (i = 0; i < spec->autocfg.line_outs; i++) {
2877 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2878 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2879 }
2880}
2881
2882static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
2883{
2884 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002885 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02002886
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002887 for (i = 0; i < spec->autocfg.hp_outs; i++) {
2888 hda_nid_t pin;
2889 pin = spec->autocfg.hp_pins[i];
2890 if (pin) /* connect to front */
2891 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
2892 }
2893 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
2894 hda_nid_t pin;
2895 pin = spec->autocfg.speaker_pins[i];
2896 if (pin) /* connect to front */
2897 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
2898 }
Mattc7d4b2f2005-06-27 14:59:41 +02002899}
2900
Matt Porter3cc08dc2006-01-23 15:27:49 +01002901static 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 +02002902{
2903 struct sigmatel_spec *spec = codec->spec;
2904 int err;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01002905 int hp_speaker_swap = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02002906
Matt Porter8b657272006-10-26 17:12:59 +02002907 if ((err = snd_hda_parse_pin_def_config(codec,
2908 &spec->autocfg,
2909 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002910 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01002911 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01002912 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02002913
Jiang Zhebcecd9b2007-11-12 12:57:03 +01002914 /* If we have no real line-out pin and multiple hp-outs, HPs should
2915 * be set up as multi-channel outputs.
2916 */
2917 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
2918 spec->autocfg.hp_outs > 1) {
2919 /* Copy hp_outs to line_outs, backup line_outs in
2920 * speaker_outs so that the following routines can handle
2921 * HP pins as primary outputs.
2922 */
2923 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
2924 sizeof(spec->autocfg.line_out_pins));
2925 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
2926 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
2927 sizeof(spec->autocfg.hp_pins));
2928 spec->autocfg.line_outs = spec->autocfg.hp_outs;
2929 hp_speaker_swap = 1;
2930 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01002931 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002932 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
2933 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01002934 u32 caps = query_amp_caps(codec,
2935 spec->autocfg.mono_out_pin, dir);
2936 hda_nid_t conn_list[1];
2937
2938 /* get the mixer node and then the mono mux if it exists */
2939 if (snd_hda_get_connections(codec,
2940 spec->autocfg.mono_out_pin, conn_list, 1) &&
2941 snd_hda_get_connections(codec, conn_list[0],
2942 conn_list, 1)) {
2943
2944 int wcaps = get_wcaps(codec, conn_list[0]);
2945 int wid_type = (wcaps & AC_WCAP_TYPE)
2946 >> AC_WCAP_TYPE_SHIFT;
2947 /* LR swap check, some stac925x have a mux that
2948 * changes the DACs output path instead of the
2949 * mono-mux path.
2950 */
2951 if (wid_type == AC_WID_AUD_SEL &&
2952 !(wcaps & AC_WCAP_LR_SWAP))
2953 spec->mono_nid = conn_list[0];
2954 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002955 if (dir) {
2956 hda_nid_t nid = spec->autocfg.mono_out_pin;
2957
2958 /* most mono outs have a least a mute/unmute switch */
2959 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
2960 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
2961 "Mono Playback Switch",
2962 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01002963 if (err < 0)
2964 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002965 /* check for volume support for the amp */
2966 if ((caps & AC_AMPCAP_NUM_STEPS)
2967 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
2968 err = stac92xx_add_control(spec,
2969 STAC_CTL_WIDGET_VOL,
2970 "Mono Playback Volume",
2971 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
2972 if (err < 0)
2973 return err;
2974 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01002975 }
2976
2977 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
2978 AC_PINCTL_OUT_EN);
2979 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01002980
Matt Porter403d1942005-11-29 15:00:51 +01002981 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
2982 return err;
Takashi Iwai19039bd2006-06-28 15:52:16 +02002983 if (spec->multiout.num_dacs == 0)
2984 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
2985 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02002986
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002987 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
2988
2989 if (err < 0)
2990 return err;
2991
Matthew Ranostay1cd22242008-07-18 18:20:52 +02002992 /* setup analog beep controls */
2993 if (spec->anabeep_nid > 0) {
2994 err = stac92xx_auto_create_beep_ctls(codec,
2995 spec->anabeep_nid);
2996 if (err < 0)
2997 return err;
2998 }
2999
3000 /* setup digital beep controls and input device */
3001#ifdef CONFIG_SND_HDA_INPUT_BEEP
3002 if (spec->digbeep_nid > 0) {
3003 hda_nid_t nid = spec->digbeep_nid;
3004
3005 err = stac92xx_auto_create_beep_ctls(codec, nid);
3006 if (err < 0)
3007 return err;
3008 err = snd_hda_attach_beep_device(codec, nid);
3009 if (err < 0)
3010 return err;
3011 }
3012#endif
3013
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003014 if (hp_speaker_swap == 1) {
3015 /* Restore the hp_outs and line_outs */
3016 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3017 sizeof(spec->autocfg.line_out_pins));
3018 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3019 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
3020 sizeof(spec->autocfg.speaker_pins));
3021 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
3022 memset(spec->autocfg.speaker_pins, 0,
3023 sizeof(spec->autocfg.speaker_pins));
3024 spec->autocfg.speaker_outs = 0;
3025 }
3026
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003027 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3028
3029 if (err < 0)
3030 return err;
3031
3032 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3033
3034 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003035 return err;
3036
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003037 if (spec->mono_nid > 0) {
3038 err = stac92xx_auto_create_mono_output_ctls(codec);
3039 if (err < 0)
3040 return err;
3041 }
3042
Matt Porter8b657272006-10-26 17:12:59 +02003043 if (spec->num_dmics > 0)
3044 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3045 &spec->autocfg)) < 0)
3046 return err;
3047
Mattc7d4b2f2005-06-27 14:59:41 +02003048 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003049 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003050 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003051
Takashi Iwai82bc9552006-03-21 11:24:42 +01003052 if (spec->autocfg.dig_out_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003053 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003054 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003055 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003056
3057 if (spec->kctl_alloc)
3058 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3059
3060 spec->input_mux = &spec->private_imux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003061 if (!spec->dinput_mux)
3062 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003063 spec->mono_mux = &spec->private_mono_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003064
3065 return 1;
3066}
3067
Takashi Iwai82bc9552006-03-21 11:24:42 +01003068/* add playback controls for HP output */
3069static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3070 struct auto_pin_cfg *cfg)
3071{
3072 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003073 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003074 unsigned int wid_caps;
3075
3076 if (! pin)
3077 return 0;
3078
3079 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003080 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003081 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003082
3083 return 0;
3084}
3085
Richard Fish160ea0d2006-09-06 13:58:25 +02003086/* add playback controls for LFE output */
3087static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3088 struct auto_pin_cfg *cfg)
3089{
3090 struct sigmatel_spec *spec = codec->spec;
3091 int err;
3092 hda_nid_t lfe_pin = 0x0;
3093 int i;
3094
3095 /*
3096 * search speaker outs and line outs for a mono speaker pin
3097 * with an amp. If one is found, add LFE controls
3098 * for it.
3099 */
3100 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3101 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003102 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003103 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3104 if (wcaps == AC_WCAP_OUT_AMP)
3105 /* found a mono speaker with an amp, must be lfe */
3106 lfe_pin = pin;
3107 }
3108
3109 /* if speaker_outs is 0, then speakers may be in line_outs */
3110 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3111 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3112 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003113 unsigned int defcfg;
Harvey Harrison8b551782008-02-29 11:56:48 +01003114 defcfg = snd_hda_codec_read(codec, pin, 0,
Richard Fish160ea0d2006-09-06 13:58:25 +02003115 AC_VERB_GET_CONFIG_DEFAULT,
3116 0x00);
Harvey Harrison8b551782008-02-29 11:56:48 +01003117 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003118 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003119 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3120 if (wcaps == AC_WCAP_OUT_AMP)
3121 /* found a mono speaker with an amp,
3122 must be lfe */
3123 lfe_pin = pin;
3124 }
3125 }
3126 }
3127
3128 if (lfe_pin) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003129 err = create_controls(spec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003130 if (err < 0)
3131 return err;
3132 }
3133
3134 return 0;
3135}
3136
Mattc7d4b2f2005-06-27 14:59:41 +02003137static int stac9200_parse_auto_config(struct hda_codec *codec)
3138{
3139 struct sigmatel_spec *spec = codec->spec;
3140 int err;
3141
Kailang Yangdf694da2005-12-05 19:42:22 +01003142 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003143 return err;
3144
3145 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3146 return err;
3147
Takashi Iwai82bc9552006-03-21 11:24:42 +01003148 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3149 return err;
3150
Richard Fish160ea0d2006-09-06 13:58:25 +02003151 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3152 return err;
3153
Takashi Iwai82bc9552006-03-21 11:24:42 +01003154 if (spec->autocfg.dig_out_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003155 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003156 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003157 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003158
3159 if (spec->kctl_alloc)
3160 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3161
3162 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003163 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003164
3165 return 1;
3166}
3167
Sam Revitch62fe78e2006-05-10 15:09:17 +02003168/*
3169 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3170 * funky external mute control using GPIO pins.
3171 */
3172
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003173static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003174 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003175{
3176 unsigned int gpiostate, gpiomask, gpiodir;
3177
3178 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3179 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003180 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003181
3182 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3183 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003184 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003185
3186 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3187 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003188 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003189
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003190 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003191 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3192
3193 snd_hda_codec_write(codec, codec->afg, 0,
3194 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003195 snd_hda_codec_read(codec, codec->afg, 0,
3196 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003197
3198 msleep(1);
3199
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003200 snd_hda_codec_read(codec, codec->afg, 0,
3201 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003202}
3203
Takashi Iwai314634b2006-09-21 11:56:18 +02003204static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3205 unsigned int event)
3206{
3207 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003208 snd_hda_codec_write_cache(codec, nid, 0,
3209 AC_VERB_SET_UNSOLICITED_ENABLE,
3210 (AC_USRSP_EN | event));
Takashi Iwai314634b2006-09-21 11:56:18 +02003211}
3212
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003213static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3214{
3215 int i;
3216 for (i = 0; i < cfg->hp_outs; i++)
3217 if (cfg->hp_pins[i] == nid)
3218 return 1; /* nid is a HP-Out */
3219
3220 return 0; /* nid is not a HP-Out */
3221};
3222
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003223static void stac92xx_power_down(struct hda_codec *codec)
3224{
3225 struct sigmatel_spec *spec = codec->spec;
3226
3227 /* power down inactive DACs */
3228 hda_nid_t *dac;
3229 for (dac = spec->dac_list; *dac; dac++)
Matthew Ranostay44510892008-02-21 07:49:31 +01003230 if (!is_in_dac_nids(spec, *dac) &&
3231 spec->multiout.hp_nid != *dac)
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003232 snd_hda_codec_write_cache(codec, *dac, 0,
3233 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3234}
3235
Mattc7d4b2f2005-06-27 14:59:41 +02003236static int stac92xx_init(struct hda_codec *codec)
3237{
3238 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003239 struct auto_pin_cfg *cfg = &spec->autocfg;
3240 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003241
Mattc7d4b2f2005-06-27 14:59:41 +02003242 snd_hda_sequence_write(codec, spec->init);
3243
Takashi Iwai82bc9552006-03-21 11:24:42 +01003244 /* set up pins */
3245 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02003246 /* Enable unsolicited responses on the HP widget */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003247 for (i = 0; i < cfg->hp_outs; i++)
Takashi Iwai314634b2006-09-21 11:56:18 +02003248 enable_pin_detect(codec, cfg->hp_pins[i],
3249 STAC_HP_EVENT);
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01003250 /* force to enable the first line-out; the others are set up
3251 * in unsol_event
3252 */
3253 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3254 AC_PINCTL_OUT_EN);
Takashi Iwaieb995a82006-09-21 14:28:21 +02003255 stac92xx_auto_init_hp_out(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003256 /* fake event to set up pins */
3257 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3258 } else {
3259 stac92xx_auto_init_multi_out(codec);
3260 stac92xx_auto_init_hp_out(codec);
3261 }
3262 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01003263 hda_nid_t nid = cfg->input_pins[i];
3264 if (nid) {
3265 unsigned int pinctl = AC_PINCTL_IN_EN;
3266 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
3267 pinctl |= stac92xx_get_vref(codec, nid);
3268 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3269 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01003270 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003271 for (i = 0; i < spec->num_dmics; i++)
3272 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3273 AC_PINCTL_IN_EN);
3274 for (i = 0; i < spec->num_pwrs; i++) {
3275 int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
3276 ? STAC_HP_EVENT : STAC_PWR_EVENT;
3277 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
3278 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003279 int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
3280 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003281 def_conf = get_defcfg_connect(def_conf);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003282 /* outputs are only ports capable of power management
3283 * any attempts on powering down a input port cause the
3284 * referenced VREF to act quirky.
3285 */
3286 if (pinctl & AC_PINCTL_IN_EN)
3287 continue;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003288 /* skip any ports that don't have jacks since presence
3289 * detection is useless */
3290 if (def_conf && def_conf != AC_JACK_PORT_FIXED)
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003291 continue;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003292 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3293 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3294 }
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003295 if (spec->dac_list)
3296 stac92xx_power_down(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003297 if (cfg->dig_out_pin)
3298 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3299 AC_PINCTL_OUT_EN);
3300 if (cfg->dig_in_pin)
3301 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3302 AC_PINCTL_IN_EN);
3303
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003304 stac_gpio_set(codec, spec->gpio_mask,
3305 spec->gpio_dir, spec->gpio_data);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003306
Mattc7d4b2f2005-06-27 14:59:41 +02003307 return 0;
3308}
3309
Matt2f2f4252005-04-13 14:45:30 +02003310static void stac92xx_free(struct hda_codec *codec)
3311{
Mattc7d4b2f2005-06-27 14:59:41 +02003312 struct sigmatel_spec *spec = codec->spec;
3313 int i;
3314
3315 if (! spec)
3316 return;
3317
3318 if (spec->kctl_alloc) {
3319 for (i = 0; i < spec->num_kctl_used; i++)
3320 kfree(spec->kctl_alloc[i].name);
3321 kfree(spec->kctl_alloc);
3322 }
3323
Richard Fish11b44bb2006-08-23 18:31:34 +02003324 if (spec->bios_pin_configs)
3325 kfree(spec->bios_pin_configs);
3326
Mattc7d4b2f2005-06-27 14:59:41 +02003327 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003328 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02003329}
3330
Matt4e550962005-07-04 17:51:39 +02003331static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3332 unsigned int flag)
3333{
3334 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3335 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02003336
Takashi Iwaif9acba42007-05-29 18:01:06 +02003337 if (pin_ctl & AC_PINCTL_IN_EN) {
3338 /*
3339 * we need to check the current set-up direction of
3340 * shared input pins since they can be switched via
3341 * "xxx as Output" mixer switch
3342 */
3343 struct sigmatel_spec *spec = codec->spec;
3344 struct auto_pin_cfg *cfg = &spec->autocfg;
3345 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3346 spec->line_switch) ||
3347 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3348 spec->mic_switch))
3349 return;
3350 }
3351
Steve Longerbeam7b043892007-05-03 20:50:03 +02003352 /* if setting pin direction bits, clear the current
3353 direction bits first */
3354 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3355 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3356
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003357 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003358 AC_VERB_SET_PIN_WIDGET_CONTROL,
3359 pin_ctl | flag);
3360}
3361
3362static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3363 unsigned int flag)
3364{
3365 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3366 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003367 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003368 AC_VERB_SET_PIN_WIDGET_CONTROL,
3369 pin_ctl & ~flag);
3370}
3371
Jiang Zhe40c1d302007-11-12 13:05:16 +01003372static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02003373{
3374 if (!nid)
3375 return 0;
3376 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Jiang Zhe40c1d302007-11-12 13:05:16 +01003377 & (1 << 31)) {
3378 unsigned int pinctl;
3379 pinctl = snd_hda_codec_read(codec, nid, 0,
3380 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3381 if (pinctl & AC_PINCTL_IN_EN)
3382 return 0; /* mic- or line-input */
3383 else
3384 return 1; /* HP-output */
3385 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003386 return 0;
3387}
3388
3389static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
Matt4e550962005-07-04 17:51:39 +02003390{
3391 struct sigmatel_spec *spec = codec->spec;
3392 struct auto_pin_cfg *cfg = &spec->autocfg;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003393 int nid = cfg->hp_pins[cfg->hp_outs - 1];
Matt4e550962005-07-04 17:51:39 +02003394 int i, presence;
3395
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003396 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003397 if (spec->gpio_mute)
3398 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3399 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3400
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003401 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003402 if (presence)
3403 break;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003404 if (spec->hp_switch && cfg->hp_pins[i] == nid)
3405 break;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003406 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003407 }
Matt4e550962005-07-04 17:51:39 +02003408
3409 if (presence) {
3410 /* disable lineouts, enable hp */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003411 if (spec->hp_switch)
3412 stac92xx_reset_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003413 for (i = 0; i < cfg->line_outs; i++)
3414 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3415 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003416 for (i = 0; i < cfg->speaker_outs; i++)
3417 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3418 AC_PINCTL_OUT_EN);
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003419 if (spec->eapd_mask)
3420 stac_gpio_set(codec, spec->gpio_mask,
3421 spec->gpio_dir, spec->gpio_data &
3422 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003423 } else {
3424 /* enable lineouts, disable hp */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003425 if (spec->hp_switch)
3426 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003427 for (i = 0; i < cfg->line_outs; i++)
3428 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3429 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003430 for (i = 0; i < cfg->speaker_outs; i++)
3431 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3432 AC_PINCTL_OUT_EN);
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003433 if (spec->eapd_mask)
3434 stac_gpio_set(codec, spec->gpio_mask,
3435 spec->gpio_dir, spec->gpio_data |
3436 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003437 }
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003438 if (!spec->hp_switch && cfg->hp_outs > 1 && presence)
3439 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003440}
3441
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003442static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
3443{
3444 struct sigmatel_spec *spec = codec->spec;
3445 hda_nid_t nid = spec->pwr_nids[idx];
3446 int presence, val;
3447 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
3448 & 0x000000ff;
3449 presence = get_hp_pin_presence(codec, nid);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003450
3451 /* several codecs have two power down bits */
3452 if (spec->pwr_mapping)
3453 idx = spec->pwr_mapping[idx];
3454 else
3455 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003456
3457 if (presence)
3458 val &= ~idx;
3459 else
3460 val |= idx;
3461
3462 /* power down unused output ports */
3463 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
3464};
3465
Takashi Iwai314634b2006-09-21 11:56:18 +02003466static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
3467{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003468 struct sigmatel_spec *spec = codec->spec;
3469 int idx = res >> 26 & 0x0f;
3470
3471 switch ((res >> 26) & 0x30) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003472 case STAC_HP_EVENT:
3473 stac92xx_hp_detect(codec, res);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003474 /* fallthru */
3475 case STAC_PWR_EVENT:
3476 if (spec->num_pwrs > 0)
3477 stac92xx_pin_sense(codec, idx);
Takashi Iwai314634b2006-09-21 11:56:18 +02003478 }
3479}
3480
Takashi Iwaicb53c622007-08-10 17:21:45 +02003481#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02003482static int stac92xx_resume(struct hda_codec *codec)
3483{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003484 struct sigmatel_spec *spec = codec->spec;
3485
Richard Fish11b44bb2006-08-23 18:31:34 +02003486 stac92xx_set_config_regs(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003487 snd_hda_sequence_write(codec, spec->init);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003488 stac_gpio_set(codec, spec->gpio_mask,
3489 spec->gpio_dir, spec->gpio_data);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003490 snd_hda_codec_resume_amp(codec);
3491 snd_hda_codec_resume_cache(codec);
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003492 /* power down inactive DACs */
3493 if (spec->dac_list)
3494 stac92xx_power_down(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003495 /* invoke unsolicited event to reset the HP state */
3496 if (spec->hp_detect)
3497 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
Mattff6fdc32005-06-27 15:06:52 +02003498 return 0;
3499}
3500#endif
3501
Matt2f2f4252005-04-13 14:45:30 +02003502static struct hda_codec_ops stac92xx_patch_ops = {
3503 .build_controls = stac92xx_build_controls,
3504 .build_pcms = stac92xx_build_pcms,
3505 .init = stac92xx_init,
3506 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02003507 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003508#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02003509 .resume = stac92xx_resume,
3510#endif
Matt2f2f4252005-04-13 14:45:30 +02003511};
3512
3513static int patch_stac9200(struct hda_codec *codec)
3514{
3515 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003516 int err;
Matt2f2f4252005-04-13 14:45:30 +02003517
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003518 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02003519 if (spec == NULL)
3520 return -ENOMEM;
3521
3522 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003523 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02003524 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003525 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
3526 stac9200_models,
3527 stac9200_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02003528 if (spec->board_config < 0) {
3529 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
3530 err = stac92xx_save_bios_config_regs(codec);
3531 if (err < 0) {
3532 stac92xx_free(codec);
3533 return err;
3534 }
3535 spec->pin_configs = spec->bios_pin_configs;
3536 } else {
Matt Porter403d1942005-11-29 15:00:51 +01003537 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
3538 stac92xx_set_config_regs(codec);
3539 }
Matt2f2f4252005-04-13 14:45:30 +02003540
3541 spec->multiout.max_channels = 2;
3542 spec->multiout.num_dacs = 1;
3543 spec->multiout.dac_nids = stac9200_dac_nids;
3544 spec->adc_nids = stac9200_adc_nids;
3545 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02003546 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02003547 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003548 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003549 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003550
Tobin Davisbf277782008-02-03 20:31:47 +01003551 if (spec->board_config == STAC_9200_GATEWAY ||
3552 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02003553 spec->init = stac9200_eapd_init;
3554 else
3555 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02003556 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02003557
Takashi Iwai117f2572008-03-18 09:53:23 +01003558 if (spec->board_config == STAC_9200_PANASONIC) {
3559 spec->gpio_mask = spec->gpio_dir = 0x09;
3560 spec->gpio_data = 0x00;
3561 }
3562
Mattc7d4b2f2005-06-27 14:59:41 +02003563 err = stac9200_parse_auto_config(codec);
3564 if (err < 0) {
3565 stac92xx_free(codec);
3566 return err;
3567 }
Matt2f2f4252005-04-13 14:45:30 +02003568
3569 codec->patch_ops = stac92xx_patch_ops;
3570
3571 return 0;
3572}
3573
Tobin Davis8e21c342007-01-08 11:04:17 +01003574static int patch_stac925x(struct hda_codec *codec)
3575{
3576 struct sigmatel_spec *spec;
3577 int err;
3578
3579 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3580 if (spec == NULL)
3581 return -ENOMEM;
3582
3583 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003584 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01003585 spec->pin_nids = stac925x_pin_nids;
3586 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
3587 stac925x_models,
3588 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01003589 again:
Tobin Davis8e21c342007-01-08 11:04:17 +01003590 if (spec->board_config < 0) {
Tobin Davis2c11f952007-05-17 09:36:34 +02003591 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
3592 "using BIOS defaults\n");
Tobin Davis8e21c342007-01-08 11:04:17 +01003593 err = stac92xx_save_bios_config_regs(codec);
3594 if (err < 0) {
3595 stac92xx_free(codec);
3596 return err;
3597 }
3598 spec->pin_configs = spec->bios_pin_configs;
3599 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
3600 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
3601 stac92xx_set_config_regs(codec);
3602 }
3603
3604 spec->multiout.max_channels = 2;
3605 spec->multiout.num_dacs = 1;
3606 spec->multiout.dac_nids = stac925x_dac_nids;
3607 spec->adc_nids = stac925x_adc_nids;
3608 spec->mux_nids = stac925x_mux_nids;
3609 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003610 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003611 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02003612 switch (codec->vendor_id) {
3613 case 0x83847632: /* STAC9202 */
3614 case 0x83847633: /* STAC9202D */
3615 case 0x83847636: /* STAC9251 */
3616 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02003617 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02003618 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01003619 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
3620 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02003621 break;
3622 default:
3623 spec->num_dmics = 0;
3624 break;
3625 }
Tobin Davis8e21c342007-01-08 11:04:17 +01003626
3627 spec->init = stac925x_core_init;
3628 spec->mixer = stac925x_mixer;
3629
3630 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01003631 if (!err) {
3632 if (spec->board_config < 0) {
3633 printk(KERN_WARNING "hda_codec: No auto-config is "
3634 "available, default to model=ref\n");
3635 spec->board_config = STAC_925x_REF;
3636 goto again;
3637 }
3638 err = -EINVAL;
3639 }
Tobin Davis8e21c342007-01-08 11:04:17 +01003640 if (err < 0) {
3641 stac92xx_free(codec);
3642 return err;
3643 }
3644
3645 codec->patch_ops = stac92xx_patch_ops;
3646
3647 return 0;
3648}
3649
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003650static struct hda_input_mux stac92hd73xx_dmux = {
3651 .num_items = 4,
3652 .items = {
3653 { "Analog Inputs", 0x0b },
3654 { "CD", 0x08 },
3655 { "Digital Mic 1", 0x09 },
3656 { "Digital Mic 2", 0x0a },
3657 }
3658};
3659
3660static int patch_stac92hd73xx(struct hda_codec *codec)
3661{
3662 struct sigmatel_spec *spec;
3663 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
3664 int err = 0;
3665
3666 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3667 if (spec == NULL)
3668 return -ENOMEM;
3669
3670 codec->spec = spec;
3671 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
3672 spec->pin_nids = stac92hd73xx_pin_nids;
3673 spec->board_config = snd_hda_check_board_config(codec,
3674 STAC_92HD73XX_MODELS,
3675 stac92hd73xx_models,
3676 stac92hd73xx_cfg_tbl);
3677again:
3678 if (spec->board_config < 0) {
3679 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3680 " STAC92HD73XX, using BIOS defaults\n");
3681 err = stac92xx_save_bios_config_regs(codec);
3682 if (err < 0) {
3683 stac92xx_free(codec);
3684 return err;
3685 }
3686 spec->pin_configs = spec->bios_pin_configs;
3687 } else {
3688 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
3689 stac92xx_set_config_regs(codec);
3690 }
3691
3692 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
3693 conn, STAC92HD73_DAC_COUNT + 2) - 1;
3694
3695 if (spec->multiout.num_dacs < 0) {
3696 printk(KERN_WARNING "hda_codec: Could not determine "
3697 "number of channels defaulting to DAC count\n");
3698 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
3699 }
3700
3701 switch (spec->multiout.num_dacs) {
3702 case 0x3: /* 6 Channel */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003703 spec->multiout.hp_nid = 0x17;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003704 spec->mixer = stac92hd73xx_6ch_mixer;
3705 spec->init = stac92hd73xx_6ch_core_init;
3706 break;
3707 case 0x4: /* 8 Channel */
3708 spec->multiout.hp_nid = 0x18;
3709 spec->mixer = stac92hd73xx_8ch_mixer;
3710 spec->init = stac92hd73xx_8ch_core_init;
3711 break;
3712 case 0x5: /* 10 Channel */
3713 spec->multiout.hp_nid = 0x19;
3714 spec->mixer = stac92hd73xx_10ch_mixer;
3715 spec->init = stac92hd73xx_10ch_core_init;
3716 };
3717
3718 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
3719 spec->aloopback_mask = 0x01;
3720 spec->aloopback_shift = 8;
3721
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003722 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003723 spec->mux_nids = stac92hd73xx_mux_nids;
3724 spec->adc_nids = stac92hd73xx_adc_nids;
3725 spec->dmic_nids = stac92hd73xx_dmic_nids;
3726 spec->dmux_nids = stac92hd73xx_dmux_nids;
3727
3728 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
3729 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01003730 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003731 spec->dinput_mux = &stac92hd73xx_dmux;
3732 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003733 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003734 spec->gpio_data = 0x01;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003735
Matthew Ranostaya7662642008-02-21 07:51:14 +01003736 switch (spec->board_config) {
3737 case STAC_DELL_M6:
Matthew Ranostayd654a662008-03-14 08:46:51 +01003738 spec->init = dell_eq_core_init;
Matthew Ranostaya7662642008-02-21 07:51:14 +01003739 switch (codec->subsystem_id) {
3740 case 0x1028025e: /* Analog Mics */
3741 case 0x1028025f:
3742 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
3743 spec->num_dmics = 0;
3744 break;
Matthew Ranostayd654a662008-03-14 08:46:51 +01003745 case 0x10280271: /* Digital Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01003746 case 0x10280272:
Matthew Ranostayd654a662008-03-14 08:46:51 +01003747 spec->init = dell_m6_core_init;
3748 /* fall-through */
3749 case 0x10280254:
3750 case 0x10280255:
Matthew Ranostaya7662642008-02-21 07:51:14 +01003751 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
3752 spec->num_dmics = 1;
3753 break;
3754 case 0x10280256: /* Both */
3755 case 0x10280057:
3756 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
3757 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
3758 spec->num_dmics = 1;
3759 break;
3760 }
3761 break;
3762 default:
3763 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
3764 }
3765
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003766 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
3767 spec->pwr_nids = stac92hd73xx_pwr_nids;
3768
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003769 err = stac92xx_parse_auto_config(codec, 0x22, 0x24);
3770
3771 if (!err) {
3772 if (spec->board_config < 0) {
3773 printk(KERN_WARNING "hda_codec: No auto-config is "
3774 "available, default to model=ref\n");
3775 spec->board_config = STAC_92HD73XX_REF;
3776 goto again;
3777 }
3778 err = -EINVAL;
3779 }
3780
3781 if (err < 0) {
3782 stac92xx_free(codec);
3783 return err;
3784 }
3785
3786 codec->patch_ops = stac92xx_patch_ops;
3787
3788 return 0;
3789}
3790
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003791static struct hda_input_mux stac92hd83xxx_dmux = {
3792 .num_items = 3,
3793 .items = {
3794 { "Analog Inputs", 0x03 },
3795 { "Digital Mic 1", 0x04 },
3796 { "Digital Mic 2", 0x05 },
3797 }
3798};
3799
3800static int patch_stac92hd83xxx(struct hda_codec *codec)
3801{
3802 struct sigmatel_spec *spec;
3803 int err;
3804
3805 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3806 if (spec == NULL)
3807 return -ENOMEM;
3808
3809 codec->spec = spec;
3810 spec->mono_nid = 0x19;
3811 spec->digbeep_nid = 0x21;
3812 spec->dmic_nids = stac92hd83xxx_dmic_nids;
3813 spec->dmux_nids = stac92hd83xxx_dmux_nids;
3814 spec->adc_nids = stac92hd83xxx_adc_nids;
3815 spec->pwr_nids = stac92hd83xxx_pwr_nids;
3816 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
3817 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
3818 spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
3819
3820 spec->init = stac92hd83xxx_core_init;
3821 switch (codec->vendor_id) {
3822 case 0x111d7605:
3823 spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
3824 break;
3825 default:
3826 spec->num_pwrs--;
3827 spec->init++; /* switch to config #2 */
3828 spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
3829 }
3830
3831 spec->mixer = stac92hd83xxx_mixer;
3832 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
3833 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
3834 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
3835 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
3836 spec->dinput_mux = &stac92hd83xxx_dmux;
3837 spec->pin_nids = stac92hd83xxx_pin_nids;
3838 spec->board_config = snd_hda_check_board_config(codec,
3839 STAC_92HD83XXX_MODELS,
3840 stac92hd83xxx_models,
3841 stac92hd83xxx_cfg_tbl);
3842again:
3843 if (spec->board_config < 0) {
3844 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3845 " STAC92HD83XXX, using BIOS defaults\n");
3846 err = stac92xx_save_bios_config_regs(codec);
3847 if (err < 0) {
3848 stac92xx_free(codec);
3849 return err;
3850 }
3851 spec->pin_configs = spec->bios_pin_configs;
3852 } else {
3853 spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config];
3854 stac92xx_set_config_regs(codec);
3855 }
3856
3857 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
3858 if (!err) {
3859 if (spec->board_config < 0) {
3860 printk(KERN_WARNING "hda_codec: No auto-config is "
3861 "available, default to model=ref\n");
3862 spec->board_config = STAC_92HD83XXX_REF;
3863 goto again;
3864 }
3865 err = -EINVAL;
3866 }
3867
3868 if (err < 0) {
3869 stac92xx_free(codec);
3870 return err;
3871 }
3872
3873 codec->patch_ops = stac92xx_patch_ops;
3874
3875 return 0;
3876}
3877
3878
Matthew Ranostaye035b842007-11-06 11:53:55 +01003879static int patch_stac92hd71bxx(struct hda_codec *codec)
3880{
3881 struct sigmatel_spec *spec;
3882 int err = 0;
3883
3884 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3885 if (spec == NULL)
3886 return -ENOMEM;
3887
3888 codec->spec = spec;
3889 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003890 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01003891 spec->pin_nids = stac92hd71bxx_pin_nids;
3892 spec->board_config = snd_hda_check_board_config(codec,
3893 STAC_92HD71BXX_MODELS,
3894 stac92hd71bxx_models,
3895 stac92hd71bxx_cfg_tbl);
3896again:
3897 if (spec->board_config < 0) {
3898 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3899 " STAC92HD71BXX, using BIOS defaults\n");
3900 err = stac92xx_save_bios_config_regs(codec);
3901 if (err < 0) {
3902 stac92xx_free(codec);
3903 return err;
3904 }
3905 spec->pin_configs = spec->bios_pin_configs;
3906 } else {
3907 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
3908 stac92xx_set_config_regs(codec);
3909 }
3910
Matthew Ranostay541eee82007-12-14 12:08:04 +01003911 switch (codec->vendor_id) {
3912 case 0x111d76b6: /* 4 Port without Analog Mixer */
3913 case 0x111d76b7:
3914 case 0x111d76b4: /* 6 Port without Analog Mixer */
3915 case 0x111d76b5:
3916 spec->mixer = stac92hd71bxx_mixer;
3917 spec->init = stac92hd71bxx_core_init;
3918 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003919 case 0x111d7608: /* 5 Port with Analog Mixer */
3920 /* no output amps */
3921 spec->num_pwrs = 0;
3922 spec->mixer = stac92hd71bxx_analog_mixer;
3923
3924 /* disable VSW */
3925 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
3926 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
3927 break;
3928 case 0x111d7603: /* 6 Port with Analog Mixer */
3929 /* no output amps */
3930 spec->num_pwrs = 0;
3931 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01003932 default:
3933 spec->mixer = stac92hd71bxx_analog_mixer;
3934 spec->init = stac92hd71bxx_analog_core_init;
3935 }
3936
3937 spec->aloopback_mask = 0x20;
3938 spec->aloopback_shift = 0;
3939
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003940 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003941 spec->gpio_mask = 0x01;
3942 spec->gpio_dir = 0x01;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003943 spec->gpio_data = 0x01;
Matthew Ranostaye035b842007-11-06 11:53:55 +01003944
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003945 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01003946 spec->mux_nids = stac92hd71bxx_mux_nids;
3947 spec->adc_nids = stac92hd71bxx_adc_nids;
3948 spec->dmic_nids = stac92hd71bxx_dmic_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003949 spec->dmux_nids = stac92hd71bxx_dmux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003950 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01003951
3952 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
3953 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
3954 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
Takashi Iwai1697055e2007-12-18 18:05:52 +01003955 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01003956
Takashi Iwaiaea7bb02008-02-25 18:26:41 +01003957 spec->multiout.num_dacs = 1;
Matthew Ranostaye035b842007-11-06 11:53:55 +01003958 spec->multiout.hp_nid = 0x11;
3959 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
3960
3961 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
3962 if (!err) {
3963 if (spec->board_config < 0) {
3964 printk(KERN_WARNING "hda_codec: No auto-config is "
3965 "available, default to model=ref\n");
3966 spec->board_config = STAC_92HD71BXX_REF;
3967 goto again;
3968 }
3969 err = -EINVAL;
3970 }
3971
3972 if (err < 0) {
3973 stac92xx_free(codec);
3974 return err;
3975 }
3976
3977 codec->patch_ops = stac92xx_patch_ops;
3978
3979 return 0;
3980};
3981
Matt2f2f4252005-04-13 14:45:30 +02003982static int patch_stac922x(struct hda_codec *codec)
3983{
3984 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003985 int err;
Matt2f2f4252005-04-13 14:45:30 +02003986
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003987 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02003988 if (spec == NULL)
3989 return -ENOMEM;
3990
3991 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003992 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02003993 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003994 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
3995 stac922x_models,
3996 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08003997 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003998 spec->gpio_mask = spec->gpio_dir = 0x03;
3999 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004000 /* Intel Macs have all same PCI SSID, so we need to check
4001 * codec SSID to distinguish the exact models
4002 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004003 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004004 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004005
4006 case 0x106b0800:
4007 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02004008 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004009 case 0x106b0600:
4010 case 0x106b0700:
4011 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004012 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004013 case 0x106b0e00:
4014 case 0x106b0f00:
4015 case 0x106b1600:
4016 case 0x106b1700:
4017 case 0x106b0200:
4018 case 0x106b1e00:
4019 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004020 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004021 case 0x106b1a00:
4022 case 0x00000100:
4023 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02004024 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004025 case 0x106b0a00:
4026 case 0x106b2200:
4027 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02004028 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08004029 default:
4030 spec->board_config = STAC_INTEL_MAC_V3;
4031 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004032 }
4033 }
4034
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004035 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004036 if (spec->board_config < 0) {
4037 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
4038 "using BIOS defaults\n");
4039 err = stac92xx_save_bios_config_regs(codec);
4040 if (err < 0) {
4041 stac92xx_free(codec);
4042 return err;
4043 }
4044 spec->pin_configs = spec->bios_pin_configs;
4045 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
Matt Porter403d1942005-11-29 15:00:51 +01004046 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
4047 stac92xx_set_config_regs(codec);
4048 }
Matt2f2f4252005-04-13 14:45:30 +02004049
Matt2f2f4252005-04-13 14:45:30 +02004050 spec->adc_nids = stac922x_adc_nids;
4051 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004052 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004053 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004054 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004055 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004056
4057 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004058 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004059
4060 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02004061
Matt Porter3cc08dc2006-01-23 15:27:49 +01004062 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004063 if (!err) {
4064 if (spec->board_config < 0) {
4065 printk(KERN_WARNING "hda_codec: No auto-config is "
4066 "available, default to model=ref\n");
4067 spec->board_config = STAC_D945_REF;
4068 goto again;
4069 }
4070 err = -EINVAL;
4071 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004072 if (err < 0) {
4073 stac92xx_free(codec);
4074 return err;
4075 }
4076
4077 codec->patch_ops = stac92xx_patch_ops;
4078
Takashi Iwai807a46362007-05-29 19:01:37 +02004079 /* Fix Mux capture level; max to 2 */
4080 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
4081 (0 << AC_AMPCAP_OFFSET_SHIFT) |
4082 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4083 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4084 (0 << AC_AMPCAP_MUTE_SHIFT));
4085
Matt Porter3cc08dc2006-01-23 15:27:49 +01004086 return 0;
4087}
4088
4089static int patch_stac927x(struct hda_codec *codec)
4090{
4091 struct sigmatel_spec *spec;
4092 int err;
4093
4094 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4095 if (spec == NULL)
4096 return -ENOMEM;
4097
4098 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004099 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004100 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004101 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
4102 stac927x_models,
4103 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004104 again:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004105 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
4106 if (spec->board_config < 0)
4107 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4108 "STAC927x, using BIOS defaults\n");
Richard Fish11b44bb2006-08-23 18:31:34 +02004109 err = stac92xx_save_bios_config_regs(codec);
4110 if (err < 0) {
4111 stac92xx_free(codec);
4112 return err;
4113 }
4114 spec->pin_configs = spec->bios_pin_configs;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004115 } else {
Matt Porter3cc08dc2006-01-23 15:27:49 +01004116 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
4117 stac92xx_set_config_regs(codec);
4118 }
4119
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004120 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004121 spec->adc_nids = stac927x_adc_nids;
4122 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
4123 spec->mux_nids = stac927x_mux_nids;
4124 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004125 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004126 spec->multiout.dac_nids = spec->dac_nids;
4127
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004128 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02004129 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004130 case STAC_D965_5ST:
4131 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004132 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004133 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004134 spec->num_dmics = 0;
4135
Tobin Davis93ed1502006-09-01 21:03:12 +02004136 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004137 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004138 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004139 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02004140 switch (codec->subsystem_id) {
4141 case 0x10280209:
4142 case 0x1028022e:
4143 /* correct the device field to SPDIF out */
4144 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
4145 break;
4146 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01004147 /* configure the analog microphone on some laptops */
4148 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01004149 /* correct the front output jack as a hp out */
Matthew Ranostay7989fba2008-02-21 07:50:12 +01004150 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01004151 /* correct the front input jack as a mic */
4152 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
4153 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004154 case STAC_DELL_3ST:
4155 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004156 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004157 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004158 spec->dmic_nids = stac927x_dmic_nids;
4159 spec->num_dmics = STAC927X_NUM_DMICS;
4160
Tobin Davis93ed1502006-09-01 21:03:12 +02004161 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004162 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004163 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004164 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004165 break;
4166 default:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004167 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004168 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004169 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004170 spec->num_dmics = 0;
4171
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004172 spec->init = stac927x_core_init;
4173 spec->mixer = stac927x_mixer;
4174 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004175
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004176 spec->num_pwrs = 0;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004177 spec->aloopback_mask = 0x40;
4178 spec->aloopback_shift = 0;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004179
Matt Porter3cc08dc2006-01-23 15:27:49 +01004180 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004181 if (!err) {
4182 if (spec->board_config < 0) {
4183 printk(KERN_WARNING "hda_codec: No auto-config is "
4184 "available, default to model=ref\n");
4185 spec->board_config = STAC_D965_REF;
4186 goto again;
4187 }
4188 err = -EINVAL;
4189 }
Mattc7d4b2f2005-06-27 14:59:41 +02004190 if (err < 0) {
4191 stac92xx_free(codec);
4192 return err;
4193 }
Matt2f2f4252005-04-13 14:45:30 +02004194
4195 codec->patch_ops = stac92xx_patch_ops;
4196
Takashi Iwai52987652008-01-16 16:09:47 +01004197 /*
4198 * !!FIXME!!
4199 * The STAC927x seem to require fairly long delays for certain
4200 * command sequences. With too short delays (even if the answer
4201 * is set to RIRB properly), it results in the silence output
4202 * on some hardwares like Dell.
4203 *
4204 * The below flag enables the longer delay (see get_response
4205 * in hda_intel.c).
4206 */
4207 codec->bus->needs_damn_long_delay = 1;
4208
Matt2f2f4252005-04-13 14:45:30 +02004209 return 0;
4210}
4211
Matt Porterf3302a52006-07-31 12:49:34 +02004212static int patch_stac9205(struct hda_codec *codec)
4213{
4214 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02004215 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02004216
4217 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4218 if (spec == NULL)
4219 return -ENOMEM;
4220
4221 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004222 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004223 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004224 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
4225 stac9205_models,
4226 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004227 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004228 if (spec->board_config < 0) {
4229 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
4230 err = stac92xx_save_bios_config_regs(codec);
4231 if (err < 0) {
4232 stac92xx_free(codec);
4233 return err;
4234 }
4235 spec->pin_configs = spec->bios_pin_configs;
4236 } else {
Matt Porterf3302a52006-07-31 12:49:34 +02004237 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
4238 stac92xx_set_config_regs(codec);
4239 }
4240
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004241 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02004242 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004243 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02004244 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004245 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004246 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02004247 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004248 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004249 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004250 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02004251
4252 spec->init = stac9205_core_init;
4253 spec->mixer = stac9205_mixer;
4254
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004255 spec->aloopback_mask = 0x40;
4256 spec->aloopback_shift = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02004257 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02004258
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004259 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004260 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02004261 /* Enable SPDIF in/out */
4262 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
4263 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01004264
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004265 /* Enable unsol response for GPIO4/Dock HP connection */
4266 snd_hda_codec_write(codec, codec->afg, 0,
4267 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4268 snd_hda_codec_write_cache(codec, codec->afg, 0,
4269 AC_VERB_SET_UNSOLICITED_ENABLE,
4270 (AC_USRSP_EN | STAC_HP_EVENT));
4271
4272 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004273 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004274 spec->gpio_mask = 0x1b;
4275 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01004276 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004277 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02004278 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004279 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004280 break;
4281 default:
4282 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004283 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004284 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004285 break;
4286 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02004287
Matt Porterf3302a52006-07-31 12:49:34 +02004288 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004289 if (!err) {
4290 if (spec->board_config < 0) {
4291 printk(KERN_WARNING "hda_codec: No auto-config is "
4292 "available, default to model=ref\n");
4293 spec->board_config = STAC_9205_REF;
4294 goto again;
4295 }
4296 err = -EINVAL;
4297 }
Matt Porterf3302a52006-07-31 12:49:34 +02004298 if (err < 0) {
4299 stac92xx_free(codec);
4300 return err;
4301 }
4302
4303 codec->patch_ops = stac92xx_patch_ops;
4304
4305 return 0;
4306}
4307
Matt2f2f4252005-04-13 14:45:30 +02004308/*
Guillaume Munch6d859062006-08-22 17:15:47 +02004309 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01004310 */
4311
Guillaume Munch99ccc562006-08-16 19:35:12 +02004312/* static config for Sony VAIO FE550G and Sony VAIO AR */
Takashi Iwaidb064e52006-03-16 16:04:58 +01004313static hda_nid_t vaio_dacs[] = { 0x2 };
4314#define VAIO_HP_DAC 0x5
4315static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
4316static hda_nid_t vaio_mux_nids[] = { 0x15 };
4317
4318static struct hda_input_mux vaio_mux = {
Takashi Iwaia3a2f422007-10-11 11:21:21 +02004319 .num_items = 3,
Takashi Iwaidb064e52006-03-16 16:04:58 +01004320 .items = {
Takashi Iwaid7737812006-04-25 13:05:43 +02004321 /* { "HP", 0x0 }, */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004322 { "Mic Jack", 0x1 },
4323 { "Internal Mic", 0x2 },
Takashi Iwaidb064e52006-03-16 16:04:58 +01004324 { "PCM", 0x3 },
4325 }
4326};
4327
4328static struct hda_verb vaio_init[] = {
4329 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004330 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
Takashi Iwaidb064e52006-03-16 16:04:58 +01004331 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4332 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4333 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4334 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004335 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01004336 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4337 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4338 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4339 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4340 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4341 {}
4342};
4343
Guillaume Munch6d859062006-08-22 17:15:47 +02004344static struct hda_verb vaio_ar_init[] = {
4345 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
4346 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4347 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4348 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4349/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
4350 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004351 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Guillaume Munch6d859062006-08-22 17:15:47 +02004352 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4353 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4354/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
4355 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4356 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4357 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4358 {}
4359};
4360
Takashi Iwaidb064e52006-03-16 16:04:58 +01004361/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02004362static struct hda_bind_ctls vaio_bind_master_vol = {
4363 .ops = &snd_hda_bind_vol,
4364 .values = {
4365 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4366 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4367 0
4368 },
4369};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004370
4371/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02004372static struct hda_bind_ctls vaio_bind_master_sw = {
4373 .ops = &snd_hda_bind_sw,
4374 .values = {
4375 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4376 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4377 0,
4378 },
4379};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004380
4381static struct snd_kcontrol_new vaio_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02004382 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4383 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Takashi Iwaidb064e52006-03-16 16:04:58 +01004384 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4385 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4386 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4387 {
4388 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4389 .name = "Capture Source",
4390 .count = 1,
4391 .info = stac92xx_mux_enum_info,
4392 .get = stac92xx_mux_enum_get,
4393 .put = stac92xx_mux_enum_put,
4394 },
4395 {}
4396};
4397
Guillaume Munch6d859062006-08-22 17:15:47 +02004398static struct snd_kcontrol_new vaio_ar_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02004399 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4400 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Guillaume Munch6d859062006-08-22 17:15:47 +02004401 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4402 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4403 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4404 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
4405 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
4406 {
4407 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4408 .name = "Capture Source",
4409 .count = 1,
4410 .info = stac92xx_mux_enum_info,
4411 .get = stac92xx_mux_enum_get,
4412 .put = stac92xx_mux_enum_put,
4413 },
4414 {}
4415};
4416
4417static struct hda_codec_ops stac9872_patch_ops = {
Takashi Iwaidb064e52006-03-16 16:04:58 +01004418 .build_controls = stac92xx_build_controls,
4419 .build_pcms = stac92xx_build_pcms,
4420 .init = stac92xx_init,
4421 .free = stac92xx_free,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004422#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaidb064e52006-03-16 16:04:58 +01004423 .resume = stac92xx_resume,
4424#endif
4425};
4426
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004427static int stac9872_vaio_init(struct hda_codec *codec)
4428{
4429 int err;
4430
4431 err = stac92xx_init(codec);
4432 if (err < 0)
4433 return err;
4434 if (codec->patch_ops.unsol_event)
4435 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
4436 return 0;
4437}
4438
4439static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
4440{
Jiang Zhe40c1d302007-11-12 13:05:16 +01004441 if (get_hp_pin_presence(codec, 0x0a)) {
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004442 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4443 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4444 } else {
4445 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4446 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4447 }
4448}
4449
4450static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
4451{
4452 switch (res >> 26) {
4453 case STAC_HP_EVENT:
4454 stac9872_vaio_hp_detect(codec, res);
4455 break;
4456 }
4457}
4458
4459static struct hda_codec_ops stac9872_vaio_patch_ops = {
4460 .build_controls = stac92xx_build_controls,
4461 .build_pcms = stac92xx_build_pcms,
4462 .init = stac9872_vaio_init,
4463 .free = stac92xx_free,
4464 .unsol_event = stac9872_vaio_unsol_event,
4465#ifdef CONFIG_PM
4466 .resume = stac92xx_resume,
4467#endif
4468};
4469
Guillaume Munch6d859062006-08-22 17:15:47 +02004470enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
4471 CXD9872RD_VAIO,
4472 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
4473 STAC9872AK_VAIO,
4474 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
4475 STAC9872K_VAIO,
4476 /* AR Series. id=0x83847664 and subsys=104D1300 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004477 CXD9872AKD_VAIO,
4478 STAC_9872_MODELS,
4479};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004480
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004481static const char *stac9872_models[STAC_9872_MODELS] = {
4482 [CXD9872RD_VAIO] = "vaio",
4483 [CXD9872AKD_VAIO] = "vaio-ar",
4484};
4485
4486static struct snd_pci_quirk stac9872_cfg_tbl[] = {
4487 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
4488 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
4489 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
Tobin Davis68e22542007-03-12 11:36:39 +01004490 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
Takashi Iwaidb064e52006-03-16 16:04:58 +01004491 {}
4492};
4493
Guillaume Munch6d859062006-08-22 17:15:47 +02004494static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01004495{
4496 struct sigmatel_spec *spec;
4497 int board_config;
4498
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004499 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
4500 stac9872_models,
4501 stac9872_cfg_tbl);
Takashi Iwaidb064e52006-03-16 16:04:58 +01004502 if (board_config < 0)
4503 /* unknown config, let generic-parser do its job... */
4504 return snd_hda_parse_generic_codec(codec);
4505
4506 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4507 if (spec == NULL)
4508 return -ENOMEM;
4509
4510 codec->spec = spec;
4511 switch (board_config) {
Guillaume Munch6d859062006-08-22 17:15:47 +02004512 case CXD9872RD_VAIO:
4513 case STAC9872AK_VAIO:
4514 case STAC9872K_VAIO:
Takashi Iwaidb064e52006-03-16 16:04:58 +01004515 spec->mixer = vaio_mixer;
4516 spec->init = vaio_init;
4517 spec->multiout.max_channels = 2;
4518 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
4519 spec->multiout.dac_nids = vaio_dacs;
4520 spec->multiout.hp_nid = VAIO_HP_DAC;
4521 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
4522 spec->adc_nids = vaio_adcs;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004523 spec->num_pwrs = 0;
Takashi Iwaidb064e52006-03-16 16:04:58 +01004524 spec->input_mux = &vaio_mux;
4525 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004526 codec->patch_ops = stac9872_vaio_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01004527 break;
Guillaume Munch6d859062006-08-22 17:15:47 +02004528
4529 case CXD9872AKD_VAIO:
4530 spec->mixer = vaio_ar_mixer;
4531 spec->init = vaio_ar_init;
4532 spec->multiout.max_channels = 2;
4533 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
4534 spec->multiout.dac_nids = vaio_dacs;
4535 spec->multiout.hp_nid = VAIO_HP_DAC;
4536 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004537 spec->num_pwrs = 0;
Guillaume Munch6d859062006-08-22 17:15:47 +02004538 spec->adc_nids = vaio_adcs;
4539 spec->input_mux = &vaio_mux;
4540 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004541 codec->patch_ops = stac9872_patch_ops;
Guillaume Munch6d859062006-08-22 17:15:47 +02004542 break;
Takashi Iwaidb064e52006-03-16 16:04:58 +01004543 }
4544
Takashi Iwaidb064e52006-03-16 16:04:58 +01004545 return 0;
4546}
4547
4548
4549/*
Matt2f2f4252005-04-13 14:45:30 +02004550 * patch entries
4551 */
4552struct hda_codec_preset snd_hda_preset_sigmatel[] = {
4553 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
4554 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
4555 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
4556 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
4557 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
4558 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
4559 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02004560 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
4561 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
4562 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
4563 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
4564 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
4565 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01004566 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
4567 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
4568 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
4569 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
4570 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
4571 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
4572 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
4573 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
4574 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
4575 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01004576 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
4577 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
4578 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
4579 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
4580 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
4581 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02004582 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
4583 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02004584 /* The following does not take into account .id=0x83847661 when subsys =
4585 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
4586 * currently not fully supported.
4587 */
4588 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
4589 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
4590 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02004591 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
4592 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
4593 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
4594 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
4595 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
4596 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
4597 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
4598 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004599 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004600 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
4601 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004602 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01004603 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
4604 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004605 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01004606 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
4607 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
4608 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
4609 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
4610 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
4611 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
4612 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
4613 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02004614 {} /* terminator */
4615};