blob: d7c622f944f6f393e7ba55c42653b28f2698e6f7 [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},
862};
863
Matthew Ranostaye035b842007-11-06 11:53:55 +0100864static struct hda_verb stac92hd71bxx_core_init[] = {
865 /* set master volume and direct control */
866 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
867 /* connect headphone jack to dac1 */
868 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100869 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
870 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
871 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
872 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100873};
874
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400875#define HD_DISABLE_PORTF 2
Matthew Ranostay541eee82007-12-14 12:08:04 +0100876static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200877 /* start of config #1 */
878
879 /* connect port 0f to audio mixer */
880 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200881 /* unmute right and left channels for node 0x0f */
882 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
883 /* start of config #2 */
884
Matthew Ranostay541eee82007-12-14 12:08:04 +0100885 /* set master volume and direct control */
886 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
887 /* connect headphone jack to dac1 */
888 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200889 /* unmute right and left channels for nodes 0x0a, 0xd */
Matthew Ranostaye035b842007-11-06 11:53:55 +0100890 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
891 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100892 {}
893};
894
Tobin Davis8e21c342007-01-08 11:04:17 +0100895static struct hda_verb stac925x_core_init[] = {
896 /* set dac0mux for dac converter */
897 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
898 {}
899};
900
Mattc7d4b2f2005-06-27 14:59:41 +0200901static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200902 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200903 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200904 {}
905};
906
Tobin Davis93ed1502006-09-01 21:03:12 +0200907static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200908 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200909 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200910 /* unmute node 0x1b */
911 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
912 /* select node 0x03 as DAC */
913 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
914 {}
915};
916
Matt Porter3cc08dc2006-01-23 15:27:49 +0100917static struct hda_verb stac927x_core_init[] = {
918 /* set master volume and direct control */
919 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200920 /* enable analog pc beep path */
921 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100922 {}
923};
924
Matt Porterf3302a52006-07-31 12:49:34 +0200925static struct hda_verb stac9205_core_init[] = {
926 /* set master volume and direct control */
927 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200928 /* enable analog pc beep path */
929 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200930 {}
931};
932
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100933#define STAC_MONO_MUX \
934 { \
935 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
936 .name = "Mono Mux", \
937 .count = 1, \
938 .info = stac92xx_mono_mux_enum_info, \
939 .get = stac92xx_mono_mux_enum_get, \
940 .put = stac92xx_mono_mux_enum_put, \
941 }
942
Matthew Ranostay89385032008-09-11 09:49:39 -0400943#define STAC_AMP_MUX \
944 { \
945 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
946 .name = "Amp Selector Capture Switch", \
947 .count = 1, \
948 .info = stac92xx_amp_mux_enum_info, \
949 .get = stac92xx_amp_mux_enum_get, \
950 .put = stac92xx_amp_mux_enum_put, \
951 }
952
953#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
954 { \
955 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
956 .name = xname, \
957 .index = 0, \
958 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
959 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
960 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
961 .info = stac92xx_amp_volume_info, \
962 .get = stac92xx_amp_volume_get, \
963 .put = stac92xx_amp_volume_put, \
964 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
965 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
966 }
967
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200968#define STAC_INPUT_SOURCE(cnt) \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200969 { \
970 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
971 .name = "Input Source", \
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200972 .count = cnt, \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200973 .info = stac92xx_mux_enum_info, \
974 .get = stac92xx_mux_enum_get, \
975 .put = stac92xx_mux_enum_put, \
976 }
977
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100978#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200979 { \
980 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
981 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100982 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200983 .info = stac92xx_aloopback_info, \
984 .get = stac92xx_aloopback_get, \
985 .put = stac92xx_aloopback_put, \
986 .private_value = verb_read | (verb_write << 16), \
987 }
988
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100989static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200990 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
991 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200992 STAC_INPUT_SOURCE(1),
Matt2f2f4252005-04-13 14:45:30 +0200993 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
994 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200995 { } /* end */
996};
997
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400998#define DELL_M6_MIXER 6
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100999static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04001000 /* start of config #1 */
1001 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1002 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1003
1004 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1005 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1006
1007 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1008 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1009
1010 /* start of config #2 */
1011 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1012 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1013
1014 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1015 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1016
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001017 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1018
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001019 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1020 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1021
1022 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1023 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1024
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001025 { } /* end */
1026};
1027
1028static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001029 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1030
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001031 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1032 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1033
1034 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1035 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1036
1037 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1038 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1039
1040 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1041 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1042
1043 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1044 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1045
1046 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1047 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1048
1049 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1050 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1051 { } /* end */
1052};
1053
1054static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001055 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1056
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001057 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1058 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1059
1060 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1061 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1062
1063 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1064 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1065
1066 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1067 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1068
1069 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1070 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1071
1072 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1073 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1074
1075 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1076 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1077 { } /* end */
1078};
1079
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001080
1081static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1082 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1083 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1084
1085 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1086 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1087
1088 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT),
1089 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
1090
1091 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
1092 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
1093
1094 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
1095 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
1096
1097 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
1098 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
1099
1100 /*
1101 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
1102 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
1103 */
1104 { } /* end */
1105};
1106
Matthew Ranostay541eee82007-12-14 12:08:04 +01001107static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001108 STAC_INPUT_SOURCE(2),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001109 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001110
Matthew Ranostay9b359472007-11-07 13:03:12 +01001111 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1112 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay9b359472007-11-07 13:03:12 +01001113
1114 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1115 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001116 /* analog pc-beep replaced with digital beep support */
1117 /*
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001118 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1119 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001120 */
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001121
Matthew Ranostay687cb982008-10-11 13:52:43 -04001122 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1123 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001124
Matthew Ranostay687cb982008-10-11 13:52:43 -04001125 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1126 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001127
1128 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1129 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1130
1131 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1132 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001133 { } /* end */
1134};
1135
Matthew Ranostay541eee82007-12-14 12:08:04 +01001136static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +01001137 STAC_INPUT_SOURCE(2),
1138 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1139
Matthew Ranostay541eee82007-12-14 12:08:04 +01001140 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1141 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001142
1143 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1144 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001145 { } /* end */
1146};
1147
Tobin Davis8e21c342007-01-08 11:04:17 +01001148static struct snd_kcontrol_new stac925x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001149 STAC_INPUT_SOURCE(1),
Tobin Davis8e21c342007-01-08 11:04:17 +01001150 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +02001151 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001152 { } /* end */
1153};
1154
Takashi Iwaid1d985f2006-11-23 19:27:12 +01001155static struct snd_kcontrol_new stac9205_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001156 STAC_INPUT_SOURCE(2),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001157 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001158
1159 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1160 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001161
1162 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1163 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001164 { } /* end */
1165};
1166
1167/* This needs to be generated dynamically based on sequence */
1168static struct snd_kcontrol_new stac922x_mixer[] = {
1169 STAC_INPUT_SOURCE(2),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001170 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1171 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001172
1173 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1174 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001175 { } /* end */
1176};
1177
1178
1179static struct snd_kcontrol_new stac927x_mixer[] = {
1180 STAC_INPUT_SOURCE(3),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001181 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001182
1183 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1184 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001185
1186 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1187 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001188
1189 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1190 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
Matt Porterf3302a52006-07-31 12:49:34 +02001191 { } /* end */
1192};
1193
Takashi Iwai1697055e2007-12-18 18:05:52 +01001194static struct snd_kcontrol_new stac_dmux_mixer = {
1195 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1196 .name = "Digital Input Source",
1197 /* count set later */
1198 .info = stac92xx_dmux_enum_info,
1199 .get = stac92xx_dmux_enum_get,
1200 .put = stac92xx_dmux_enum_put,
1201};
1202
Matthew Ranostayd9737752008-09-07 12:03:41 +02001203static struct snd_kcontrol_new stac_smux_mixer = {
1204 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001205 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001206 /* count set later */
1207 .info = stac92xx_smux_enum_info,
1208 .get = stac92xx_smux_enum_get,
1209 .put = stac92xx_smux_enum_put,
1210};
1211
Takashi Iwai2134ea42008-01-10 16:53:55 +01001212static const char *slave_vols[] = {
1213 "Front Playback Volume",
1214 "Surround Playback Volume",
1215 "Center Playback Volume",
1216 "LFE Playback Volume",
1217 "Side Playback Volume",
1218 "Headphone Playback Volume",
1219 "Headphone Playback Volume",
1220 "Speaker Playback Volume",
1221 "External Speaker Playback Volume",
1222 "Speaker2 Playback Volume",
1223 NULL
1224};
1225
1226static const char *slave_sws[] = {
1227 "Front Playback Switch",
1228 "Surround Playback Switch",
1229 "Center Playback Switch",
1230 "LFE Playback Switch",
1231 "Side Playback Switch",
1232 "Headphone Playback Switch",
1233 "Headphone Playback Switch",
1234 "Speaker Playback Switch",
1235 "External Speaker Playback Switch",
1236 "Speaker2 Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001237 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001238 NULL
1239};
1240
Matt2f2f4252005-04-13 14:45:30 +02001241static int stac92xx_build_controls(struct hda_codec *codec)
1242{
1243 struct sigmatel_spec *spec = codec->spec;
1244 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001245 int i;
Matt2f2f4252005-04-13 14:45:30 +02001246
1247 err = snd_hda_add_new_ctls(codec, spec->mixer);
1248 if (err < 0)
1249 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001250
1251 for (i = 0; i < spec->num_mixers; i++) {
1252 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1253 if (err < 0)
1254 return err;
1255 }
Takashi Iwai1697055e2007-12-18 18:05:52 +01001256 if (spec->num_dmuxes > 0) {
1257 stac_dmux_mixer.count = spec->num_dmuxes;
1258 err = snd_ctl_add(codec->bus->card,
1259 snd_ctl_new1(&stac_dmux_mixer, codec));
1260 if (err < 0)
1261 return err;
1262 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001263 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001264 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1265 struct hda_input_mux *smux = &spec->private_smux;
1266 /* check for mute support on SPDIF out */
1267 if (wcaps & AC_WCAP_OUT_AMP) {
1268 smux->items[smux->num_items].label = "Off";
1269 smux->items[smux->num_items].index = 0;
1270 smux->num_items++;
1271 spec->spdif_mute = 1;
1272 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001273 stac_smux_mixer.count = spec->num_smuxes;
1274 err = snd_ctl_add(codec->bus->card,
1275 snd_ctl_new1(&stac_smux_mixer, codec));
1276 if (err < 0)
1277 return err;
1278 }
Mattc7d4b2f2005-06-27 14:59:41 +02001279
Mattdabbed62005-06-14 10:19:34 +02001280 if (spec->multiout.dig_out_nid) {
1281 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1282 if (err < 0)
1283 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001284 err = snd_hda_create_spdif_share_sw(codec,
1285 &spec->multiout);
1286 if (err < 0)
1287 return err;
1288 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001289 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001290 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001291 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1292 if (err < 0)
1293 return err;
1294 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001295
1296 /* if we have no master control, let's create it */
1297 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001298 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001299 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001300 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001301 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001302 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001303 if (err < 0)
1304 return err;
1305 }
1306 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1307 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1308 NULL, slave_sws);
1309 if (err < 0)
1310 return err;
1311 }
1312
Mattdabbed62005-06-14 10:19:34 +02001313 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001314}
1315
Matt Porter403d1942005-11-29 15:00:51 +01001316static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001317 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001318 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1319};
1320
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001321/*
1322 STAC 9200 pin configs for
1323 102801A8
1324 102801DE
1325 102801E8
1326*/
1327static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001328 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1329 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001330};
1331
1332/*
1333 STAC 9200 pin configs for
1334 102801C0
1335 102801C1
1336*/
1337static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001338 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1339 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001340};
1341
1342/*
1343 STAC 9200 pin configs for
1344 102801C4 (Dell Dimension E310)
1345 102801C5
1346 102801C7
1347 102801D9
1348 102801DA
1349 102801E3
1350*/
1351static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001352 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1353 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001354};
1355
1356
1357/*
1358 STAC 9200-32 pin configs for
1359 102801B5 (Dell Inspiron 630m)
1360 102801D8 (Dell Inspiron 640m)
1361*/
1362static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001363 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1364 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001365};
1366
1367/*
1368 STAC 9200-32 pin configs for
1369 102801C2 (Dell Latitude D620)
1370 102801C8
1371 102801CC (Dell Latitude D820)
1372 102801D4
1373 102801D6
1374*/
1375static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001376 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1377 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001378};
1379
1380/*
1381 STAC 9200-32 pin configs for
1382 102801CE (Dell XPS M1710)
1383 102801CF (Dell Precision M90)
1384*/
1385static unsigned int dell9200_m23_pin_configs[8] = {
1386 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1387 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1388};
1389
1390/*
1391 STAC 9200-32 pin configs for
1392 102801C9
1393 102801CA
1394 102801CB (Dell Latitude 120L)
1395 102801D3
1396*/
1397static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001398 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1399 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001400};
1401
1402/*
1403 STAC 9200-32 pin configs for
1404 102801BD (Dell Inspiron E1505n)
1405 102801EE
1406 102801EF
1407*/
1408static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001409 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1410 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001411};
1412
1413/*
1414 STAC 9200-32 pin configs for
1415 102801F5 (Dell Inspiron 1501)
1416 102801F6
1417*/
1418static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001419 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1420 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001421};
1422
1423/*
1424 STAC 9200-32
1425 102801CD (Dell Inspiron E1705/9400)
1426*/
1427static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001428 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1429 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001430};
1431
Tobin Davisbf277782008-02-03 20:31:47 +01001432static unsigned int oqo9200_pin_configs[8] = {
1433 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1434 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1435};
1436
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001437
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001438static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1439 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001440 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001441 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1442 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1443 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1444 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1445 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1446 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1447 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1448 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1449 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1450 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001451 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001452};
1453
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001454static const char *stac9200_models[STAC_9200_MODELS] = {
1455 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001456 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001457 [STAC_9200_DELL_D21] = "dell-d21",
1458 [STAC_9200_DELL_D22] = "dell-d22",
1459 [STAC_9200_DELL_D23] = "dell-d23",
1460 [STAC_9200_DELL_M21] = "dell-m21",
1461 [STAC_9200_DELL_M22] = "dell-m22",
1462 [STAC_9200_DELL_M23] = "dell-m23",
1463 [STAC_9200_DELL_M24] = "dell-m24",
1464 [STAC_9200_DELL_M25] = "dell-m25",
1465 [STAC_9200_DELL_M26] = "dell-m26",
1466 [STAC_9200_DELL_M27] = "dell-m27",
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001467 [STAC_9200_GATEWAY] = "gateway",
Takashi Iwai117f2572008-03-18 09:53:23 +01001468 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001469};
1470
1471static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1472 /* SigmaTel reference board */
1473 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1474 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001475 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001476 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1477 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001478 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001479 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1480 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1481 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1482 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1483 "unknown Dell", STAC_9200_DELL_D22),
1484 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1485 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001486 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001487 "Dell Latitude D620", STAC_9200_DELL_M22),
1488 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1489 "unknown Dell", STAC_9200_DELL_D23),
1490 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1491 "unknown Dell", STAC_9200_DELL_D23),
1492 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1493 "unknown Dell", STAC_9200_DELL_M22),
1494 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1495 "unknown Dell", STAC_9200_DELL_M24),
1496 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1497 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001498 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001499 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001500 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001501 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001502 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001503 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001504 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001505 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001506 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001507 "Dell Precision M90", STAC_9200_DELL_M23),
1508 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1509 "unknown Dell", STAC_9200_DELL_M22),
1510 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1511 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001512 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001513 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001514 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001515 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1516 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1517 "unknown Dell", STAC_9200_DELL_D23),
1518 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1519 "unknown Dell", STAC_9200_DELL_D23),
1520 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1521 "unknown Dell", STAC_9200_DELL_D21),
1522 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1523 "unknown Dell", STAC_9200_DELL_D23),
1524 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1525 "unknown Dell", STAC_9200_DELL_D21),
1526 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1527 "unknown Dell", STAC_9200_DELL_M25),
1528 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1529 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001530 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001531 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1532 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1533 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001534 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001535 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001536 /* Gateway machines needs EAPD to be set on resume */
1537 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1538 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1539 STAC_9200_GATEWAY),
1540 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1541 STAC_9200_GATEWAY),
Tobin Davisbf277782008-02-03 20:31:47 +01001542 /* OQO Mobile */
1543 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001544 {} /* terminator */
1545};
1546
Tobin Davis8e21c342007-01-08 11:04:17 +01001547static unsigned int ref925x_pin_configs[8] = {
1548 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001549 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001550};
1551
1552static unsigned int stac925x_MA6_pin_configs[8] = {
1553 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1554 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1555};
1556
Tobin Davis2c11f952007-05-17 09:36:34 +02001557static unsigned int stac925x_PA6_pin_configs[8] = {
1558 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1559 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1560};
1561
Tobin Davis8e21c342007-01-08 11:04:17 +01001562static unsigned int stac925xM2_2_pin_configs[8] = {
Steve Longerbeam7353e142007-05-29 14:36:17 +02001563 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1564 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001565};
1566
1567static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1568 [STAC_REF] = ref925x_pin_configs,
1569 [STAC_M2_2] = stac925xM2_2_pin_configs,
1570 [STAC_MA6] = stac925x_MA6_pin_configs,
Tobin Davis2c11f952007-05-17 09:36:34 +02001571 [STAC_PA6] = stac925x_PA6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001572};
1573
1574static const char *stac925x_models[STAC_925x_MODELS] = {
1575 [STAC_REF] = "ref",
1576 [STAC_M2_2] = "m2-2",
1577 [STAC_MA6] = "m6",
Tobin Davis2c11f952007-05-17 09:36:34 +02001578 [STAC_PA6] = "pa6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001579};
1580
1581static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1582 /* SigmaTel reference board */
1583 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001584 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Tobin Davis8e21c342007-01-08 11:04:17 +01001585 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1586 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1587 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
Tobin Davis2c11f952007-05-17 09:36:34 +02001588 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
Tobin Davis8e21c342007-01-08 11:04:17 +01001589 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1590 {} /* terminator */
1591};
1592
Matthew Ranostaya7662642008-02-21 07:51:14 +01001593static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001594 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1595 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1596 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001597 0x01452050,
1598};
1599
1600static unsigned int dell_m6_pin_configs[13] = {
1601 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001602 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001603 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1604 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001605};
1606
1607static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001608 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001609 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1610 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1611 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001612 [STAC_DELL_EQ] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001613};
1614
1615static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01001616 [STAC_92HD73XX_NO_JD] = "no-jd",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001617 [STAC_92HD73XX_REF] = "ref",
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001618 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1619 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1620 [STAC_DELL_M6_BOTH] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001621 [STAC_DELL_EQ] = "dell-eq",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001622};
1623
1624static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1625 /* SigmaTel reference board */
1626 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001627 "DFI LanParty", STAC_92HD73XX_REF),
1628 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001629 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001630 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001631 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001632 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001633 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001634 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
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, 0x025e,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001637 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001638 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
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, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001641 "unknown Dell", STAC_DELL_M6_DMIC),
1642 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1643 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01001644 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001645 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Joerg Schirottkefa620e92008-12-19 08:13:49 +01001646 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1647 "Dell Studio 17", STAC_DELL_M6_DMIC),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001648 {} /* terminator */
1649};
1650
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001651static unsigned int ref92hd83xxx_pin_configs[14] = {
1652 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1653 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1654 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1655 0x01451160, 0x98560170,
1656};
1657
1658static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1659 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1660};
1661
1662static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1663 [STAC_92HD83XXX_REF] = "ref",
1664};
1665
1666static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1667 /* SigmaTel reference board */
1668 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1669 "DFI LanParty", STAC_92HD71BXX_REF),
1670};
1671
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001672static unsigned int ref92hd71bxx_pin_configs[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001673 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001674 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001675 0x90a000f0, 0x01452050, 0x01452050,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001676};
1677
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001678static unsigned int dell_m4_1_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001679 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001680 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001681 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001682};
1683
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001684static unsigned int dell_m4_2_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001685 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1686 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001687 0x40f000f0, 0x044413b0, 0x044413b0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001688};
1689
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001690static unsigned int dell_m4_3_pin_configs[11] = {
1691 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1692 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1693 0x40f000f0, 0x044413b0, 0x044413b0,
1694};
1695
Matthew Ranostaye035b842007-11-06 11:53:55 +01001696static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1697 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001698 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1699 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001700 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001701 [STAC_HP_M4] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001702};
1703
1704static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1705 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001706 [STAC_DELL_M4_1] = "dell-m4-1",
1707 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001708 [STAC_DELL_M4_3] = "dell-m4-3",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001709 [STAC_HP_M4] = "hp-m4",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001710};
1711
1712static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1713 /* SigmaTel reference board */
1714 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1715 "DFI LanParty", STAC_92HD71BXX_REF),
Takashi Iwai80bf2722008-11-18 10:48:41 +01001716 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f2,
1717 "HP dv5", STAC_HP_M4),
1718 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4,
1719 "HP dv7", STAC_HP_M4),
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001720 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1721 "unknown HP", STAC_HP_M4),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001722 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1723 "unknown Dell", STAC_DELL_M4_1),
1724 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1725 "unknown Dell", STAC_DELL_M4_1),
1726 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1727 "unknown Dell", STAC_DELL_M4_1),
1728 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1729 "unknown Dell", STAC_DELL_M4_1),
1730 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1731 "unknown Dell", STAC_DELL_M4_1),
1732 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1733 "unknown Dell", STAC_DELL_M4_1),
1734 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1735 "unknown Dell", STAC_DELL_M4_1),
1736 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1737 "unknown Dell", STAC_DELL_M4_2),
1738 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1739 "unknown Dell", STAC_DELL_M4_2),
1740 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1741 "unknown Dell", STAC_DELL_M4_2),
1742 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1743 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001744 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1745 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001746 {} /* terminator */
1747};
1748
Matt Porter403d1942005-11-29 15:00:51 +01001749static unsigned int ref922x_pin_configs[10] = {
1750 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1751 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001752 0x40000100, 0x40000100,
1753};
1754
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001755/*
1756 STAC 922X pin configs for
1757 102801A7
1758 102801AB
1759 102801A9
1760 102801D1
1761 102801D2
1762*/
1763static unsigned int dell_922x_d81_pin_configs[10] = {
1764 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1765 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1766 0x01813122, 0x400001f2,
1767};
1768
1769/*
1770 STAC 922X pin configs for
1771 102801AC
1772 102801D0
1773*/
1774static unsigned int dell_922x_d82_pin_configs[10] = {
1775 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1776 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1777 0x01813122, 0x400001f1,
1778};
1779
1780/*
1781 STAC 922X pin configs for
1782 102801BF
1783*/
1784static unsigned int dell_922x_m81_pin_configs[10] = {
1785 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1786 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1787 0x40C003f1, 0x405003f0,
1788};
1789
1790/*
1791 STAC 9221 A1 pin configs for
1792 102801D7 (Dell XPS M1210)
1793*/
1794static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001795 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1796 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001797 0x508003f3, 0x405003f4,
1798};
1799
Matt Porter403d1942005-11-29 15:00:51 +01001800static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001801 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001802 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1803 0x02a19120, 0x40000100,
1804};
1805
1806static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001807 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1808 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001809 0x02a19320, 0x40000100,
1810};
1811
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001812static unsigned int intel_mac_v1_pin_configs[10] = {
1813 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1814 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001815 0x400000fc, 0x400000fb,
1816};
1817
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001818static unsigned int intel_mac_v2_pin_configs[10] = {
1819 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1820 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001821 0x400000fc, 0x400000fb,
1822};
1823
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001824static unsigned int intel_mac_v3_pin_configs[10] = {
1825 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1826 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1827 0x400000fc, 0x400000fb,
1828};
1829
1830static unsigned int intel_mac_v4_pin_configs[10] = {
1831 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1832 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1833 0x400000fc, 0x400000fb,
1834};
1835
1836static unsigned int intel_mac_v5_pin_configs[10] = {
1837 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1838 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1839 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001840};
1841
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001842static unsigned int ecs202_pin_configs[10] = {
1843 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1844 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1845 0x9037012e, 0x40e000f2,
1846};
Takashi Iwai76c08822007-06-19 12:17:42 +02001847
Takashi Iwai19039bd2006-06-28 15:52:16 +02001848static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001849 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001850 [STAC_D945GTP3] = d945gtp3_pin_configs,
1851 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001852 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1853 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1854 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1855 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1856 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001857 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001858 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001859 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1860 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1861 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1862 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1863 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1864 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001865 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001866 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1867 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1868 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1869 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001870};
1871
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001872static const char *stac922x_models[STAC_922X_MODELS] = {
1873 [STAC_D945_REF] = "ref",
1874 [STAC_D945GTP5] = "5stack",
1875 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001876 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1877 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1878 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1879 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1880 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001881 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001882 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001883 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001884 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001885 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1886 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001887 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001888 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001889 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001890 [STAC_922X_DELL_D81] = "dell-d81",
1891 [STAC_922X_DELL_D82] = "dell-d82",
1892 [STAC_922X_DELL_M81] = "dell-m81",
1893 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001894};
1895
1896static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1897 /* SigmaTel reference board */
1898 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1899 "DFI LanParty", STAC_D945_REF),
1900 /* Intel 945G based systems */
1901 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1902 "Intel D945G", STAC_D945GTP3),
1903 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1904 "Intel D945G", STAC_D945GTP3),
1905 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1906 "Intel D945G", STAC_D945GTP3),
1907 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1908 "Intel D945G", STAC_D945GTP3),
1909 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1910 "Intel D945G", STAC_D945GTP3),
1911 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1912 "Intel D945G", STAC_D945GTP3),
1913 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1914 "Intel D945G", STAC_D945GTP3),
1915 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1916 "Intel D945G", STAC_D945GTP3),
1917 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1918 "Intel D945G", STAC_D945GTP3),
1919 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1920 "Intel D945G", STAC_D945GTP3),
1921 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1922 "Intel D945G", STAC_D945GTP3),
1923 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1924 "Intel D945G", STAC_D945GTP3),
1925 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1926 "Intel D945G", STAC_D945GTP3),
1927 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1928 "Intel D945G", STAC_D945GTP3),
1929 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1930 "Intel D945G", STAC_D945GTP3),
1931 /* Intel D945G 5-stack systems */
1932 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1933 "Intel D945G", STAC_D945GTP5),
1934 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1935 "Intel D945G", STAC_D945GTP5),
1936 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1937 "Intel D945G", STAC_D945GTP5),
1938 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1939 "Intel D945G", STAC_D945GTP5),
1940 /* Intel 945P based systems */
1941 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1942 "Intel D945P", STAC_D945GTP3),
1943 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1944 "Intel D945P", STAC_D945GTP3),
1945 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1946 "Intel D945P", STAC_D945GTP3),
1947 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1948 "Intel D945P", STAC_D945GTP3),
1949 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1950 "Intel D945P", STAC_D945GTP3),
1951 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1952 "Intel D945P", STAC_D945GTP5),
1953 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08001954 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001955 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001956 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001957 /* Dell systems */
1958 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1959 "unknown Dell", STAC_922X_DELL_D81),
1960 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1961 "unknown Dell", STAC_922X_DELL_D81),
1962 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1963 "unknown Dell", STAC_922X_DELL_D81),
1964 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1965 "unknown Dell", STAC_922X_DELL_D82),
1966 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1967 "unknown Dell", STAC_922X_DELL_M81),
1968 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1969 "unknown Dell", STAC_922X_DELL_D82),
1970 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1971 "unknown Dell", STAC_922X_DELL_D81),
1972 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1973 "unknown Dell", STAC_922X_DELL_D81),
1974 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1975 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001976 /* ECS/PC Chips boards */
1977 SND_PCI_QUIRK(0x1019, 0x2144,
1978 "ECS/PC chips", STAC_ECS_202),
1979 SND_PCI_QUIRK(0x1019, 0x2608,
1980 "ECS/PC chips", STAC_ECS_202),
1981 SND_PCI_QUIRK(0x1019, 0x2633,
1982 "ECS/PC chips P17G/1333", STAC_ECS_202),
1983 SND_PCI_QUIRK(0x1019, 0x2811,
1984 "ECS/PC chips", STAC_ECS_202),
1985 SND_PCI_QUIRK(0x1019, 0x2812,
1986 "ECS/PC chips", STAC_ECS_202),
1987 SND_PCI_QUIRK(0x1019, 0x2813,
1988 "ECS/PC chips", STAC_ECS_202),
1989 SND_PCI_QUIRK(0x1019, 0x2814,
1990 "ECS/PC chips", STAC_ECS_202),
1991 SND_PCI_QUIRK(0x1019, 0x2815,
1992 "ECS/PC chips", STAC_ECS_202),
1993 SND_PCI_QUIRK(0x1019, 0x2816,
1994 "ECS/PC chips", STAC_ECS_202),
1995 SND_PCI_QUIRK(0x1019, 0x2817,
1996 "ECS/PC chips", STAC_ECS_202),
1997 SND_PCI_QUIRK(0x1019, 0x2818,
1998 "ECS/PC chips", STAC_ECS_202),
1999 SND_PCI_QUIRK(0x1019, 0x2819,
2000 "ECS/PC chips", STAC_ECS_202),
2001 SND_PCI_QUIRK(0x1019, 0x2820,
2002 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01002003 {} /* terminator */
2004};
2005
Matt Porter3cc08dc2006-01-23 15:27:49 +01002006static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002007 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2008 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2009 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2010 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002011};
2012
Tobin Davis93ed1502006-09-01 21:03:12 +02002013static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002014 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2015 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2016 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2017 0x40000100, 0x40000100
2018};
2019
Tobin Davis93ed1502006-09-01 21:03:12 +02002020static unsigned int d965_5st_pin_configs[14] = {
2021 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2022 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2023 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2024 0x40000100, 0x40000100
2025};
2026
Tobin Davis4ff076e2007-08-07 11:48:12 +02002027static unsigned int dell_3st_pin_configs[14] = {
2028 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2029 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002030 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002031 0x40c003fc, 0x40000100
2032};
2033
Tobin Davis93ed1502006-09-01 21:03:12 +02002034static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002035 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002036 [STAC_D965_REF] = ref927x_pin_configs,
2037 [STAC_D965_3ST] = d965_3st_pin_configs,
2038 [STAC_D965_5ST] = d965_5st_pin_configs,
2039 [STAC_DELL_3ST] = dell_3st_pin_configs,
2040 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002041};
2042
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002043static const char *stac927x_models[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002044 [STAC_D965_REF_NO_JD] = "ref-no-jd",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002045 [STAC_D965_REF] = "ref",
2046 [STAC_D965_3ST] = "3stack",
2047 [STAC_D965_5ST] = "5stack",
2048 [STAC_DELL_3ST] = "dell-3stack",
2049 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002050};
2051
2052static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2053 /* SigmaTel reference board */
2054 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2055 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002056 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002057 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2058 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002059 /* 965 based 3 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002060 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
2061 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
2062 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
2063 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
2064 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
2065 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
2066 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
2067 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
2068 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
2069 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
2070 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
2071 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
2072 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
2073 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
2074 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
2075 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002076 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002077 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002078 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002079 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2080 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002081 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002082 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2083 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002084 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02002085 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002086 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2087 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2088 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2089 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002090 /* 965 based 5 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002091 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2092 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2093 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2094 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2095 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2096 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2097 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2098 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2099 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002100 {} /* terminator */
2101};
2102
Matt Porterf3302a52006-07-31 12:49:34 +02002103static unsigned int ref9205_pin_configs[12] = {
2104 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002105 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002106 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002107};
2108
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002109/*
2110 STAC 9205 pin configs for
2111 102801F1
2112 102801F2
2113 102801FC
2114 102801FD
2115 10280204
2116 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002117 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002118*/
2119static unsigned int dell_9205_m42_pin_configs[12] = {
2120 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2121 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2122 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2123};
2124
2125/*
2126 STAC 9205 pin configs for
2127 102801F9
2128 102801FA
2129 102801FE
2130 102801FF (Dell Precision M4300)
2131 10280206
2132 10280200
2133 10280201
2134*/
2135static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002136 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2137 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2138 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2139};
2140
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002141static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002142 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2143 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2144 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2145};
2146
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002147static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002148 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002149 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2150 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2151 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Matt Porterf3302a52006-07-31 12:49:34 +02002152};
2153
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002154static const char *stac9205_models[STAC_9205_MODELS] = {
2155 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002156 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002157 [STAC_9205_DELL_M43] = "dell-m43",
2158 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002159};
2160
2161static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2162 /* SigmaTel reference board */
2163 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2164 "DFI LanParty", STAC_9205_REF),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002165 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2166 "unknown Dell", STAC_9205_DELL_M42),
2167 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2168 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002169 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002170 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002171 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2172 "Dell Precision", STAC_9205_DELL_M43),
2173 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2174 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002175 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2176 "unknown Dell", STAC_9205_DELL_M42),
2177 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2178 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002179 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2180 "Dell Precision", STAC_9205_DELL_M43),
2181 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002182 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002183 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2184 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002185 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2186 "Dell Precision", STAC_9205_DELL_M43),
2187 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2188 "Dell Precision", STAC_9205_DELL_M43),
2189 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2190 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002191 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2192 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002193 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2194 "Dell Vostro 1500", STAC_9205_DELL_M42),
Matt Porterf3302a52006-07-31 12:49:34 +02002195 {} /* terminator */
2196};
2197
Richard Fish11b44bb2006-08-23 18:31:34 +02002198static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2199{
2200 int i;
2201 struct sigmatel_spec *spec = codec->spec;
2202
2203 if (! spec->bios_pin_configs) {
2204 spec->bios_pin_configs = kcalloc(spec->num_pins,
2205 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
2206 if (! spec->bios_pin_configs)
2207 return -ENOMEM;
2208 }
2209
2210 for (i = 0; i < spec->num_pins; i++) {
2211 hda_nid_t nid = spec->pin_nids[i];
2212 unsigned int pin_cfg;
2213
2214 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2215 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2216 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2217 nid, pin_cfg);
2218 spec->bios_pin_configs[i] = pin_cfg;
2219 }
2220
2221 return 0;
2222}
2223
Matthew Ranostay87d48362007-07-17 11:52:24 +02002224static void stac92xx_set_config_reg(struct hda_codec *codec,
2225 hda_nid_t pin_nid, unsigned int pin_config)
2226{
2227 int i;
2228 snd_hda_codec_write(codec, pin_nid, 0,
2229 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2230 pin_config & 0x000000ff);
2231 snd_hda_codec_write(codec, pin_nid, 0,
2232 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2233 (pin_config & 0x0000ff00) >> 8);
2234 snd_hda_codec_write(codec, pin_nid, 0,
2235 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2236 (pin_config & 0x00ff0000) >> 16);
2237 snd_hda_codec_write(codec, pin_nid, 0,
2238 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2239 pin_config >> 24);
2240 i = snd_hda_codec_read(codec, pin_nid, 0,
2241 AC_VERB_GET_CONFIG_DEFAULT,
2242 0x00);
2243 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2244 pin_nid, i);
2245}
2246
Matt2f2f4252005-04-13 14:45:30 +02002247static void stac92xx_set_config_regs(struct hda_codec *codec)
2248{
2249 int i;
2250 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002251
Matthew Ranostay87d48362007-07-17 11:52:24 +02002252 if (!spec->pin_configs)
2253 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002254
Matthew Ranostay87d48362007-07-17 11:52:24 +02002255 for (i = 0; i < spec->num_pins; i++)
2256 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2257 spec->pin_configs[i]);
Matt2f2f4252005-04-13 14:45:30 +02002258}
Matt2f2f4252005-04-13 14:45:30 +02002259
Matt2f2f4252005-04-13 14:45:30 +02002260/*
2261 * Analog playback callbacks
2262 */
2263static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2264 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002265 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002266{
2267 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002268 if (spec->stream_delay)
2269 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002270 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2271 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002272}
2273
2274static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2275 struct hda_codec *codec,
2276 unsigned int stream_tag,
2277 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002278 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002279{
2280 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002281 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002282}
2283
2284static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2285 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002286 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002287{
2288 struct sigmatel_spec *spec = codec->spec;
2289 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2290}
2291
2292/*
Mattdabbed62005-06-14 10:19:34 +02002293 * Digital playback callbacks
2294 */
2295static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2296 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002297 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002298{
2299 struct sigmatel_spec *spec = codec->spec;
2300 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2301}
2302
2303static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2304 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002305 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002306{
2307 struct sigmatel_spec *spec = codec->spec;
2308 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2309}
2310
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002311static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2312 struct hda_codec *codec,
2313 unsigned int stream_tag,
2314 unsigned int format,
2315 struct snd_pcm_substream *substream)
2316{
2317 struct sigmatel_spec *spec = codec->spec;
2318 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2319 stream_tag, format, substream);
2320}
2321
Mattdabbed62005-06-14 10:19:34 +02002322
2323/*
Matt2f2f4252005-04-13 14:45:30 +02002324 * Analog capture callbacks
2325 */
2326static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2327 struct hda_codec *codec,
2328 unsigned int stream_tag,
2329 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002330 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002331{
2332 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002333 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002334
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002335 if (spec->powerdown_adcs) {
2336 msleep(40);
2337 snd_hda_codec_write_cache(codec, nid, 0,
2338 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2339 }
2340 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002341 return 0;
2342}
2343
2344static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2345 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002346 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002347{
2348 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002349 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002350
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002351 snd_hda_codec_cleanup_stream(codec, nid);
2352 if (spec->powerdown_adcs)
2353 snd_hda_codec_write_cache(codec, nid, 0,
2354 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002355 return 0;
2356}
2357
Mattdabbed62005-06-14 10:19:34 +02002358static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2359 .substreams = 1,
2360 .channels_min = 2,
2361 .channels_max = 2,
2362 /* NID is set in stac92xx_build_pcms */
2363 .ops = {
2364 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002365 .close = stac92xx_dig_playback_pcm_close,
2366 .prepare = stac92xx_dig_playback_pcm_prepare
Mattdabbed62005-06-14 10:19:34 +02002367 },
2368};
2369
2370static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2371 .substreams = 1,
2372 .channels_min = 2,
2373 .channels_max = 2,
2374 /* NID is set in stac92xx_build_pcms */
2375};
2376
Matt2f2f4252005-04-13 14:45:30 +02002377static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2378 .substreams = 1,
2379 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002380 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002381 .nid = 0x02, /* NID to query formats and rates */
2382 .ops = {
2383 .open = stac92xx_playback_pcm_open,
2384 .prepare = stac92xx_playback_pcm_prepare,
2385 .cleanup = stac92xx_playback_pcm_cleanup
2386 },
2387};
2388
Matt Porter3cc08dc2006-01-23 15:27:49 +01002389static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2390 .substreams = 1,
2391 .channels_min = 2,
2392 .channels_max = 2,
2393 .nid = 0x06, /* NID to query formats and rates */
2394 .ops = {
2395 .open = stac92xx_playback_pcm_open,
2396 .prepare = stac92xx_playback_pcm_prepare,
2397 .cleanup = stac92xx_playback_pcm_cleanup
2398 },
2399};
2400
Matt2f2f4252005-04-13 14:45:30 +02002401static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002402 .channels_min = 2,
2403 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002404 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002405 .ops = {
2406 .prepare = stac92xx_capture_pcm_prepare,
2407 .cleanup = stac92xx_capture_pcm_cleanup
2408 },
2409};
2410
2411static int stac92xx_build_pcms(struct hda_codec *codec)
2412{
2413 struct sigmatel_spec *spec = codec->spec;
2414 struct hda_pcm *info = spec->pcm_rec;
2415
2416 codec->num_pcms = 1;
2417 codec->pcm_info = info;
2418
Mattc7d4b2f2005-06-27 14:59:41 +02002419 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002420 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Matt2f2f4252005-04-13 14:45:30 +02002421 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002422 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002423 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002424
2425 if (spec->alt_switch) {
2426 codec->num_pcms++;
2427 info++;
2428 info->name = "STAC92xx Analog Alt";
2429 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2430 }
Matt2f2f4252005-04-13 14:45:30 +02002431
Mattdabbed62005-06-14 10:19:34 +02002432 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2433 codec->num_pcms++;
2434 info++;
2435 info->name = "STAC92xx Digital";
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002436 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Mattdabbed62005-06-14 10:19:34 +02002437 if (spec->multiout.dig_out_nid) {
2438 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2439 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2440 }
2441 if (spec->dig_in_nid) {
2442 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2443 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2444 }
2445 }
2446
Matt2f2f4252005-04-13 14:45:30 +02002447 return 0;
2448}
2449
Takashi Iwaic960a032006-03-23 17:06:28 +01002450static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2451{
2452 unsigned int pincap = snd_hda_param_read(codec, nid,
2453 AC_PAR_PIN_CAP);
2454 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2455 if (pincap & AC_PINCAP_VREF_100)
2456 return AC_PINCTL_VREF_100;
2457 if (pincap & AC_PINCAP_VREF_80)
2458 return AC_PINCTL_VREF_80;
2459 if (pincap & AC_PINCAP_VREF_50)
2460 return AC_PINCTL_VREF_50;
2461 if (pincap & AC_PINCAP_VREF_GRD)
2462 return AC_PINCTL_VREF_GRD;
2463 return 0;
2464}
2465
Matt Porter403d1942005-11-29 15:00:51 +01002466static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2467
2468{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002469 snd_hda_codec_write_cache(codec, nid, 0,
2470 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002471}
2472
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002473#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2474
2475static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2476 struct snd_ctl_elem_value *ucontrol)
2477{
2478 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2479 struct sigmatel_spec *spec = codec->spec;
2480
Takashi Iwaid7a89432008-11-12 09:48:04 +01002481 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002482 return 0;
2483}
2484
2485static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2486 struct snd_ctl_elem_value *ucontrol)
2487{
2488 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2489 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002490 int nid = kcontrol->private_value;
2491
2492 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002493
2494 /* check to be sure that the ports are upto date with
2495 * switch changes
2496 */
2497 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2498
2499 return 1;
2500}
2501
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002502#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002503
2504static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2505{
2506 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2507 struct sigmatel_spec *spec = codec->spec;
2508 int io_idx = kcontrol-> private_value & 0xff;
2509
2510 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2511 return 0;
2512}
2513
2514static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2515{
2516 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2517 struct sigmatel_spec *spec = codec->spec;
2518 hda_nid_t nid = kcontrol->private_value >> 8;
2519 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002520 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002521
2522 spec->io_switch[io_idx] = val;
2523
2524 if (val)
2525 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002526 else {
2527 unsigned int pinctl = AC_PINCTL_IN_EN;
2528 if (io_idx) /* set VREF for mic */
2529 pinctl |= stac92xx_get_vref(codec, nid);
2530 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2531 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002532
2533 /* check the auto-mute again: we need to mute/unmute the speaker
2534 * appropriately according to the pin direction
2535 */
2536 if (spec->hp_detect)
2537 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2538
Matt Porter403d1942005-11-29 15:00:51 +01002539 return 1;
2540}
2541
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002542#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2543
2544static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2545 struct snd_ctl_elem_value *ucontrol)
2546{
2547 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2548 struct sigmatel_spec *spec = codec->spec;
2549
2550 ucontrol->value.integer.value[0] = spec->clfe_swap;
2551 return 0;
2552}
2553
2554static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2555 struct snd_ctl_elem_value *ucontrol)
2556{
2557 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2558 struct sigmatel_spec *spec = codec->spec;
2559 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002560 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002561
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002562 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002563 return 0;
2564
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002565 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002566
2567 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2568 spec->clfe_swap ? 0x4 : 0x0);
2569
2570 return 1;
2571}
2572
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002573#define STAC_CODEC_HP_SWITCH(xname) \
2574 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2575 .name = xname, \
2576 .index = 0, \
2577 .info = stac92xx_hp_switch_info, \
2578 .get = stac92xx_hp_switch_get, \
2579 .put = stac92xx_hp_switch_put, \
2580 }
2581
Matt Porter403d1942005-11-29 15:00:51 +01002582#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2583 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2584 .name = xname, \
2585 .index = 0, \
2586 .info = stac92xx_io_switch_info, \
2587 .get = stac92xx_io_switch_get, \
2588 .put = stac92xx_io_switch_put, \
2589 .private_value = xpval, \
2590 }
2591
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002592#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2593 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2594 .name = xname, \
2595 .index = 0, \
2596 .info = stac92xx_clfe_switch_info, \
2597 .get = stac92xx_clfe_switch_get, \
2598 .put = stac92xx_clfe_switch_put, \
2599 .private_value = xpval, \
2600 }
Matt Porter403d1942005-11-29 15:00:51 +01002601
Mattc7d4b2f2005-06-27 14:59:41 +02002602enum {
2603 STAC_CTL_WIDGET_VOL,
2604 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002605 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002606 STAC_CTL_WIDGET_AMP_MUX,
2607 STAC_CTL_WIDGET_AMP_VOL,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002608 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002609 STAC_CTL_WIDGET_IO_SWITCH,
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002610 STAC_CTL_WIDGET_CLFE_SWITCH
Mattc7d4b2f2005-06-27 14:59:41 +02002611};
2612
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002613static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002614 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2615 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002616 STAC_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002617 STAC_AMP_MUX,
2618 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002619 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002620 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002621 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002622};
2623
2624/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002625static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2626 struct snd_kcontrol_new *ktemp,
2627 int idx, const char *name,
2628 unsigned long val)
Mattc7d4b2f2005-06-27 14:59:41 +02002629{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002630 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002631
2632 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2633 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2634
2635 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2636 if (! knew)
2637 return -ENOMEM;
2638 if (spec->kctl_alloc) {
2639 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2640 kfree(spec->kctl_alloc);
2641 }
2642 spec->kctl_alloc = knew;
2643 spec->num_kctl_alloc = num;
2644 }
2645
2646 knew = &spec->kctl_alloc[spec->num_kctl_used];
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002647 *knew = *ktemp;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002648 knew->index = idx;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002649 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002650 if (!knew->name)
Mattc7d4b2f2005-06-27 14:59:41 +02002651 return -ENOMEM;
2652 knew->private_value = val;
2653 spec->num_kctl_used++;
2654 return 0;
2655}
2656
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002657static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2658 int type, int idx, const char *name,
2659 unsigned long val)
2660{
2661 return stac92xx_add_control_temp(spec,
2662 &stac92xx_control_templates[type],
2663 idx, name, val);
2664}
2665
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002666
2667/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002668static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2669 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002670{
2671 return stac92xx_add_control_idx(spec, type, 0, name, val);
2672}
2673
Matt Porter403d1942005-11-29 15:00:51 +01002674/* flag inputs as additional dynamic lineouts */
2675static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2676{
2677 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002678 unsigned int wcaps, wtype;
2679 int i, num_dacs = 0;
2680
2681 /* use the wcaps cache to count all DACs available for line-outs */
2682 for (i = 0; i < codec->num_nodes; i++) {
2683 wcaps = codec->wcaps[i];
2684 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002685
Steve Longerbeam7b043892007-05-03 20:50:03 +02002686 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2687 num_dacs++;
2688 }
Matt Porter403d1942005-11-29 15:00:51 +01002689
Steve Longerbeam7b043892007-05-03 20:50:03 +02002690 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2691
Matt Porter403d1942005-11-29 15:00:51 +01002692 switch (cfg->line_outs) {
2693 case 3:
2694 /* add line-in as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002695 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002696 cfg->line_out_pins[cfg->line_outs] =
2697 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002698 spec->line_switch = 1;
2699 cfg->line_outs++;
2700 }
2701 break;
2702 case 2:
2703 /* add line-in as clfe and mic as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002704 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002705 cfg->line_out_pins[cfg->line_outs] =
2706 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002707 spec->line_switch = 1;
2708 cfg->line_outs++;
2709 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002710 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002711 cfg->line_out_pins[cfg->line_outs] =
2712 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002713 spec->mic_switch = 1;
2714 cfg->line_outs++;
2715 }
2716 break;
2717 case 1:
2718 /* add line-in as surr and mic as clfe */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002719 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002720 cfg->line_out_pins[cfg->line_outs] =
2721 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002722 spec->line_switch = 1;
2723 cfg->line_outs++;
2724 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002725 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002726 cfg->line_out_pins[cfg->line_outs] =
2727 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002728 spec->mic_switch = 1;
2729 cfg->line_outs++;
2730 }
2731 break;
2732 }
2733
2734 return 0;
2735}
2736
Steve Longerbeam7b043892007-05-03 20:50:03 +02002737
2738static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2739{
2740 int i;
2741
2742 for (i = 0; i < spec->multiout.num_dacs; i++) {
2743 if (spec->multiout.dac_nids[i] == nid)
2744 return 1;
2745 }
2746
2747 return 0;
2748}
2749
Matt Porter3cc08dc2006-01-23 15:27:49 +01002750/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02002751 * Fill in the dac_nids table from the parsed pin configuration
2752 * This function only works when every pin in line_out_pins[]
2753 * contains atleast one DAC in its connection list. Some 92xx
2754 * codecs are not connected directly to a DAC, such as the 9200
2755 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002756 */
Takashi Iwai19039bd2006-06-28 15:52:16 +02002757static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaidf802952007-07-02 19:18:00 +02002758 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002759{
2760 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002761 int i, j, conn_len = 0;
2762 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2763 unsigned int wcaps, wtype;
2764
Mattc7d4b2f2005-06-27 14:59:41 +02002765 for (i = 0; i < cfg->line_outs; i++) {
2766 nid = cfg->line_out_pins[i];
Steve Longerbeam7b043892007-05-03 20:50:03 +02002767 conn_len = snd_hda_get_connections(codec, nid, conn,
2768 HDA_MAX_CONNECTIONS);
2769 for (j = 0; j < conn_len; j++) {
2770 wcaps = snd_hda_param_read(codec, conn[j],
2771 AC_PAR_AUDIO_WIDGET_CAP);
2772 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002773 if (wtype != AC_WID_AUD_OUT ||
2774 (wcaps & AC_WCAP_DIGITAL))
2775 continue;
2776 /* conn[j] is a DAC routed to this line-out */
2777 if (!is_in_dac_nids(spec, conn[j]))
2778 break;
2779 }
2780
2781 if (j == conn_len) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002782 if (spec->multiout.num_dacs > 0) {
2783 /* we have already working output pins,
2784 * so let's drop the broken ones again
2785 */
2786 cfg->line_outs = spec->multiout.num_dacs;
2787 break;
2788 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002789 /* error out, no available DAC found */
2790 snd_printk(KERN_ERR
2791 "%s: No available DAC for pin 0x%x\n",
2792 __func__, nid);
2793 return -ENODEV;
2794 }
2795
2796 spec->multiout.dac_nids[i] = conn[j];
2797 spec->multiout.num_dacs++;
2798 if (conn_len > 1) {
2799 /* select this DAC in the pin's input mux */
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002800 snd_hda_codec_write_cache(codec, nid, 0,
2801 AC_VERB_SET_CONNECT_SEL, j);
Steve Longerbeam7b043892007-05-03 20:50:03 +02002802
2803 }
Mattc7d4b2f2005-06-27 14:59:41 +02002804 }
2805
Steve Longerbeam7b043892007-05-03 20:50:03 +02002806 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2807 spec->multiout.num_dacs,
2808 spec->multiout.dac_nids[0],
2809 spec->multiout.dac_nids[1],
2810 spec->multiout.dac_nids[2],
2811 spec->multiout.dac_nids[3],
2812 spec->multiout.dac_nids[4]);
Mattc7d4b2f2005-06-27 14:59:41 +02002813 return 0;
2814}
2815
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002816/* create volume control/switch for the given prefx type */
2817static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2818{
2819 char name[32];
2820 int err;
2821
2822 sprintf(name, "%s Playback Volume", pfx);
2823 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2824 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2825 if (err < 0)
2826 return err;
2827 sprintf(name, "%s Playback Switch", pfx);
2828 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2829 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2830 if (err < 0)
2831 return err;
2832 return 0;
2833}
2834
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002835static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2836{
2837 if (!spec->multiout.hp_nid)
2838 spec->multiout.hp_nid = nid;
2839 else if (spec->multiout.num_dacs > 4) {
2840 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2841 return 1;
2842 } else {
2843 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2844 spec->multiout.num_dacs++;
2845 }
2846 return 0;
2847}
2848
2849static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2850{
2851 if (is_in_dac_nids(spec, nid))
2852 return 1;
2853 if (spec->multiout.hp_nid == nid)
2854 return 1;
2855 return 0;
2856}
2857
Mattc7d4b2f2005-06-27 14:59:41 +02002858/* add playback controls from the parsed DAC table */
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002859static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
Takashi Iwai19039bd2006-06-28 15:52:16 +02002860 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002861{
Takashi Iwai19039bd2006-06-28 15:52:16 +02002862 static const char *chname[4] = {
2863 "Front", "Surround", NULL /*CLFE*/, "Side"
2864 };
Matthew Ranostayd21995e2008-10-13 13:22:45 -04002865 hda_nid_t nid = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02002866 int i, err;
2867
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002868 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002869 unsigned int wid_caps, pincap;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002870
2871
Takashi Iwai40ac8c42008-02-29 14:16:17 +01002872 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
Matt Porter403d1942005-11-29 15:00:51 +01002873 if (!spec->multiout.dac_nids[i])
Mattc7d4b2f2005-06-27 14:59:41 +02002874 continue;
2875
2876 nid = spec->multiout.dac_nids[i];
2877
2878 if (i == 2) {
2879 /* Center/LFE */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002880 err = create_controls(spec, "Center", nid, 1);
2881 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002882 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002883 err = create_controls(spec, "LFE", nid, 2);
2884 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002885 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002886
2887 wid_caps = get_wcaps(codec, nid);
2888
2889 if (wid_caps & AC_WCAP_LR_SWAP) {
2890 err = stac92xx_add_control(spec,
2891 STAC_CTL_WIDGET_CLFE_SWITCH,
2892 "Swap Center/LFE Playback Switch", nid);
2893
2894 if (err < 0)
2895 return err;
2896 }
2897
Mattc7d4b2f2005-06-27 14:59:41 +02002898 } else {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002899 err = create_controls(spec, chname[i], nid, 3);
2900 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002901 return err;
2902 }
2903 }
2904
Matthew Ranostayfedb7562008-09-23 21:46:30 -04002905 if ((spec->multiout.num_dacs - cfg->line_outs) > 0 &&
2906 cfg->hp_outs && !spec->multiout.hp_nid)
2907 spec->multiout.hp_nid = nid;
2908
Takashi Iwai95026622008-11-24 07:51:11 +01002909 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002910 err = stac92xx_add_control(spec,
2911 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01002912 "Headphone as Line Out Switch",
2913 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002914 if (err < 0)
2915 return err;
2916 }
2917
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002918 if (spec->line_switch) {
2919 nid = cfg->input_pins[AUTO_PIN_LINE];
2920 pincap = snd_hda_param_read(codec, nid,
2921 AC_PAR_PIN_CAP);
2922 if (pincap & AC_PINCAP_OUT) {
2923 err = stac92xx_add_control(spec,
2924 STAC_CTL_WIDGET_IO_SWITCH,
2925 "Line In as Output Switch", nid << 8);
2926 if (err < 0)
2927 return err;
2928 }
2929 }
Matt Porter403d1942005-11-29 15:00:51 +01002930
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002931 if (spec->mic_switch) {
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002932 unsigned int def_conf;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002933 unsigned int mic_pin = AUTO_PIN_MIC;
2934again:
2935 nid = cfg->input_pins[mic_pin];
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002936 def_conf = snd_hda_codec_read(codec, nid, 0,
2937 AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002938 /* some laptops have an internal analog microphone
2939 * which can't be used as a output */
2940 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2941 pincap = snd_hda_param_read(codec, nid,
2942 AC_PAR_PIN_CAP);
2943 if (pincap & AC_PINCAP_OUT) {
2944 err = stac92xx_add_control(spec,
2945 STAC_CTL_WIDGET_IO_SWITCH,
2946 "Mic as Output Switch", (nid << 8) | 1);
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002947 nid = snd_hda_codec_read(codec, nid, 0,
2948 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2949 if (!check_in_dac_nids(spec, nid))
2950 add_spec_dacs(spec, nid);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002951 if (err < 0)
2952 return err;
2953 }
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002954 } else if (mic_pin == AUTO_PIN_MIC) {
2955 mic_pin = AUTO_PIN_FRONT_MIC;
2956 goto again;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002957 }
2958 }
Matt Porter403d1942005-11-29 15:00:51 +01002959
Mattc7d4b2f2005-06-27 14:59:41 +02002960 return 0;
2961}
2962
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002963/* add playback controls for Speaker and HP outputs */
2964static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2965 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002966{
2967 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02002968 hda_nid_t nid;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002969 int i, old_num_dacs, err;
Mattc7d4b2f2005-06-27 14:59:41 +02002970
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002971 old_num_dacs = spec->multiout.num_dacs;
2972 for (i = 0; i < cfg->hp_outs; i++) {
2973 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2974 if (wid_caps & AC_WCAP_UNSOL_CAP)
2975 spec->hp_detect = 1;
2976 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2977 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2978 if (check_in_dac_nids(spec, nid))
2979 nid = 0;
2980 if (! nid)
Mattc7d4b2f2005-06-27 14:59:41 +02002981 continue;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002982 add_spec_dacs(spec, nid);
2983 }
2984 for (i = 0; i < cfg->speaker_outs; i++) {
Steve Longerbeam7b043892007-05-03 20:50:03 +02002985 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002986 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2987 if (check_in_dac_nids(spec, nid))
2988 nid = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002989 if (! nid)
2990 continue;
2991 add_spec_dacs(spec, nid);
Mattc7d4b2f2005-06-27 14:59:41 +02002992 }
Matthew Ranostay1b290a52007-07-12 15:17:34 +02002993 for (i = 0; i < cfg->line_outs; i++) {
2994 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2995 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2996 if (check_in_dac_nids(spec, nid))
2997 nid = 0;
2998 if (! nid)
2999 continue;
3000 add_spec_dacs(spec, nid);
3001 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003002 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
3003 static const char *pfxs[] = {
3004 "Speaker", "External Speaker", "Speaker2",
3005 };
3006 err = create_controls(spec, pfxs[i - old_num_dacs],
3007 spec->multiout.dac_nids[i], 3);
3008 if (err < 0)
3009 return err;
3010 }
3011 if (spec->multiout.hp_nid) {
Takashi Iwai2626a262008-03-14 09:18:32 +01003012 err = create_controls(spec, "Headphone",
3013 spec->multiout.hp_nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003014 if (err < 0)
3015 return err;
3016 }
Mattc7d4b2f2005-06-27 14:59:41 +02003017
3018 return 0;
3019}
3020
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003021/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003022static const char *stac92xx_mono_labels[4] = {
3023 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003024};
3025
3026/* create mono mux for mono out on capable codecs */
3027static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3028{
3029 struct sigmatel_spec *spec = codec->spec;
3030 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3031 int i, num_cons;
3032 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3033
3034 num_cons = snd_hda_get_connections(codec,
3035 spec->mono_nid,
3036 con_lst,
3037 HDA_MAX_NUM_INPUTS);
3038 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3039 return -EINVAL;
3040
3041 for (i = 0; i < num_cons; i++) {
3042 mono_mux->items[mono_mux->num_items].label =
3043 stac92xx_mono_labels[i];
3044 mono_mux->items[mono_mux->num_items].index = i;
3045 mono_mux->num_items++;
3046 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003047
3048 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3049 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003050}
3051
Matthew Ranostay89385032008-09-11 09:49:39 -04003052/* labels for amp mux outputs */
3053static const char *stac92xx_amp_labels[3] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04003054 "Front Microphone", "Microphone", "Line In",
Matthew Ranostay89385032008-09-11 09:49:39 -04003055};
3056
3057/* create amp out controls mux on capable codecs */
3058static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3059{
3060 struct sigmatel_spec *spec = codec->spec;
3061 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3062 int i, err;
3063
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003064 for (i = 0; i < spec->num_amps; i++) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003065 amp_mux->items[amp_mux->num_items].label =
3066 stac92xx_amp_labels[i];
3067 amp_mux->items[amp_mux->num_items].index = i;
3068 amp_mux->num_items++;
3069 }
3070
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003071 if (spec->num_amps > 1) {
3072 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3073 "Amp Selector Capture Switch", 0);
3074 if (err < 0)
3075 return err;
3076 }
Matthew Ranostay89385032008-09-11 09:49:39 -04003077 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3078 "Amp Capture Volume",
3079 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3080}
3081
3082
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003083/* create PC beep volume controls */
3084static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3085 hda_nid_t nid)
3086{
3087 struct sigmatel_spec *spec = codec->spec;
3088 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3089 int err;
3090
3091 /* check for mute support for the the amp */
3092 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3093 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3094 "PC Beep Playback Switch",
3095 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3096 if (err < 0)
3097 return err;
3098 }
3099
3100 /* check to see if there is volume support for the amp */
3101 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3102 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3103 "PC Beep Playback Volume",
3104 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3105 if (err < 0)
3106 return err;
3107 }
3108 return 0;
3109}
3110
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003111#ifdef CONFIG_SND_HDA_INPUT_BEEP
3112#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3113
3114static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3115 struct snd_ctl_elem_value *ucontrol)
3116{
3117 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3118 ucontrol->value.integer.value[0] = codec->beep->enabled;
3119 return 0;
3120}
3121
3122static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3123 struct snd_ctl_elem_value *ucontrol)
3124{
3125 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3126 int enabled = !!ucontrol->value.integer.value[0];
3127 if (codec->beep->enabled != enabled) {
3128 codec->beep->enabled = enabled;
3129 return 1;
3130 }
3131 return 0;
3132}
3133
3134static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3135 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3136 .info = stac92xx_dig_beep_switch_info,
3137 .get = stac92xx_dig_beep_switch_get,
3138 .put = stac92xx_dig_beep_switch_put,
3139};
3140
3141static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3142{
3143 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3144 0, "PC Beep Playback Switch", 0);
3145}
3146#endif
3147
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003148static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3149{
3150 struct sigmatel_spec *spec = codec->spec;
3151 int wcaps, nid, i, err = 0;
3152
3153 for (i = 0; i < spec->num_muxes; i++) {
3154 nid = spec->mux_nids[i];
3155 wcaps = get_wcaps(codec, nid);
3156
3157 if (wcaps & AC_WCAP_OUT_AMP) {
3158 err = stac92xx_add_control_idx(spec,
3159 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3160 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3161 if (err < 0)
3162 return err;
3163 }
3164 }
3165 return 0;
3166};
3167
Matthew Ranostayd9737752008-09-07 12:03:41 +02003168static const char *stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003169 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003170};
3171
3172static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3173{
3174 struct sigmatel_spec *spec = codec->spec;
3175 struct hda_input_mux *spdif_mux = &spec->private_smux;
Matthew Ranostay65973632008-09-16 10:39:37 -04003176 const char **labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003177 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003178 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003179
3180 num_cons = snd_hda_get_connections(codec,
3181 spec->smux_nids[0],
3182 con_lst,
3183 HDA_MAX_NUM_INPUTS);
Matthew Ranostay65973632008-09-16 10:39:37 -04003184 if (!num_cons)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003185 return -EINVAL;
3186
Matthew Ranostay65973632008-09-16 10:39:37 -04003187 if (!labels)
3188 labels = stac92xx_spdif_labels;
3189
Matthew Ranostayd9737752008-09-07 12:03:41 +02003190 for (i = 0; i < num_cons; i++) {
Matthew Ranostay65973632008-09-16 10:39:37 -04003191 spdif_mux->items[spdif_mux->num_items].label = labels[i];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003192 spdif_mux->items[spdif_mux->num_items].index = i;
3193 spdif_mux->num_items++;
3194 }
3195
3196 return 0;
3197}
3198
Matt Porter8b657272006-10-26 17:12:59 +02003199/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003200static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003201 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3202 "Digital Mic 3", "Digital Mic 4"
3203};
3204
3205/* create playback/capture controls for input pins on dmic capable codecs */
3206static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3207 const struct auto_pin_cfg *cfg)
3208{
3209 struct sigmatel_spec *spec = codec->spec;
3210 struct hda_input_mux *dimux = &spec->private_dimux;
3211 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003212 int err, i, j;
3213 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02003214
3215 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3216 dimux->items[dimux->num_items].index = 0;
3217 dimux->num_items++;
3218
3219 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003220 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003221 int index;
3222 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003223 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02003224 unsigned int def_conf;
3225
3226 def_conf = snd_hda_codec_read(codec,
3227 spec->dmic_nids[i],
3228 0,
3229 AC_VERB_GET_CONFIG_DEFAULT,
3230 0);
3231 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3232 continue;
3233
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003234 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02003235 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003236 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02003237 con_lst,
3238 HDA_MAX_NUM_INPUTS);
3239 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003240 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02003241 index = j;
3242 goto found;
3243 }
3244 continue;
3245found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003246 wcaps = get_wcaps(codec, nid) &
3247 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003248
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003249 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003250 sprintf(name, "%s Capture Volume",
3251 stac92xx_dmic_labels[dimux->num_items]);
3252
3253 err = stac92xx_add_control(spec,
3254 STAC_CTL_WIDGET_VOL,
3255 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003256 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3257 (wcaps & AC_WCAP_OUT_AMP) ?
3258 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003259 if (err < 0)
3260 return err;
3261 }
3262
Matt Porter8b657272006-10-26 17:12:59 +02003263 dimux->items[dimux->num_items].label =
3264 stac92xx_dmic_labels[dimux->num_items];
3265 dimux->items[dimux->num_items].index = index;
3266 dimux->num_items++;
3267 }
3268
3269 return 0;
3270}
3271
Mattc7d4b2f2005-06-27 14:59:41 +02003272/* create playback/capture controls for input pins */
3273static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3274{
3275 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003276 struct hda_input_mux *imux = &spec->private_imux;
3277 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3278 int i, j, k;
3279
3280 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003281 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02003282
Takashi Iwai314634b2006-09-21 11:56:18 +02003283 if (!cfg->input_pins[i])
3284 continue;
3285 index = -1;
3286 for (j = 0; j < spec->num_muxes; j++) {
3287 int num_cons;
3288 num_cons = snd_hda_get_connections(codec,
3289 spec->mux_nids[j],
3290 con_lst,
3291 HDA_MAX_NUM_INPUTS);
3292 for (k = 0; k < num_cons; k++)
3293 if (con_lst[k] == cfg->input_pins[i]) {
3294 index = k;
3295 goto found;
3296 }
Mattc7d4b2f2005-06-27 14:59:41 +02003297 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003298 continue;
3299 found:
3300 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3301 imux->items[imux->num_items].index = index;
3302 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003303 }
3304
Steve Longerbeam7b043892007-05-03 20:50:03 +02003305 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003306 /*
3307 * Set the current input for the muxes.
3308 * The STAC9221 has two input muxes with identical source
3309 * NID lists. Hopefully this won't get confused.
3310 */
3311 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003312 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3313 AC_VERB_SET_CONNECT_SEL,
3314 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003315 }
3316 }
3317
Mattc7d4b2f2005-06-27 14:59:41 +02003318 return 0;
3319}
3320
Mattc7d4b2f2005-06-27 14:59:41 +02003321static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3322{
3323 struct sigmatel_spec *spec = codec->spec;
3324 int i;
3325
3326 for (i = 0; i < spec->autocfg.line_outs; i++) {
3327 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3328 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3329 }
3330}
3331
3332static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3333{
3334 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003335 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003336
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003337 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3338 hda_nid_t pin;
3339 pin = spec->autocfg.hp_pins[i];
3340 if (pin) /* connect to front */
3341 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3342 }
3343 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3344 hda_nid_t pin;
3345 pin = spec->autocfg.speaker_pins[i];
3346 if (pin) /* connect to front */
3347 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3348 }
Mattc7d4b2f2005-06-27 14:59:41 +02003349}
3350
Matt Porter3cc08dc2006-01-23 15:27:49 +01003351static 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 +02003352{
3353 struct sigmatel_spec *spec = codec->spec;
3354 int err;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003355 int hp_speaker_swap = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003356
Matt Porter8b657272006-10-26 17:12:59 +02003357 if ((err = snd_hda_parse_pin_def_config(codec,
3358 &spec->autocfg,
3359 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003360 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003361 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003362 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003363
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003364 /* If we have no real line-out pin and multiple hp-outs, HPs should
3365 * be set up as multi-channel outputs.
3366 */
3367 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3368 spec->autocfg.hp_outs > 1) {
3369 /* Copy hp_outs to line_outs, backup line_outs in
3370 * speaker_outs so that the following routines can handle
3371 * HP pins as primary outputs.
3372 */
3373 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3374 sizeof(spec->autocfg.line_out_pins));
3375 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3376 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3377 sizeof(spec->autocfg.hp_pins));
3378 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3379 hp_speaker_swap = 1;
3380 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003381 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003382 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3383 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003384 u32 caps = query_amp_caps(codec,
3385 spec->autocfg.mono_out_pin, dir);
3386 hda_nid_t conn_list[1];
3387
3388 /* get the mixer node and then the mono mux if it exists */
3389 if (snd_hda_get_connections(codec,
3390 spec->autocfg.mono_out_pin, conn_list, 1) &&
3391 snd_hda_get_connections(codec, conn_list[0],
3392 conn_list, 1)) {
3393
3394 int wcaps = get_wcaps(codec, conn_list[0]);
3395 int wid_type = (wcaps & AC_WCAP_TYPE)
3396 >> AC_WCAP_TYPE_SHIFT;
3397 /* LR swap check, some stac925x have a mux that
3398 * changes the DACs output path instead of the
3399 * mono-mux path.
3400 */
3401 if (wid_type == AC_WID_AUD_SEL &&
3402 !(wcaps & AC_WCAP_LR_SWAP))
3403 spec->mono_nid = conn_list[0];
3404 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003405 if (dir) {
3406 hda_nid_t nid = spec->autocfg.mono_out_pin;
3407
3408 /* most mono outs have a least a mute/unmute switch */
3409 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3410 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3411 "Mono Playback Switch",
3412 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003413 if (err < 0)
3414 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003415 /* check for volume support for the amp */
3416 if ((caps & AC_AMPCAP_NUM_STEPS)
3417 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3418 err = stac92xx_add_control(spec,
3419 STAC_CTL_WIDGET_VOL,
3420 "Mono Playback Volume",
3421 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3422 if (err < 0)
3423 return err;
3424 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003425 }
3426
3427 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3428 AC_PINCTL_OUT_EN);
3429 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003430
Matt Porter403d1942005-11-29 15:00:51 +01003431 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
3432 return err;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003433 if (spec->multiout.num_dacs == 0)
3434 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
3435 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003436
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003437 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
3438
3439 if (err < 0)
3440 return err;
3441
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003442 /* setup analog beep controls */
3443 if (spec->anabeep_nid > 0) {
3444 err = stac92xx_auto_create_beep_ctls(codec,
3445 spec->anabeep_nid);
3446 if (err < 0)
3447 return err;
3448 }
3449
3450 /* setup digital beep controls and input device */
3451#ifdef CONFIG_SND_HDA_INPUT_BEEP
3452 if (spec->digbeep_nid > 0) {
3453 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003454 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003455
3456 err = stac92xx_auto_create_beep_ctls(codec, nid);
3457 if (err < 0)
3458 return err;
3459 err = snd_hda_attach_beep_device(codec, nid);
3460 if (err < 0)
3461 return err;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003462 /* if no beep switch is available, make its own one */
3463 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3464 if (codec->beep &&
3465 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3466 err = stac92xx_beep_switch_ctl(codec);
3467 if (err < 0)
3468 return err;
3469 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003470 }
3471#endif
3472
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003473 if (hp_speaker_swap == 1) {
3474 /* Restore the hp_outs and line_outs */
3475 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3476 sizeof(spec->autocfg.line_out_pins));
3477 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3478 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
3479 sizeof(spec->autocfg.speaker_pins));
3480 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
3481 memset(spec->autocfg.speaker_pins, 0,
3482 sizeof(spec->autocfg.speaker_pins));
3483 spec->autocfg.speaker_outs = 0;
3484 }
3485
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003486 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3487
3488 if (err < 0)
3489 return err;
3490
3491 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3492
3493 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003494 return err;
3495
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003496 if (spec->mono_nid > 0) {
3497 err = stac92xx_auto_create_mono_output_ctls(codec);
3498 if (err < 0)
3499 return err;
3500 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003501 if (spec->num_amps > 0) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003502 err = stac92xx_auto_create_amp_output_ctls(codec);
3503 if (err < 0)
3504 return err;
3505 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003506 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003507 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3508 &spec->autocfg)) < 0)
3509 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003510 if (spec->num_muxes > 0) {
3511 err = stac92xx_auto_create_mux_input_ctls(codec);
3512 if (err < 0)
3513 return err;
3514 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003515 if (spec->num_smuxes > 0) {
3516 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3517 if (err < 0)
3518 return err;
3519 }
Matt Porter8b657272006-10-26 17:12:59 +02003520
Mattc7d4b2f2005-06-27 14:59:41 +02003521 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003522 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003523 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003524
Takashi Iwai82bc9552006-03-21 11:24:42 +01003525 if (spec->autocfg.dig_out_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003526 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003527 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003528 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003529
3530 if (spec->kctl_alloc)
3531 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3532
3533 spec->input_mux = &spec->private_imux;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003534 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003535 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003536 spec->mono_mux = &spec->private_mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -04003537 spec->amp_mux = &spec->private_amp_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003538 return 1;
3539}
3540
Takashi Iwai82bc9552006-03-21 11:24:42 +01003541/* add playback controls for HP output */
3542static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3543 struct auto_pin_cfg *cfg)
3544{
3545 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003546 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003547 unsigned int wid_caps;
3548
3549 if (! pin)
3550 return 0;
3551
3552 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003553 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003554 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003555
3556 return 0;
3557}
3558
Richard Fish160ea0d2006-09-06 13:58:25 +02003559/* add playback controls for LFE output */
3560static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3561 struct auto_pin_cfg *cfg)
3562{
3563 struct sigmatel_spec *spec = codec->spec;
3564 int err;
3565 hda_nid_t lfe_pin = 0x0;
3566 int i;
3567
3568 /*
3569 * search speaker outs and line outs for a mono speaker pin
3570 * with an amp. If one is found, add LFE controls
3571 * for it.
3572 */
3573 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3574 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003575 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003576 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3577 if (wcaps == AC_WCAP_OUT_AMP)
3578 /* found a mono speaker with an amp, must be lfe */
3579 lfe_pin = pin;
3580 }
3581
3582 /* if speaker_outs is 0, then speakers may be in line_outs */
3583 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3584 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3585 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003586 unsigned int defcfg;
Harvey Harrison8b551782008-02-29 11:56:48 +01003587 defcfg = snd_hda_codec_read(codec, pin, 0,
Richard Fish160ea0d2006-09-06 13:58:25 +02003588 AC_VERB_GET_CONFIG_DEFAULT,
3589 0x00);
Harvey Harrison8b551782008-02-29 11:56:48 +01003590 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003591 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003592 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3593 if (wcaps == AC_WCAP_OUT_AMP)
3594 /* found a mono speaker with an amp,
3595 must be lfe */
3596 lfe_pin = pin;
3597 }
3598 }
3599 }
3600
3601 if (lfe_pin) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003602 err = create_controls(spec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003603 if (err < 0)
3604 return err;
3605 }
3606
3607 return 0;
3608}
3609
Mattc7d4b2f2005-06-27 14:59:41 +02003610static int stac9200_parse_auto_config(struct hda_codec *codec)
3611{
3612 struct sigmatel_spec *spec = codec->spec;
3613 int err;
3614
Kailang Yangdf694da2005-12-05 19:42:22 +01003615 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003616 return err;
3617
3618 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3619 return err;
3620
Takashi Iwai82bc9552006-03-21 11:24:42 +01003621 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3622 return err;
3623
Richard Fish160ea0d2006-09-06 13:58:25 +02003624 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3625 return err;
3626
Takashi Iwai355a0ec2008-11-11 16:46:19 +01003627 if (spec->num_muxes > 0) {
3628 err = stac92xx_auto_create_mux_input_ctls(codec);
3629 if (err < 0)
3630 return err;
3631 }
3632
Takashi Iwai82bc9552006-03-21 11:24:42 +01003633 if (spec->autocfg.dig_out_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003634 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003635 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003636 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003637
3638 if (spec->kctl_alloc)
3639 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3640
3641 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003642 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003643
3644 return 1;
3645}
3646
Sam Revitch62fe78e2006-05-10 15:09:17 +02003647/*
3648 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3649 * funky external mute control using GPIO pins.
3650 */
3651
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003652static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003653 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003654{
3655 unsigned int gpiostate, gpiomask, gpiodir;
3656
3657 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3658 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003659 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003660
3661 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3662 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003663 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003664
3665 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3666 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003667 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003668
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003669 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003670 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3671
3672 snd_hda_codec_write(codec, codec->afg, 0,
3673 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003674 snd_hda_codec_read(codec, codec->afg, 0,
3675 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003676
3677 msleep(1);
3678
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003679 snd_hda_codec_read(codec, codec->afg, 0,
3680 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003681}
3682
Takashi Iwai314634b2006-09-21 11:56:18 +02003683static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3684 unsigned int event)
3685{
3686 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003687 snd_hda_codec_write_cache(codec, nid, 0,
3688 AC_VERB_SET_UNSOLICITED_ENABLE,
3689 (AC_USRSP_EN | event));
Takashi Iwai314634b2006-09-21 11:56:18 +02003690}
3691
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003692static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3693{
3694 int i;
3695 for (i = 0; i < cfg->hp_outs; i++)
3696 if (cfg->hp_pins[i] == nid)
3697 return 1; /* nid is a HP-Out */
3698
3699 return 0; /* nid is not a HP-Out */
3700};
3701
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003702static void stac92xx_power_down(struct hda_codec *codec)
3703{
3704 struct sigmatel_spec *spec = codec->spec;
3705
3706 /* power down inactive DACs */
3707 hda_nid_t *dac;
3708 for (dac = spec->dac_list; *dac; dac++)
Matthew Ranostay44510892008-02-21 07:49:31 +01003709 if (!is_in_dac_nids(spec, *dac) &&
3710 spec->multiout.hp_nid != *dac)
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003711 snd_hda_codec_write_cache(codec, *dac, 0,
3712 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3713}
3714
Takashi Iwaif73d3582008-11-25 08:21:51 +01003715static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
3716 int enable);
3717
Mattc7d4b2f2005-06-27 14:59:41 +02003718static int stac92xx_init(struct hda_codec *codec)
3719{
3720 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003721 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01003722 unsigned int gpio;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003723 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003724
Mattc7d4b2f2005-06-27 14:59:41 +02003725 snd_hda_sequence_write(codec, spec->init);
3726
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003727 /* power down adcs initially */
3728 if (spec->powerdown_adcs)
3729 for (i = 0; i < spec->num_adcs; i++)
3730 snd_hda_codec_write_cache(codec,
3731 spec->adc_nids[i], 0,
3732 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01003733
3734 /* set up GPIO */
3735 gpio = spec->gpio_data;
3736 /* turn on EAPD statically when spec->eapd_switch isn't set.
3737 * otherwise, unsol event will turn it on/off dynamically
3738 */
3739 if (!spec->eapd_switch)
3740 gpio |= spec->eapd_mask;
3741 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
3742
Takashi Iwai82bc9552006-03-21 11:24:42 +01003743 /* set up pins */
3744 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02003745 /* Enable unsolicited responses on the HP widget */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003746 for (i = 0; i < cfg->hp_outs; i++)
Takashi Iwai314634b2006-09-21 11:56:18 +02003747 enable_pin_detect(codec, cfg->hp_pins[i],
3748 STAC_HP_EVENT);
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01003749 /* force to enable the first line-out; the others are set up
3750 * in unsol_event
3751 */
3752 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3753 AC_PINCTL_OUT_EN);
Takashi Iwaieb995a82006-09-21 14:28:21 +02003754 stac92xx_auto_init_hp_out(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003755 /* fake event to set up pins */
3756 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3757 } else {
3758 stac92xx_auto_init_multi_out(codec);
3759 stac92xx_auto_init_hp_out(codec);
3760 }
3761 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01003762 hda_nid_t nid = cfg->input_pins[i];
3763 if (nid) {
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01003764 unsigned int pinctl;
3765 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
3766 /* for mic pins, force to initialize */
3767 pinctl = stac92xx_get_vref(codec, nid);
3768 } else {
3769 pinctl = snd_hda_codec_read(codec, nid, 0,
3770 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3771 /* if PINCTL already set then skip */
3772 if (pinctl & AC_PINCTL_IN_EN)
3773 continue;
3774 }
3775 pinctl |= AC_PINCTL_IN_EN;
Takashi Iwaic960a032006-03-23 17:06:28 +01003776 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3777 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01003778 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003779 for (i = 0; i < spec->num_dmics; i++)
3780 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3781 AC_PINCTL_IN_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003782 if (cfg->dig_out_pin)
3783 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3784 AC_PINCTL_OUT_EN);
3785 if (cfg->dig_in_pin)
3786 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3787 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01003788 for (i = 0; i < spec->num_pwrs; i++) {
3789 hda_nid_t nid = spec->pwr_nids[i];
3790 int pinctl, def_conf;
3791 int event = STAC_PWR_EVENT;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003792
Takashi Iwaif73d3582008-11-25 08:21:51 +01003793 if (is_nid_hp_pin(cfg, nid) && spec->hp_detect)
3794 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003795
Takashi Iwaif73d3582008-11-25 08:21:51 +01003796 pinctl = snd_hda_codec_read(codec, nid, 0,
3797 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3798 /* outputs are only ports capable of power management
3799 * any attempts on powering down a input port cause the
3800 * referenced VREF to act quirky.
3801 */
3802 if (pinctl & AC_PINCTL_IN_EN)
3803 continue;
3804 def_conf = snd_hda_codec_read(codec, nid, 0,
3805 AC_VERB_GET_CONFIG_DEFAULT, 0);
3806 def_conf = get_defcfg_connect(def_conf);
3807 /* skip any ports that don't have jacks since presence
3808 * detection is useless */
3809 if (def_conf != AC_JACK_PORT_COMPLEX) {
3810 if (def_conf != AC_JACK_PORT_NONE)
3811 stac_toggle_power_map(codec, nid, 1);
3812 continue;
3813 }
3814 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3815 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3816 }
3817 if (spec->dac_list)
3818 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02003819 return 0;
3820}
3821
Matt2f2f4252005-04-13 14:45:30 +02003822static void stac92xx_free(struct hda_codec *codec)
3823{
Mattc7d4b2f2005-06-27 14:59:41 +02003824 struct sigmatel_spec *spec = codec->spec;
3825 int i;
3826
3827 if (! spec)
3828 return;
3829
3830 if (spec->kctl_alloc) {
3831 for (i = 0; i < spec->num_kctl_used; i++)
3832 kfree(spec->kctl_alloc[i].name);
3833 kfree(spec->kctl_alloc);
3834 }
3835
Richard Fish11b44bb2006-08-23 18:31:34 +02003836 if (spec->bios_pin_configs)
3837 kfree(spec->bios_pin_configs);
3838
Mattc7d4b2f2005-06-27 14:59:41 +02003839 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003840 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02003841}
3842
Matt4e550962005-07-04 17:51:39 +02003843static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3844 unsigned int flag)
3845{
3846 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3847 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02003848
Takashi Iwaif9acba42007-05-29 18:01:06 +02003849 if (pin_ctl & AC_PINCTL_IN_EN) {
3850 /*
3851 * we need to check the current set-up direction of
3852 * shared input pins since they can be switched via
3853 * "xxx as Output" mixer switch
3854 */
3855 struct sigmatel_spec *spec = codec->spec;
3856 struct auto_pin_cfg *cfg = &spec->autocfg;
3857 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3858 spec->line_switch) ||
3859 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3860 spec->mic_switch))
3861 return;
3862 }
3863
Steve Longerbeam7b043892007-05-03 20:50:03 +02003864 /* if setting pin direction bits, clear the current
3865 direction bits first */
3866 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3867 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3868
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003869 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003870 AC_VERB_SET_PIN_WIDGET_CONTROL,
3871 pin_ctl | flag);
3872}
3873
3874static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3875 unsigned int flag)
3876{
3877 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3878 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003879 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003880 AC_VERB_SET_PIN_WIDGET_CONTROL,
3881 pin_ctl & ~flag);
3882}
3883
Jiang Zhe40c1d302007-11-12 13:05:16 +01003884static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02003885{
3886 if (!nid)
3887 return 0;
3888 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Jiang Zhe40c1d302007-11-12 13:05:16 +01003889 & (1 << 31)) {
3890 unsigned int pinctl;
3891 pinctl = snd_hda_codec_read(codec, nid, 0,
3892 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3893 if (pinctl & AC_PINCTL_IN_EN)
3894 return 0; /* mic- or line-input */
3895 else
3896 return 1; /* HP-output */
3897 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003898 return 0;
3899}
3900
Takashi Iwaid7a89432008-11-12 09:48:04 +01003901/* return non-zero if the hp-pin of the given array index isn't
3902 * a jack-detection target
3903 */
3904static int no_hp_sensing(struct sigmatel_spec *spec, int i)
3905{
3906 struct auto_pin_cfg *cfg = &spec->autocfg;
3907
3908 /* ignore sensing of shared line and mic jacks */
3909 if (spec->line_switch &&
3910 cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_LINE])
3911 return 1;
3912 if (spec->mic_switch &&
3913 cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_MIC])
3914 return 1;
3915 /* ignore if the pin is set as line-out */
3916 if (cfg->hp_pins[i] == spec->hp_switch)
3917 return 1;
3918 return 0;
3919}
3920
Takashi Iwai314634b2006-09-21 11:56:18 +02003921static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
Matt4e550962005-07-04 17:51:39 +02003922{
3923 struct sigmatel_spec *spec = codec->spec;
3924 struct auto_pin_cfg *cfg = &spec->autocfg;
3925 int i, presence;
3926
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003927 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003928 if (spec->gpio_mute)
3929 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3930 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3931
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003932 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003933 if (presence)
3934 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01003935 if (no_hp_sensing(spec, i))
3936 continue;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003937 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003938 }
Matt4e550962005-07-04 17:51:39 +02003939
3940 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01003941 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003942 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01003943 stac92xx_reset_pinctl(codec, spec->hp_switch,
3944 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003945 for (i = 0; i < cfg->line_outs; i++)
3946 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3947 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003948 for (i = 0; i < cfg->speaker_outs; i++)
3949 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3950 AC_PINCTL_OUT_EN);
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05003951 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003952 stac_gpio_set(codec, spec->gpio_mask,
3953 spec->gpio_dir, spec->gpio_data &
3954 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003955 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01003956 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003957 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01003958 stac92xx_set_pinctl(codec, spec->hp_switch,
3959 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003960 for (i = 0; i < cfg->line_outs; i++)
3961 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3962 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003963 for (i = 0; i < cfg->speaker_outs; i++)
3964 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3965 AC_PINCTL_OUT_EN);
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05003966 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003967 stac_gpio_set(codec, spec->gpio_mask,
3968 spec->gpio_dir, spec->gpio_data |
3969 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003970 }
Takashi Iwaid7a89432008-11-12 09:48:04 +01003971 /* toggle hp outs */
3972 for (i = 0; i < cfg->hp_outs; i++) {
3973 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
3974 if (no_hp_sensing(spec, i))
3975 continue;
3976 if (presence)
3977 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
3978 else
3979 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
3980 }
Matt4e550962005-07-04 17:51:39 +02003981}
3982
Takashi Iwaif73d3582008-11-25 08:21:51 +01003983static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
3984 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003985{
3986 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01003987 unsigned int idx, val;
3988
3989 for (idx = 0; idx < spec->num_pwrs; idx++) {
3990 if (spec->pwr_nids[idx] == nid)
3991 break;
3992 }
3993 if (idx >= spec->num_pwrs)
3994 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003995
3996 /* several codecs have two power down bits */
3997 if (spec->pwr_mapping)
3998 idx = spec->pwr_mapping[idx];
3999 else
4000 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004001
Takashi Iwaif73d3582008-11-25 08:21:51 +01004002 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4003 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004004 val &= ~idx;
4005 else
4006 val |= idx;
4007
4008 /* power down unused output ports */
4009 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004010}
4011
4012static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4013{
4014 stac_toggle_power_map(codec, nid, get_hp_pin_presence(codec, nid));
4015}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004016
Takashi Iwai314634b2006-09-21 11:56:18 +02004017static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4018{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004019 struct sigmatel_spec *spec = codec->spec;
4020 int idx = res >> 26 & 0x0f;
4021
Matthew Ranostay72474be2008-10-09 09:32:17 -04004022 switch ((res >> 26) & 0x70) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004023 case STAC_HP_EVENT:
4024 stac92xx_hp_detect(codec, res);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004025 /* fallthru */
4026 case STAC_PWR_EVENT:
4027 if (spec->num_pwrs > 0)
4028 stac92xx_pin_sense(codec, idx);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004029 break;
4030 case STAC_VREF_EVENT: {
4031 int data = snd_hda_codec_read(codec, codec->afg, 0,
4032 AC_VERB_GET_GPIO_DATA, 0);
4033 /* toggle VREF state based on GPIOx status */
4034 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4035 !!(data & (1 << idx)));
4036 break;
4037 }
Takashi Iwai314634b2006-09-21 11:56:18 +02004038 }
4039}
4040
Takashi Iwaicb53c622007-08-10 17:21:45 +02004041#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004042static int stac92xx_resume(struct hda_codec *codec)
4043{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004044 struct sigmatel_spec *spec = codec->spec;
4045
Richard Fish11b44bb2006-08-23 18:31:34 +02004046 stac92xx_set_config_regs(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004047 snd_hda_sequence_write(codec, spec->init);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004048 stac_gpio_set(codec, spec->gpio_mask,
4049 spec->gpio_dir, spec->gpio_data);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004050 snd_hda_codec_resume_amp(codec);
4051 snd_hda_codec_resume_cache(codec);
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004052 /* power down inactive DACs */
4053 if (spec->dac_list)
4054 stac92xx_power_down(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004055 /* invoke unsolicited event to reset the HP state */
4056 if (spec->hp_detect)
4057 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
Mattff6fdc32005-06-27 15:06:52 +02004058 return 0;
4059}
4060#endif
4061
Matt2f2f4252005-04-13 14:45:30 +02004062static struct hda_codec_ops stac92xx_patch_ops = {
4063 .build_controls = stac92xx_build_controls,
4064 .build_pcms = stac92xx_build_pcms,
4065 .init = stac92xx_init,
4066 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02004067 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004068#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004069 .resume = stac92xx_resume,
4070#endif
Matt2f2f4252005-04-13 14:45:30 +02004071};
4072
4073static int patch_stac9200(struct hda_codec *codec)
4074{
4075 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004076 int err;
Matt2f2f4252005-04-13 14:45:30 +02004077
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004078 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004079 if (spec == NULL)
4080 return -ENOMEM;
4081
4082 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004083 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004084 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004085 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4086 stac9200_models,
4087 stac9200_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02004088 if (spec->board_config < 0) {
4089 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
4090 err = stac92xx_save_bios_config_regs(codec);
4091 if (err < 0) {
4092 stac92xx_free(codec);
4093 return err;
4094 }
4095 spec->pin_configs = spec->bios_pin_configs;
4096 } else {
Matt Porter403d1942005-11-29 15:00:51 +01004097 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
4098 stac92xx_set_config_regs(codec);
4099 }
Matt2f2f4252005-04-13 14:45:30 +02004100
4101 spec->multiout.max_channels = 2;
4102 spec->multiout.num_dacs = 1;
4103 spec->multiout.dac_nids = stac9200_dac_nids;
4104 spec->adc_nids = stac9200_adc_nids;
4105 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02004106 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02004107 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004108 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004109 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004110
Tobin Davisbf277782008-02-03 20:31:47 +01004111 if (spec->board_config == STAC_9200_GATEWAY ||
4112 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02004113 spec->init = stac9200_eapd_init;
4114 else
4115 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004116 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004117
Takashi Iwai117f2572008-03-18 09:53:23 +01004118 if (spec->board_config == STAC_9200_PANASONIC) {
4119 spec->gpio_mask = spec->gpio_dir = 0x09;
4120 spec->gpio_data = 0x00;
4121 }
4122
Mattc7d4b2f2005-06-27 14:59:41 +02004123 err = stac9200_parse_auto_config(codec);
4124 if (err < 0) {
4125 stac92xx_free(codec);
4126 return err;
4127 }
Matt2f2f4252005-04-13 14:45:30 +02004128
4129 codec->patch_ops = stac92xx_patch_ops;
4130
4131 return 0;
4132}
4133
Tobin Davis8e21c342007-01-08 11:04:17 +01004134static int patch_stac925x(struct hda_codec *codec)
4135{
4136 struct sigmatel_spec *spec;
4137 int err;
4138
4139 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4140 if (spec == NULL)
4141 return -ENOMEM;
4142
4143 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004144 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01004145 spec->pin_nids = stac925x_pin_nids;
4146 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
4147 stac925x_models,
4148 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004149 again:
Tobin Davis8e21c342007-01-08 11:04:17 +01004150 if (spec->board_config < 0) {
Tobin Davis2c11f952007-05-17 09:36:34 +02004151 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
4152 "using BIOS defaults\n");
Tobin Davis8e21c342007-01-08 11:04:17 +01004153 err = stac92xx_save_bios_config_regs(codec);
4154 if (err < 0) {
4155 stac92xx_free(codec);
4156 return err;
4157 }
4158 spec->pin_configs = spec->bios_pin_configs;
4159 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
4160 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
4161 stac92xx_set_config_regs(codec);
4162 }
4163
4164 spec->multiout.max_channels = 2;
4165 spec->multiout.num_dacs = 1;
4166 spec->multiout.dac_nids = stac925x_dac_nids;
4167 spec->adc_nids = stac925x_adc_nids;
4168 spec->mux_nids = stac925x_mux_nids;
4169 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004170 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004171 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02004172 switch (codec->vendor_id) {
4173 case 0x83847632: /* STAC9202 */
4174 case 0x83847633: /* STAC9202D */
4175 case 0x83847636: /* STAC9251 */
4176 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02004177 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02004178 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004179 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4180 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02004181 break;
4182 default:
4183 spec->num_dmics = 0;
4184 break;
4185 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004186
4187 spec->init = stac925x_core_init;
4188 spec->mixer = stac925x_mixer;
4189
4190 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004191 if (!err) {
4192 if (spec->board_config < 0) {
4193 printk(KERN_WARNING "hda_codec: No auto-config is "
4194 "available, default to model=ref\n");
4195 spec->board_config = STAC_925x_REF;
4196 goto again;
4197 }
4198 err = -EINVAL;
4199 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004200 if (err < 0) {
4201 stac92xx_free(codec);
4202 return err;
4203 }
4204
4205 codec->patch_ops = stac92xx_patch_ops;
4206
4207 return 0;
4208}
4209
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004210static struct hda_input_mux stac92hd73xx_dmux = {
4211 .num_items = 4,
4212 .items = {
4213 { "Analog Inputs", 0x0b },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004214 { "Digital Mic 1", 0x09 },
4215 { "Digital Mic 2", 0x0a },
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004216 { "CD", 0x08 },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004217 }
4218};
4219
4220static int patch_stac92hd73xx(struct hda_codec *codec)
4221{
4222 struct sigmatel_spec *spec;
4223 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4224 int err = 0;
4225
4226 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4227 if (spec == NULL)
4228 return -ENOMEM;
4229
4230 codec->spec = spec;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02004231 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004232 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4233 spec->pin_nids = stac92hd73xx_pin_nids;
4234 spec->board_config = snd_hda_check_board_config(codec,
4235 STAC_92HD73XX_MODELS,
4236 stac92hd73xx_models,
4237 stac92hd73xx_cfg_tbl);
4238again:
4239 if (spec->board_config < 0) {
4240 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4241 " STAC92HD73XX, using BIOS defaults\n");
4242 err = stac92xx_save_bios_config_regs(codec);
4243 if (err < 0) {
4244 stac92xx_free(codec);
4245 return err;
4246 }
4247 spec->pin_configs = spec->bios_pin_configs;
4248 } else {
4249 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
4250 stac92xx_set_config_regs(codec);
4251 }
4252
4253 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
4254 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4255
4256 if (spec->multiout.num_dacs < 0) {
4257 printk(KERN_WARNING "hda_codec: Could not determine "
4258 "number of channels defaulting to DAC count\n");
4259 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
4260 }
4261
4262 switch (spec->multiout.num_dacs) {
4263 case 0x3: /* 6 Channel */
Takashi Iwai85f13b62008-12-19 08:20:38 +01004264 spec->multiout.hp_nid = 0x17;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004265 spec->mixer = stac92hd73xx_6ch_mixer;
4266 spec->init = stac92hd73xx_6ch_core_init;
4267 break;
4268 case 0x4: /* 8 Channel */
Takashi Iwai85f13b62008-12-19 08:20:38 +01004269 spec->multiout.hp_nid = 0x18;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004270 spec->mixer = stac92hd73xx_8ch_mixer;
4271 spec->init = stac92hd73xx_8ch_core_init;
4272 break;
4273 case 0x5: /* 10 Channel */
Takashi Iwai85f13b62008-12-19 08:20:38 +01004274 spec->multiout.hp_nid = 0x19;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004275 spec->mixer = stac92hd73xx_10ch_mixer;
4276 spec->init = stac92hd73xx_10ch_core_init;
4277 };
4278
4279 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
4280 spec->aloopback_mask = 0x01;
4281 spec->aloopback_shift = 8;
4282
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004283 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004284 spec->mux_nids = stac92hd73xx_mux_nids;
4285 spec->adc_nids = stac92hd73xx_adc_nids;
4286 spec->dmic_nids = stac92hd73xx_dmic_nids;
4287 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004288 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostay89385032008-09-11 09:49:39 -04004289 spec->amp_nids = stac92hd73xx_amp_nids;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004290 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004291
4292 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4293 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01004294 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004295 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4296 sizeof(stac92hd73xx_dmux));
4297
Matthew Ranostaya7662642008-02-21 07:51:14 +01004298 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004299 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004300 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004301 /* fallthru */
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004302 case STAC_DELL_M6_AMIC:
4303 case STAC_DELL_M6_DMIC:
4304 case STAC_DELL_M6_BOTH:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004305 spec->num_smuxes = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004306 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4307 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004308 spec->eapd_switch = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004309 spec->num_amps = 1;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004310
4311 if (!spec->init)
4312 spec->init = dell_m6_core_init;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004313 switch (spec->board_config) {
4314 case STAC_DELL_M6_AMIC: /* Analog Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004315 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4316 spec->num_dmics = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004317 spec->private_dimux.num_items = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004318 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004319 case STAC_DELL_M6_DMIC: /* Digital Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004320 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4321 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004322 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004323 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004324 case STAC_DELL_M6_BOTH: /* Both */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004325 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4326 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4327 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004328 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004329 break;
4330 }
4331 break;
4332 default:
4333 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004334 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004335 spec->eapd_switch = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004336 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004337 if (spec->board_config > STAC_92HD73XX_REF) {
4338 /* GPIO0 High = Enable EAPD */
4339 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4340 spec->gpio_data = 0x01;
4341 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004342 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004343
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004344 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4345 spec->pwr_nids = stac92hd73xx_pwr_nids;
4346
Matthew Ranostayd9737752008-09-07 12:03:41 +02004347 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004348
4349 if (!err) {
4350 if (spec->board_config < 0) {
4351 printk(KERN_WARNING "hda_codec: No auto-config is "
4352 "available, default to model=ref\n");
4353 spec->board_config = STAC_92HD73XX_REF;
4354 goto again;
4355 }
4356 err = -EINVAL;
4357 }
4358
4359 if (err < 0) {
4360 stac92xx_free(codec);
4361 return err;
4362 }
4363
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01004364 if (spec->board_config == STAC_92HD73XX_NO_JD)
4365 spec->hp_detect = 0;
4366
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004367 codec->patch_ops = stac92xx_patch_ops;
4368
4369 return 0;
4370}
4371
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004372static struct hda_input_mux stac92hd83xxx_dmux = {
4373 .num_items = 3,
4374 .items = {
4375 { "Analog Inputs", 0x03 },
4376 { "Digital Mic 1", 0x04 },
4377 { "Digital Mic 2", 0x05 },
4378 }
4379};
4380
4381static int patch_stac92hd83xxx(struct hda_codec *codec)
4382{
4383 struct sigmatel_spec *spec;
4384 int err;
4385
4386 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4387 if (spec == NULL)
4388 return -ENOMEM;
4389
4390 codec->spec = spec;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004391 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004392 spec->mono_nid = 0x19;
4393 spec->digbeep_nid = 0x21;
4394 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4395 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4396 spec->adc_nids = stac92hd83xxx_adc_nids;
4397 spec->pwr_nids = stac92hd83xxx_pwr_nids;
4398 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4399 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
4400 spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
4401
4402 spec->init = stac92hd83xxx_core_init;
4403 switch (codec->vendor_id) {
4404 case 0x111d7605:
4405 spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
4406 break;
4407 default:
4408 spec->num_pwrs--;
4409 spec->init++; /* switch to config #2 */
4410 spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
4411 }
4412
4413 spec->mixer = stac92hd83xxx_mixer;
4414 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4415 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4416 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
4417 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4418 spec->dinput_mux = &stac92hd83xxx_dmux;
4419 spec->pin_nids = stac92hd83xxx_pin_nids;
4420 spec->board_config = snd_hda_check_board_config(codec,
4421 STAC_92HD83XXX_MODELS,
4422 stac92hd83xxx_models,
4423 stac92hd83xxx_cfg_tbl);
4424again:
4425 if (spec->board_config < 0) {
4426 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4427 " STAC92HD83XXX, using BIOS defaults\n");
4428 err = stac92xx_save_bios_config_regs(codec);
4429 if (err < 0) {
4430 stac92xx_free(codec);
4431 return err;
4432 }
4433 spec->pin_configs = spec->bios_pin_configs;
4434 } else {
4435 spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config];
4436 stac92xx_set_config_regs(codec);
4437 }
4438
4439 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4440 if (!err) {
4441 if (spec->board_config < 0) {
4442 printk(KERN_WARNING "hda_codec: No auto-config is "
4443 "available, default to model=ref\n");
4444 spec->board_config = STAC_92HD83XXX_REF;
4445 goto again;
4446 }
4447 err = -EINVAL;
4448 }
4449
4450 if (err < 0) {
4451 stac92xx_free(codec);
4452 return err;
4453 }
4454
4455 codec->patch_ops = stac92xx_patch_ops;
4456
4457 return 0;
4458}
4459
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004460#ifdef SND_HDA_NEEDS_RESUME
4461static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr)
4462{
4463 struct sigmatel_spec *spec = codec->spec;
4464 int i;
4465 snd_hda_codec_write_cache(codec, codec->afg, 0,
4466 AC_VERB_SET_POWER_STATE, pwr);
4467
4468 msleep(1);
4469 for (i = 0; i < spec->num_adcs; i++) {
4470 snd_hda_codec_write_cache(codec,
4471 spec->adc_nids[i], 0,
4472 AC_VERB_SET_POWER_STATE, pwr);
4473 }
4474};
4475
4476static int stac92hd71xx_resume(struct hda_codec *codec)
4477{
4478 stac92hd71xx_set_power_state(codec, AC_PWRST_D0);
4479 return stac92xx_resume(codec);
4480}
4481
4482static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state)
4483{
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004484 struct sigmatel_spec *spec = codec->spec;
4485
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004486 stac92hd71xx_set_power_state(codec, AC_PWRST_D3);
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004487 if (spec->eapd_mask)
4488 stac_gpio_set(codec, spec->gpio_mask,
4489 spec->gpio_dir, spec->gpio_data &
4490 ~spec->eapd_mask);
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004491 return 0;
4492};
4493
4494#endif
4495
4496static struct hda_codec_ops stac92hd71bxx_patch_ops = {
4497 .build_controls = stac92xx_build_controls,
4498 .build_pcms = stac92xx_build_pcms,
4499 .init = stac92xx_init,
4500 .free = stac92xx_free,
4501 .unsol_event = stac92xx_unsol_event,
4502#ifdef SND_HDA_NEEDS_RESUME
4503 .resume = stac92hd71xx_resume,
4504 .suspend = stac92hd71xx_suspend,
4505#endif
4506};
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004507
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004508static struct hda_input_mux stac92hd71bxx_dmux = {
4509 .num_items = 4,
4510 .items = {
4511 { "Analog Inputs", 0x00 },
4512 { "Mixer", 0x01 },
4513 { "Digital Mic 1", 0x02 },
4514 { "Digital Mic 2", 0x03 },
4515 }
4516};
4517
Matthew Ranostaye035b842007-11-06 11:53:55 +01004518static int patch_stac92hd71bxx(struct hda_codec *codec)
4519{
4520 struct sigmatel_spec *spec;
4521 int err = 0;
4522
4523 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4524 if (spec == NULL)
4525 return -ENOMEM;
4526
4527 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004528 codec->patch_ops = stac92xx_patch_ops;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004529 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004530 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004531 spec->pin_nids = stac92hd71bxx_pin_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004532 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux,
4533 sizeof(stac92hd71bxx_dmux));
Matthew Ranostaye035b842007-11-06 11:53:55 +01004534 spec->board_config = snd_hda_check_board_config(codec,
4535 STAC_92HD71BXX_MODELS,
4536 stac92hd71bxx_models,
4537 stac92hd71bxx_cfg_tbl);
4538again:
4539 if (spec->board_config < 0) {
4540 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4541 " STAC92HD71BXX, using BIOS defaults\n");
4542 err = stac92xx_save_bios_config_regs(codec);
4543 if (err < 0) {
4544 stac92xx_free(codec);
4545 return err;
4546 }
4547 spec->pin_configs = spec->bios_pin_configs;
4548 } else {
4549 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
4550 stac92xx_set_config_regs(codec);
4551 }
4552
Takashi Iwai41c3b642008-11-18 10:45:15 +01004553 if (spec->board_config > STAC_92HD71BXX_REF) {
4554 /* GPIO0 = EAPD */
4555 spec->gpio_mask = 0x01;
4556 spec->gpio_dir = 0x01;
4557 spec->gpio_data = 0x01;
4558 }
4559
Matthew Ranostay541eee82007-12-14 12:08:04 +01004560 switch (codec->vendor_id) {
4561 case 0x111d76b6: /* 4 Port without Analog Mixer */
4562 case 0x111d76b7:
4563 case 0x111d76b4: /* 6 Port without Analog Mixer */
4564 case 0x111d76b5:
4565 spec->mixer = stac92hd71bxx_mixer;
4566 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004567 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004568 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004569 case 0x111d7608: /* 5 Port with Analog Mixer */
Takashi Iwai8e5f2622008-11-15 19:28:54 +01004570 switch (spec->board_config) {
4571 case STAC_HP_M4:
Matthew Ranostay72474be2008-10-09 09:32:17 -04004572 /* Enable VREF power saving on GPIO1 detect */
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01004573 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay72474be2008-10-09 09:32:17 -04004574 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
4575 snd_hda_codec_write_cache(codec, codec->afg, 0,
4576 AC_VERB_SET_UNSOLICITED_ENABLE,
4577 (AC_USRSP_EN | STAC_VREF_EVENT | 0x01));
4578 spec->gpio_mask |= 0x02;
4579 break;
4580 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004581 if ((codec->revision_id & 0xf) == 0 ||
4582 (codec->revision_id & 0xf) == 1) {
4583#ifdef SND_HDA_NEEDS_RESUME
4584 codec->patch_ops = stac92hd71bxx_patch_ops;
4585#endif
4586 spec->stream_delay = 40; /* 40 milliseconds */
4587 }
4588
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004589 /* no output amps */
4590 spec->num_pwrs = 0;
4591 spec->mixer = stac92hd71bxx_analog_mixer;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004592 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004593
4594 /* disable VSW */
4595 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
4596 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
4597 break;
4598 case 0x111d7603: /* 6 Port with Analog Mixer */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004599 if ((codec->revision_id & 0xf) == 1) {
4600#ifdef SND_HDA_NEEDS_RESUME
4601 codec->patch_ops = stac92hd71bxx_patch_ops;
4602#endif
4603 spec->stream_delay = 40; /* 40 milliseconds */
4604 }
4605
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004606 /* no output amps */
4607 spec->num_pwrs = 0;
4608 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01004609 default:
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004610 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004611 spec->mixer = stac92hd71bxx_analog_mixer;
4612 spec->init = stac92hd71bxx_analog_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004613 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004614 }
4615
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004616 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004617 spec->aloopback_shift = 0;
4618
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004619 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004620 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004621 spec->mux_nids = stac92hd71bxx_mux_nids;
4622 spec->adc_nids = stac92hd71bxx_adc_nids;
4623 spec->dmic_nids = stac92hd71bxx_dmic_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004624 spec->dmux_nids = stac92hd71bxx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004625 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004626 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004627
4628 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
4629 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004630
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004631 switch (spec->board_config) {
4632 case STAC_HP_M4:
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004633 /* enable internal microphone */
Matthew Ranostayb9aea712008-10-09 08:37:28 -04004634 stac92xx_set_config_reg(codec, 0x0e, 0x01813040);
4635 stac92xx_auto_set_pinctl(codec, 0x0e,
4636 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05004637 /* fallthru */
4638 case STAC_DELL_M4_2:
4639 spec->num_dmics = 0;
4640 spec->num_smuxes = 0;
4641 spec->num_dmuxes = 0;
4642 break;
4643 case STAC_DELL_M4_1:
4644 case STAC_DELL_M4_3:
4645 spec->num_dmics = 1;
4646 spec->num_smuxes = 0;
4647 spec->num_dmuxes = 0;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004648 break;
4649 default:
4650 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
4651 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
4652 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4653 };
4654
Takashi Iwaiaea7bb02008-02-25 18:26:41 +01004655 spec->multiout.num_dacs = 1;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004656 spec->multiout.hp_nid = 0x11;
4657 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004658 if (spec->dinput_mux)
4659 spec->private_dimux.num_items +=
4660 spec->num_dmics -
4661 (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004662
4663 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
4664 if (!err) {
4665 if (spec->board_config < 0) {
4666 printk(KERN_WARNING "hda_codec: No auto-config is "
4667 "available, default to model=ref\n");
4668 spec->board_config = STAC_92HD71BXX_REF;
4669 goto again;
4670 }
4671 err = -EINVAL;
4672 }
4673
4674 if (err < 0) {
4675 stac92xx_free(codec);
4676 return err;
4677 }
4678
Matthew Ranostaye035b842007-11-06 11:53:55 +01004679 return 0;
4680};
4681
Matt2f2f4252005-04-13 14:45:30 +02004682static int patch_stac922x(struct hda_codec *codec)
4683{
4684 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004685 int err;
Matt2f2f4252005-04-13 14:45:30 +02004686
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004687 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004688 if (spec == NULL)
4689 return -ENOMEM;
4690
4691 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004692 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004693 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004694 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
4695 stac922x_models,
4696 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08004697 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004698 spec->gpio_mask = spec->gpio_dir = 0x03;
4699 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004700 /* Intel Macs have all same PCI SSID, so we need to check
4701 * codec SSID to distinguish the exact models
4702 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004703 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004704 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004705
4706 case 0x106b0800:
4707 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02004708 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004709 case 0x106b0600:
4710 case 0x106b0700:
4711 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004712 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004713 case 0x106b0e00:
4714 case 0x106b0f00:
4715 case 0x106b1600:
4716 case 0x106b1700:
4717 case 0x106b0200:
4718 case 0x106b1e00:
4719 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004720 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004721 case 0x106b1a00:
4722 case 0x00000100:
4723 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02004724 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004725 case 0x106b0a00:
4726 case 0x106b2200:
4727 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02004728 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08004729 default:
4730 spec->board_config = STAC_INTEL_MAC_V3;
4731 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004732 }
4733 }
4734
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004735 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004736 if (spec->board_config < 0) {
4737 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
4738 "using BIOS defaults\n");
4739 err = stac92xx_save_bios_config_regs(codec);
4740 if (err < 0) {
4741 stac92xx_free(codec);
4742 return err;
4743 }
4744 spec->pin_configs = spec->bios_pin_configs;
4745 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
Matt Porter403d1942005-11-29 15:00:51 +01004746 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
4747 stac92xx_set_config_regs(codec);
4748 }
Matt2f2f4252005-04-13 14:45:30 +02004749
Matt2f2f4252005-04-13 14:45:30 +02004750 spec->adc_nids = stac922x_adc_nids;
4751 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004752 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004753 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004754 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004755 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004756
4757 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004758 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004759
4760 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02004761
Matt Porter3cc08dc2006-01-23 15:27:49 +01004762 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004763 if (!err) {
4764 if (spec->board_config < 0) {
4765 printk(KERN_WARNING "hda_codec: No auto-config is "
4766 "available, default to model=ref\n");
4767 spec->board_config = STAC_D945_REF;
4768 goto again;
4769 }
4770 err = -EINVAL;
4771 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004772 if (err < 0) {
4773 stac92xx_free(codec);
4774 return err;
4775 }
4776
4777 codec->patch_ops = stac92xx_patch_ops;
4778
Takashi Iwai807a46362007-05-29 19:01:37 +02004779 /* Fix Mux capture level; max to 2 */
4780 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
4781 (0 << AC_AMPCAP_OFFSET_SHIFT) |
4782 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4783 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4784 (0 << AC_AMPCAP_MUTE_SHIFT));
4785
Matt Porter3cc08dc2006-01-23 15:27:49 +01004786 return 0;
4787}
4788
4789static int patch_stac927x(struct hda_codec *codec)
4790{
4791 struct sigmatel_spec *spec;
4792 int err;
4793
4794 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4795 if (spec == NULL)
4796 return -ENOMEM;
4797
4798 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004799 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004800 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004801 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
4802 stac927x_models,
4803 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004804 again:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004805 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
4806 if (spec->board_config < 0)
4807 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4808 "STAC927x, using BIOS defaults\n");
Richard Fish11b44bb2006-08-23 18:31:34 +02004809 err = stac92xx_save_bios_config_regs(codec);
4810 if (err < 0) {
4811 stac92xx_free(codec);
4812 return err;
4813 }
4814 spec->pin_configs = spec->bios_pin_configs;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004815 } else {
Matt Porter3cc08dc2006-01-23 15:27:49 +01004816 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
4817 stac92xx_set_config_regs(codec);
4818 }
4819
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004820 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004821 spec->adc_nids = stac927x_adc_nids;
4822 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
4823 spec->mux_nids = stac927x_mux_nids;
4824 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004825 spec->smux_nids = stac927x_smux_nids;
4826 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04004827 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004828 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004829 spec->multiout.dac_nids = spec->dac_nids;
4830
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004831 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02004832 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004833 case STAC_D965_5ST:
4834 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004835 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004836 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004837 spec->num_dmics = 0;
4838
Tobin Davis93ed1502006-09-01 21:03:12 +02004839 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004840 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004841 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004842 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02004843 switch (codec->subsystem_id) {
4844 case 0x10280209:
4845 case 0x1028022e:
4846 /* correct the device field to SPDIF out */
4847 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
4848 break;
4849 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01004850 /* configure the analog microphone on some laptops */
4851 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01004852 /* correct the front output jack as a hp out */
Matthew Ranostay7989fba2008-02-21 07:50:12 +01004853 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01004854 /* correct the front input jack as a mic */
4855 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
4856 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004857 case STAC_DELL_3ST:
4858 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004859 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004860 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004861 spec->dmic_nids = stac927x_dmic_nids;
4862 spec->num_dmics = STAC927X_NUM_DMICS;
4863
Tobin Davis93ed1502006-09-01 21:03:12 +02004864 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004865 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004866 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004867 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004868 break;
4869 default:
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004870 if (spec->board_config > STAC_D965_REF) {
4871 /* GPIO0 High = Enable EAPD */
4872 spec->eapd_mask = spec->gpio_mask = 0x01;
4873 spec->gpio_dir = spec->gpio_data = 0x01;
4874 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004875 spec->num_dmics = 0;
4876
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004877 spec->init = stac927x_core_init;
4878 spec->mixer = stac927x_mixer;
4879 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004880
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004881 spec->num_pwrs = 0;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004882 spec->aloopback_mask = 0x40;
4883 spec->aloopback_shift = 0;
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004884 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004885
Matt Porter3cc08dc2006-01-23 15:27:49 +01004886 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004887 if (!err) {
4888 if (spec->board_config < 0) {
4889 printk(KERN_WARNING "hda_codec: No auto-config is "
4890 "available, default to model=ref\n");
4891 spec->board_config = STAC_D965_REF;
4892 goto again;
4893 }
4894 err = -EINVAL;
4895 }
Mattc7d4b2f2005-06-27 14:59:41 +02004896 if (err < 0) {
4897 stac92xx_free(codec);
4898 return err;
4899 }
Matt2f2f4252005-04-13 14:45:30 +02004900
4901 codec->patch_ops = stac92xx_patch_ops;
4902
Takashi Iwai52987652008-01-16 16:09:47 +01004903 /*
4904 * !!FIXME!!
4905 * The STAC927x seem to require fairly long delays for certain
4906 * command sequences. With too short delays (even if the answer
4907 * is set to RIRB properly), it results in the silence output
4908 * on some hardwares like Dell.
4909 *
4910 * The below flag enables the longer delay (see get_response
4911 * in hda_intel.c).
4912 */
4913 codec->bus->needs_damn_long_delay = 1;
4914
Takashi Iwaie28d8322008-12-17 13:48:29 +01004915 /* no jack detecion for ref-no-jd model */
4916 if (spec->board_config == STAC_D965_REF_NO_JD)
4917 spec->hp_detect = 0;
4918
Matt2f2f4252005-04-13 14:45:30 +02004919 return 0;
4920}
4921
Matt Porterf3302a52006-07-31 12:49:34 +02004922static int patch_stac9205(struct hda_codec *codec)
4923{
4924 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02004925 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02004926
4927 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4928 if (spec == NULL)
4929 return -ENOMEM;
4930
4931 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004932 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004933 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004934 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
4935 stac9205_models,
4936 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004937 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004938 if (spec->board_config < 0) {
4939 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
4940 err = stac92xx_save_bios_config_regs(codec);
4941 if (err < 0) {
4942 stac92xx_free(codec);
4943 return err;
4944 }
4945 spec->pin_configs = spec->bios_pin_configs;
4946 } else {
Matt Porterf3302a52006-07-31 12:49:34 +02004947 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
4948 stac92xx_set_config_regs(codec);
4949 }
4950
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004951 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02004952 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004953 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02004954 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004955 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004956 spec->smux_nids = stac9205_smux_nids;
4957 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004958 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02004959 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004960 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004961 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004962 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02004963
4964 spec->init = stac9205_core_init;
4965 spec->mixer = stac9205_mixer;
4966
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004967 spec->aloopback_mask = 0x40;
4968 spec->aloopback_shift = 0;
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004969 spec->eapd_switch = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02004970 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02004971
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004972 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004973 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02004974 /* Enable SPDIF in/out */
4975 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
4976 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01004977
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004978 /* Enable unsol response for GPIO4/Dock HP connection */
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01004979 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004980 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4981 snd_hda_codec_write_cache(codec, codec->afg, 0,
4982 AC_VERB_SET_UNSOLICITED_ENABLE,
4983 (AC_USRSP_EN | STAC_HP_EVENT));
4984
4985 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004986 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004987 spec->gpio_mask = 0x1b;
4988 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01004989 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004990 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02004991 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004992 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004993 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004994 case STAC_9205_REF:
4995 /* SPDIF-In enabled */
4996 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004997 default:
4998 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004999 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005000 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005001 break;
5002 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02005003
Matt Porterf3302a52006-07-31 12:49:34 +02005004 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005005 if (!err) {
5006 if (spec->board_config < 0) {
5007 printk(KERN_WARNING "hda_codec: No auto-config is "
5008 "available, default to model=ref\n");
5009 spec->board_config = STAC_9205_REF;
5010 goto again;
5011 }
5012 err = -EINVAL;
5013 }
Matt Porterf3302a52006-07-31 12:49:34 +02005014 if (err < 0) {
5015 stac92xx_free(codec);
5016 return err;
5017 }
5018
5019 codec->patch_ops = stac92xx_patch_ops;
5020
5021 return 0;
5022}
5023
Matt2f2f4252005-04-13 14:45:30 +02005024/*
Guillaume Munch6d859062006-08-22 17:15:47 +02005025 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01005026 */
5027
Guillaume Munch99ccc562006-08-16 19:35:12 +02005028/* static config for Sony VAIO FE550G and Sony VAIO AR */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005029static hda_nid_t vaio_dacs[] = { 0x2 };
5030#define VAIO_HP_DAC 0x5
5031static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
5032static hda_nid_t vaio_mux_nids[] = { 0x15 };
5033
5034static struct hda_input_mux vaio_mux = {
Takashi Iwaia3a2f422007-10-11 11:21:21 +02005035 .num_items = 3,
Takashi Iwaidb064e52006-03-16 16:04:58 +01005036 .items = {
Takashi Iwaid7737812006-04-25 13:05:43 +02005037 /* { "HP", 0x0 }, */
Takashi Iwai1624cb92007-07-05 13:10:51 +02005038 { "Mic Jack", 0x1 },
5039 { "Internal Mic", 0x2 },
Takashi Iwaidb064e52006-03-16 16:04:58 +01005040 { "PCM", 0x3 },
5041 }
5042};
5043
5044static struct hda_verb vaio_init[] = {
5045 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005046 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
Takashi Iwaidb064e52006-03-16 16:04:58 +01005047 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5048 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5049 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5050 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02005051 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005052 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5053 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5054 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5055 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5056 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5057 {}
5058};
5059
Guillaume Munch6d859062006-08-22 17:15:47 +02005060static struct hda_verb vaio_ar_init[] = {
5061 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
5062 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5063 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5064 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5065/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
5066 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02005067 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Guillaume Munch6d859062006-08-22 17:15:47 +02005068 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5069 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5070/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
5071 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5072 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5073 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5074 {}
5075};
5076
Takashi Iwaidb064e52006-03-16 16:04:58 +01005077/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02005078static struct hda_bind_ctls vaio_bind_master_vol = {
5079 .ops = &snd_hda_bind_vol,
5080 .values = {
5081 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
5082 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
5083 0
5084 },
5085};
Takashi Iwaidb064e52006-03-16 16:04:58 +01005086
5087/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02005088static struct hda_bind_ctls vaio_bind_master_sw = {
5089 .ops = &snd_hda_bind_sw,
5090 .values = {
5091 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
5092 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
5093 0,
5094 },
5095};
Takashi Iwaidb064e52006-03-16 16:04:58 +01005096
5097static struct snd_kcontrol_new vaio_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02005098 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
5099 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Takashi Iwaidb064e52006-03-16 16:04:58 +01005100 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5101 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5102 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5103 {
5104 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5105 .name = "Capture Source",
5106 .count = 1,
5107 .info = stac92xx_mux_enum_info,
5108 .get = stac92xx_mux_enum_get,
5109 .put = stac92xx_mux_enum_put,
5110 },
5111 {}
5112};
5113
Guillaume Munch6d859062006-08-22 17:15:47 +02005114static struct snd_kcontrol_new vaio_ar_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02005115 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
5116 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Guillaume Munch6d859062006-08-22 17:15:47 +02005117 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5118 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5119 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5120 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
5121 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
5122 {
5123 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5124 .name = "Capture Source",
5125 .count = 1,
5126 .info = stac92xx_mux_enum_info,
5127 .get = stac92xx_mux_enum_get,
5128 .put = stac92xx_mux_enum_put,
5129 },
5130 {}
5131};
5132
5133static struct hda_codec_ops stac9872_patch_ops = {
Takashi Iwaidb064e52006-03-16 16:04:58 +01005134 .build_controls = stac92xx_build_controls,
5135 .build_pcms = stac92xx_build_pcms,
5136 .init = stac92xx_init,
5137 .free = stac92xx_free,
Takashi Iwaicb53c622007-08-10 17:21:45 +02005138#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaidb064e52006-03-16 16:04:58 +01005139 .resume = stac92xx_resume,
5140#endif
5141};
5142
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005143static int stac9872_vaio_init(struct hda_codec *codec)
5144{
5145 int err;
5146
5147 err = stac92xx_init(codec);
5148 if (err < 0)
5149 return err;
5150 if (codec->patch_ops.unsol_event)
5151 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
5152 return 0;
5153}
5154
5155static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
5156{
Jiang Zhe40c1d302007-11-12 13:05:16 +01005157 if (get_hp_pin_presence(codec, 0x0a)) {
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005158 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5159 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5160 } else {
5161 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5162 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5163 }
5164}
5165
5166static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
5167{
5168 switch (res >> 26) {
5169 case STAC_HP_EVENT:
5170 stac9872_vaio_hp_detect(codec, res);
5171 break;
5172 }
5173}
5174
5175static struct hda_codec_ops stac9872_vaio_patch_ops = {
5176 .build_controls = stac92xx_build_controls,
5177 .build_pcms = stac92xx_build_pcms,
5178 .init = stac9872_vaio_init,
5179 .free = stac92xx_free,
5180 .unsol_event = stac9872_vaio_unsol_event,
5181#ifdef CONFIG_PM
5182 .resume = stac92xx_resume,
5183#endif
5184};
5185
Guillaume Munch6d859062006-08-22 17:15:47 +02005186enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
5187 CXD9872RD_VAIO,
5188 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
5189 STAC9872AK_VAIO,
5190 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
5191 STAC9872K_VAIO,
5192 /* AR Series. id=0x83847664 and subsys=104D1300 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005193 CXD9872AKD_VAIO,
5194 STAC_9872_MODELS,
5195};
Takashi Iwaidb064e52006-03-16 16:04:58 +01005196
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005197static const char *stac9872_models[STAC_9872_MODELS] = {
5198 [CXD9872RD_VAIO] = "vaio",
5199 [CXD9872AKD_VAIO] = "vaio-ar",
5200};
5201
5202static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5203 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
5204 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
5205 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
Tobin Davis68e22542007-03-12 11:36:39 +01005206 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
Takashi Iwaidb064e52006-03-16 16:04:58 +01005207 {}
5208};
5209
Guillaume Munch6d859062006-08-22 17:15:47 +02005210static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01005211{
5212 struct sigmatel_spec *spec;
5213 int board_config;
5214
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005215 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5216 stac9872_models,
5217 stac9872_cfg_tbl);
Takashi Iwaidb064e52006-03-16 16:04:58 +01005218 if (board_config < 0)
5219 /* unknown config, let generic-parser do its job... */
5220 return snd_hda_parse_generic_codec(codec);
5221
5222 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5223 if (spec == NULL)
5224 return -ENOMEM;
5225
5226 codec->spec = spec;
5227 switch (board_config) {
Guillaume Munch6d859062006-08-22 17:15:47 +02005228 case CXD9872RD_VAIO:
5229 case STAC9872AK_VAIO:
5230 case STAC9872K_VAIO:
Takashi Iwaidb064e52006-03-16 16:04:58 +01005231 spec->mixer = vaio_mixer;
5232 spec->init = vaio_init;
5233 spec->multiout.max_channels = 2;
5234 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5235 spec->multiout.dac_nids = vaio_dacs;
5236 spec->multiout.hp_nid = VAIO_HP_DAC;
5237 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5238 spec->adc_nids = vaio_adcs;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005239 spec->num_pwrs = 0;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005240 spec->input_mux = &vaio_mux;
5241 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005242 codec->patch_ops = stac9872_vaio_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005243 break;
Guillaume Munch6d859062006-08-22 17:15:47 +02005244
5245 case CXD9872AKD_VAIO:
5246 spec->mixer = vaio_ar_mixer;
5247 spec->init = vaio_ar_init;
5248 spec->multiout.max_channels = 2;
5249 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5250 spec->multiout.dac_nids = vaio_dacs;
5251 spec->multiout.hp_nid = VAIO_HP_DAC;
5252 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005253 spec->num_pwrs = 0;
Guillaume Munch6d859062006-08-22 17:15:47 +02005254 spec->adc_nids = vaio_adcs;
5255 spec->input_mux = &vaio_mux;
5256 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005257 codec->patch_ops = stac9872_patch_ops;
Guillaume Munch6d859062006-08-22 17:15:47 +02005258 break;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005259 }
5260
Takashi Iwaidb064e52006-03-16 16:04:58 +01005261 return 0;
5262}
5263
5264
5265/*
Matt2f2f4252005-04-13 14:45:30 +02005266 * patch entries
5267 */
5268struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5269 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5270 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5271 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5272 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5273 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5274 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5275 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02005276 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5277 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5278 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5279 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5280 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5281 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01005282 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5283 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5284 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5285 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5286 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5287 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5288 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5289 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5290 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5291 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01005292 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5293 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5294 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5295 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5296 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5297 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02005298 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5299 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02005300 /* The following does not take into account .id=0x83847661 when subsys =
5301 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5302 * currently not fully supported.
5303 */
5304 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5305 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5306 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02005307 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5308 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5309 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5310 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5311 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5312 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5313 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5314 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005315 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005316 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5317 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005318 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01005319 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5320 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005321 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01005322 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5323 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5324 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5325 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5326 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5327 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5328 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5329 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02005330 {} /* terminator */
5331};