blob: b77f330d2650b7c13d23d1d0f84d9344d973940a [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 Ranostayc39555d2008-11-14 17:46:22 -050039
40#define STAC_VREF_EVENT 0x00
41#define STAC_INSERT_EVENT 0x10
Matthew Ranostaya64135a2008-01-10 16:55:06 +010042#define STAC_PWR_EVENT 0x20
43#define STAC_HP_EVENT 0x30
Matt4e550962005-07-04 17:51:39 +020044
Takashi Iwaif5fcc132006-11-24 17:07:44 +010045enum {
46 STAC_REF,
Tobin Davisbf277782008-02-03 20:31:47 +010047 STAC_9200_OQO,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020048 STAC_9200_DELL_D21,
49 STAC_9200_DELL_D22,
50 STAC_9200_DELL_D23,
51 STAC_9200_DELL_M21,
52 STAC_9200_DELL_M22,
53 STAC_9200_DELL_M23,
54 STAC_9200_DELL_M24,
55 STAC_9200_DELL_M25,
56 STAC_9200_DELL_M26,
57 STAC_9200_DELL_M27,
Takashi Iwai1194b5b2007-10-10 10:04:26 +020058 STAC_9200_GATEWAY,
Takashi Iwai117f2572008-03-18 09:53:23 +010059 STAC_9200_PANASONIC,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010060 STAC_9200_MODELS
61};
62
63enum {
64 STAC_9205_REF,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020065 STAC_9205_DELL_M42,
Tobin Davisae0a8ed2007-08-13 15:50:29 +020066 STAC_9205_DELL_M43,
67 STAC_9205_DELL_M44,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010068 STAC_9205_MODELS
69};
70
71enum {
Takashi Iwai9e43f0d2008-12-17 14:51:01 +010072 STAC_92HD73XX_NO_JD, /* no jack-detection */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010073 STAC_92HD73XX_REF,
Takashi Iwai661cd8f2008-11-25 15:18:29 +010074 STAC_DELL_M6_AMIC,
75 STAC_DELL_M6_DMIC,
76 STAC_DELL_M6_BOTH,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -050077 STAC_DELL_EQ,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010078 STAC_92HD73XX_MODELS
79};
80
81enum {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020082 STAC_92HD83XXX_REF,
83 STAC_92HD83XXX_MODELS
84};
85
86enum {
Matthew Ranostaye035b842007-11-06 11:53:55 +010087 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010088 STAC_DELL_M4_1,
89 STAC_DELL_M4_2,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -050090 STAC_DELL_M4_3,
Matthew Ranostay6a14f582008-09-12 12:02:30 -040091 STAC_HP_M4,
Matthew Ranostaye035b842007-11-06 11:53:55 +010092 STAC_92HD71BXX_MODELS
93};
94
95enum {
Tobin Davis8e21c342007-01-08 11:04:17 +010096 STAC_925x_REF,
97 STAC_M2_2,
98 STAC_MA6,
Tobin Davis2c11f952007-05-17 09:36:34 +020099 STAC_PA6,
Tobin Davis8e21c342007-01-08 11:04:17 +0100100 STAC_925x_MODELS
101};
102
103enum {
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100104 STAC_D945_REF,
105 STAC_D945GTP3,
106 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200107 STAC_INTEL_MAC_V1,
108 STAC_INTEL_MAC_V2,
109 STAC_INTEL_MAC_V3,
110 STAC_INTEL_MAC_V4,
111 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800112 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
113 * is given, one of the above models will be
114 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200115 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100116 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100117 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100118 STAC_MACBOOK_PRO_V1,
119 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200120 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200121 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300122 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200123 STAC_922X_DELL_D81,
124 STAC_922X_DELL_D82,
125 STAC_922X_DELL_M81,
126 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100127 STAC_922X_MODELS
128};
129
130enum {
Takashi Iwaie28d8322008-12-17 13:48:29 +0100131 STAC_D965_REF_NO_JD, /* no jack-detection */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100132 STAC_D965_REF,
133 STAC_D965_3ST,
134 STAC_D965_5ST,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200135 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100136 STAC_DELL_BIOS,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100137 STAC_927X_MODELS
138};
Matt Porter403d1942005-11-29 15:00:51 +0100139
Matt2f2f4252005-04-13 14:45:30 +0200140struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100141 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200142 unsigned int num_mixers;
143
Matt Porter403d1942005-11-29 15:00:51 +0100144 int board_config;
Matthew Ranostay0253fdc2008-11-16 11:42:34 -0500145 unsigned int eapd_switch: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200146 unsigned int surr_switch: 1;
Matt Porter403d1942005-11-29 15:00:51 +0100147 unsigned int line_switch: 1;
148 unsigned int mic_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100149 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100150 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400151 unsigned int spdif_mute: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200152
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100153 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200154 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100155 unsigned int gpio_mask;
156 unsigned int gpio_dir;
157 unsigned int gpio_data;
158 unsigned int gpio_mute;
159
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200160 /* stream */
161 unsigned int stream_delay;
162
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100163 /* analog loopback */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100164 unsigned char aloopback_mask;
165 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200166
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100167 /* power management */
168 unsigned int num_pwrs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200169 unsigned int *pwr_mapping;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100170 hda_nid_t *pwr_nids;
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100171 hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100172
Matt2f2f4252005-04-13 14:45:30 +0200173 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100174 struct hda_input_mux *mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400175 struct hda_input_mux *amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100176 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200177 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100178 hda_nid_t dac_nids[5];
Matt2f2f4252005-04-13 14:45:30 +0200179
180 /* capture */
181 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200182 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200183 hda_nid_t *mux_nids;
184 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200185 hda_nid_t *dmic_nids;
186 unsigned int num_dmics;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100187 hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100188 unsigned int num_dmuxes;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200189 hda_nid_t *smux_nids;
190 unsigned int num_smuxes;
Matthew Ranostay65973632008-09-16 10:39:37 -0400191 const char **spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200192
Mattdabbed62005-06-14 10:19:34 +0200193 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100194 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200195 hda_nid_t anabeep_nid;
196 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200197
Matt2f2f4252005-04-13 14:45:30 +0200198 /* pin widgets */
199 hda_nid_t *pin_nids;
200 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200201 unsigned int *pin_configs;
Richard Fish11b44bb2006-08-23 18:31:34 +0200202 unsigned int *bios_pin_configs;
Matt2f2f4252005-04-13 14:45:30 +0200203
204 /* codec specific stuff */
205 struct hda_verb *init;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100206 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200207
208 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200209 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100210 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200211 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100212 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200213 struct hda_input_mux *sinput_mux;
214 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400215 unsigned int cur_amux;
216 hda_nid_t *amp_nids;
217 unsigned int num_amps;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200218 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200219
Matt Porter403d1942005-11-29 15:00:51 +0100220 /* i/o switches */
221 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200222 unsigned int clfe_swap;
Takashi Iwaid7a89432008-11-12 09:48:04 +0100223 unsigned int hp_switch; /* NID of HP as line-out */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200224 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200225
Mattc7d4b2f2005-06-27 14:59:41 +0200226 struct hda_pcm pcm_rec[2]; /* PCM information */
227
228 /* dynamic controls and input_mux */
229 struct auto_pin_cfg autocfg;
230 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100231 struct snd_kcontrol_new *kctl_alloc;
Matt Porter8b657272006-10-26 17:12:59 +0200232 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200233 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200234 struct hda_input_mux private_smux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400235 struct hda_input_mux private_amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100236 struct hda_input_mux private_mono_mux;
Matt2f2f4252005-04-13 14:45:30 +0200237};
238
239static hda_nid_t stac9200_adc_nids[1] = {
240 0x03,
241};
242
243static hda_nid_t stac9200_mux_nids[1] = {
244 0x0c,
245};
246
247static hda_nid_t stac9200_dac_nids[1] = {
248 0x02,
249};
250
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100251static hda_nid_t stac92hd73xx_pwr_nids[8] = {
252 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
253 0x0f, 0x10, 0x11
254};
255
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400256static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
257 0x26, 0,
258};
259
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100260static hda_nid_t stac92hd73xx_adc_nids[2] = {
261 0x1a, 0x1b
262};
263
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400264#define DELL_M6_AMP 2
265static hda_nid_t stac92hd73xx_amp_nids[3] = {
266 0x0b, 0x0c, 0x0e
Matthew Ranostay89385032008-09-11 09:49:39 -0400267};
268
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100269#define STAC92HD73XX_NUM_DMICS 2
270static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
271 0x13, 0x14, 0
272};
273
274#define STAC92HD73_DAC_COUNT 5
275static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
276 0x15, 0x16, 0x17, 0x18, 0x19,
277};
278
279static hda_nid_t stac92hd73xx_mux_nids[4] = {
280 0x28, 0x29, 0x2a, 0x2b,
281};
282
283static hda_nid_t stac92hd73xx_dmux_nids[2] = {
284 0x20, 0x21,
285};
286
Matthew Ranostayd9737752008-09-07 12:03:41 +0200287static hda_nid_t stac92hd73xx_smux_nids[2] = {
288 0x22, 0x23,
289};
290
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200291#define STAC92HD83XXX_NUM_DMICS 2
292static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
293 0x11, 0x12, 0
294};
295
296#define STAC92HD81_DAC_COUNT 2
297#define STAC92HD83_DAC_COUNT 3
298static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = {
299 0x13, 0x14, 0x22,
300};
301
302static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
303 0x17, 0x18,
304};
305
306static hda_nid_t stac92hd83xxx_adc_nids[2] = {
307 0x15, 0x16,
308};
309
310static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
311 0xa, 0xb, 0xd, 0xe,
312};
313
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400314static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
315 0x1e, 0,
316};
317
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200318static unsigned int stac92hd83xxx_pwr_mapping[4] = {
319 0x03, 0x0c, 0x10, 0x40,
320};
321
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100322static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
323 0x0a, 0x0d, 0x0f
324};
325
Matthew Ranostaye035b842007-11-06 11:53:55 +0100326static hda_nid_t stac92hd71bxx_adc_nids[2] = {
327 0x12, 0x13,
328};
329
330static hda_nid_t stac92hd71bxx_mux_nids[2] = {
331 0x1a, 0x1b
332};
333
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400334static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
335 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100336};
337
Matthew Ranostayd9737752008-09-07 12:03:41 +0200338static hda_nid_t stac92hd71bxx_smux_nids[2] = {
339 0x24, 0x25,
340};
341
Takashi Iwaiaea7bb02008-02-25 18:26:41 +0100342static hda_nid_t stac92hd71bxx_dac_nids[1] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100343 0x10, /*0x11, */
344};
345
346#define STAC92HD71BXX_NUM_DMICS 2
347static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
348 0x18, 0x19, 0
349};
350
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400351static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
352 0x22, 0
353};
354
Tobin Davis8e21c342007-01-08 11:04:17 +0100355static hda_nid_t stac925x_adc_nids[1] = {
356 0x03,
357};
358
359static hda_nid_t stac925x_mux_nids[1] = {
360 0x0f,
361};
362
363static hda_nid_t stac925x_dac_nids[1] = {
364 0x02,
365};
366
Takashi Iwaif6e98522007-10-16 14:27:04 +0200367#define STAC925X_NUM_DMICS 1
368static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
369 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200370};
371
Takashi Iwai1697055e2007-12-18 18:05:52 +0100372static hda_nid_t stac925x_dmux_nids[1] = {
373 0x14,
374};
375
Matt2f2f4252005-04-13 14:45:30 +0200376static hda_nid_t stac922x_adc_nids[2] = {
377 0x06, 0x07,
378};
379
380static hda_nid_t stac922x_mux_nids[2] = {
381 0x12, 0x13,
382};
383
Matt Porter3cc08dc2006-01-23 15:27:49 +0100384static hda_nid_t stac927x_adc_nids[3] = {
385 0x07, 0x08, 0x09
386};
387
388static hda_nid_t stac927x_mux_nids[3] = {
389 0x15, 0x16, 0x17
390};
391
Matthew Ranostayd9737752008-09-07 12:03:41 +0200392static hda_nid_t stac927x_smux_nids[1] = {
393 0x21,
394};
395
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100396static hda_nid_t stac927x_dac_nids[6] = {
397 0x02, 0x03, 0x04, 0x05, 0x06, 0
398};
399
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100400static hda_nid_t stac927x_dmux_nids[1] = {
401 0x1b,
402};
403
Matthew Ranostay7f168592007-10-18 17:38:17 +0200404#define STAC927X_NUM_DMICS 2
405static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
406 0x13, 0x14, 0
407};
408
Matthew Ranostay65973632008-09-16 10:39:37 -0400409static const char *stac927x_spdif_labels[5] = {
410 "Digital Playback", "ADAT", "Analog Mux 1",
411 "Analog Mux 2", "Analog Mux 3"
412};
413
Matt Porterf3302a52006-07-31 12:49:34 +0200414static hda_nid_t stac9205_adc_nids[2] = {
415 0x12, 0x13
416};
417
418static hda_nid_t stac9205_mux_nids[2] = {
419 0x19, 0x1a
420};
421
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100422static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100423 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100424};
425
Matthew Ranostayd9737752008-09-07 12:03:41 +0200426static hda_nid_t stac9205_smux_nids[1] = {
427 0x21,
428};
429
Takashi Iwaif6e98522007-10-16 14:27:04 +0200430#define STAC9205_NUM_DMICS 2
431static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
432 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200433};
434
Mattc7d4b2f2005-06-27 14:59:41 +0200435static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200436 0x08, 0x09, 0x0d, 0x0e,
437 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200438};
439
Tobin Davis8e21c342007-01-08 11:04:17 +0100440static hda_nid_t stac925x_pin_nids[8] = {
441 0x07, 0x08, 0x0a, 0x0b,
442 0x0c, 0x0d, 0x10, 0x11,
443};
444
Matt2f2f4252005-04-13 14:45:30 +0200445static hda_nid_t stac922x_pin_nids[10] = {
446 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
447 0x0f, 0x10, 0x11, 0x15, 0x1b,
448};
449
Matthew Ranostaya7662642008-02-21 07:51:14 +0100450static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100451 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
452 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200453 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100454};
455
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200456static hda_nid_t stac92hd83xxx_pin_nids[14] = {
457 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
458 0x0f, 0x10, 0x11, 0x12, 0x13,
459 0x1d, 0x1e, 0x1f, 0x20
460};
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400461static hda_nid_t stac92hd71bxx_pin_nids[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100462 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
463 0x0f, 0x14, 0x18, 0x19, 0x1e,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400464 0x1f,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100465};
466
Matt Porter3cc08dc2006-01-23 15:27:49 +0100467static hda_nid_t stac927x_pin_nids[14] = {
468 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
469 0x0f, 0x10, 0x11, 0x12, 0x13,
470 0x14, 0x21, 0x22, 0x23,
471};
472
Matt Porterf3302a52006-07-31 12:49:34 +0200473static hda_nid_t stac9205_pin_nids[12] = {
474 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
475 0x0f, 0x14, 0x16, 0x17, 0x18,
476 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200477};
478
Matthew Ranostay89385032008-09-11 09:49:39 -0400479#define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
480
481static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
482 struct snd_ctl_elem_value *ucontrol)
483{
484 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
485 struct sigmatel_spec *spec = codec->spec;
486 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
487
488 kcontrol->private_value ^= get_amp_nid(kcontrol);
489 kcontrol->private_value |= nid;
490
491 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
492}
493
494static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
495 struct snd_ctl_elem_value *ucontrol)
496{
497 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
498 struct sigmatel_spec *spec = codec->spec;
499 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
500
501 kcontrol->private_value ^= get_amp_nid(kcontrol);
502 kcontrol->private_value |= nid;
503
504 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
505}
506
Matt Porter8b657272006-10-26 17:12:59 +0200507static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
508 struct snd_ctl_elem_info *uinfo)
509{
510 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
511 struct sigmatel_spec *spec = codec->spec;
512 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
513}
514
515static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
516 struct snd_ctl_elem_value *ucontrol)
517{
518 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
519 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100520 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200521
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100522 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200523 return 0;
524}
525
526static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
527 struct snd_ctl_elem_value *ucontrol)
528{
529 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
530 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100531 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200532
533 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100534 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200535}
536
Matthew Ranostayd9737752008-09-07 12:03:41 +0200537static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
538 struct snd_ctl_elem_info *uinfo)
539{
540 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
541 struct sigmatel_spec *spec = codec->spec;
542 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
543}
544
545static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
546 struct snd_ctl_elem_value *ucontrol)
547{
548 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
549 struct sigmatel_spec *spec = codec->spec;
550 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
551
552 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
553 return 0;
554}
555
556static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
557 struct snd_ctl_elem_value *ucontrol)
558{
559 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
560 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400561 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200562 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400563 int err, val;
564 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200565
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400566 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200567 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400568 if (err < 0)
569 return err;
570
571 if (spec->spdif_mute) {
572 if (smux_idx == 0)
573 nid = spec->multiout.dig_out_nid;
574 else
575 nid = codec->slave_dig_outs[smux_idx - 1];
576 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
577 val = AMP_OUT_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400578 else
Takashi Iwaic1e99bd2008-10-29 08:03:42 +0100579 val = AMP_OUT_UNMUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400580 /* un/mute SPDIF out */
581 snd_hda_codec_write_cache(codec, nid, 0,
582 AC_VERB_SET_AMP_GAIN_MUTE, val);
583 }
584 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200585}
586
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100587static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200588{
589 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
590 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200591 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200592}
593
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100594static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200595{
596 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
597 struct sigmatel_spec *spec = codec->spec;
598 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
599
600 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
601 return 0;
602}
603
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100604static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200605{
606 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
607 struct sigmatel_spec *spec = codec->spec;
608 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
609
Mattc7d4b2f2005-06-27 14:59:41 +0200610 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200611 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
612}
613
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100614static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
615 struct snd_ctl_elem_info *uinfo)
616{
617 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
618 struct sigmatel_spec *spec = codec->spec;
619 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
620}
621
622static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
623 struct snd_ctl_elem_value *ucontrol)
624{
625 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
626 struct sigmatel_spec *spec = codec->spec;
627
628 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
629 return 0;
630}
631
632static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
633 struct snd_ctl_elem_value *ucontrol)
634{
635 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
636 struct sigmatel_spec *spec = codec->spec;
637
638 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
639 spec->mono_nid, &spec->cur_mmux);
640}
641
Matthew Ranostay89385032008-09-11 09:49:39 -0400642static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
643 struct snd_ctl_elem_info *uinfo)
644{
645 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
646 struct sigmatel_spec *spec = codec->spec;
647 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
648}
649
650static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
651 struct snd_ctl_elem_value *ucontrol)
652{
653 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
654 struct sigmatel_spec *spec = codec->spec;
655
656 ucontrol->value.enumerated.item[0] = spec->cur_amux;
657 return 0;
658}
659
660static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
661 struct snd_ctl_elem_value *ucontrol)
662{
663 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
664 struct sigmatel_spec *spec = codec->spec;
665 struct snd_kcontrol *ctl =
666 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
667 if (!ctl)
668 return -EINVAL;
669
670 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
671 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
672
673 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
674 0, &spec->cur_amux);
675}
676
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200677#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
678
679static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
680 struct snd_ctl_elem_value *ucontrol)
681{
682 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100683 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200684 struct sigmatel_spec *spec = codec->spec;
685
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100686 ucontrol->value.integer.value[0] = !!(spec->aloopback &
687 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200688 return 0;
689}
690
691static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
692 struct snd_ctl_elem_value *ucontrol)
693{
694 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
695 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100696 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200697 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100698 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200699
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100700 idx_val = spec->aloopback_mask << idx;
701 if (ucontrol->value.integer.value[0])
702 val = spec->aloopback | idx_val;
703 else
704 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100705 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200706 return 0;
707
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100708 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200709
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100710 /* Only return the bits defined by the shift value of the
711 * first two bytes of the mask
712 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200713 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100714 kcontrol->private_value & 0xFFFF, 0x0);
715 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200716
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100717 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200718 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100719 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200720 } else {
721 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100722 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200723 }
724
725 snd_hda_codec_write_cache(codec, codec->afg, 0,
726 kcontrol->private_value >> 16, dac_mode);
727
728 return 1;
729}
730
Mattc7d4b2f2005-06-27 14:59:41 +0200731static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200732 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200733 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200734 {}
735};
736
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200737static struct hda_verb stac9200_eapd_init[] = {
738 /* set dac0mux for dac converter */
739 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
740 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
741 {}
742};
743
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100744static struct hda_verb stac92hd73xx_6ch_core_init[] = {
745 /* set master volume and direct control */
746 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
747 /* setup audio connections */
748 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
749 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
750 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
751 /* setup adcs to point to mixer */
752 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
753 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100754 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
755 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
756 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
757 /* setup import muxs */
758 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
759 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
760 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
761 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
762 {}
763};
764
Matthew Ranostayd654a662008-03-14 08:46:51 +0100765static struct hda_verb dell_eq_core_init[] = {
766 /* set master volume to max value without distortion
767 * and direct control */
768 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
769 /* setup audio connections */
770 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
Matthew Ranostayf7cf0a72008-09-13 10:36:58 -0400771 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x02},
772 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100773 /* setup adcs to point to mixer */
774 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
775 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
776 /* setup import muxs */
777 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
778 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
779 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
780 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
781 {}
782};
783
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100784static struct hda_verb dell_m6_core_init[] = {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -0500785 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100786 /* setup audio connections */
Matthew Ranostay7747ecc2008-03-10 11:30:04 +0100787 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
788 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100789 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
790 /* setup adcs to point to mixer */
791 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
792 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
793 /* setup import muxs */
794 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
795 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
796 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
797 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
798 {}
799};
800
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100801static struct hda_verb stac92hd73xx_8ch_core_init[] = {
802 /* set master volume and direct control */
803 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
804 /* setup audio connections */
805 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
806 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
807 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
808 /* connect hp ports to dac3 */
809 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
810 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
811 /* setup adcs to point to mixer */
812 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
813 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100814 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
815 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
816 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
817 /* setup import muxs */
818 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
819 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
820 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
821 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
822 {}
823};
824
825static struct hda_verb stac92hd73xx_10ch_core_init[] = {
826 /* set master volume and direct control */
827 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
828 /* setup audio connections */
829 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
830 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
831 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
832 /* dac3 is connected to import3 mux */
833 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
834 /* connect hp ports to dac4 */
835 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
836 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
837 /* setup adcs to point to mixer */
838 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
839 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100840 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
841 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
842 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
843 /* setup import muxs */
844 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
845 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
846 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
847 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
848 {}
849};
850
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200851static struct hda_verb stac92hd83xxx_core_init[] = {
852 /* start of config #1 */
853 { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3},
854
855 /* start of config #2 */
856 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
857 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
858 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
859
860 /* power state controls amps */
861 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200862 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200863};
864
Matthew Ranostaye035b842007-11-06 11:53:55 +0100865static struct hda_verb stac92hd71bxx_core_init[] = {
866 /* set master volume and direct control */
867 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
868 /* connect headphone jack to dac1 */
869 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100870 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
871 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
872 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
873 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200874 {}
Matthew Ranostay541eee82007-12-14 12:08:04 +0100875};
876
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400877#define HD_DISABLE_PORTF 2
Matthew Ranostay541eee82007-12-14 12:08:04 +0100878static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200879 /* start of config #1 */
880
881 /* connect port 0f to audio mixer */
882 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200883 /* unmute right and left channels for node 0x0f */
884 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
885 /* start of config #2 */
886
Matthew Ranostay541eee82007-12-14 12:08:04 +0100887 /* set master volume and direct control */
888 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
889 /* connect headphone jack to dac1 */
890 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200891 /* unmute right and left channels for nodes 0x0a, 0xd */
Matthew Ranostaye035b842007-11-06 11:53:55 +0100892 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
893 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100894 {}
895};
896
Tobin Davis8e21c342007-01-08 11:04:17 +0100897static struct hda_verb stac925x_core_init[] = {
898 /* set dac0mux for dac converter */
899 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
900 {}
901};
902
Mattc7d4b2f2005-06-27 14:59:41 +0200903static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200904 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200905 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200906 {}
907};
908
Tobin Davis93ed1502006-09-01 21:03:12 +0200909static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200910 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200911 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200912 /* unmute node 0x1b */
913 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
914 /* select node 0x03 as DAC */
915 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
916 {}
917};
918
Matt Porter3cc08dc2006-01-23 15:27:49 +0100919static struct hda_verb stac927x_core_init[] = {
920 /* set master volume and direct control */
921 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200922 /* enable analog pc beep path */
923 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100924 {}
925};
926
Matt Porterf3302a52006-07-31 12:49:34 +0200927static struct hda_verb stac9205_core_init[] = {
928 /* set master volume and direct control */
929 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200930 /* enable analog pc beep path */
931 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200932 {}
933};
934
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100935#define STAC_MONO_MUX \
936 { \
937 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
938 .name = "Mono Mux", \
939 .count = 1, \
940 .info = stac92xx_mono_mux_enum_info, \
941 .get = stac92xx_mono_mux_enum_get, \
942 .put = stac92xx_mono_mux_enum_put, \
943 }
944
Matthew Ranostay89385032008-09-11 09:49:39 -0400945#define STAC_AMP_MUX \
946 { \
947 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
948 .name = "Amp Selector Capture Switch", \
949 .count = 1, \
950 .info = stac92xx_amp_mux_enum_info, \
951 .get = stac92xx_amp_mux_enum_get, \
952 .put = stac92xx_amp_mux_enum_put, \
953 }
954
955#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
956 { \
957 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
958 .name = xname, \
959 .index = 0, \
960 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
961 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
962 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
963 .info = stac92xx_amp_volume_info, \
964 .get = stac92xx_amp_volume_get, \
965 .put = stac92xx_amp_volume_put, \
966 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
967 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
968 }
969
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200970#define STAC_INPUT_SOURCE(cnt) \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200971 { \
972 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
973 .name = "Input Source", \
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200974 .count = cnt, \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200975 .info = stac92xx_mux_enum_info, \
976 .get = stac92xx_mux_enum_get, \
977 .put = stac92xx_mux_enum_put, \
978 }
979
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100980#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200981 { \
982 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
983 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100984 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200985 .info = stac92xx_aloopback_info, \
986 .get = stac92xx_aloopback_get, \
987 .put = stac92xx_aloopback_put, \
988 .private_value = verb_read | (verb_write << 16), \
989 }
990
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100991static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200992 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
993 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200994 STAC_INPUT_SOURCE(1),
Matt2f2f4252005-04-13 14:45:30 +0200995 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
996 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200997 { } /* end */
998};
999
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04001000#define DELL_M6_MIXER 6
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001001static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04001002 /* start of config #1 */
1003 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1004 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1005
1006 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1007 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1008
1009 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1010 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1011
1012 /* start of config #2 */
1013 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1014 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1015
1016 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1017 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1018
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001019 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1020
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001021 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1022 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1023
1024 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1025 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1026
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001027 { } /* end */
1028};
1029
1030static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001031 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1032
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001033 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1034 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1035
1036 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1037 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1038
1039 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1040 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1041
1042 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1043 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1044
1045 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1046 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1047
1048 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1049 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1050
1051 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1052 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1053 { } /* end */
1054};
1055
1056static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001057 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1058
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001059 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1060 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1061
1062 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1063 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1064
1065 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1066 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1067
1068 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1069 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1070
1071 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1072 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1073
1074 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1075 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1076
1077 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1078 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1079 { } /* end */
1080};
1081
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001082
1083static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1084 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1085 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1086
1087 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1088 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1089
1090 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT),
1091 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
1092
1093 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
1094 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
1095
1096 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
1097 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
1098
1099 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
1100 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
1101
1102 /*
1103 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
1104 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
1105 */
1106 { } /* end */
1107};
1108
Matthew Ranostay541eee82007-12-14 12:08:04 +01001109static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001110 STAC_INPUT_SOURCE(2),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001111 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001112
Matthew Ranostay9b359472007-11-07 13:03:12 +01001113 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1114 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay9b359472007-11-07 13:03:12 +01001115
1116 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1117 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001118 /* analog pc-beep replaced with digital beep support */
1119 /*
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001120 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1121 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001122 */
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001123
Matthew Ranostay687cb982008-10-11 13:52:43 -04001124 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1125 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001126
Matthew Ranostay687cb982008-10-11 13:52:43 -04001127 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1128 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001129
1130 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1131 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1132
1133 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1134 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001135 { } /* end */
1136};
1137
Matthew Ranostay541eee82007-12-14 12:08:04 +01001138static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +01001139 STAC_INPUT_SOURCE(2),
1140 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1141
Matthew Ranostay541eee82007-12-14 12:08:04 +01001142 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1143 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001144
1145 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1146 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001147 { } /* end */
1148};
1149
Tobin Davis8e21c342007-01-08 11:04:17 +01001150static struct snd_kcontrol_new stac925x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001151 STAC_INPUT_SOURCE(1),
Tobin Davis8e21c342007-01-08 11:04:17 +01001152 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +02001153 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001154 { } /* end */
1155};
1156
Takashi Iwaid1d985f2006-11-23 19:27:12 +01001157static struct snd_kcontrol_new stac9205_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001158 STAC_INPUT_SOURCE(2),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001159 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001160
1161 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1162 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001163
1164 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1165 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001166 { } /* end */
1167};
1168
1169/* This needs to be generated dynamically based on sequence */
1170static struct snd_kcontrol_new stac922x_mixer[] = {
1171 STAC_INPUT_SOURCE(2),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001172 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1173 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001174
1175 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1176 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001177 { } /* end */
1178};
1179
1180
1181static struct snd_kcontrol_new stac927x_mixer[] = {
1182 STAC_INPUT_SOURCE(3),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001183 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001184
1185 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1186 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001187
1188 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1189 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001190
1191 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1192 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
Matt Porterf3302a52006-07-31 12:49:34 +02001193 { } /* end */
1194};
1195
Takashi Iwai1697055e2007-12-18 18:05:52 +01001196static struct snd_kcontrol_new stac_dmux_mixer = {
1197 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1198 .name = "Digital Input Source",
1199 /* count set later */
1200 .info = stac92xx_dmux_enum_info,
1201 .get = stac92xx_dmux_enum_get,
1202 .put = stac92xx_dmux_enum_put,
1203};
1204
Matthew Ranostayd9737752008-09-07 12:03:41 +02001205static struct snd_kcontrol_new stac_smux_mixer = {
1206 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001207 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001208 /* count set later */
1209 .info = stac92xx_smux_enum_info,
1210 .get = stac92xx_smux_enum_get,
1211 .put = stac92xx_smux_enum_put,
1212};
1213
Takashi Iwai2134ea42008-01-10 16:53:55 +01001214static const char *slave_vols[] = {
1215 "Front Playback Volume",
1216 "Surround Playback Volume",
1217 "Center Playback Volume",
1218 "LFE Playback Volume",
1219 "Side Playback Volume",
1220 "Headphone Playback Volume",
1221 "Headphone Playback Volume",
1222 "Speaker Playback Volume",
1223 "External Speaker Playback Volume",
1224 "Speaker2 Playback Volume",
1225 NULL
1226};
1227
1228static const char *slave_sws[] = {
1229 "Front Playback Switch",
1230 "Surround Playback Switch",
1231 "Center Playback Switch",
1232 "LFE Playback Switch",
1233 "Side Playback Switch",
1234 "Headphone Playback Switch",
1235 "Headphone Playback Switch",
1236 "Speaker Playback Switch",
1237 "External Speaker Playback Switch",
1238 "Speaker2 Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001239 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001240 NULL
1241};
1242
Matt2f2f4252005-04-13 14:45:30 +02001243static int stac92xx_build_controls(struct hda_codec *codec)
1244{
1245 struct sigmatel_spec *spec = codec->spec;
1246 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001247 int i;
Matt2f2f4252005-04-13 14:45:30 +02001248
1249 err = snd_hda_add_new_ctls(codec, spec->mixer);
1250 if (err < 0)
1251 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001252
1253 for (i = 0; i < spec->num_mixers; i++) {
1254 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1255 if (err < 0)
1256 return err;
1257 }
Takashi Iwai1697055e2007-12-18 18:05:52 +01001258 if (spec->num_dmuxes > 0) {
1259 stac_dmux_mixer.count = spec->num_dmuxes;
1260 err = snd_ctl_add(codec->bus->card,
1261 snd_ctl_new1(&stac_dmux_mixer, codec));
1262 if (err < 0)
1263 return err;
1264 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001265 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001266 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1267 struct hda_input_mux *smux = &spec->private_smux;
1268 /* check for mute support on SPDIF out */
1269 if (wcaps & AC_WCAP_OUT_AMP) {
1270 smux->items[smux->num_items].label = "Off";
1271 smux->items[smux->num_items].index = 0;
1272 smux->num_items++;
1273 spec->spdif_mute = 1;
1274 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001275 stac_smux_mixer.count = spec->num_smuxes;
1276 err = snd_ctl_add(codec->bus->card,
1277 snd_ctl_new1(&stac_smux_mixer, codec));
1278 if (err < 0)
1279 return err;
1280 }
Mattc7d4b2f2005-06-27 14:59:41 +02001281
Mattdabbed62005-06-14 10:19:34 +02001282 if (spec->multiout.dig_out_nid) {
1283 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1284 if (err < 0)
1285 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001286 err = snd_hda_create_spdif_share_sw(codec,
1287 &spec->multiout);
1288 if (err < 0)
1289 return err;
1290 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001291 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001292 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001293 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1294 if (err < 0)
1295 return err;
1296 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001297
1298 /* if we have no master control, let's create it */
1299 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001300 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001301 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001302 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001303 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001304 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001305 if (err < 0)
1306 return err;
1307 }
1308 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1309 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1310 NULL, slave_sws);
1311 if (err < 0)
1312 return err;
1313 }
1314
Mattdabbed62005-06-14 10:19:34 +02001315 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001316}
1317
Matt Porter403d1942005-11-29 15:00:51 +01001318static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001319 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001320 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1321};
1322
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001323/*
1324 STAC 9200 pin configs for
1325 102801A8
1326 102801DE
1327 102801E8
1328*/
1329static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001330 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1331 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001332};
1333
1334/*
1335 STAC 9200 pin configs for
1336 102801C0
1337 102801C1
1338*/
1339static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001340 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1341 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001342};
1343
1344/*
1345 STAC 9200 pin configs for
1346 102801C4 (Dell Dimension E310)
1347 102801C5
1348 102801C7
1349 102801D9
1350 102801DA
1351 102801E3
1352*/
1353static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001354 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1355 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001356};
1357
1358
1359/*
1360 STAC 9200-32 pin configs for
1361 102801B5 (Dell Inspiron 630m)
1362 102801D8 (Dell Inspiron 640m)
1363*/
1364static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001365 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1366 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001367};
1368
1369/*
1370 STAC 9200-32 pin configs for
1371 102801C2 (Dell Latitude D620)
1372 102801C8
1373 102801CC (Dell Latitude D820)
1374 102801D4
1375 102801D6
1376*/
1377static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001378 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1379 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001380};
1381
1382/*
1383 STAC 9200-32 pin configs for
1384 102801CE (Dell XPS M1710)
1385 102801CF (Dell Precision M90)
1386*/
1387static unsigned int dell9200_m23_pin_configs[8] = {
1388 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1389 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1390};
1391
1392/*
1393 STAC 9200-32 pin configs for
1394 102801C9
1395 102801CA
1396 102801CB (Dell Latitude 120L)
1397 102801D3
1398*/
1399static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001400 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1401 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001402};
1403
1404/*
1405 STAC 9200-32 pin configs for
1406 102801BD (Dell Inspiron E1505n)
1407 102801EE
1408 102801EF
1409*/
1410static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001411 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1412 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001413};
1414
1415/*
1416 STAC 9200-32 pin configs for
1417 102801F5 (Dell Inspiron 1501)
1418 102801F6
1419*/
1420static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001421 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1422 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001423};
1424
1425/*
1426 STAC 9200-32
1427 102801CD (Dell Inspiron E1705/9400)
1428*/
1429static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001430 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1431 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001432};
1433
Tobin Davisbf277782008-02-03 20:31:47 +01001434static unsigned int oqo9200_pin_configs[8] = {
1435 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1436 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1437};
1438
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001439
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001440static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1441 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001442 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001443 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1444 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1445 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1446 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1447 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1448 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1449 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1450 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1451 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1452 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001453 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001454};
1455
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001456static const char *stac9200_models[STAC_9200_MODELS] = {
1457 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001458 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001459 [STAC_9200_DELL_D21] = "dell-d21",
1460 [STAC_9200_DELL_D22] = "dell-d22",
1461 [STAC_9200_DELL_D23] = "dell-d23",
1462 [STAC_9200_DELL_M21] = "dell-m21",
1463 [STAC_9200_DELL_M22] = "dell-m22",
1464 [STAC_9200_DELL_M23] = "dell-m23",
1465 [STAC_9200_DELL_M24] = "dell-m24",
1466 [STAC_9200_DELL_M25] = "dell-m25",
1467 [STAC_9200_DELL_M26] = "dell-m26",
1468 [STAC_9200_DELL_M27] = "dell-m27",
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001469 [STAC_9200_GATEWAY] = "gateway",
Takashi Iwai117f2572008-03-18 09:53:23 +01001470 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001471};
1472
1473static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1474 /* SigmaTel reference board */
1475 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1476 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001477 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001478 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1479 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001480 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001481 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1482 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1483 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1484 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1485 "unknown Dell", STAC_9200_DELL_D22),
1486 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1487 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001488 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001489 "Dell Latitude D620", STAC_9200_DELL_M22),
1490 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1491 "unknown Dell", STAC_9200_DELL_D23),
1492 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1493 "unknown Dell", STAC_9200_DELL_D23),
1494 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1495 "unknown Dell", STAC_9200_DELL_M22),
1496 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1497 "unknown Dell", STAC_9200_DELL_M24),
1498 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1499 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001500 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001501 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001502 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001503 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001504 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001505 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001506 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001507 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001508 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001509 "Dell Precision M90", STAC_9200_DELL_M23),
1510 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1511 "unknown Dell", STAC_9200_DELL_M22),
1512 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1513 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001514 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001515 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001516 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001517 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1518 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1519 "unknown Dell", STAC_9200_DELL_D23),
1520 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1521 "unknown Dell", STAC_9200_DELL_D23),
1522 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1523 "unknown Dell", STAC_9200_DELL_D21),
1524 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1525 "unknown Dell", STAC_9200_DELL_D23),
1526 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1527 "unknown Dell", STAC_9200_DELL_D21),
1528 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1529 "unknown Dell", STAC_9200_DELL_M25),
1530 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1531 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001532 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001533 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1534 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1535 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001536 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001537 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001538 /* Gateway machines needs EAPD to be set on resume */
1539 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1540 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1541 STAC_9200_GATEWAY),
1542 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1543 STAC_9200_GATEWAY),
Tobin Davisbf277782008-02-03 20:31:47 +01001544 /* OQO Mobile */
1545 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001546 {} /* terminator */
1547};
1548
Tobin Davis8e21c342007-01-08 11:04:17 +01001549static unsigned int ref925x_pin_configs[8] = {
1550 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001551 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001552};
1553
1554static unsigned int stac925x_MA6_pin_configs[8] = {
1555 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1556 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1557};
1558
Tobin Davis2c11f952007-05-17 09:36:34 +02001559static unsigned int stac925x_PA6_pin_configs[8] = {
1560 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1561 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1562};
1563
Tobin Davis8e21c342007-01-08 11:04:17 +01001564static unsigned int stac925xM2_2_pin_configs[8] = {
Steve Longerbeam7353e142007-05-29 14:36:17 +02001565 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1566 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001567};
1568
1569static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1570 [STAC_REF] = ref925x_pin_configs,
1571 [STAC_M2_2] = stac925xM2_2_pin_configs,
1572 [STAC_MA6] = stac925x_MA6_pin_configs,
Tobin Davis2c11f952007-05-17 09:36:34 +02001573 [STAC_PA6] = stac925x_PA6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001574};
1575
1576static const char *stac925x_models[STAC_925x_MODELS] = {
1577 [STAC_REF] = "ref",
1578 [STAC_M2_2] = "m2-2",
1579 [STAC_MA6] = "m6",
Tobin Davis2c11f952007-05-17 09:36:34 +02001580 [STAC_PA6] = "pa6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001581};
1582
1583static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1584 /* SigmaTel reference board */
1585 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001586 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Tobin Davis8e21c342007-01-08 11:04:17 +01001587 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1588 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1589 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
Tobin Davis2c11f952007-05-17 09:36:34 +02001590 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
Tobin Davis8e21c342007-01-08 11:04:17 +01001591 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1592 {} /* terminator */
1593};
1594
Matthew Ranostaya7662642008-02-21 07:51:14 +01001595static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001596 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1597 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1598 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001599 0x01452050,
1600};
1601
1602static unsigned int dell_m6_pin_configs[13] = {
1603 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001604 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001605 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1606 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001607};
1608
1609static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001610 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001611 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1612 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1613 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001614 [STAC_DELL_EQ] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001615};
1616
1617static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01001618 [STAC_92HD73XX_NO_JD] = "no-jd",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001619 [STAC_92HD73XX_REF] = "ref",
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001620 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1621 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1622 [STAC_DELL_M6_BOTH] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001623 [STAC_DELL_EQ] = "dell-eq",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001624};
1625
1626static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1627 /* SigmaTel reference board */
1628 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001629 "DFI LanParty", STAC_92HD73XX_REF),
1630 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001631 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001632 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001633 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001634 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001635 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001636 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001637 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001638 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001639 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001640 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001641 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001642 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001643 "unknown Dell", STAC_DELL_M6_DMIC),
1644 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1645 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01001646 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001647 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Joerg Schirottkefa620e92008-12-19 08:13:49 +01001648 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1649 "Dell Studio 17", STAC_DELL_M6_DMIC),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001650 {} /* terminator */
1651};
1652
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001653static unsigned int ref92hd83xxx_pin_configs[14] = {
1654 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1655 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1656 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1657 0x01451160, 0x98560170,
1658};
1659
1660static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1661 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1662};
1663
1664static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1665 [STAC_92HD83XXX_REF] = "ref",
1666};
1667
1668static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1669 /* SigmaTel reference board */
1670 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1671 "DFI LanParty", STAC_92HD71BXX_REF),
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -02001672 {} /* terminator */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001673};
1674
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001675static unsigned int ref92hd71bxx_pin_configs[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001676 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001677 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001678 0x90a000f0, 0x01452050, 0x01452050,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001679};
1680
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001681static unsigned int dell_m4_1_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001682 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001683 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001684 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001685};
1686
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001687static unsigned int dell_m4_2_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001688 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1689 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001690 0x40f000f0, 0x044413b0, 0x044413b0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001691};
1692
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001693static unsigned int dell_m4_3_pin_configs[11] = {
1694 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1695 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1696 0x40f000f0, 0x044413b0, 0x044413b0,
1697};
1698
Matthew Ranostaye035b842007-11-06 11:53:55 +01001699static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1700 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001701 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1702 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001703 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001704 [STAC_HP_M4] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001705};
1706
1707static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1708 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001709 [STAC_DELL_M4_1] = "dell-m4-1",
1710 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001711 [STAC_DELL_M4_3] = "dell-m4-3",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001712 [STAC_HP_M4] = "hp-m4",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001713};
1714
1715static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1716 /* SigmaTel reference board */
1717 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1718 "DFI LanParty", STAC_92HD71BXX_REF),
Takashi Iwai80bf2722008-11-18 10:48:41 +01001719 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f2,
1720 "HP dv5", STAC_HP_M4),
1721 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4,
1722 "HP dv7", STAC_HP_M4),
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001723 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1724 "unknown HP", STAC_HP_M4),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001725 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1726 "unknown Dell", STAC_DELL_M4_1),
1727 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1728 "unknown Dell", STAC_DELL_M4_1),
1729 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1730 "unknown Dell", STAC_DELL_M4_1),
1731 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1732 "unknown Dell", STAC_DELL_M4_1),
1733 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1734 "unknown Dell", STAC_DELL_M4_1),
1735 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1736 "unknown Dell", STAC_DELL_M4_1),
1737 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1738 "unknown Dell", STAC_DELL_M4_1),
1739 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1740 "unknown Dell", STAC_DELL_M4_2),
1741 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1742 "unknown Dell", STAC_DELL_M4_2),
1743 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1744 "unknown Dell", STAC_DELL_M4_2),
1745 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1746 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001747 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1748 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001749 {} /* terminator */
1750};
1751
Matt Porter403d1942005-11-29 15:00:51 +01001752static unsigned int ref922x_pin_configs[10] = {
1753 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1754 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001755 0x40000100, 0x40000100,
1756};
1757
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001758/*
1759 STAC 922X pin configs for
1760 102801A7
1761 102801AB
1762 102801A9
1763 102801D1
1764 102801D2
1765*/
1766static unsigned int dell_922x_d81_pin_configs[10] = {
1767 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1768 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1769 0x01813122, 0x400001f2,
1770};
1771
1772/*
1773 STAC 922X pin configs for
1774 102801AC
1775 102801D0
1776*/
1777static unsigned int dell_922x_d82_pin_configs[10] = {
1778 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1779 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1780 0x01813122, 0x400001f1,
1781};
1782
1783/*
1784 STAC 922X pin configs for
1785 102801BF
1786*/
1787static unsigned int dell_922x_m81_pin_configs[10] = {
1788 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1789 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1790 0x40C003f1, 0x405003f0,
1791};
1792
1793/*
1794 STAC 9221 A1 pin configs for
1795 102801D7 (Dell XPS M1210)
1796*/
1797static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001798 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1799 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001800 0x508003f3, 0x405003f4,
1801};
1802
Matt Porter403d1942005-11-29 15:00:51 +01001803static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001804 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001805 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1806 0x02a19120, 0x40000100,
1807};
1808
1809static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001810 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1811 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001812 0x02a19320, 0x40000100,
1813};
1814
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001815static unsigned int intel_mac_v1_pin_configs[10] = {
1816 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1817 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001818 0x400000fc, 0x400000fb,
1819};
1820
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001821static unsigned int intel_mac_v2_pin_configs[10] = {
1822 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1823 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001824 0x400000fc, 0x400000fb,
1825};
1826
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001827static unsigned int intel_mac_v3_pin_configs[10] = {
1828 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1829 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1830 0x400000fc, 0x400000fb,
1831};
1832
1833static unsigned int intel_mac_v4_pin_configs[10] = {
1834 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1835 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1836 0x400000fc, 0x400000fb,
1837};
1838
1839static unsigned int intel_mac_v5_pin_configs[10] = {
1840 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1841 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1842 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001843};
1844
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001845static unsigned int ecs202_pin_configs[10] = {
1846 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1847 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1848 0x9037012e, 0x40e000f2,
1849};
Takashi Iwai76c08822007-06-19 12:17:42 +02001850
Takashi Iwai19039bd2006-06-28 15:52:16 +02001851static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001852 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001853 [STAC_D945GTP3] = d945gtp3_pin_configs,
1854 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001855 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1856 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1857 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1858 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1859 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001860 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001861 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001862 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1863 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1864 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1865 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1866 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1867 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001868 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001869 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1870 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1871 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1872 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001873};
1874
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001875static const char *stac922x_models[STAC_922X_MODELS] = {
1876 [STAC_D945_REF] = "ref",
1877 [STAC_D945GTP5] = "5stack",
1878 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001879 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1880 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1881 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1882 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1883 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001884 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001885 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001886 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001887 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001888 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1889 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001890 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001891 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001892 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001893 [STAC_922X_DELL_D81] = "dell-d81",
1894 [STAC_922X_DELL_D82] = "dell-d82",
1895 [STAC_922X_DELL_M81] = "dell-m81",
1896 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001897};
1898
1899static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1900 /* SigmaTel reference board */
1901 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1902 "DFI LanParty", STAC_D945_REF),
1903 /* Intel 945G based systems */
1904 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1905 "Intel D945G", STAC_D945GTP3),
1906 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1907 "Intel D945G", STAC_D945GTP3),
1908 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1909 "Intel D945G", STAC_D945GTP3),
1910 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1911 "Intel D945G", STAC_D945GTP3),
1912 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1913 "Intel D945G", STAC_D945GTP3),
1914 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1915 "Intel D945G", STAC_D945GTP3),
1916 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1917 "Intel D945G", STAC_D945GTP3),
1918 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1919 "Intel D945G", STAC_D945GTP3),
1920 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1921 "Intel D945G", STAC_D945GTP3),
1922 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1923 "Intel D945G", STAC_D945GTP3),
1924 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1925 "Intel D945G", STAC_D945GTP3),
1926 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1927 "Intel D945G", STAC_D945GTP3),
1928 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1929 "Intel D945G", STAC_D945GTP3),
1930 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1931 "Intel D945G", STAC_D945GTP3),
1932 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1933 "Intel D945G", STAC_D945GTP3),
1934 /* Intel D945G 5-stack systems */
1935 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1936 "Intel D945G", STAC_D945GTP5),
1937 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1938 "Intel D945G", STAC_D945GTP5),
1939 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1940 "Intel D945G", STAC_D945GTP5),
1941 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1942 "Intel D945G", STAC_D945GTP5),
1943 /* Intel 945P based systems */
1944 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1945 "Intel D945P", STAC_D945GTP3),
1946 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1947 "Intel D945P", STAC_D945GTP3),
1948 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1949 "Intel D945P", STAC_D945GTP3),
1950 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1951 "Intel D945P", STAC_D945GTP3),
1952 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1953 "Intel D945P", STAC_D945GTP3),
1954 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1955 "Intel D945P", STAC_D945GTP5),
1956 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08001957 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001958 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001959 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001960 /* Dell systems */
1961 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1962 "unknown Dell", STAC_922X_DELL_D81),
1963 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1964 "unknown Dell", STAC_922X_DELL_D81),
1965 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1966 "unknown Dell", STAC_922X_DELL_D81),
1967 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1968 "unknown Dell", STAC_922X_DELL_D82),
1969 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1970 "unknown Dell", STAC_922X_DELL_M81),
1971 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1972 "unknown Dell", STAC_922X_DELL_D82),
1973 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1974 "unknown Dell", STAC_922X_DELL_D81),
1975 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1976 "unknown Dell", STAC_922X_DELL_D81),
1977 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1978 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001979 /* ECS/PC Chips boards */
1980 SND_PCI_QUIRK(0x1019, 0x2144,
1981 "ECS/PC chips", STAC_ECS_202),
1982 SND_PCI_QUIRK(0x1019, 0x2608,
1983 "ECS/PC chips", STAC_ECS_202),
1984 SND_PCI_QUIRK(0x1019, 0x2633,
1985 "ECS/PC chips P17G/1333", STAC_ECS_202),
1986 SND_PCI_QUIRK(0x1019, 0x2811,
1987 "ECS/PC chips", STAC_ECS_202),
1988 SND_PCI_QUIRK(0x1019, 0x2812,
1989 "ECS/PC chips", STAC_ECS_202),
1990 SND_PCI_QUIRK(0x1019, 0x2813,
1991 "ECS/PC chips", STAC_ECS_202),
1992 SND_PCI_QUIRK(0x1019, 0x2814,
1993 "ECS/PC chips", STAC_ECS_202),
1994 SND_PCI_QUIRK(0x1019, 0x2815,
1995 "ECS/PC chips", STAC_ECS_202),
1996 SND_PCI_QUIRK(0x1019, 0x2816,
1997 "ECS/PC chips", STAC_ECS_202),
1998 SND_PCI_QUIRK(0x1019, 0x2817,
1999 "ECS/PC chips", STAC_ECS_202),
2000 SND_PCI_QUIRK(0x1019, 0x2818,
2001 "ECS/PC chips", STAC_ECS_202),
2002 SND_PCI_QUIRK(0x1019, 0x2819,
2003 "ECS/PC chips", STAC_ECS_202),
2004 SND_PCI_QUIRK(0x1019, 0x2820,
2005 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01002006 {} /* terminator */
2007};
2008
Matt Porter3cc08dc2006-01-23 15:27:49 +01002009static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002010 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2011 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2012 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2013 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002014};
2015
Tobin Davis93ed1502006-09-01 21:03:12 +02002016static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002017 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2018 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2019 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2020 0x40000100, 0x40000100
2021};
2022
Tobin Davis93ed1502006-09-01 21:03:12 +02002023static unsigned int d965_5st_pin_configs[14] = {
2024 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2025 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2026 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2027 0x40000100, 0x40000100
2028};
2029
Tobin Davis4ff076e2007-08-07 11:48:12 +02002030static unsigned int dell_3st_pin_configs[14] = {
2031 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2032 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002033 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002034 0x40c003fc, 0x40000100
2035};
2036
Tobin Davis93ed1502006-09-01 21:03:12 +02002037static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002038 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002039 [STAC_D965_REF] = ref927x_pin_configs,
2040 [STAC_D965_3ST] = d965_3st_pin_configs,
2041 [STAC_D965_5ST] = d965_5st_pin_configs,
2042 [STAC_DELL_3ST] = dell_3st_pin_configs,
2043 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002044};
2045
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002046static const char *stac927x_models[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002047 [STAC_D965_REF_NO_JD] = "ref-no-jd",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002048 [STAC_D965_REF] = "ref",
2049 [STAC_D965_3ST] = "3stack",
2050 [STAC_D965_5ST] = "5stack",
2051 [STAC_DELL_3ST] = "dell-3stack",
2052 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002053};
2054
2055static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2056 /* SigmaTel reference board */
2057 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2058 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002059 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002060 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2061 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002062 /* 965 based 3 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002063 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
2064 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
2065 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
2066 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
2067 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
2068 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
2069 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
2070 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
2071 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
2072 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
2073 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
2074 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
2075 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
2076 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
2077 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
2078 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002079 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002080 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002081 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002082 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2083 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002084 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002085 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2086 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002087 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02002088 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002089 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2090 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2091 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2092 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002093 /* 965 based 5 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002094 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2095 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2096 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2097 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2098 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2099 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2100 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2101 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2102 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002103 {} /* terminator */
2104};
2105
Matt Porterf3302a52006-07-31 12:49:34 +02002106static unsigned int ref9205_pin_configs[12] = {
2107 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002108 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002109 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002110};
2111
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002112/*
2113 STAC 9205 pin configs for
2114 102801F1
2115 102801F2
2116 102801FC
2117 102801FD
2118 10280204
2119 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002120 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002121*/
2122static unsigned int dell_9205_m42_pin_configs[12] = {
2123 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2124 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2125 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2126};
2127
2128/*
2129 STAC 9205 pin configs for
2130 102801F9
2131 102801FA
2132 102801FE
2133 102801FF (Dell Precision M4300)
2134 10280206
2135 10280200
2136 10280201
2137*/
2138static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002139 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2140 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2141 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2142};
2143
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002144static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002145 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2146 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2147 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2148};
2149
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002150static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002151 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002152 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2153 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2154 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Matt Porterf3302a52006-07-31 12:49:34 +02002155};
2156
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002157static const char *stac9205_models[STAC_9205_MODELS] = {
2158 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002159 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002160 [STAC_9205_DELL_M43] = "dell-m43",
2161 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002162};
2163
2164static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2165 /* SigmaTel reference board */
2166 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2167 "DFI LanParty", STAC_9205_REF),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002168 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2169 "unknown Dell", STAC_9205_DELL_M42),
2170 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2171 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002172 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002173 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002174 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2175 "Dell Precision", STAC_9205_DELL_M43),
2176 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2177 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002178 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2179 "unknown Dell", STAC_9205_DELL_M42),
2180 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2181 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002182 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2183 "Dell Precision", STAC_9205_DELL_M43),
2184 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002185 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002186 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2187 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002188 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2189 "Dell Precision", STAC_9205_DELL_M43),
2190 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2191 "Dell Precision", STAC_9205_DELL_M43),
2192 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2193 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002194 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2195 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002196 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2197 "Dell Vostro 1500", STAC_9205_DELL_M42),
Matt Porterf3302a52006-07-31 12:49:34 +02002198 {} /* terminator */
2199};
2200
Richard Fish11b44bb2006-08-23 18:31:34 +02002201static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2202{
2203 int i;
2204 struct sigmatel_spec *spec = codec->spec;
2205
2206 if (! spec->bios_pin_configs) {
2207 spec->bios_pin_configs = kcalloc(spec->num_pins,
2208 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
2209 if (! spec->bios_pin_configs)
2210 return -ENOMEM;
2211 }
2212
2213 for (i = 0; i < spec->num_pins; i++) {
2214 hda_nid_t nid = spec->pin_nids[i];
2215 unsigned int pin_cfg;
2216
2217 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2218 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2219 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2220 nid, pin_cfg);
2221 spec->bios_pin_configs[i] = pin_cfg;
2222 }
2223
2224 return 0;
2225}
2226
Matthew Ranostay87d48362007-07-17 11:52:24 +02002227static void stac92xx_set_config_reg(struct hda_codec *codec,
2228 hda_nid_t pin_nid, unsigned int pin_config)
2229{
2230 int i;
2231 snd_hda_codec_write(codec, pin_nid, 0,
2232 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2233 pin_config & 0x000000ff);
2234 snd_hda_codec_write(codec, pin_nid, 0,
2235 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2236 (pin_config & 0x0000ff00) >> 8);
2237 snd_hda_codec_write(codec, pin_nid, 0,
2238 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2239 (pin_config & 0x00ff0000) >> 16);
2240 snd_hda_codec_write(codec, pin_nid, 0,
2241 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2242 pin_config >> 24);
2243 i = snd_hda_codec_read(codec, pin_nid, 0,
2244 AC_VERB_GET_CONFIG_DEFAULT,
2245 0x00);
2246 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2247 pin_nid, i);
2248}
2249
Matt2f2f4252005-04-13 14:45:30 +02002250static void stac92xx_set_config_regs(struct hda_codec *codec)
2251{
2252 int i;
2253 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002254
Matthew Ranostay87d48362007-07-17 11:52:24 +02002255 if (!spec->pin_configs)
2256 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002257
Matthew Ranostay87d48362007-07-17 11:52:24 +02002258 for (i = 0; i < spec->num_pins; i++)
2259 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2260 spec->pin_configs[i]);
Matt2f2f4252005-04-13 14:45:30 +02002261}
Matt2f2f4252005-04-13 14:45:30 +02002262
Matt2f2f4252005-04-13 14:45:30 +02002263/*
2264 * Analog playback callbacks
2265 */
2266static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2267 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002268 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002269{
2270 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002271 if (spec->stream_delay)
2272 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002273 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2274 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002275}
2276
2277static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2278 struct hda_codec *codec,
2279 unsigned int stream_tag,
2280 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002281 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002282{
2283 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002284 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002285}
2286
2287static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2288 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002289 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002290{
2291 struct sigmatel_spec *spec = codec->spec;
2292 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2293}
2294
2295/*
Mattdabbed62005-06-14 10:19:34 +02002296 * Digital playback callbacks
2297 */
2298static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2299 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002300 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002301{
2302 struct sigmatel_spec *spec = codec->spec;
2303 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2304}
2305
2306static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2307 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002308 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002309{
2310 struct sigmatel_spec *spec = codec->spec;
2311 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2312}
2313
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002314static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2315 struct hda_codec *codec,
2316 unsigned int stream_tag,
2317 unsigned int format,
2318 struct snd_pcm_substream *substream)
2319{
2320 struct sigmatel_spec *spec = codec->spec;
2321 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2322 stream_tag, format, substream);
2323}
2324
Mattdabbed62005-06-14 10:19:34 +02002325
2326/*
Matt2f2f4252005-04-13 14:45:30 +02002327 * Analog capture callbacks
2328 */
2329static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2330 struct hda_codec *codec,
2331 unsigned int stream_tag,
2332 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002333 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002334{
2335 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002336 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002337
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002338 if (spec->powerdown_adcs) {
2339 msleep(40);
2340 snd_hda_codec_write_cache(codec, nid, 0,
2341 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2342 }
2343 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002344 return 0;
2345}
2346
2347static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2348 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002349 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002350{
2351 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002352 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002353
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002354 snd_hda_codec_cleanup_stream(codec, nid);
2355 if (spec->powerdown_adcs)
2356 snd_hda_codec_write_cache(codec, nid, 0,
2357 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002358 return 0;
2359}
2360
Mattdabbed62005-06-14 10:19:34 +02002361static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2362 .substreams = 1,
2363 .channels_min = 2,
2364 .channels_max = 2,
2365 /* NID is set in stac92xx_build_pcms */
2366 .ops = {
2367 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002368 .close = stac92xx_dig_playback_pcm_close,
2369 .prepare = stac92xx_dig_playback_pcm_prepare
Mattdabbed62005-06-14 10:19:34 +02002370 },
2371};
2372
2373static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2374 .substreams = 1,
2375 .channels_min = 2,
2376 .channels_max = 2,
2377 /* NID is set in stac92xx_build_pcms */
2378};
2379
Matt2f2f4252005-04-13 14:45:30 +02002380static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2381 .substreams = 1,
2382 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002383 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002384 .nid = 0x02, /* NID to query formats and rates */
2385 .ops = {
2386 .open = stac92xx_playback_pcm_open,
2387 .prepare = stac92xx_playback_pcm_prepare,
2388 .cleanup = stac92xx_playback_pcm_cleanup
2389 },
2390};
2391
Matt Porter3cc08dc2006-01-23 15:27:49 +01002392static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2393 .substreams = 1,
2394 .channels_min = 2,
2395 .channels_max = 2,
2396 .nid = 0x06, /* NID to query formats and rates */
2397 .ops = {
2398 .open = stac92xx_playback_pcm_open,
2399 .prepare = stac92xx_playback_pcm_prepare,
2400 .cleanup = stac92xx_playback_pcm_cleanup
2401 },
2402};
2403
Matt2f2f4252005-04-13 14:45:30 +02002404static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002405 .channels_min = 2,
2406 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002407 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002408 .ops = {
2409 .prepare = stac92xx_capture_pcm_prepare,
2410 .cleanup = stac92xx_capture_pcm_cleanup
2411 },
2412};
2413
2414static int stac92xx_build_pcms(struct hda_codec *codec)
2415{
2416 struct sigmatel_spec *spec = codec->spec;
2417 struct hda_pcm *info = spec->pcm_rec;
2418
2419 codec->num_pcms = 1;
2420 codec->pcm_info = info;
2421
Mattc7d4b2f2005-06-27 14:59:41 +02002422 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002423 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Matt2f2f4252005-04-13 14:45:30 +02002424 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002425 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002426 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002427
2428 if (spec->alt_switch) {
2429 codec->num_pcms++;
2430 info++;
2431 info->name = "STAC92xx Analog Alt";
2432 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2433 }
Matt2f2f4252005-04-13 14:45:30 +02002434
Mattdabbed62005-06-14 10:19:34 +02002435 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2436 codec->num_pcms++;
2437 info++;
2438 info->name = "STAC92xx Digital";
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002439 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Mattdabbed62005-06-14 10:19:34 +02002440 if (spec->multiout.dig_out_nid) {
2441 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2442 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2443 }
2444 if (spec->dig_in_nid) {
2445 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2446 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2447 }
2448 }
2449
Matt2f2f4252005-04-13 14:45:30 +02002450 return 0;
2451}
2452
Takashi Iwaic960a032006-03-23 17:06:28 +01002453static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2454{
2455 unsigned int pincap = snd_hda_param_read(codec, nid,
2456 AC_PAR_PIN_CAP);
2457 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2458 if (pincap & AC_PINCAP_VREF_100)
2459 return AC_PINCTL_VREF_100;
2460 if (pincap & AC_PINCAP_VREF_80)
2461 return AC_PINCTL_VREF_80;
2462 if (pincap & AC_PINCAP_VREF_50)
2463 return AC_PINCTL_VREF_50;
2464 if (pincap & AC_PINCAP_VREF_GRD)
2465 return AC_PINCTL_VREF_GRD;
2466 return 0;
2467}
2468
Matt Porter403d1942005-11-29 15:00:51 +01002469static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2470
2471{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002472 snd_hda_codec_write_cache(codec, nid, 0,
2473 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002474}
2475
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002476#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2477
2478static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2479 struct snd_ctl_elem_value *ucontrol)
2480{
2481 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2482 struct sigmatel_spec *spec = codec->spec;
2483
Takashi Iwaid7a89432008-11-12 09:48:04 +01002484 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002485 return 0;
2486}
2487
2488static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2489 struct snd_ctl_elem_value *ucontrol)
2490{
2491 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2492 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002493 int nid = kcontrol->private_value;
2494
2495 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002496
2497 /* check to be sure that the ports are upto date with
2498 * switch changes
2499 */
2500 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2501
2502 return 1;
2503}
2504
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002505#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002506
2507static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2508{
2509 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2510 struct sigmatel_spec *spec = codec->spec;
2511 int io_idx = kcontrol-> private_value & 0xff;
2512
2513 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2514 return 0;
2515}
2516
2517static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2518{
2519 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2520 struct sigmatel_spec *spec = codec->spec;
2521 hda_nid_t nid = kcontrol->private_value >> 8;
2522 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002523 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002524
2525 spec->io_switch[io_idx] = val;
2526
2527 if (val)
2528 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002529 else {
2530 unsigned int pinctl = AC_PINCTL_IN_EN;
2531 if (io_idx) /* set VREF for mic */
2532 pinctl |= stac92xx_get_vref(codec, nid);
2533 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2534 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002535
2536 /* check the auto-mute again: we need to mute/unmute the speaker
2537 * appropriately according to the pin direction
2538 */
2539 if (spec->hp_detect)
2540 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2541
Matt Porter403d1942005-11-29 15:00:51 +01002542 return 1;
2543}
2544
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002545#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2546
2547static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2548 struct snd_ctl_elem_value *ucontrol)
2549{
2550 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2551 struct sigmatel_spec *spec = codec->spec;
2552
2553 ucontrol->value.integer.value[0] = spec->clfe_swap;
2554 return 0;
2555}
2556
2557static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2558 struct snd_ctl_elem_value *ucontrol)
2559{
2560 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2561 struct sigmatel_spec *spec = codec->spec;
2562 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002563 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002564
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002565 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002566 return 0;
2567
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002568 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002569
2570 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2571 spec->clfe_swap ? 0x4 : 0x0);
2572
2573 return 1;
2574}
2575
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002576#define STAC_CODEC_HP_SWITCH(xname) \
2577 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2578 .name = xname, \
2579 .index = 0, \
2580 .info = stac92xx_hp_switch_info, \
2581 .get = stac92xx_hp_switch_get, \
2582 .put = stac92xx_hp_switch_put, \
2583 }
2584
Matt Porter403d1942005-11-29 15:00:51 +01002585#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2586 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2587 .name = xname, \
2588 .index = 0, \
2589 .info = stac92xx_io_switch_info, \
2590 .get = stac92xx_io_switch_get, \
2591 .put = stac92xx_io_switch_put, \
2592 .private_value = xpval, \
2593 }
2594
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002595#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2596 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2597 .name = xname, \
2598 .index = 0, \
2599 .info = stac92xx_clfe_switch_info, \
2600 .get = stac92xx_clfe_switch_get, \
2601 .put = stac92xx_clfe_switch_put, \
2602 .private_value = xpval, \
2603 }
Matt Porter403d1942005-11-29 15:00:51 +01002604
Mattc7d4b2f2005-06-27 14:59:41 +02002605enum {
2606 STAC_CTL_WIDGET_VOL,
2607 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002608 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002609 STAC_CTL_WIDGET_AMP_MUX,
2610 STAC_CTL_WIDGET_AMP_VOL,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002611 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002612 STAC_CTL_WIDGET_IO_SWITCH,
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002613 STAC_CTL_WIDGET_CLFE_SWITCH
Mattc7d4b2f2005-06-27 14:59:41 +02002614};
2615
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002616static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002617 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2618 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002619 STAC_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002620 STAC_AMP_MUX,
2621 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002622 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002623 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002624 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002625};
2626
2627/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002628static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2629 struct snd_kcontrol_new *ktemp,
2630 int idx, const char *name,
2631 unsigned long val)
Mattc7d4b2f2005-06-27 14:59:41 +02002632{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002633 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002634
2635 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2636 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2637
2638 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2639 if (! knew)
2640 return -ENOMEM;
2641 if (spec->kctl_alloc) {
2642 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2643 kfree(spec->kctl_alloc);
2644 }
2645 spec->kctl_alloc = knew;
2646 spec->num_kctl_alloc = num;
2647 }
2648
2649 knew = &spec->kctl_alloc[spec->num_kctl_used];
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002650 *knew = *ktemp;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002651 knew->index = idx;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002652 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002653 if (!knew->name)
Mattc7d4b2f2005-06-27 14:59:41 +02002654 return -ENOMEM;
2655 knew->private_value = val;
2656 spec->num_kctl_used++;
2657 return 0;
2658}
2659
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002660static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2661 int type, int idx, const char *name,
2662 unsigned long val)
2663{
2664 return stac92xx_add_control_temp(spec,
2665 &stac92xx_control_templates[type],
2666 idx, name, val);
2667}
2668
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002669
2670/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002671static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2672 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002673{
2674 return stac92xx_add_control_idx(spec, type, 0, name, val);
2675}
2676
Matt Porter403d1942005-11-29 15:00:51 +01002677/* flag inputs as additional dynamic lineouts */
2678static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2679{
2680 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002681 unsigned int wcaps, wtype;
2682 int i, num_dacs = 0;
2683
2684 /* use the wcaps cache to count all DACs available for line-outs */
2685 for (i = 0; i < codec->num_nodes; i++) {
2686 wcaps = codec->wcaps[i];
2687 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002688
Steve Longerbeam7b043892007-05-03 20:50:03 +02002689 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2690 num_dacs++;
2691 }
Matt Porter403d1942005-11-29 15:00:51 +01002692
Steve Longerbeam7b043892007-05-03 20:50:03 +02002693 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2694
Matt Porter403d1942005-11-29 15:00:51 +01002695 switch (cfg->line_outs) {
2696 case 3:
2697 /* add line-in as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002698 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002699 cfg->line_out_pins[cfg->line_outs] =
2700 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002701 spec->line_switch = 1;
2702 cfg->line_outs++;
2703 }
2704 break;
2705 case 2:
2706 /* add line-in as clfe and mic as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002707 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002708 cfg->line_out_pins[cfg->line_outs] =
2709 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002710 spec->line_switch = 1;
2711 cfg->line_outs++;
2712 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002713 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002714 cfg->line_out_pins[cfg->line_outs] =
2715 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002716 spec->mic_switch = 1;
2717 cfg->line_outs++;
2718 }
2719 break;
2720 case 1:
2721 /* add line-in as surr and mic as clfe */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002722 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002723 cfg->line_out_pins[cfg->line_outs] =
2724 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002725 spec->line_switch = 1;
2726 cfg->line_outs++;
2727 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002728 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002729 cfg->line_out_pins[cfg->line_outs] =
2730 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002731 spec->mic_switch = 1;
2732 cfg->line_outs++;
2733 }
2734 break;
2735 }
2736
2737 return 0;
2738}
2739
Steve Longerbeam7b043892007-05-03 20:50:03 +02002740
2741static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2742{
2743 int i;
2744
2745 for (i = 0; i < spec->multiout.num_dacs; i++) {
2746 if (spec->multiout.dac_nids[i] == nid)
2747 return 1;
2748 }
2749
2750 return 0;
2751}
2752
Matt Porter3cc08dc2006-01-23 15:27:49 +01002753/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02002754 * Fill in the dac_nids table from the parsed pin configuration
2755 * This function only works when every pin in line_out_pins[]
2756 * contains atleast one DAC in its connection list. Some 92xx
2757 * codecs are not connected directly to a DAC, such as the 9200
2758 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002759 */
Takashi Iwai19039bd2006-06-28 15:52:16 +02002760static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaidf802952007-07-02 19:18:00 +02002761 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002762{
2763 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002764 int i, j, conn_len = 0;
2765 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2766 unsigned int wcaps, wtype;
2767
Mattc7d4b2f2005-06-27 14:59:41 +02002768 for (i = 0; i < cfg->line_outs; i++) {
2769 nid = cfg->line_out_pins[i];
Steve Longerbeam7b043892007-05-03 20:50:03 +02002770 conn_len = snd_hda_get_connections(codec, nid, conn,
2771 HDA_MAX_CONNECTIONS);
2772 for (j = 0; j < conn_len; j++) {
2773 wcaps = snd_hda_param_read(codec, conn[j],
2774 AC_PAR_AUDIO_WIDGET_CAP);
2775 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002776 if (wtype != AC_WID_AUD_OUT ||
2777 (wcaps & AC_WCAP_DIGITAL))
2778 continue;
2779 /* conn[j] is a DAC routed to this line-out */
2780 if (!is_in_dac_nids(spec, conn[j]))
2781 break;
2782 }
2783
2784 if (j == conn_len) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002785 if (spec->multiout.num_dacs > 0) {
2786 /* we have already working output pins,
2787 * so let's drop the broken ones again
2788 */
2789 cfg->line_outs = spec->multiout.num_dacs;
2790 break;
2791 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002792 /* error out, no available DAC found */
2793 snd_printk(KERN_ERR
2794 "%s: No available DAC for pin 0x%x\n",
2795 __func__, nid);
2796 return -ENODEV;
2797 }
2798
2799 spec->multiout.dac_nids[i] = conn[j];
2800 spec->multiout.num_dacs++;
2801 if (conn_len > 1) {
2802 /* select this DAC in the pin's input mux */
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002803 snd_hda_codec_write_cache(codec, nid, 0,
2804 AC_VERB_SET_CONNECT_SEL, j);
Steve Longerbeam7b043892007-05-03 20:50:03 +02002805
2806 }
Mattc7d4b2f2005-06-27 14:59:41 +02002807 }
2808
Steve Longerbeam7b043892007-05-03 20:50:03 +02002809 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2810 spec->multiout.num_dacs,
2811 spec->multiout.dac_nids[0],
2812 spec->multiout.dac_nids[1],
2813 spec->multiout.dac_nids[2],
2814 spec->multiout.dac_nids[3],
2815 spec->multiout.dac_nids[4]);
Mattc7d4b2f2005-06-27 14:59:41 +02002816 return 0;
2817}
2818
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002819/* create volume control/switch for the given prefx type */
2820static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2821{
2822 char name[32];
2823 int err;
2824
2825 sprintf(name, "%s Playback Volume", pfx);
2826 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2827 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2828 if (err < 0)
2829 return err;
2830 sprintf(name, "%s Playback Switch", pfx);
2831 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2832 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2833 if (err < 0)
2834 return err;
2835 return 0;
2836}
2837
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002838static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2839{
2840 if (!spec->multiout.hp_nid)
2841 spec->multiout.hp_nid = nid;
2842 else if (spec->multiout.num_dacs > 4) {
2843 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2844 return 1;
2845 } else {
2846 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2847 spec->multiout.num_dacs++;
2848 }
2849 return 0;
2850}
2851
2852static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2853{
2854 if (is_in_dac_nids(spec, nid))
2855 return 1;
2856 if (spec->multiout.hp_nid == nid)
2857 return 1;
2858 return 0;
2859}
2860
Mattc7d4b2f2005-06-27 14:59:41 +02002861/* add playback controls from the parsed DAC table */
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002862static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
Takashi Iwai19039bd2006-06-28 15:52:16 +02002863 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002864{
Takashi Iwai19039bd2006-06-28 15:52:16 +02002865 static const char *chname[4] = {
2866 "Front", "Surround", NULL /*CLFE*/, "Side"
2867 };
Matthew Ranostayd21995e2008-10-13 13:22:45 -04002868 hda_nid_t nid = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02002869 int i, err;
2870
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002871 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002872 unsigned int wid_caps, pincap;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002873
2874
Takashi Iwai40ac8c42008-02-29 14:16:17 +01002875 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
Matt Porter403d1942005-11-29 15:00:51 +01002876 if (!spec->multiout.dac_nids[i])
Mattc7d4b2f2005-06-27 14:59:41 +02002877 continue;
2878
2879 nid = spec->multiout.dac_nids[i];
2880
2881 if (i == 2) {
2882 /* Center/LFE */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002883 err = create_controls(spec, "Center", nid, 1);
2884 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002885 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002886 err = create_controls(spec, "LFE", nid, 2);
2887 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002888 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002889
2890 wid_caps = get_wcaps(codec, nid);
2891
2892 if (wid_caps & AC_WCAP_LR_SWAP) {
2893 err = stac92xx_add_control(spec,
2894 STAC_CTL_WIDGET_CLFE_SWITCH,
2895 "Swap Center/LFE Playback Switch", nid);
2896
2897 if (err < 0)
2898 return err;
2899 }
2900
Mattc7d4b2f2005-06-27 14:59:41 +02002901 } else {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002902 err = create_controls(spec, chname[i], nid, 3);
2903 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002904 return err;
2905 }
2906 }
2907
Matthew Ranostayfedb7562008-09-23 21:46:30 -04002908 if ((spec->multiout.num_dacs - cfg->line_outs) > 0 &&
Takashi Iwai8f55c1e2008-12-19 14:02:32 +01002909 cfg->hp_outs == 1 && !spec->multiout.hp_nid)
Matthew Ranostayfedb7562008-09-23 21:46:30 -04002910 spec->multiout.hp_nid = nid;
2911
Takashi Iwai95026622008-11-24 07:51:11 +01002912 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002913 err = stac92xx_add_control(spec,
2914 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01002915 "Headphone as Line Out Switch",
2916 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002917 if (err < 0)
2918 return err;
2919 }
2920
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002921 if (spec->line_switch) {
2922 nid = cfg->input_pins[AUTO_PIN_LINE];
2923 pincap = snd_hda_param_read(codec, nid,
2924 AC_PAR_PIN_CAP);
2925 if (pincap & AC_PINCAP_OUT) {
2926 err = stac92xx_add_control(spec,
2927 STAC_CTL_WIDGET_IO_SWITCH,
2928 "Line In as Output Switch", nid << 8);
2929 if (err < 0)
2930 return err;
2931 }
2932 }
Matt Porter403d1942005-11-29 15:00:51 +01002933
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002934 if (spec->mic_switch) {
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002935 unsigned int def_conf;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002936 unsigned int mic_pin = AUTO_PIN_MIC;
2937again:
2938 nid = cfg->input_pins[mic_pin];
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002939 def_conf = snd_hda_codec_read(codec, nid, 0,
2940 AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002941 /* some laptops have an internal analog microphone
2942 * which can't be used as a output */
2943 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2944 pincap = snd_hda_param_read(codec, nid,
2945 AC_PAR_PIN_CAP);
2946 if (pincap & AC_PINCAP_OUT) {
2947 err = stac92xx_add_control(spec,
2948 STAC_CTL_WIDGET_IO_SWITCH,
2949 "Mic as Output Switch", (nid << 8) | 1);
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002950 nid = snd_hda_codec_read(codec, nid, 0,
2951 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2952 if (!check_in_dac_nids(spec, nid))
2953 add_spec_dacs(spec, nid);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002954 if (err < 0)
2955 return err;
2956 }
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002957 } else if (mic_pin == AUTO_PIN_MIC) {
2958 mic_pin = AUTO_PIN_FRONT_MIC;
2959 goto again;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002960 }
2961 }
Matt Porter403d1942005-11-29 15:00:51 +01002962
Mattc7d4b2f2005-06-27 14:59:41 +02002963 return 0;
2964}
2965
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002966/* add playback controls for Speaker and HP outputs */
2967static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2968 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002969{
2970 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02002971 hda_nid_t nid;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002972 int i, old_num_dacs, err;
Mattc7d4b2f2005-06-27 14:59:41 +02002973
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002974 old_num_dacs = spec->multiout.num_dacs;
2975 for (i = 0; i < cfg->hp_outs; i++) {
2976 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2977 if (wid_caps & AC_WCAP_UNSOL_CAP)
2978 spec->hp_detect = 1;
2979 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2980 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2981 if (check_in_dac_nids(spec, nid))
2982 nid = 0;
2983 if (! nid)
Mattc7d4b2f2005-06-27 14:59:41 +02002984 continue;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002985 add_spec_dacs(spec, nid);
2986 }
2987 for (i = 0; i < cfg->speaker_outs; i++) {
Steve Longerbeam7b043892007-05-03 20:50:03 +02002988 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002989 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2990 if (check_in_dac_nids(spec, nid))
2991 nid = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002992 if (! nid)
2993 continue;
2994 add_spec_dacs(spec, nid);
Mattc7d4b2f2005-06-27 14:59:41 +02002995 }
Matthew Ranostay1b290a52007-07-12 15:17:34 +02002996 for (i = 0; i < cfg->line_outs; i++) {
2997 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2998 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2999 if (check_in_dac_nids(spec, nid))
3000 nid = 0;
3001 if (! nid)
3002 continue;
3003 add_spec_dacs(spec, nid);
3004 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003005 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
3006 static const char *pfxs[] = {
3007 "Speaker", "External Speaker", "Speaker2",
3008 };
3009 err = create_controls(spec, pfxs[i - old_num_dacs],
3010 spec->multiout.dac_nids[i], 3);
3011 if (err < 0)
3012 return err;
3013 }
3014 if (spec->multiout.hp_nid) {
Takashi Iwai2626a262008-03-14 09:18:32 +01003015 err = create_controls(spec, "Headphone",
3016 spec->multiout.hp_nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003017 if (err < 0)
3018 return err;
3019 }
Mattc7d4b2f2005-06-27 14:59:41 +02003020
3021 return 0;
3022}
3023
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003024/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003025static const char *stac92xx_mono_labels[4] = {
3026 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003027};
3028
3029/* create mono mux for mono out on capable codecs */
3030static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3031{
3032 struct sigmatel_spec *spec = codec->spec;
3033 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3034 int i, num_cons;
3035 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3036
3037 num_cons = snd_hda_get_connections(codec,
3038 spec->mono_nid,
3039 con_lst,
3040 HDA_MAX_NUM_INPUTS);
3041 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3042 return -EINVAL;
3043
3044 for (i = 0; i < num_cons; i++) {
3045 mono_mux->items[mono_mux->num_items].label =
3046 stac92xx_mono_labels[i];
3047 mono_mux->items[mono_mux->num_items].index = i;
3048 mono_mux->num_items++;
3049 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003050
3051 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3052 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003053}
3054
Matthew Ranostay89385032008-09-11 09:49:39 -04003055/* labels for amp mux outputs */
3056static const char *stac92xx_amp_labels[3] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04003057 "Front Microphone", "Microphone", "Line In",
Matthew Ranostay89385032008-09-11 09:49:39 -04003058};
3059
3060/* create amp out controls mux on capable codecs */
3061static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3062{
3063 struct sigmatel_spec *spec = codec->spec;
3064 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3065 int i, err;
3066
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003067 for (i = 0; i < spec->num_amps; i++) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003068 amp_mux->items[amp_mux->num_items].label =
3069 stac92xx_amp_labels[i];
3070 amp_mux->items[amp_mux->num_items].index = i;
3071 amp_mux->num_items++;
3072 }
3073
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003074 if (spec->num_amps > 1) {
3075 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3076 "Amp Selector Capture Switch", 0);
3077 if (err < 0)
3078 return err;
3079 }
Matthew Ranostay89385032008-09-11 09:49:39 -04003080 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3081 "Amp Capture Volume",
3082 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3083}
3084
3085
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003086/* create PC beep volume controls */
3087static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3088 hda_nid_t nid)
3089{
3090 struct sigmatel_spec *spec = codec->spec;
3091 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3092 int err;
3093
3094 /* check for mute support for the the amp */
3095 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3096 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3097 "PC Beep Playback Switch",
3098 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3099 if (err < 0)
3100 return err;
3101 }
3102
3103 /* check to see if there is volume support for the amp */
3104 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3105 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3106 "PC Beep Playback Volume",
3107 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3108 if (err < 0)
3109 return err;
3110 }
3111 return 0;
3112}
3113
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003114#ifdef CONFIG_SND_HDA_INPUT_BEEP
3115#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3116
3117static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3118 struct snd_ctl_elem_value *ucontrol)
3119{
3120 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3121 ucontrol->value.integer.value[0] = codec->beep->enabled;
3122 return 0;
3123}
3124
3125static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3126 struct snd_ctl_elem_value *ucontrol)
3127{
3128 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3129 int enabled = !!ucontrol->value.integer.value[0];
3130 if (codec->beep->enabled != enabled) {
3131 codec->beep->enabled = enabled;
3132 return 1;
3133 }
3134 return 0;
3135}
3136
3137static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3138 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3139 .info = stac92xx_dig_beep_switch_info,
3140 .get = stac92xx_dig_beep_switch_get,
3141 .put = stac92xx_dig_beep_switch_put,
3142};
3143
3144static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3145{
3146 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3147 0, "PC Beep Playback Switch", 0);
3148}
3149#endif
3150
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003151static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3152{
3153 struct sigmatel_spec *spec = codec->spec;
3154 int wcaps, nid, i, err = 0;
3155
3156 for (i = 0; i < spec->num_muxes; i++) {
3157 nid = spec->mux_nids[i];
3158 wcaps = get_wcaps(codec, nid);
3159
3160 if (wcaps & AC_WCAP_OUT_AMP) {
3161 err = stac92xx_add_control_idx(spec,
3162 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3163 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3164 if (err < 0)
3165 return err;
3166 }
3167 }
3168 return 0;
3169};
3170
Matthew Ranostayd9737752008-09-07 12:03:41 +02003171static const char *stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003172 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003173};
3174
3175static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3176{
3177 struct sigmatel_spec *spec = codec->spec;
3178 struct hda_input_mux *spdif_mux = &spec->private_smux;
Matthew Ranostay65973632008-09-16 10:39:37 -04003179 const char **labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003180 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003181 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003182
3183 num_cons = snd_hda_get_connections(codec,
3184 spec->smux_nids[0],
3185 con_lst,
3186 HDA_MAX_NUM_INPUTS);
Matthew Ranostay65973632008-09-16 10:39:37 -04003187 if (!num_cons)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003188 return -EINVAL;
3189
Matthew Ranostay65973632008-09-16 10:39:37 -04003190 if (!labels)
3191 labels = stac92xx_spdif_labels;
3192
Matthew Ranostayd9737752008-09-07 12:03:41 +02003193 for (i = 0; i < num_cons; i++) {
Matthew Ranostay65973632008-09-16 10:39:37 -04003194 spdif_mux->items[spdif_mux->num_items].label = labels[i];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003195 spdif_mux->items[spdif_mux->num_items].index = i;
3196 spdif_mux->num_items++;
3197 }
3198
3199 return 0;
3200}
3201
Matt Porter8b657272006-10-26 17:12:59 +02003202/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003203static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003204 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3205 "Digital Mic 3", "Digital Mic 4"
3206};
3207
3208/* create playback/capture controls for input pins on dmic capable codecs */
3209static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3210 const struct auto_pin_cfg *cfg)
3211{
3212 struct sigmatel_spec *spec = codec->spec;
3213 struct hda_input_mux *dimux = &spec->private_dimux;
3214 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003215 int err, i, j;
3216 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02003217
3218 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3219 dimux->items[dimux->num_items].index = 0;
3220 dimux->num_items++;
3221
3222 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003223 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003224 int index;
3225 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003226 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02003227 unsigned int def_conf;
3228
3229 def_conf = snd_hda_codec_read(codec,
3230 spec->dmic_nids[i],
3231 0,
3232 AC_VERB_GET_CONFIG_DEFAULT,
3233 0);
3234 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3235 continue;
3236
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003237 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02003238 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003239 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02003240 con_lst,
3241 HDA_MAX_NUM_INPUTS);
3242 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003243 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02003244 index = j;
3245 goto found;
3246 }
3247 continue;
3248found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003249 wcaps = get_wcaps(codec, nid) &
3250 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003251
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003252 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003253 sprintf(name, "%s Capture Volume",
3254 stac92xx_dmic_labels[dimux->num_items]);
3255
3256 err = stac92xx_add_control(spec,
3257 STAC_CTL_WIDGET_VOL,
3258 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003259 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3260 (wcaps & AC_WCAP_OUT_AMP) ?
3261 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003262 if (err < 0)
3263 return err;
3264 }
3265
Matt Porter8b657272006-10-26 17:12:59 +02003266 dimux->items[dimux->num_items].label =
3267 stac92xx_dmic_labels[dimux->num_items];
3268 dimux->items[dimux->num_items].index = index;
3269 dimux->num_items++;
3270 }
3271
3272 return 0;
3273}
3274
Mattc7d4b2f2005-06-27 14:59:41 +02003275/* create playback/capture controls for input pins */
3276static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3277{
3278 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003279 struct hda_input_mux *imux = &spec->private_imux;
3280 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3281 int i, j, k;
3282
3283 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003284 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02003285
Takashi Iwai314634b2006-09-21 11:56:18 +02003286 if (!cfg->input_pins[i])
3287 continue;
3288 index = -1;
3289 for (j = 0; j < spec->num_muxes; j++) {
3290 int num_cons;
3291 num_cons = snd_hda_get_connections(codec,
3292 spec->mux_nids[j],
3293 con_lst,
3294 HDA_MAX_NUM_INPUTS);
3295 for (k = 0; k < num_cons; k++)
3296 if (con_lst[k] == cfg->input_pins[i]) {
3297 index = k;
3298 goto found;
3299 }
Mattc7d4b2f2005-06-27 14:59:41 +02003300 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003301 continue;
3302 found:
3303 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3304 imux->items[imux->num_items].index = index;
3305 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003306 }
3307
Steve Longerbeam7b043892007-05-03 20:50:03 +02003308 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003309 /*
3310 * Set the current input for the muxes.
3311 * The STAC9221 has two input muxes with identical source
3312 * NID lists. Hopefully this won't get confused.
3313 */
3314 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003315 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3316 AC_VERB_SET_CONNECT_SEL,
3317 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003318 }
3319 }
3320
Mattc7d4b2f2005-06-27 14:59:41 +02003321 return 0;
3322}
3323
Mattc7d4b2f2005-06-27 14:59:41 +02003324static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3325{
3326 struct sigmatel_spec *spec = codec->spec;
3327 int i;
3328
3329 for (i = 0; i < spec->autocfg.line_outs; i++) {
3330 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3331 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3332 }
3333}
3334
3335static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3336{
3337 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003338 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003339
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003340 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3341 hda_nid_t pin;
3342 pin = spec->autocfg.hp_pins[i];
3343 if (pin) /* connect to front */
3344 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3345 }
3346 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3347 hda_nid_t pin;
3348 pin = spec->autocfg.speaker_pins[i];
3349 if (pin) /* connect to front */
3350 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3351 }
Mattc7d4b2f2005-06-27 14:59:41 +02003352}
3353
Matt Porter3cc08dc2006-01-23 15:27:49 +01003354static 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 +02003355{
3356 struct sigmatel_spec *spec = codec->spec;
3357 int err;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003358 int hp_speaker_swap = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003359
Matt Porter8b657272006-10-26 17:12:59 +02003360 if ((err = snd_hda_parse_pin_def_config(codec,
3361 &spec->autocfg,
3362 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003363 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003364 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003365 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003366
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003367 /* If we have no real line-out pin and multiple hp-outs, HPs should
3368 * be set up as multi-channel outputs.
3369 */
3370 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3371 spec->autocfg.hp_outs > 1) {
3372 /* Copy hp_outs to line_outs, backup line_outs in
3373 * speaker_outs so that the following routines can handle
3374 * HP pins as primary outputs.
3375 */
3376 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3377 sizeof(spec->autocfg.line_out_pins));
3378 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3379 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3380 sizeof(spec->autocfg.hp_pins));
3381 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3382 hp_speaker_swap = 1;
3383 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003384 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003385 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3386 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003387 u32 caps = query_amp_caps(codec,
3388 spec->autocfg.mono_out_pin, dir);
3389 hda_nid_t conn_list[1];
3390
3391 /* get the mixer node and then the mono mux if it exists */
3392 if (snd_hda_get_connections(codec,
3393 spec->autocfg.mono_out_pin, conn_list, 1) &&
3394 snd_hda_get_connections(codec, conn_list[0],
3395 conn_list, 1)) {
3396
3397 int wcaps = get_wcaps(codec, conn_list[0]);
3398 int wid_type = (wcaps & AC_WCAP_TYPE)
3399 >> AC_WCAP_TYPE_SHIFT;
3400 /* LR swap check, some stac925x have a mux that
3401 * changes the DACs output path instead of the
3402 * mono-mux path.
3403 */
3404 if (wid_type == AC_WID_AUD_SEL &&
3405 !(wcaps & AC_WCAP_LR_SWAP))
3406 spec->mono_nid = conn_list[0];
3407 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003408 if (dir) {
3409 hda_nid_t nid = spec->autocfg.mono_out_pin;
3410
3411 /* most mono outs have a least a mute/unmute switch */
3412 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3413 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3414 "Mono Playback Switch",
3415 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003416 if (err < 0)
3417 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003418 /* check for volume support for the amp */
3419 if ((caps & AC_AMPCAP_NUM_STEPS)
3420 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3421 err = stac92xx_add_control(spec,
3422 STAC_CTL_WIDGET_VOL,
3423 "Mono Playback Volume",
3424 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3425 if (err < 0)
3426 return err;
3427 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003428 }
3429
3430 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3431 AC_PINCTL_OUT_EN);
3432 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003433
Matt Porter403d1942005-11-29 15:00:51 +01003434 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
3435 return err;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003436 if (spec->multiout.num_dacs == 0)
3437 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
3438 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003439
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003440 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
3441
3442 if (err < 0)
3443 return err;
3444
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003445 /* setup analog beep controls */
3446 if (spec->anabeep_nid > 0) {
3447 err = stac92xx_auto_create_beep_ctls(codec,
3448 spec->anabeep_nid);
3449 if (err < 0)
3450 return err;
3451 }
3452
3453 /* setup digital beep controls and input device */
3454#ifdef CONFIG_SND_HDA_INPUT_BEEP
3455 if (spec->digbeep_nid > 0) {
3456 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003457 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003458
3459 err = stac92xx_auto_create_beep_ctls(codec, nid);
3460 if (err < 0)
3461 return err;
3462 err = snd_hda_attach_beep_device(codec, nid);
3463 if (err < 0)
3464 return err;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003465 /* if no beep switch is available, make its own one */
3466 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3467 if (codec->beep &&
3468 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3469 err = stac92xx_beep_switch_ctl(codec);
3470 if (err < 0)
3471 return err;
3472 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003473 }
3474#endif
3475
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003476 if (hp_speaker_swap == 1) {
3477 /* Restore the hp_outs and line_outs */
3478 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3479 sizeof(spec->autocfg.line_out_pins));
3480 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3481 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
3482 sizeof(spec->autocfg.speaker_pins));
3483 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
3484 memset(spec->autocfg.speaker_pins, 0,
3485 sizeof(spec->autocfg.speaker_pins));
3486 spec->autocfg.speaker_outs = 0;
3487 }
3488
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003489 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3490
3491 if (err < 0)
3492 return err;
3493
3494 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3495
3496 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003497 return err;
3498
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003499 if (spec->mono_nid > 0) {
3500 err = stac92xx_auto_create_mono_output_ctls(codec);
3501 if (err < 0)
3502 return err;
3503 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003504 if (spec->num_amps > 0) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003505 err = stac92xx_auto_create_amp_output_ctls(codec);
3506 if (err < 0)
3507 return err;
3508 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003509 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003510 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3511 &spec->autocfg)) < 0)
3512 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003513 if (spec->num_muxes > 0) {
3514 err = stac92xx_auto_create_mux_input_ctls(codec);
3515 if (err < 0)
3516 return err;
3517 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003518 if (spec->num_smuxes > 0) {
3519 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3520 if (err < 0)
3521 return err;
3522 }
Matt Porter8b657272006-10-26 17:12:59 +02003523
Mattc7d4b2f2005-06-27 14:59:41 +02003524 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003525 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003526 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003527
Takashi Iwai82bc9552006-03-21 11:24:42 +01003528 if (spec->autocfg.dig_out_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003529 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003530 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003531 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003532
3533 if (spec->kctl_alloc)
3534 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3535
3536 spec->input_mux = &spec->private_imux;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003537 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003538 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003539 spec->mono_mux = &spec->private_mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -04003540 spec->amp_mux = &spec->private_amp_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003541 return 1;
3542}
3543
Takashi Iwai82bc9552006-03-21 11:24:42 +01003544/* add playback controls for HP output */
3545static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3546 struct auto_pin_cfg *cfg)
3547{
3548 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003549 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003550 unsigned int wid_caps;
3551
3552 if (! pin)
3553 return 0;
3554
3555 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003556 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003557 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003558
3559 return 0;
3560}
3561
Richard Fish160ea0d2006-09-06 13:58:25 +02003562/* add playback controls for LFE output */
3563static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3564 struct auto_pin_cfg *cfg)
3565{
3566 struct sigmatel_spec *spec = codec->spec;
3567 int err;
3568 hda_nid_t lfe_pin = 0x0;
3569 int i;
3570
3571 /*
3572 * search speaker outs and line outs for a mono speaker pin
3573 * with an amp. If one is found, add LFE controls
3574 * for it.
3575 */
3576 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3577 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003578 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003579 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3580 if (wcaps == AC_WCAP_OUT_AMP)
3581 /* found a mono speaker with an amp, must be lfe */
3582 lfe_pin = pin;
3583 }
3584
3585 /* if speaker_outs is 0, then speakers may be in line_outs */
3586 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3587 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3588 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003589 unsigned int defcfg;
Harvey Harrison8b551782008-02-29 11:56:48 +01003590 defcfg = snd_hda_codec_read(codec, pin, 0,
Richard Fish160ea0d2006-09-06 13:58:25 +02003591 AC_VERB_GET_CONFIG_DEFAULT,
3592 0x00);
Harvey Harrison8b551782008-02-29 11:56:48 +01003593 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003594 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003595 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3596 if (wcaps == AC_WCAP_OUT_AMP)
3597 /* found a mono speaker with an amp,
3598 must be lfe */
3599 lfe_pin = pin;
3600 }
3601 }
3602 }
3603
3604 if (lfe_pin) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003605 err = create_controls(spec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003606 if (err < 0)
3607 return err;
3608 }
3609
3610 return 0;
3611}
3612
Mattc7d4b2f2005-06-27 14:59:41 +02003613static int stac9200_parse_auto_config(struct hda_codec *codec)
3614{
3615 struct sigmatel_spec *spec = codec->spec;
3616 int err;
3617
Kailang Yangdf694da2005-12-05 19:42:22 +01003618 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003619 return err;
3620
3621 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3622 return err;
3623
Takashi Iwai82bc9552006-03-21 11:24:42 +01003624 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3625 return err;
3626
Richard Fish160ea0d2006-09-06 13:58:25 +02003627 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3628 return err;
3629
Takashi Iwai355a0ec2008-11-11 16:46:19 +01003630 if (spec->num_muxes > 0) {
3631 err = stac92xx_auto_create_mux_input_ctls(codec);
3632 if (err < 0)
3633 return err;
3634 }
3635
Takashi Iwai82bc9552006-03-21 11:24:42 +01003636 if (spec->autocfg.dig_out_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003637 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003638 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003639 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003640
3641 if (spec->kctl_alloc)
3642 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3643
3644 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003645 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003646
3647 return 1;
3648}
3649
Sam Revitch62fe78e2006-05-10 15:09:17 +02003650/*
3651 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3652 * funky external mute control using GPIO pins.
3653 */
3654
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003655static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003656 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003657{
3658 unsigned int gpiostate, gpiomask, gpiodir;
3659
3660 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3661 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003662 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003663
3664 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3665 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003666 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003667
3668 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3669 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003670 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003671
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003672 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003673 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3674
3675 snd_hda_codec_write(codec, codec->afg, 0,
3676 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003677 snd_hda_codec_read(codec, codec->afg, 0,
3678 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003679
3680 msleep(1);
3681
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003682 snd_hda_codec_read(codec, codec->afg, 0,
3683 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003684}
3685
Takashi Iwai314634b2006-09-21 11:56:18 +02003686static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3687 unsigned int event)
3688{
3689 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003690 snd_hda_codec_write_cache(codec, nid, 0,
3691 AC_VERB_SET_UNSOLICITED_ENABLE,
3692 (AC_USRSP_EN | event));
Takashi Iwai314634b2006-09-21 11:56:18 +02003693}
3694
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003695static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3696{
3697 int i;
3698 for (i = 0; i < cfg->hp_outs; i++)
3699 if (cfg->hp_pins[i] == nid)
3700 return 1; /* nid is a HP-Out */
3701
3702 return 0; /* nid is not a HP-Out */
3703};
3704
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003705static void stac92xx_power_down(struct hda_codec *codec)
3706{
3707 struct sigmatel_spec *spec = codec->spec;
3708
3709 /* power down inactive DACs */
3710 hda_nid_t *dac;
3711 for (dac = spec->dac_list; *dac; dac++)
Matthew Ranostay44510892008-02-21 07:49:31 +01003712 if (!is_in_dac_nids(spec, *dac) &&
3713 spec->multiout.hp_nid != *dac)
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003714 snd_hda_codec_write_cache(codec, *dac, 0,
3715 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3716}
3717
Takashi Iwaif73d3582008-11-25 08:21:51 +01003718static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
3719 int enable);
3720
Mattc7d4b2f2005-06-27 14:59:41 +02003721static int stac92xx_init(struct hda_codec *codec)
3722{
3723 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003724 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01003725 unsigned int gpio;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003726 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003727
Mattc7d4b2f2005-06-27 14:59:41 +02003728 snd_hda_sequence_write(codec, spec->init);
3729
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003730 /* power down adcs initially */
3731 if (spec->powerdown_adcs)
3732 for (i = 0; i < spec->num_adcs; i++)
3733 snd_hda_codec_write_cache(codec,
3734 spec->adc_nids[i], 0,
3735 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01003736
3737 /* set up GPIO */
3738 gpio = spec->gpio_data;
3739 /* turn on EAPD statically when spec->eapd_switch isn't set.
3740 * otherwise, unsol event will turn it on/off dynamically
3741 */
3742 if (!spec->eapd_switch)
3743 gpio |= spec->eapd_mask;
3744 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
3745
Takashi Iwai82bc9552006-03-21 11:24:42 +01003746 /* set up pins */
3747 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02003748 /* Enable unsolicited responses on the HP widget */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003749 for (i = 0; i < cfg->hp_outs; i++)
Takashi Iwai314634b2006-09-21 11:56:18 +02003750 enable_pin_detect(codec, cfg->hp_pins[i],
3751 STAC_HP_EVENT);
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01003752 /* force to enable the first line-out; the others are set up
3753 * in unsol_event
3754 */
3755 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3756 AC_PINCTL_OUT_EN);
Takashi Iwaieb995a82006-09-21 14:28:21 +02003757 stac92xx_auto_init_hp_out(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003758 /* fake event to set up pins */
3759 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3760 } else {
3761 stac92xx_auto_init_multi_out(codec);
3762 stac92xx_auto_init_hp_out(codec);
3763 }
3764 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01003765 hda_nid_t nid = cfg->input_pins[i];
3766 if (nid) {
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01003767 unsigned int pinctl;
3768 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
3769 /* for mic pins, force to initialize */
3770 pinctl = stac92xx_get_vref(codec, nid);
3771 } else {
3772 pinctl = snd_hda_codec_read(codec, nid, 0,
3773 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3774 /* if PINCTL already set then skip */
3775 if (pinctl & AC_PINCTL_IN_EN)
3776 continue;
3777 }
3778 pinctl |= AC_PINCTL_IN_EN;
Takashi Iwaic960a032006-03-23 17:06:28 +01003779 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3780 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01003781 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003782 for (i = 0; i < spec->num_dmics; i++)
3783 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3784 AC_PINCTL_IN_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003785 if (cfg->dig_out_pin)
3786 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3787 AC_PINCTL_OUT_EN);
3788 if (cfg->dig_in_pin)
3789 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3790 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01003791 for (i = 0; i < spec->num_pwrs; i++) {
3792 hda_nid_t nid = spec->pwr_nids[i];
3793 int pinctl, def_conf;
3794 int event = STAC_PWR_EVENT;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003795
Takashi Iwaif73d3582008-11-25 08:21:51 +01003796 if (is_nid_hp_pin(cfg, nid) && spec->hp_detect)
3797 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003798
Takashi Iwaif73d3582008-11-25 08:21:51 +01003799 pinctl = snd_hda_codec_read(codec, nid, 0,
3800 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3801 /* outputs are only ports capable of power management
3802 * any attempts on powering down a input port cause the
3803 * referenced VREF to act quirky.
3804 */
3805 if (pinctl & AC_PINCTL_IN_EN)
3806 continue;
3807 def_conf = snd_hda_codec_read(codec, nid, 0,
3808 AC_VERB_GET_CONFIG_DEFAULT, 0);
3809 def_conf = get_defcfg_connect(def_conf);
3810 /* skip any ports that don't have jacks since presence
3811 * detection is useless */
3812 if (def_conf != AC_JACK_PORT_COMPLEX) {
3813 if (def_conf != AC_JACK_PORT_NONE)
3814 stac_toggle_power_map(codec, nid, 1);
3815 continue;
3816 }
3817 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3818 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3819 }
3820 if (spec->dac_list)
3821 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02003822 return 0;
3823}
3824
Matt2f2f4252005-04-13 14:45:30 +02003825static void stac92xx_free(struct hda_codec *codec)
3826{
Mattc7d4b2f2005-06-27 14:59:41 +02003827 struct sigmatel_spec *spec = codec->spec;
3828 int i;
3829
3830 if (! spec)
3831 return;
3832
3833 if (spec->kctl_alloc) {
3834 for (i = 0; i < spec->num_kctl_used; i++)
3835 kfree(spec->kctl_alloc[i].name);
3836 kfree(spec->kctl_alloc);
3837 }
3838
Richard Fish11b44bb2006-08-23 18:31:34 +02003839 if (spec->bios_pin_configs)
3840 kfree(spec->bios_pin_configs);
3841
Mattc7d4b2f2005-06-27 14:59:41 +02003842 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003843 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02003844}
3845
Matt4e550962005-07-04 17:51:39 +02003846static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3847 unsigned int flag)
3848{
3849 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3850 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02003851
Takashi Iwaif9acba42007-05-29 18:01:06 +02003852 if (pin_ctl & AC_PINCTL_IN_EN) {
3853 /*
3854 * we need to check the current set-up direction of
3855 * shared input pins since they can be switched via
3856 * "xxx as Output" mixer switch
3857 */
3858 struct sigmatel_spec *spec = codec->spec;
3859 struct auto_pin_cfg *cfg = &spec->autocfg;
3860 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3861 spec->line_switch) ||
3862 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3863 spec->mic_switch))
3864 return;
3865 }
3866
Steve Longerbeam7b043892007-05-03 20:50:03 +02003867 /* if setting pin direction bits, clear the current
3868 direction bits first */
3869 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3870 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3871
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003872 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003873 AC_VERB_SET_PIN_WIDGET_CONTROL,
3874 pin_ctl | flag);
3875}
3876
3877static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3878 unsigned int flag)
3879{
3880 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3881 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003882 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003883 AC_VERB_SET_PIN_WIDGET_CONTROL,
3884 pin_ctl & ~flag);
3885}
3886
Jiang Zhe40c1d302007-11-12 13:05:16 +01003887static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02003888{
3889 if (!nid)
3890 return 0;
3891 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Jiang Zhe40c1d302007-11-12 13:05:16 +01003892 & (1 << 31)) {
3893 unsigned int pinctl;
3894 pinctl = snd_hda_codec_read(codec, nid, 0,
3895 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3896 if (pinctl & AC_PINCTL_IN_EN)
3897 return 0; /* mic- or line-input */
3898 else
3899 return 1; /* HP-output */
3900 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003901 return 0;
3902}
3903
Takashi Iwaid7a89432008-11-12 09:48:04 +01003904/* return non-zero if the hp-pin of the given array index isn't
3905 * a jack-detection target
3906 */
3907static int no_hp_sensing(struct sigmatel_spec *spec, int i)
3908{
3909 struct auto_pin_cfg *cfg = &spec->autocfg;
3910
3911 /* ignore sensing of shared line and mic jacks */
3912 if (spec->line_switch &&
3913 cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_LINE])
3914 return 1;
3915 if (spec->mic_switch &&
3916 cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_MIC])
3917 return 1;
3918 /* ignore if the pin is set as line-out */
3919 if (cfg->hp_pins[i] == spec->hp_switch)
3920 return 1;
3921 return 0;
3922}
3923
Takashi Iwai314634b2006-09-21 11:56:18 +02003924static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
Matt4e550962005-07-04 17:51:39 +02003925{
3926 struct sigmatel_spec *spec = codec->spec;
3927 struct auto_pin_cfg *cfg = &spec->autocfg;
3928 int i, presence;
3929
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003930 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003931 if (spec->gpio_mute)
3932 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3933 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3934
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003935 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003936 if (presence)
3937 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01003938 if (no_hp_sensing(spec, i))
3939 continue;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003940 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003941 }
Matt4e550962005-07-04 17:51:39 +02003942
3943 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01003944 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003945 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01003946 stac92xx_reset_pinctl(codec, spec->hp_switch,
3947 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003948 for (i = 0; i < cfg->line_outs; i++)
3949 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3950 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003951 for (i = 0; i < cfg->speaker_outs; i++)
3952 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3953 AC_PINCTL_OUT_EN);
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05003954 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003955 stac_gpio_set(codec, spec->gpio_mask,
3956 spec->gpio_dir, spec->gpio_data &
3957 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003958 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01003959 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003960 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01003961 stac92xx_set_pinctl(codec, spec->hp_switch,
3962 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003963 for (i = 0; i < cfg->line_outs; i++)
3964 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3965 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003966 for (i = 0; i < cfg->speaker_outs; i++)
3967 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3968 AC_PINCTL_OUT_EN);
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05003969 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003970 stac_gpio_set(codec, spec->gpio_mask,
3971 spec->gpio_dir, spec->gpio_data |
3972 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003973 }
Takashi Iwaid7a89432008-11-12 09:48:04 +01003974 /* toggle hp outs */
3975 for (i = 0; i < cfg->hp_outs; i++) {
3976 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
3977 if (no_hp_sensing(spec, i))
3978 continue;
3979 if (presence)
3980 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
3981 else
3982 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
3983 }
Matt4e550962005-07-04 17:51:39 +02003984}
3985
Takashi Iwaif73d3582008-11-25 08:21:51 +01003986static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
3987 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003988{
3989 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01003990 unsigned int idx, val;
3991
3992 for (idx = 0; idx < spec->num_pwrs; idx++) {
3993 if (spec->pwr_nids[idx] == nid)
3994 break;
3995 }
3996 if (idx >= spec->num_pwrs)
3997 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003998
3999 /* several codecs have two power down bits */
4000 if (spec->pwr_mapping)
4001 idx = spec->pwr_mapping[idx];
4002 else
4003 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004004
Takashi Iwaif73d3582008-11-25 08:21:51 +01004005 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4006 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004007 val &= ~idx;
4008 else
4009 val |= idx;
4010
4011 /* power down unused output ports */
4012 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004013}
4014
4015static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4016{
4017 stac_toggle_power_map(codec, nid, get_hp_pin_presence(codec, nid));
4018}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004019
Takashi Iwai314634b2006-09-21 11:56:18 +02004020static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4021{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004022 struct sigmatel_spec *spec = codec->spec;
4023 int idx = res >> 26 & 0x0f;
4024
Matthew Ranostay72474be2008-10-09 09:32:17 -04004025 switch ((res >> 26) & 0x70) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004026 case STAC_HP_EVENT:
4027 stac92xx_hp_detect(codec, res);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004028 /* fallthru */
4029 case STAC_PWR_EVENT:
4030 if (spec->num_pwrs > 0)
4031 stac92xx_pin_sense(codec, idx);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004032 break;
4033 case STAC_VREF_EVENT: {
4034 int data = snd_hda_codec_read(codec, codec->afg, 0,
4035 AC_VERB_GET_GPIO_DATA, 0);
4036 /* toggle VREF state based on GPIOx status */
4037 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4038 !!(data & (1 << idx)));
4039 break;
4040 }
Takashi Iwai314634b2006-09-21 11:56:18 +02004041 }
4042}
4043
Takashi Iwaicb53c622007-08-10 17:21:45 +02004044#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004045static int stac92xx_resume(struct hda_codec *codec)
4046{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004047 struct sigmatel_spec *spec = codec->spec;
4048
Richard Fish11b44bb2006-08-23 18:31:34 +02004049 stac92xx_set_config_regs(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004050 snd_hda_sequence_write(codec, spec->init);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004051 stac_gpio_set(codec, spec->gpio_mask,
4052 spec->gpio_dir, spec->gpio_data);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004053 snd_hda_codec_resume_amp(codec);
4054 snd_hda_codec_resume_cache(codec);
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004055 /* power down inactive DACs */
4056 if (spec->dac_list)
4057 stac92xx_power_down(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004058 /* invoke unsolicited event to reset the HP state */
4059 if (spec->hp_detect)
4060 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
Mattff6fdc32005-06-27 15:06:52 +02004061 return 0;
4062}
4063#endif
4064
Matt2f2f4252005-04-13 14:45:30 +02004065static struct hda_codec_ops stac92xx_patch_ops = {
4066 .build_controls = stac92xx_build_controls,
4067 .build_pcms = stac92xx_build_pcms,
4068 .init = stac92xx_init,
4069 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02004070 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004071#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004072 .resume = stac92xx_resume,
4073#endif
Matt2f2f4252005-04-13 14:45:30 +02004074};
4075
4076static int patch_stac9200(struct hda_codec *codec)
4077{
4078 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004079 int err;
Matt2f2f4252005-04-13 14:45:30 +02004080
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004081 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004082 if (spec == NULL)
4083 return -ENOMEM;
4084
4085 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004086 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004087 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004088 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4089 stac9200_models,
4090 stac9200_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02004091 if (spec->board_config < 0) {
4092 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
4093 err = stac92xx_save_bios_config_regs(codec);
4094 if (err < 0) {
4095 stac92xx_free(codec);
4096 return err;
4097 }
4098 spec->pin_configs = spec->bios_pin_configs;
4099 } else {
Matt Porter403d1942005-11-29 15:00:51 +01004100 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
4101 stac92xx_set_config_regs(codec);
4102 }
Matt2f2f4252005-04-13 14:45:30 +02004103
4104 spec->multiout.max_channels = 2;
4105 spec->multiout.num_dacs = 1;
4106 spec->multiout.dac_nids = stac9200_dac_nids;
4107 spec->adc_nids = stac9200_adc_nids;
4108 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02004109 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02004110 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004111 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004112 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004113
Tobin Davisbf277782008-02-03 20:31:47 +01004114 if (spec->board_config == STAC_9200_GATEWAY ||
4115 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02004116 spec->init = stac9200_eapd_init;
4117 else
4118 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004119 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004120
Takashi Iwai117f2572008-03-18 09:53:23 +01004121 if (spec->board_config == STAC_9200_PANASONIC) {
4122 spec->gpio_mask = spec->gpio_dir = 0x09;
4123 spec->gpio_data = 0x00;
4124 }
4125
Mattc7d4b2f2005-06-27 14:59:41 +02004126 err = stac9200_parse_auto_config(codec);
4127 if (err < 0) {
4128 stac92xx_free(codec);
4129 return err;
4130 }
Matt2f2f4252005-04-13 14:45:30 +02004131
4132 codec->patch_ops = stac92xx_patch_ops;
4133
4134 return 0;
4135}
4136
Tobin Davis8e21c342007-01-08 11:04:17 +01004137static int patch_stac925x(struct hda_codec *codec)
4138{
4139 struct sigmatel_spec *spec;
4140 int err;
4141
4142 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4143 if (spec == NULL)
4144 return -ENOMEM;
4145
4146 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004147 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01004148 spec->pin_nids = stac925x_pin_nids;
4149 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
4150 stac925x_models,
4151 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004152 again:
Tobin Davis8e21c342007-01-08 11:04:17 +01004153 if (spec->board_config < 0) {
Tobin Davis2c11f952007-05-17 09:36:34 +02004154 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
4155 "using BIOS defaults\n");
Tobin Davis8e21c342007-01-08 11:04:17 +01004156 err = stac92xx_save_bios_config_regs(codec);
4157 if (err < 0) {
4158 stac92xx_free(codec);
4159 return err;
4160 }
4161 spec->pin_configs = spec->bios_pin_configs;
4162 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
4163 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
4164 stac92xx_set_config_regs(codec);
4165 }
4166
4167 spec->multiout.max_channels = 2;
4168 spec->multiout.num_dacs = 1;
4169 spec->multiout.dac_nids = stac925x_dac_nids;
4170 spec->adc_nids = stac925x_adc_nids;
4171 spec->mux_nids = stac925x_mux_nids;
4172 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004173 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004174 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02004175 switch (codec->vendor_id) {
4176 case 0x83847632: /* STAC9202 */
4177 case 0x83847633: /* STAC9202D */
4178 case 0x83847636: /* STAC9251 */
4179 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02004180 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02004181 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004182 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4183 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02004184 break;
4185 default:
4186 spec->num_dmics = 0;
4187 break;
4188 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004189
4190 spec->init = stac925x_core_init;
4191 spec->mixer = stac925x_mixer;
4192
4193 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004194 if (!err) {
4195 if (spec->board_config < 0) {
4196 printk(KERN_WARNING "hda_codec: No auto-config is "
4197 "available, default to model=ref\n");
4198 spec->board_config = STAC_925x_REF;
4199 goto again;
4200 }
4201 err = -EINVAL;
4202 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004203 if (err < 0) {
4204 stac92xx_free(codec);
4205 return err;
4206 }
4207
4208 codec->patch_ops = stac92xx_patch_ops;
4209
4210 return 0;
4211}
4212
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004213static struct hda_input_mux stac92hd73xx_dmux = {
4214 .num_items = 4,
4215 .items = {
4216 { "Analog Inputs", 0x0b },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004217 { "Digital Mic 1", 0x09 },
4218 { "Digital Mic 2", 0x0a },
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004219 { "CD", 0x08 },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004220 }
4221};
4222
4223static int patch_stac92hd73xx(struct hda_codec *codec)
4224{
4225 struct sigmatel_spec *spec;
4226 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4227 int err = 0;
4228
4229 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4230 if (spec == NULL)
4231 return -ENOMEM;
4232
4233 codec->spec = spec;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02004234 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004235 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4236 spec->pin_nids = stac92hd73xx_pin_nids;
4237 spec->board_config = snd_hda_check_board_config(codec,
4238 STAC_92HD73XX_MODELS,
4239 stac92hd73xx_models,
4240 stac92hd73xx_cfg_tbl);
4241again:
4242 if (spec->board_config < 0) {
4243 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4244 " STAC92HD73XX, using BIOS defaults\n");
4245 err = stac92xx_save_bios_config_regs(codec);
4246 if (err < 0) {
4247 stac92xx_free(codec);
4248 return err;
4249 }
4250 spec->pin_configs = spec->bios_pin_configs;
4251 } else {
4252 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
4253 stac92xx_set_config_regs(codec);
4254 }
4255
4256 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
4257 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4258
4259 if (spec->multiout.num_dacs < 0) {
4260 printk(KERN_WARNING "hda_codec: Could not determine "
4261 "number of channels defaulting to DAC count\n");
4262 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
4263 }
4264
4265 switch (spec->multiout.num_dacs) {
4266 case 0x3: /* 6 Channel */
Takashi Iwai85f13b62008-12-19 08:20:38 +01004267 spec->multiout.hp_nid = 0x17;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004268 spec->mixer = stac92hd73xx_6ch_mixer;
4269 spec->init = stac92hd73xx_6ch_core_init;
4270 break;
4271 case 0x4: /* 8 Channel */
Takashi Iwai85f13b62008-12-19 08:20:38 +01004272 spec->multiout.hp_nid = 0x18;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004273 spec->mixer = stac92hd73xx_8ch_mixer;
4274 spec->init = stac92hd73xx_8ch_core_init;
4275 break;
4276 case 0x5: /* 10 Channel */
Takashi Iwai85f13b62008-12-19 08:20:38 +01004277 spec->multiout.hp_nid = 0x19;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004278 spec->mixer = stac92hd73xx_10ch_mixer;
4279 spec->init = stac92hd73xx_10ch_core_init;
4280 };
4281
4282 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
4283 spec->aloopback_mask = 0x01;
4284 spec->aloopback_shift = 8;
4285
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004286 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004287 spec->mux_nids = stac92hd73xx_mux_nids;
4288 spec->adc_nids = stac92hd73xx_adc_nids;
4289 spec->dmic_nids = stac92hd73xx_dmic_nids;
4290 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004291 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostay89385032008-09-11 09:49:39 -04004292 spec->amp_nids = stac92hd73xx_amp_nids;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004293 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004294
4295 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4296 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01004297 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004298 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4299 sizeof(stac92hd73xx_dmux));
4300
Matthew Ranostaya7662642008-02-21 07:51:14 +01004301 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004302 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004303 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004304 /* fallthru */
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004305 case STAC_DELL_M6_AMIC:
4306 case STAC_DELL_M6_DMIC:
4307 case STAC_DELL_M6_BOTH:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004308 spec->num_smuxes = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004309 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4310 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004311 spec->eapd_switch = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004312 spec->num_amps = 1;
Takashi Iwai8f55c1e2008-12-19 14:02:32 +01004313 spec->multiout.hp_nid = 0; /* dual HPs */
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004314
4315 if (!spec->init)
4316 spec->init = dell_m6_core_init;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004317 switch (spec->board_config) {
4318 case STAC_DELL_M6_AMIC: /* Analog Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004319 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4320 spec->num_dmics = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004321 spec->private_dimux.num_items = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004322 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004323 case STAC_DELL_M6_DMIC: /* Digital Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004324 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4325 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004326 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004327 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004328 case STAC_DELL_M6_BOTH: /* Both */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004329 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4330 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4331 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004332 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004333 break;
4334 }
4335 break;
4336 default:
4337 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004338 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004339 spec->eapd_switch = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004340 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004341 if (spec->board_config > STAC_92HD73XX_REF) {
4342 /* GPIO0 High = Enable EAPD */
4343 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4344 spec->gpio_data = 0x01;
4345 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004346 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004347
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004348 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4349 spec->pwr_nids = stac92hd73xx_pwr_nids;
4350
Matthew Ranostayd9737752008-09-07 12:03:41 +02004351 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004352
4353 if (!err) {
4354 if (spec->board_config < 0) {
4355 printk(KERN_WARNING "hda_codec: No auto-config is "
4356 "available, default to model=ref\n");
4357 spec->board_config = STAC_92HD73XX_REF;
4358 goto again;
4359 }
4360 err = -EINVAL;
4361 }
4362
4363 if (err < 0) {
4364 stac92xx_free(codec);
4365 return err;
4366 }
4367
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01004368 if (spec->board_config == STAC_92HD73XX_NO_JD)
4369 spec->hp_detect = 0;
4370
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004371 codec->patch_ops = stac92xx_patch_ops;
4372
4373 return 0;
4374}
4375
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004376static struct hda_input_mux stac92hd83xxx_dmux = {
4377 .num_items = 3,
4378 .items = {
4379 { "Analog Inputs", 0x03 },
4380 { "Digital Mic 1", 0x04 },
4381 { "Digital Mic 2", 0x05 },
4382 }
4383};
4384
4385static int patch_stac92hd83xxx(struct hda_codec *codec)
4386{
4387 struct sigmatel_spec *spec;
4388 int err;
4389
4390 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4391 if (spec == NULL)
4392 return -ENOMEM;
4393
4394 codec->spec = spec;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004395 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004396 spec->mono_nid = 0x19;
4397 spec->digbeep_nid = 0x21;
4398 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4399 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4400 spec->adc_nids = stac92hd83xxx_adc_nids;
4401 spec->pwr_nids = stac92hd83xxx_pwr_nids;
4402 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4403 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
4404 spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
4405
4406 spec->init = stac92hd83xxx_core_init;
4407 switch (codec->vendor_id) {
4408 case 0x111d7605:
4409 spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
4410 break;
4411 default:
4412 spec->num_pwrs--;
4413 spec->init++; /* switch to config #2 */
4414 spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
4415 }
4416
4417 spec->mixer = stac92hd83xxx_mixer;
4418 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4419 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4420 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
4421 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4422 spec->dinput_mux = &stac92hd83xxx_dmux;
4423 spec->pin_nids = stac92hd83xxx_pin_nids;
4424 spec->board_config = snd_hda_check_board_config(codec,
4425 STAC_92HD83XXX_MODELS,
4426 stac92hd83xxx_models,
4427 stac92hd83xxx_cfg_tbl);
4428again:
4429 if (spec->board_config < 0) {
4430 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4431 " STAC92HD83XXX, using BIOS defaults\n");
4432 err = stac92xx_save_bios_config_regs(codec);
4433 if (err < 0) {
4434 stac92xx_free(codec);
4435 return err;
4436 }
4437 spec->pin_configs = spec->bios_pin_configs;
4438 } else {
4439 spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config];
4440 stac92xx_set_config_regs(codec);
4441 }
4442
4443 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4444 if (!err) {
4445 if (spec->board_config < 0) {
4446 printk(KERN_WARNING "hda_codec: No auto-config is "
4447 "available, default to model=ref\n");
4448 spec->board_config = STAC_92HD83XXX_REF;
4449 goto again;
4450 }
4451 err = -EINVAL;
4452 }
4453
4454 if (err < 0) {
4455 stac92xx_free(codec);
4456 return err;
4457 }
4458
4459 codec->patch_ops = stac92xx_patch_ops;
4460
4461 return 0;
4462}
4463
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004464#ifdef SND_HDA_NEEDS_RESUME
4465static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr)
4466{
4467 struct sigmatel_spec *spec = codec->spec;
4468 int i;
4469 snd_hda_codec_write_cache(codec, codec->afg, 0,
4470 AC_VERB_SET_POWER_STATE, pwr);
4471
4472 msleep(1);
4473 for (i = 0; i < spec->num_adcs; i++) {
4474 snd_hda_codec_write_cache(codec,
4475 spec->adc_nids[i], 0,
4476 AC_VERB_SET_POWER_STATE, pwr);
4477 }
4478};
4479
4480static int stac92hd71xx_resume(struct hda_codec *codec)
4481{
4482 stac92hd71xx_set_power_state(codec, AC_PWRST_D0);
4483 return stac92xx_resume(codec);
4484}
4485
4486static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state)
4487{
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004488 struct sigmatel_spec *spec = codec->spec;
4489
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004490 stac92hd71xx_set_power_state(codec, AC_PWRST_D3);
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004491 if (spec->eapd_mask)
4492 stac_gpio_set(codec, spec->gpio_mask,
4493 spec->gpio_dir, spec->gpio_data &
4494 ~spec->eapd_mask);
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004495 return 0;
4496};
4497
4498#endif
4499
4500static struct hda_codec_ops stac92hd71bxx_patch_ops = {
4501 .build_controls = stac92xx_build_controls,
4502 .build_pcms = stac92xx_build_pcms,
4503 .init = stac92xx_init,
4504 .free = stac92xx_free,
4505 .unsol_event = stac92xx_unsol_event,
4506#ifdef SND_HDA_NEEDS_RESUME
4507 .resume = stac92hd71xx_resume,
4508 .suspend = stac92hd71xx_suspend,
4509#endif
4510};
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004511
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004512static struct hda_input_mux stac92hd71bxx_dmux = {
4513 .num_items = 4,
4514 .items = {
4515 { "Analog Inputs", 0x00 },
4516 { "Mixer", 0x01 },
4517 { "Digital Mic 1", 0x02 },
4518 { "Digital Mic 2", 0x03 },
4519 }
4520};
4521
Matthew Ranostaye035b842007-11-06 11:53:55 +01004522static int patch_stac92hd71bxx(struct hda_codec *codec)
4523{
4524 struct sigmatel_spec *spec;
4525 int err = 0;
4526
4527 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4528 if (spec == NULL)
4529 return -ENOMEM;
4530
4531 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004532 codec->patch_ops = stac92xx_patch_ops;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004533 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004534 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004535 spec->pin_nids = stac92hd71bxx_pin_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004536 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux,
4537 sizeof(stac92hd71bxx_dmux));
Matthew Ranostaye035b842007-11-06 11:53:55 +01004538 spec->board_config = snd_hda_check_board_config(codec,
4539 STAC_92HD71BXX_MODELS,
4540 stac92hd71bxx_models,
4541 stac92hd71bxx_cfg_tbl);
4542again:
4543 if (spec->board_config < 0) {
4544 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4545 " STAC92HD71BXX, using BIOS defaults\n");
4546 err = stac92xx_save_bios_config_regs(codec);
4547 if (err < 0) {
4548 stac92xx_free(codec);
4549 return err;
4550 }
4551 spec->pin_configs = spec->bios_pin_configs;
4552 } else {
4553 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
4554 stac92xx_set_config_regs(codec);
4555 }
4556
Takashi Iwai41c3b642008-11-18 10:45:15 +01004557 if (spec->board_config > STAC_92HD71BXX_REF) {
4558 /* GPIO0 = EAPD */
4559 spec->gpio_mask = 0x01;
4560 spec->gpio_dir = 0x01;
4561 spec->gpio_data = 0x01;
4562 }
4563
Matthew Ranostay541eee82007-12-14 12:08:04 +01004564 switch (codec->vendor_id) {
4565 case 0x111d76b6: /* 4 Port without Analog Mixer */
4566 case 0x111d76b7:
4567 case 0x111d76b4: /* 6 Port without Analog Mixer */
4568 case 0x111d76b5:
4569 spec->mixer = stac92hd71bxx_mixer;
4570 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004571 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004572 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004573 case 0x111d7608: /* 5 Port with Analog Mixer */
Takashi Iwai8e5f2622008-11-15 19:28:54 +01004574 switch (spec->board_config) {
4575 case STAC_HP_M4:
Matthew Ranostay72474be2008-10-09 09:32:17 -04004576 /* Enable VREF power saving on GPIO1 detect */
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01004577 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay72474be2008-10-09 09:32:17 -04004578 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
4579 snd_hda_codec_write_cache(codec, codec->afg, 0,
4580 AC_VERB_SET_UNSOLICITED_ENABLE,
4581 (AC_USRSP_EN | STAC_VREF_EVENT | 0x01));
4582 spec->gpio_mask |= 0x02;
4583 break;
4584 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004585 if ((codec->revision_id & 0xf) == 0 ||
4586 (codec->revision_id & 0xf) == 1) {
4587#ifdef SND_HDA_NEEDS_RESUME
4588 codec->patch_ops = stac92hd71bxx_patch_ops;
4589#endif
4590 spec->stream_delay = 40; /* 40 milliseconds */
4591 }
4592
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004593 /* no output amps */
4594 spec->num_pwrs = 0;
4595 spec->mixer = stac92hd71bxx_analog_mixer;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004596 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004597
4598 /* disable VSW */
4599 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
4600 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
4601 break;
4602 case 0x111d7603: /* 6 Port with Analog Mixer */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004603 if ((codec->revision_id & 0xf) == 1) {
4604#ifdef SND_HDA_NEEDS_RESUME
4605 codec->patch_ops = stac92hd71bxx_patch_ops;
4606#endif
4607 spec->stream_delay = 40; /* 40 milliseconds */
4608 }
4609
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004610 /* no output amps */
4611 spec->num_pwrs = 0;
4612 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01004613 default:
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004614 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004615 spec->mixer = stac92hd71bxx_analog_mixer;
4616 spec->init = stac92hd71bxx_analog_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004617 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004618 }
4619
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004620 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004621 spec->aloopback_shift = 0;
4622
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004623 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004624 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004625 spec->mux_nids = stac92hd71bxx_mux_nids;
4626 spec->adc_nids = stac92hd71bxx_adc_nids;
4627 spec->dmic_nids = stac92hd71bxx_dmic_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004628 spec->dmux_nids = stac92hd71bxx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004629 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004630 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004631
4632 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
4633 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004634
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004635 switch (spec->board_config) {
4636 case STAC_HP_M4:
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004637 /* enable internal microphone */
Matthew Ranostayb9aea712008-10-09 08:37:28 -04004638 stac92xx_set_config_reg(codec, 0x0e, 0x01813040);
4639 stac92xx_auto_set_pinctl(codec, 0x0e,
4640 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05004641 /* fallthru */
4642 case STAC_DELL_M4_2:
4643 spec->num_dmics = 0;
4644 spec->num_smuxes = 0;
4645 spec->num_dmuxes = 0;
4646 break;
4647 case STAC_DELL_M4_1:
4648 case STAC_DELL_M4_3:
4649 spec->num_dmics = 1;
4650 spec->num_smuxes = 0;
4651 spec->num_dmuxes = 0;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004652 break;
4653 default:
4654 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
4655 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
4656 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4657 };
4658
Takashi Iwaiaea7bb02008-02-25 18:26:41 +01004659 spec->multiout.num_dacs = 1;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004660 spec->multiout.hp_nid = 0x11;
4661 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004662 if (spec->dinput_mux)
4663 spec->private_dimux.num_items +=
4664 spec->num_dmics -
4665 (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004666
4667 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
4668 if (!err) {
4669 if (spec->board_config < 0) {
4670 printk(KERN_WARNING "hda_codec: No auto-config is "
4671 "available, default to model=ref\n");
4672 spec->board_config = STAC_92HD71BXX_REF;
4673 goto again;
4674 }
4675 err = -EINVAL;
4676 }
4677
4678 if (err < 0) {
4679 stac92xx_free(codec);
4680 return err;
4681 }
4682
Matthew Ranostaye035b842007-11-06 11:53:55 +01004683 return 0;
4684};
4685
Matt2f2f4252005-04-13 14:45:30 +02004686static int patch_stac922x(struct hda_codec *codec)
4687{
4688 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004689 int err;
Matt2f2f4252005-04-13 14:45:30 +02004690
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004691 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004692 if (spec == NULL)
4693 return -ENOMEM;
4694
4695 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004696 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004697 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004698 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
4699 stac922x_models,
4700 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08004701 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004702 spec->gpio_mask = spec->gpio_dir = 0x03;
4703 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004704 /* Intel Macs have all same PCI SSID, so we need to check
4705 * codec SSID to distinguish the exact models
4706 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004707 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004708 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004709
4710 case 0x106b0800:
4711 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02004712 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004713 case 0x106b0600:
4714 case 0x106b0700:
4715 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004716 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004717 case 0x106b0e00:
4718 case 0x106b0f00:
4719 case 0x106b1600:
4720 case 0x106b1700:
4721 case 0x106b0200:
4722 case 0x106b1e00:
4723 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004724 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004725 case 0x106b1a00:
4726 case 0x00000100:
4727 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02004728 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004729 case 0x106b0a00:
4730 case 0x106b2200:
4731 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02004732 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08004733 default:
4734 spec->board_config = STAC_INTEL_MAC_V3;
4735 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004736 }
4737 }
4738
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004739 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004740 if (spec->board_config < 0) {
4741 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
4742 "using BIOS defaults\n");
4743 err = stac92xx_save_bios_config_regs(codec);
4744 if (err < 0) {
4745 stac92xx_free(codec);
4746 return err;
4747 }
4748 spec->pin_configs = spec->bios_pin_configs;
4749 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
Matt Porter403d1942005-11-29 15:00:51 +01004750 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
4751 stac92xx_set_config_regs(codec);
4752 }
Matt2f2f4252005-04-13 14:45:30 +02004753
Matt2f2f4252005-04-13 14:45:30 +02004754 spec->adc_nids = stac922x_adc_nids;
4755 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004756 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004757 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004758 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004759 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004760
4761 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004762 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004763
4764 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02004765
Matt Porter3cc08dc2006-01-23 15:27:49 +01004766 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004767 if (!err) {
4768 if (spec->board_config < 0) {
4769 printk(KERN_WARNING "hda_codec: No auto-config is "
4770 "available, default to model=ref\n");
4771 spec->board_config = STAC_D945_REF;
4772 goto again;
4773 }
4774 err = -EINVAL;
4775 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004776 if (err < 0) {
4777 stac92xx_free(codec);
4778 return err;
4779 }
4780
4781 codec->patch_ops = stac92xx_patch_ops;
4782
Takashi Iwai807a46362007-05-29 19:01:37 +02004783 /* Fix Mux capture level; max to 2 */
4784 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
4785 (0 << AC_AMPCAP_OFFSET_SHIFT) |
4786 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4787 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4788 (0 << AC_AMPCAP_MUTE_SHIFT));
4789
Matt Porter3cc08dc2006-01-23 15:27:49 +01004790 return 0;
4791}
4792
4793static int patch_stac927x(struct hda_codec *codec)
4794{
4795 struct sigmatel_spec *spec;
4796 int err;
4797
4798 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4799 if (spec == NULL)
4800 return -ENOMEM;
4801
4802 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004803 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004804 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004805 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
4806 stac927x_models,
4807 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004808 again:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004809 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
4810 if (spec->board_config < 0)
4811 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4812 "STAC927x, using BIOS defaults\n");
Richard Fish11b44bb2006-08-23 18:31:34 +02004813 err = stac92xx_save_bios_config_regs(codec);
4814 if (err < 0) {
4815 stac92xx_free(codec);
4816 return err;
4817 }
4818 spec->pin_configs = spec->bios_pin_configs;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004819 } else {
Matt Porter3cc08dc2006-01-23 15:27:49 +01004820 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
4821 stac92xx_set_config_regs(codec);
4822 }
4823
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004824 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004825 spec->adc_nids = stac927x_adc_nids;
4826 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
4827 spec->mux_nids = stac927x_mux_nids;
4828 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004829 spec->smux_nids = stac927x_smux_nids;
4830 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04004831 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004832 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004833 spec->multiout.dac_nids = spec->dac_nids;
4834
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004835 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02004836 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004837 case STAC_D965_5ST:
4838 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004839 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004840 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004841 spec->num_dmics = 0;
4842
Tobin Davis93ed1502006-09-01 21:03:12 +02004843 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004844 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004845 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004846 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02004847 switch (codec->subsystem_id) {
4848 case 0x10280209:
4849 case 0x1028022e:
4850 /* correct the device field to SPDIF out */
4851 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
4852 break;
4853 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01004854 /* configure the analog microphone on some laptops */
4855 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01004856 /* correct the front output jack as a hp out */
Matthew Ranostay7989fba2008-02-21 07:50:12 +01004857 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01004858 /* correct the front input jack as a mic */
4859 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
4860 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004861 case STAC_DELL_3ST:
4862 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004863 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004864 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004865 spec->dmic_nids = stac927x_dmic_nids;
4866 spec->num_dmics = STAC927X_NUM_DMICS;
4867
Tobin Davis93ed1502006-09-01 21:03:12 +02004868 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004869 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004870 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004871 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004872 break;
4873 default:
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004874 if (spec->board_config > STAC_D965_REF) {
4875 /* GPIO0 High = Enable EAPD */
4876 spec->eapd_mask = spec->gpio_mask = 0x01;
4877 spec->gpio_dir = spec->gpio_data = 0x01;
4878 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004879 spec->num_dmics = 0;
4880
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004881 spec->init = stac927x_core_init;
4882 spec->mixer = stac927x_mixer;
4883 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004884
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004885 spec->num_pwrs = 0;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004886 spec->aloopback_mask = 0x40;
4887 spec->aloopback_shift = 0;
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004888 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004889
Matt Porter3cc08dc2006-01-23 15:27:49 +01004890 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004891 if (!err) {
4892 if (spec->board_config < 0) {
4893 printk(KERN_WARNING "hda_codec: No auto-config is "
4894 "available, default to model=ref\n");
4895 spec->board_config = STAC_D965_REF;
4896 goto again;
4897 }
4898 err = -EINVAL;
4899 }
Mattc7d4b2f2005-06-27 14:59:41 +02004900 if (err < 0) {
4901 stac92xx_free(codec);
4902 return err;
4903 }
Matt2f2f4252005-04-13 14:45:30 +02004904
4905 codec->patch_ops = stac92xx_patch_ops;
4906
Takashi Iwai52987652008-01-16 16:09:47 +01004907 /*
4908 * !!FIXME!!
4909 * The STAC927x seem to require fairly long delays for certain
4910 * command sequences. With too short delays (even if the answer
4911 * is set to RIRB properly), it results in the silence output
4912 * on some hardwares like Dell.
4913 *
4914 * The below flag enables the longer delay (see get_response
4915 * in hda_intel.c).
4916 */
4917 codec->bus->needs_damn_long_delay = 1;
4918
Takashi Iwaie28d8322008-12-17 13:48:29 +01004919 /* no jack detecion for ref-no-jd model */
4920 if (spec->board_config == STAC_D965_REF_NO_JD)
4921 spec->hp_detect = 0;
4922
Matt2f2f4252005-04-13 14:45:30 +02004923 return 0;
4924}
4925
Matt Porterf3302a52006-07-31 12:49:34 +02004926static int patch_stac9205(struct hda_codec *codec)
4927{
4928 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02004929 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02004930
4931 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4932 if (spec == NULL)
4933 return -ENOMEM;
4934
4935 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004936 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004937 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004938 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
4939 stac9205_models,
4940 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004941 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004942 if (spec->board_config < 0) {
4943 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
4944 err = stac92xx_save_bios_config_regs(codec);
4945 if (err < 0) {
4946 stac92xx_free(codec);
4947 return err;
4948 }
4949 spec->pin_configs = spec->bios_pin_configs;
4950 } else {
Matt Porterf3302a52006-07-31 12:49:34 +02004951 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
4952 stac92xx_set_config_regs(codec);
4953 }
4954
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004955 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02004956 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004957 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02004958 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004959 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004960 spec->smux_nids = stac9205_smux_nids;
4961 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004962 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02004963 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004964 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004965 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004966 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02004967
4968 spec->init = stac9205_core_init;
4969 spec->mixer = stac9205_mixer;
4970
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004971 spec->aloopback_mask = 0x40;
4972 spec->aloopback_shift = 0;
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004973 spec->eapd_switch = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02004974 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02004975
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004976 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004977 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02004978 /* Enable SPDIF in/out */
4979 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
4980 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01004981
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004982 /* Enable unsol response for GPIO4/Dock HP connection */
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01004983 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004984 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4985 snd_hda_codec_write_cache(codec, codec->afg, 0,
4986 AC_VERB_SET_UNSOLICITED_ENABLE,
4987 (AC_USRSP_EN | STAC_HP_EVENT));
4988
4989 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004990 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004991 spec->gpio_mask = 0x1b;
4992 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01004993 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004994 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02004995 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004996 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004997 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004998 case STAC_9205_REF:
4999 /* SPDIF-In enabled */
5000 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005001 default:
5002 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005003 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005004 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005005 break;
5006 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02005007
Matt Porterf3302a52006-07-31 12:49:34 +02005008 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005009 if (!err) {
5010 if (spec->board_config < 0) {
5011 printk(KERN_WARNING "hda_codec: No auto-config is "
5012 "available, default to model=ref\n");
5013 spec->board_config = STAC_9205_REF;
5014 goto again;
5015 }
5016 err = -EINVAL;
5017 }
Matt Porterf3302a52006-07-31 12:49:34 +02005018 if (err < 0) {
5019 stac92xx_free(codec);
5020 return err;
5021 }
5022
5023 codec->patch_ops = stac92xx_patch_ops;
5024
5025 return 0;
5026}
5027
Matt2f2f4252005-04-13 14:45:30 +02005028/*
Guillaume Munch6d859062006-08-22 17:15:47 +02005029 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01005030 */
5031
Guillaume Munch99ccc562006-08-16 19:35:12 +02005032/* static config for Sony VAIO FE550G and Sony VAIO AR */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005033static hda_nid_t vaio_dacs[] = { 0x2 };
5034#define VAIO_HP_DAC 0x5
5035static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
5036static hda_nid_t vaio_mux_nids[] = { 0x15 };
5037
5038static struct hda_input_mux vaio_mux = {
Takashi Iwaia3a2f422007-10-11 11:21:21 +02005039 .num_items = 3,
Takashi Iwaidb064e52006-03-16 16:04:58 +01005040 .items = {
Takashi Iwaid7737812006-04-25 13:05:43 +02005041 /* { "HP", 0x0 }, */
Takashi Iwai1624cb92007-07-05 13:10:51 +02005042 { "Mic Jack", 0x1 },
5043 { "Internal Mic", 0x2 },
Takashi Iwaidb064e52006-03-16 16:04:58 +01005044 { "PCM", 0x3 },
5045 }
5046};
5047
5048static struct hda_verb vaio_init[] = {
5049 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005050 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
Takashi Iwaidb064e52006-03-16 16:04:58 +01005051 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5052 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5053 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5054 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02005055 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005056 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5057 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5058 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5059 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5060 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5061 {}
5062};
5063
Guillaume Munch6d859062006-08-22 17:15:47 +02005064static struct hda_verb vaio_ar_init[] = {
5065 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
5066 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5067 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5068 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5069/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
5070 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02005071 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Guillaume Munch6d859062006-08-22 17:15:47 +02005072 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5073 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5074/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
5075 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5076 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5077 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5078 {}
5079};
5080
Takashi Iwaidb064e52006-03-16 16:04:58 +01005081/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02005082static struct hda_bind_ctls vaio_bind_master_vol = {
5083 .ops = &snd_hda_bind_vol,
5084 .values = {
5085 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
5086 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
5087 0
5088 },
5089};
Takashi Iwaidb064e52006-03-16 16:04:58 +01005090
5091/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02005092static struct hda_bind_ctls vaio_bind_master_sw = {
5093 .ops = &snd_hda_bind_sw,
5094 .values = {
5095 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
5096 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
5097 0,
5098 },
5099};
Takashi Iwaidb064e52006-03-16 16:04:58 +01005100
5101static struct snd_kcontrol_new vaio_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02005102 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
5103 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Takashi Iwaidb064e52006-03-16 16:04:58 +01005104 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5105 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5106 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5107 {
5108 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5109 .name = "Capture Source",
5110 .count = 1,
5111 .info = stac92xx_mux_enum_info,
5112 .get = stac92xx_mux_enum_get,
5113 .put = stac92xx_mux_enum_put,
5114 },
5115 {}
5116};
5117
Guillaume Munch6d859062006-08-22 17:15:47 +02005118static struct snd_kcontrol_new vaio_ar_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02005119 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
5120 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Guillaume Munch6d859062006-08-22 17:15:47 +02005121 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5122 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5123 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5124 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
5125 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
5126 {
5127 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5128 .name = "Capture Source",
5129 .count = 1,
5130 .info = stac92xx_mux_enum_info,
5131 .get = stac92xx_mux_enum_get,
5132 .put = stac92xx_mux_enum_put,
5133 },
5134 {}
5135};
5136
5137static struct hda_codec_ops stac9872_patch_ops = {
Takashi Iwaidb064e52006-03-16 16:04:58 +01005138 .build_controls = stac92xx_build_controls,
5139 .build_pcms = stac92xx_build_pcms,
5140 .init = stac92xx_init,
5141 .free = stac92xx_free,
Takashi Iwaicb53c622007-08-10 17:21:45 +02005142#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaidb064e52006-03-16 16:04:58 +01005143 .resume = stac92xx_resume,
5144#endif
5145};
5146
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005147static int stac9872_vaio_init(struct hda_codec *codec)
5148{
5149 int err;
5150
5151 err = stac92xx_init(codec);
5152 if (err < 0)
5153 return err;
5154 if (codec->patch_ops.unsol_event)
5155 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
5156 return 0;
5157}
5158
5159static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
5160{
Jiang Zhe40c1d302007-11-12 13:05:16 +01005161 if (get_hp_pin_presence(codec, 0x0a)) {
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005162 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5163 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5164 } else {
5165 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5166 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5167 }
5168}
5169
5170static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
5171{
5172 switch (res >> 26) {
5173 case STAC_HP_EVENT:
5174 stac9872_vaio_hp_detect(codec, res);
5175 break;
5176 }
5177}
5178
5179static struct hda_codec_ops stac9872_vaio_patch_ops = {
5180 .build_controls = stac92xx_build_controls,
5181 .build_pcms = stac92xx_build_pcms,
5182 .init = stac9872_vaio_init,
5183 .free = stac92xx_free,
5184 .unsol_event = stac9872_vaio_unsol_event,
5185#ifdef CONFIG_PM
5186 .resume = stac92xx_resume,
5187#endif
5188};
5189
Guillaume Munch6d859062006-08-22 17:15:47 +02005190enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
5191 CXD9872RD_VAIO,
5192 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
5193 STAC9872AK_VAIO,
5194 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
5195 STAC9872K_VAIO,
5196 /* AR Series. id=0x83847664 and subsys=104D1300 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005197 CXD9872AKD_VAIO,
5198 STAC_9872_MODELS,
5199};
Takashi Iwaidb064e52006-03-16 16:04:58 +01005200
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005201static const char *stac9872_models[STAC_9872_MODELS] = {
5202 [CXD9872RD_VAIO] = "vaio",
5203 [CXD9872AKD_VAIO] = "vaio-ar",
5204};
5205
5206static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5207 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
5208 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
5209 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
Tobin Davis68e22542007-03-12 11:36:39 +01005210 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
Takashi Iwaidb064e52006-03-16 16:04:58 +01005211 {}
5212};
5213
Guillaume Munch6d859062006-08-22 17:15:47 +02005214static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01005215{
5216 struct sigmatel_spec *spec;
5217 int board_config;
5218
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005219 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5220 stac9872_models,
5221 stac9872_cfg_tbl);
Takashi Iwaidb064e52006-03-16 16:04:58 +01005222 if (board_config < 0)
5223 /* unknown config, let generic-parser do its job... */
5224 return snd_hda_parse_generic_codec(codec);
5225
5226 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5227 if (spec == NULL)
5228 return -ENOMEM;
5229
5230 codec->spec = spec;
5231 switch (board_config) {
Guillaume Munch6d859062006-08-22 17:15:47 +02005232 case CXD9872RD_VAIO:
5233 case STAC9872AK_VAIO:
5234 case STAC9872K_VAIO:
Takashi Iwaidb064e52006-03-16 16:04:58 +01005235 spec->mixer = vaio_mixer;
5236 spec->init = vaio_init;
5237 spec->multiout.max_channels = 2;
5238 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5239 spec->multiout.dac_nids = vaio_dacs;
5240 spec->multiout.hp_nid = VAIO_HP_DAC;
5241 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5242 spec->adc_nids = vaio_adcs;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005243 spec->num_pwrs = 0;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005244 spec->input_mux = &vaio_mux;
5245 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005246 codec->patch_ops = stac9872_vaio_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005247 break;
Guillaume Munch6d859062006-08-22 17:15:47 +02005248
5249 case CXD9872AKD_VAIO:
5250 spec->mixer = vaio_ar_mixer;
5251 spec->init = vaio_ar_init;
5252 spec->multiout.max_channels = 2;
5253 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5254 spec->multiout.dac_nids = vaio_dacs;
5255 spec->multiout.hp_nid = VAIO_HP_DAC;
5256 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005257 spec->num_pwrs = 0;
Guillaume Munch6d859062006-08-22 17:15:47 +02005258 spec->adc_nids = vaio_adcs;
5259 spec->input_mux = &vaio_mux;
5260 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005261 codec->patch_ops = stac9872_patch_ops;
Guillaume Munch6d859062006-08-22 17:15:47 +02005262 break;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005263 }
5264
Takashi Iwaidb064e52006-03-16 16:04:58 +01005265 return 0;
5266}
5267
5268
5269/*
Matt2f2f4252005-04-13 14:45:30 +02005270 * patch entries
5271 */
5272struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5273 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5274 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5275 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5276 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5277 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5278 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5279 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02005280 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5281 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5282 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5283 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5284 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5285 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01005286 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5287 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5288 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5289 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5290 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5291 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5292 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5293 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5294 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5295 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01005296 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5297 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5298 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5299 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5300 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5301 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02005302 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5303 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02005304 /* The following does not take into account .id=0x83847661 when subsys =
5305 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5306 * currently not fully supported.
5307 */
5308 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5309 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5310 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02005311 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5312 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5313 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5314 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5315 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5316 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5317 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5318 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005319 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005320 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5321 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005322 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01005323 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5324 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005325 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01005326 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5327 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5328 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5329 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5330 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5331 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5332 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5333 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02005334 {} /* terminator */
5335};