blob: 26d8707173b2544ae645564241c2c7ea6710b6c4 [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>
Matthew Ranostay45a6ac12008-10-15 14:45:38 -040033#include <sound/jack.h>
Matt2f2f4252005-04-13 14:45:30 +020034#include "hda_codec.h"
35#include "hda_local.h"
Matthew Ranostay1cd22242008-07-18 18:20:52 +020036#include "hda_beep.h"
Matt2f2f4252005-04-13 14:45:30 +020037
Takashi Iwaic6e4c662008-11-25 11:58:19 +010038enum {
39 STAC_VREF_EVENT = 1,
40 STAC_INSERT_EVENT,
41 STAC_PWR_EVENT,
42 STAC_HP_EVENT,
43};
Matt4e550962005-07-04 17:51:39 +020044
Takashi Iwaif5fcc132006-11-24 17:07:44 +010045enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010046 STAC_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010047 STAC_REF,
Tobin Davisbf277782008-02-03 20:31:47 +010048 STAC_9200_OQO,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020049 STAC_9200_DELL_D21,
50 STAC_9200_DELL_D22,
51 STAC_9200_DELL_D23,
52 STAC_9200_DELL_M21,
53 STAC_9200_DELL_M22,
54 STAC_9200_DELL_M23,
55 STAC_9200_DELL_M24,
56 STAC_9200_DELL_M25,
57 STAC_9200_DELL_M26,
58 STAC_9200_DELL_M27,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +020059 STAC_9200_M4,
60 STAC_9200_M4_2,
Takashi Iwai117f2572008-03-18 09:53:23 +010061 STAC_9200_PANASONIC,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010062 STAC_9200_MODELS
63};
64
65enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010066 STAC_9205_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010067 STAC_9205_REF,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020068 STAC_9205_DELL_M42,
Tobin Davisae0a8ed2007-08-13 15:50:29 +020069 STAC_9205_DELL_M43,
70 STAC_9205_DELL_M44,
Takashi Iwaid9a42682009-01-22 17:40:18 +010071 STAC_9205_EAPD,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010072 STAC_9205_MODELS
73};
74
75enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010076 STAC_92HD73XX_AUTO,
Takashi Iwai9e43f0d2008-12-17 14:51:01 +010077 STAC_92HD73XX_NO_JD, /* no jack-detection */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010078 STAC_92HD73XX_REF,
Takashi Iwai661cd8f2008-11-25 15:18:29 +010079 STAC_DELL_M6_AMIC,
80 STAC_DELL_M6_DMIC,
81 STAC_DELL_M6_BOTH,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -050082 STAC_DELL_EQ,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010083 STAC_92HD73XX_MODELS
84};
85
86enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010087 STAC_92HD83XXX_AUTO,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020088 STAC_92HD83XXX_REF,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -050089 STAC_92HD83XXX_PWR_REF,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -050090 STAC_DELL_S14,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020091 STAC_92HD83XXX_MODELS
92};
93
94enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010095 STAC_92HD71BXX_AUTO,
Matthew Ranostaye035b842007-11-06 11:53:55 +010096 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010097 STAC_DELL_M4_1,
98 STAC_DELL_M4_2,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -050099 STAC_DELL_M4_3,
Matthew Ranostay6a14f582008-09-12 12:02:30 -0400100 STAC_HP_M4,
Takashi Iwai1b0652e2009-01-14 08:27:35 +0100101 STAC_HP_DV5,
Christoph Plattnerae6241f2009-03-08 23:19:05 +0100102 STAC_HP_HDX,
James Gardiner514bf542009-05-03 04:00:44 -0400103 STAC_HP_DV4_1222NR,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100104 STAC_92HD71BXX_MODELS
105};
106
107enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100108 STAC_925x_AUTO,
Tobin Davis8e21c342007-01-08 11:04:17 +0100109 STAC_925x_REF,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200110 STAC_M1,
111 STAC_M1_2,
112 STAC_M2,
Tobin Davis8e21c342007-01-08 11:04:17 +0100113 STAC_M2_2,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200114 STAC_M3,
115 STAC_M5,
116 STAC_M6,
Tobin Davis8e21c342007-01-08 11:04:17 +0100117 STAC_925x_MODELS
118};
119
120enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100121 STAC_922X_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100122 STAC_D945_REF,
123 STAC_D945GTP3,
124 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200125 STAC_INTEL_MAC_V1,
126 STAC_INTEL_MAC_V2,
127 STAC_INTEL_MAC_V3,
128 STAC_INTEL_MAC_V4,
129 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800130 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
131 * is given, one of the above models will be
132 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200133 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100134 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100135 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100136 STAC_MACBOOK_PRO_V1,
137 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200138 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200139 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300140 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200141 STAC_922X_DELL_D81,
142 STAC_922X_DELL_D82,
143 STAC_922X_DELL_M81,
144 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100145 STAC_922X_MODELS
146};
147
148enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100149 STAC_927X_AUTO,
Takashi Iwaie28d8322008-12-17 13:48:29 +0100150 STAC_D965_REF_NO_JD, /* no jack-detection */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100151 STAC_D965_REF,
152 STAC_D965_3ST,
153 STAC_D965_5ST,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200154 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100155 STAC_DELL_BIOS,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100156 STAC_927X_MODELS
157};
Matt Porter403d1942005-11-29 15:00:51 +0100158
Takashi Iwai307282c2009-03-12 18:17:58 +0100159enum {
160 STAC_9872_AUTO,
161 STAC_9872_VAIO,
162 STAC_9872_MODELS
163};
164
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400165struct sigmatel_event {
166 hda_nid_t nid;
Takashi Iwaic6e4c662008-11-25 11:58:19 +0100167 unsigned char type;
168 unsigned char tag;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400169 int data;
170};
171
172struct sigmatel_jack {
173 hda_nid_t nid;
174 int type;
175 struct snd_jack *jack;
176};
177
Matt2f2f4252005-04-13 14:45:30 +0200178struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100179 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200180 unsigned int num_mixers;
181
Matt Porter403d1942005-11-29 15:00:51 +0100182 int board_config;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -0500183 unsigned int eapd_switch: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200184 unsigned int surr_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100185 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100186 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400187 unsigned int spdif_mute: 1;
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100188 unsigned int check_volume_offset:1;
Mattc7d4b2f2005-06-27 14:59:41 +0200189
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100190 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200191 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100192 unsigned int gpio_mask;
193 unsigned int gpio_dir;
194 unsigned int gpio_data;
195 unsigned int gpio_mute;
Takashi Iwai86d190e2009-05-26 15:18:58 +0200196 unsigned int gpio_led;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100197
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200198 /* stream */
199 unsigned int stream_delay;
200
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100201 /* analog loopback */
Takashi Iwaid78d7a92009-03-02 14:26:25 +0100202 struct snd_kcontrol_new *aloopback_ctl;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100203 unsigned char aloopback_mask;
204 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200205
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100206 /* power management */
207 unsigned int num_pwrs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200208 unsigned int *pwr_mapping;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100209 hda_nid_t *pwr_nids;
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100210 hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100211
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400212 /* jack detection */
213 struct snd_array jacks;
214
215 /* events */
216 struct snd_array events;
217
Matt2f2f4252005-04-13 14:45:30 +0200218 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100219 struct hda_input_mux *mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400220 struct hda_input_mux *amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100221 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200222 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100223 hda_nid_t dac_nids[5];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100224 hda_nid_t hp_dacs[5];
225 hda_nid_t speaker_dacs[5];
Matt2f2f4252005-04-13 14:45:30 +0200226
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100227 int volume_offset;
228
Matt2f2f4252005-04-13 14:45:30 +0200229 /* capture */
230 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200231 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200232 hda_nid_t *mux_nids;
233 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200234 hda_nid_t *dmic_nids;
235 unsigned int num_dmics;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100236 hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100237 unsigned int num_dmuxes;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200238 hda_nid_t *smux_nids;
239 unsigned int num_smuxes;
Matthew Ranostay65973632008-09-16 10:39:37 -0400240 const char **spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200241
Mattdabbed62005-06-14 10:19:34 +0200242 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100243 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200244 hda_nid_t anabeep_nid;
245 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200246
Matt2f2f4252005-04-13 14:45:30 +0200247 /* pin widgets */
248 hda_nid_t *pin_nids;
249 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200250
251 /* codec specific stuff */
252 struct hda_verb *init;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100253 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200254
255 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200256 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100257 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200258 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100259 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200260 struct hda_input_mux *sinput_mux;
261 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400262 unsigned int cur_amux;
263 hda_nid_t *amp_nids;
264 unsigned int num_amps;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200265 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200266
Matt Porter403d1942005-11-29 15:00:51 +0100267 /* i/o switches */
268 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200269 unsigned int clfe_swap;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100270 hda_nid_t line_switch; /* shared line-in for input and output */
271 hda_nid_t mic_switch; /* shared mic-in for input and output */
272 hda_nid_t hp_switch; /* NID of HP as line-out */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200273 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200274
Mattc7d4b2f2005-06-27 14:59:41 +0200275 struct hda_pcm pcm_rec[2]; /* PCM information */
276
277 /* dynamic controls and input_mux */
278 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200279 struct snd_array kctls;
Matt Porter8b657272006-10-26 17:12:59 +0200280 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200281 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200282 struct hda_input_mux private_smux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400283 struct hda_input_mux private_amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100284 struct hda_input_mux private_mono_mux;
Matt2f2f4252005-04-13 14:45:30 +0200285};
286
287static hda_nid_t stac9200_adc_nids[1] = {
288 0x03,
289};
290
291static hda_nid_t stac9200_mux_nids[1] = {
292 0x0c,
293};
294
295static hda_nid_t stac9200_dac_nids[1] = {
296 0x02,
297};
298
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100299static hda_nid_t stac92hd73xx_pwr_nids[8] = {
300 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
301 0x0f, 0x10, 0x11
302};
303
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400304static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
305 0x26, 0,
306};
307
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100308static hda_nid_t stac92hd73xx_adc_nids[2] = {
309 0x1a, 0x1b
310};
311
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400312#define DELL_M6_AMP 2
313static hda_nid_t stac92hd73xx_amp_nids[3] = {
314 0x0b, 0x0c, 0x0e
Matthew Ranostay89385032008-09-11 09:49:39 -0400315};
316
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100317#define STAC92HD73XX_NUM_DMICS 2
318static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
319 0x13, 0x14, 0
320};
321
322#define STAC92HD73_DAC_COUNT 5
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100323
324static hda_nid_t stac92hd73xx_mux_nids[4] = {
325 0x28, 0x29, 0x2a, 0x2b,
326};
327
328static hda_nid_t stac92hd73xx_dmux_nids[2] = {
329 0x20, 0x21,
330};
331
Matthew Ranostayd9737752008-09-07 12:03:41 +0200332static hda_nid_t stac92hd73xx_smux_nids[2] = {
333 0x22, 0x23,
334};
335
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200336#define STAC92HD83XXX_NUM_DMICS 2
337static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
338 0x11, 0x12, 0
339};
340
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200341#define STAC92HD83_DAC_COUNT 3
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200342
343static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
344 0x17, 0x18,
345};
346
347static hda_nid_t stac92hd83xxx_adc_nids[2] = {
348 0x15, 0x16,
349};
350
351static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
352 0xa, 0xb, 0xd, 0xe,
353};
354
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400355static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
356 0x1e, 0,
357};
358
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200359static unsigned int stac92hd83xxx_pwr_mapping[4] = {
Matthew Ranostay87e88a72009-01-22 20:38:42 -0500360 0x03, 0x0c, 0x20, 0x40,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200361};
362
Takashi Iwai9248f262009-01-14 09:40:25 +0100363static hda_nid_t stac92hd83xxx_amp_nids[1] = {
Matthew Ranostayc15c5062009-01-13 13:30:07 -0500364 0xc,
365};
366
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100367static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
368 0x0a, 0x0d, 0x0f
369};
370
Matthew Ranostaye035b842007-11-06 11:53:55 +0100371static hda_nid_t stac92hd71bxx_adc_nids[2] = {
372 0x12, 0x13,
373};
374
375static hda_nid_t stac92hd71bxx_mux_nids[2] = {
376 0x1a, 0x1b
377};
378
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400379static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
380 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100381};
382
Matthew Ranostayd9737752008-09-07 12:03:41 +0200383static hda_nid_t stac92hd71bxx_smux_nids[2] = {
384 0x24, 0x25,
385};
386
Matthew Ranostaye035b842007-11-06 11:53:55 +0100387#define STAC92HD71BXX_NUM_DMICS 2
388static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
389 0x18, 0x19, 0
390};
391
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400392static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
393 0x22, 0
394};
395
Tobin Davis8e21c342007-01-08 11:04:17 +0100396static hda_nid_t stac925x_adc_nids[1] = {
397 0x03,
398};
399
400static hda_nid_t stac925x_mux_nids[1] = {
401 0x0f,
402};
403
404static hda_nid_t stac925x_dac_nids[1] = {
405 0x02,
406};
407
Takashi Iwaif6e98522007-10-16 14:27:04 +0200408#define STAC925X_NUM_DMICS 1
409static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
410 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200411};
412
Takashi Iwai1697055e2007-12-18 18:05:52 +0100413static hda_nid_t stac925x_dmux_nids[1] = {
414 0x14,
415};
416
Matt2f2f4252005-04-13 14:45:30 +0200417static hda_nid_t stac922x_adc_nids[2] = {
418 0x06, 0x07,
419};
420
421static hda_nid_t stac922x_mux_nids[2] = {
422 0x12, 0x13,
423};
424
Matthew Ranostay45c1d852009-02-04 17:49:41 -0500425static hda_nid_t stac927x_slave_dig_outs[2] = {
426 0x1f, 0,
427};
428
Matt Porter3cc08dc2006-01-23 15:27:49 +0100429static hda_nid_t stac927x_adc_nids[3] = {
430 0x07, 0x08, 0x09
431};
432
433static hda_nid_t stac927x_mux_nids[3] = {
434 0x15, 0x16, 0x17
435};
436
Matthew Ranostayd9737752008-09-07 12:03:41 +0200437static hda_nid_t stac927x_smux_nids[1] = {
438 0x21,
439};
440
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100441static hda_nid_t stac927x_dac_nids[6] = {
442 0x02, 0x03, 0x04, 0x05, 0x06, 0
443};
444
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100445static hda_nid_t stac927x_dmux_nids[1] = {
446 0x1b,
447};
448
Matthew Ranostay7f168592007-10-18 17:38:17 +0200449#define STAC927X_NUM_DMICS 2
450static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
451 0x13, 0x14, 0
452};
453
Matthew Ranostay65973632008-09-16 10:39:37 -0400454static const char *stac927x_spdif_labels[5] = {
455 "Digital Playback", "ADAT", "Analog Mux 1",
456 "Analog Mux 2", "Analog Mux 3"
457};
458
Matt Porterf3302a52006-07-31 12:49:34 +0200459static hda_nid_t stac9205_adc_nids[2] = {
460 0x12, 0x13
461};
462
463static hda_nid_t stac9205_mux_nids[2] = {
464 0x19, 0x1a
465};
466
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100467static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100468 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100469};
470
Matthew Ranostayd9737752008-09-07 12:03:41 +0200471static hda_nid_t stac9205_smux_nids[1] = {
472 0x21,
473};
474
Takashi Iwaif6e98522007-10-16 14:27:04 +0200475#define STAC9205_NUM_DMICS 2
476static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
477 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200478};
479
Mattc7d4b2f2005-06-27 14:59:41 +0200480static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200481 0x08, 0x09, 0x0d, 0x0e,
482 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200483};
484
Tobin Davis8e21c342007-01-08 11:04:17 +0100485static hda_nid_t stac925x_pin_nids[8] = {
486 0x07, 0x08, 0x0a, 0x0b,
487 0x0c, 0x0d, 0x10, 0x11,
488};
489
Matt2f2f4252005-04-13 14:45:30 +0200490static hda_nid_t stac922x_pin_nids[10] = {
491 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
492 0x0f, 0x10, 0x11, 0x15, 0x1b,
493};
494
Matthew Ranostaya7662642008-02-21 07:51:14 +0100495static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100496 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
497 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200498 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100499};
500
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -0500501static hda_nid_t stac92hd83xxx_pin_nids[10] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200502 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -0500503 0x0f, 0x10, 0x11, 0x1f, 0x20,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200504};
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500505
506#define STAC92HD71BXX_NUM_PINS 13
507static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
508 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
509 0x00, 0x14, 0x18, 0x19, 0x1e,
510 0x1f, 0x20, 0x27
511};
512static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100513 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
514 0x0f, 0x14, 0x18, 0x19, 0x1e,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500515 0x1f, 0x20, 0x27
Matthew Ranostaye035b842007-11-06 11:53:55 +0100516};
517
Matt Porter3cc08dc2006-01-23 15:27:49 +0100518static hda_nid_t stac927x_pin_nids[14] = {
519 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
520 0x0f, 0x10, 0x11, 0x12, 0x13,
521 0x14, 0x21, 0x22, 0x23,
522};
523
Matt Porterf3302a52006-07-31 12:49:34 +0200524static hda_nid_t stac9205_pin_nids[12] = {
525 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
526 0x0f, 0x14, 0x16, 0x17, 0x18,
527 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200528};
529
Matthew Ranostay89385032008-09-11 09:49:39 -0400530#define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
531
532static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
533 struct snd_ctl_elem_value *ucontrol)
534{
535 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
536 struct sigmatel_spec *spec = codec->spec;
537 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
538
539 kcontrol->private_value ^= get_amp_nid(kcontrol);
540 kcontrol->private_value |= nid;
541
542 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
543}
544
545static int stac92xx_amp_volume_put(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 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
551
552 kcontrol->private_value ^= get_amp_nid(kcontrol);
553 kcontrol->private_value |= nid;
554
555 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
556}
557
Matt Porter8b657272006-10-26 17:12:59 +0200558static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
559 struct snd_ctl_elem_info *uinfo)
560{
561 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
562 struct sigmatel_spec *spec = codec->spec;
563 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
564}
565
566static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
567 struct snd_ctl_elem_value *ucontrol)
568{
569 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
570 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100571 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200572
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100573 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200574 return 0;
575}
576
577static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
578 struct snd_ctl_elem_value *ucontrol)
579{
580 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
581 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100582 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200583
584 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100585 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200586}
587
Matthew Ranostayd9737752008-09-07 12:03:41 +0200588static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
589 struct snd_ctl_elem_info *uinfo)
590{
591 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
592 struct sigmatel_spec *spec = codec->spec;
593 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
594}
595
596static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
597 struct snd_ctl_elem_value *ucontrol)
598{
599 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
600 struct sigmatel_spec *spec = codec->spec;
601 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
602
603 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
604 return 0;
605}
606
607static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
608 struct snd_ctl_elem_value *ucontrol)
609{
610 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
611 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400612 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200613 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400614 int err, val;
615 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200616
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400617 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200618 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400619 if (err < 0)
620 return err;
621
622 if (spec->spdif_mute) {
623 if (smux_idx == 0)
624 nid = spec->multiout.dig_out_nid;
625 else
626 nid = codec->slave_dig_outs[smux_idx - 1];
627 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100628 val = HDA_AMP_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400629 else
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100630 val = 0;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400631 /* un/mute SPDIF out */
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100632 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
633 HDA_AMP_MUTE, val);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400634 }
635 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200636}
637
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200638static unsigned int stac92xx_vref_set(struct hda_codec *codec,
639 hda_nid_t nid, unsigned int new_vref)
640{
641 unsigned int error;
642 unsigned int pincfg;
643 pincfg = snd_hda_codec_read(codec, nid, 0,
644 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
645
646 pincfg &= 0xff;
647 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
648 pincfg |= new_vref;
649
650 if (new_vref == AC_PINCTL_VREF_HIZ)
651 pincfg |= AC_PINCTL_OUT_EN;
652 else
653 pincfg |= AC_PINCTL_IN_EN;
654
655 error = snd_hda_codec_write_cache(codec, nid, 0,
656 AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg);
657 if (error < 0)
658 return error;
659 else
660 return 1;
661}
662
663static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
664{
665 unsigned int vref;
666 vref = snd_hda_codec_read(codec, nid, 0,
667 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
668 vref &= AC_PINCTL_VREFEN;
669 return vref;
670}
671
672static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
673 struct snd_ctl_elem_value *ucontrol)
674{
675 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
676 unsigned int new_vref;
677 unsigned int error;
678
679 if (ucontrol->value.enumerated.item[0] == 0)
680 new_vref = AC_PINCTL_VREF_80;
681 else if (ucontrol->value.enumerated.item[0] == 1)
682 new_vref = AC_PINCTL_VREF_GRD;
683 else
684 new_vref = AC_PINCTL_VREF_HIZ;
685
686 if (new_vref != stac92xx_vref_get(codec, kcontrol->private_value)) {
687 error = stac92xx_vref_set(codec,
688 kcontrol->private_value, new_vref);
689 return error;
690 }
691
692 return 0;
693}
694
695static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
696 struct snd_ctl_elem_value *ucontrol)
697{
698 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
699 unsigned int vref = stac92xx_vref_get(codec, kcontrol->private_value);
700 if (vref == AC_PINCTL_VREF_80)
701 ucontrol->value.enumerated.item[0] = 0;
702 else if (vref == AC_PINCTL_VREF_GRD)
703 ucontrol->value.enumerated.item[0] = 1;
704 else if (vref == AC_PINCTL_VREF_HIZ)
705 ucontrol->value.enumerated.item[0] = 2;
706
707 return 0;
708}
709
710static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
711 struct snd_ctl_elem_info *uinfo)
712{
713 static char *texts[] = {
714 "Mic In", "Line In", "Line Out"
715 };
716
717 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
718 uinfo->value.enumerated.items = 3;
719 uinfo->count = 1;
720 if (uinfo->value.enumerated.item >= 3)
721 uinfo->value.enumerated.item = 2;
722 strcpy(uinfo->value.enumerated.name,
723 texts[uinfo->value.enumerated.item]);
724
725 return 0;
726}
727
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100728static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200729{
730 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
731 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200732 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200733}
734
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100735static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200736{
737 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
738 struct sigmatel_spec *spec = codec->spec;
739 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
740
741 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
742 return 0;
743}
744
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100745static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200746{
747 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
748 struct sigmatel_spec *spec = codec->spec;
749 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
750
Mattc7d4b2f2005-06-27 14:59:41 +0200751 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200752 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
753}
754
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100755static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
756 struct snd_ctl_elem_info *uinfo)
757{
758 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
759 struct sigmatel_spec *spec = codec->spec;
760 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
761}
762
763static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
764 struct snd_ctl_elem_value *ucontrol)
765{
766 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
767 struct sigmatel_spec *spec = codec->spec;
768
769 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
770 return 0;
771}
772
773static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
774 struct snd_ctl_elem_value *ucontrol)
775{
776 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
777 struct sigmatel_spec *spec = codec->spec;
778
779 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
780 spec->mono_nid, &spec->cur_mmux);
781}
782
Matthew Ranostay89385032008-09-11 09:49:39 -0400783static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
784 struct snd_ctl_elem_info *uinfo)
785{
786 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
787 struct sigmatel_spec *spec = codec->spec;
788 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
789}
790
791static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
792 struct snd_ctl_elem_value *ucontrol)
793{
794 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
795 struct sigmatel_spec *spec = codec->spec;
796
797 ucontrol->value.enumerated.item[0] = spec->cur_amux;
798 return 0;
799}
800
801static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
802 struct snd_ctl_elem_value *ucontrol)
803{
804 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
805 struct sigmatel_spec *spec = codec->spec;
806 struct snd_kcontrol *ctl =
807 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
808 if (!ctl)
809 return -EINVAL;
810
811 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
812 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
813
814 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
815 0, &spec->cur_amux);
816}
817
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200818#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
819
820static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
821 struct snd_ctl_elem_value *ucontrol)
822{
823 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100824 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200825 struct sigmatel_spec *spec = codec->spec;
826
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100827 ucontrol->value.integer.value[0] = !!(spec->aloopback &
828 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200829 return 0;
830}
831
832static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
833 struct snd_ctl_elem_value *ucontrol)
834{
835 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
836 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100837 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200838 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100839 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200840
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100841 idx_val = spec->aloopback_mask << idx;
842 if (ucontrol->value.integer.value[0])
843 val = spec->aloopback | idx_val;
844 else
845 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100846 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200847 return 0;
848
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100849 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200850
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100851 /* Only return the bits defined by the shift value of the
852 * first two bytes of the mask
853 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200854 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100855 kcontrol->private_value & 0xFFFF, 0x0);
856 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200857
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100858 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200859 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100860 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200861 } else {
862 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100863 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200864 }
865
866 snd_hda_codec_write_cache(codec, codec->afg, 0,
867 kcontrol->private_value >> 16, dac_mode);
868
869 return 1;
870}
871
Mattc7d4b2f2005-06-27 14:59:41 +0200872static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200873 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200874 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200875 {}
876};
877
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200878static struct hda_verb stac9200_eapd_init[] = {
879 /* set dac0mux for dac converter */
880 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
881 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
882 {}
883};
884
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100885static struct hda_verb stac92hd73xx_6ch_core_init[] = {
886 /* set master volume and direct control */
887 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100888 /* setup adcs to point to mixer */
889 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
890 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100891 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
892 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
893 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
894 /* setup import muxs */
895 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
896 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
897 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
898 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
899 {}
900};
901
Matthew Ranostayd654a662008-03-14 08:46:51 +0100902static struct hda_verb dell_eq_core_init[] = {
903 /* set master volume to max value without distortion
904 * and direct control */
905 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100906 /* setup adcs to point to mixer */
907 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
908 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
909 /* setup import muxs */
910 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
911 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
912 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
913 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
914 {}
915};
916
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100917static struct hda_verb dell_m6_core_init[] = {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -0500918 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100919 /* setup adcs to point to mixer */
920 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
921 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
922 /* setup import muxs */
923 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
924 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
925 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
926 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
927 {}
928};
929
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100930static struct hda_verb stac92hd73xx_8ch_core_init[] = {
931 /* set master volume and direct control */
932 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100933 /* setup adcs to point to mixer */
934 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
935 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100936 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
937 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
938 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
939 /* setup import muxs */
940 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
941 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
942 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
943 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
944 {}
945};
946
947static struct hda_verb stac92hd73xx_10ch_core_init[] = {
948 /* set master volume and direct control */
949 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100950 /* dac3 is connected to import3 mux */
951 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100952 /* setup adcs to point to mixer */
953 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
954 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100955 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
956 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
957 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
958 /* setup import muxs */
959 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
960 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
961 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
962 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
963 {}
964};
965
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200966static struct hda_verb stac92hd83xxx_core_init[] = {
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -0500967 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1},
968 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1},
969 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200970
971 /* power state controls amps */
972 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200973 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200974};
975
Matthew Ranostaye035b842007-11-06 11:53:55 +0100976static struct hda_verb stac92hd71bxx_core_init[] = {
977 /* set master volume and direct control */
978 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200979 {}
Matthew Ranostay541eee82007-12-14 12:08:04 +0100980};
981
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500982#define HD_DISABLE_PORTF 1
Matthew Ranostay541eee82007-12-14 12:08:04 +0100983static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200984 /* start of config #1 */
985
986 /* connect port 0f to audio mixer */
987 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200988 /* start of config #2 */
989
Matthew Ranostay541eee82007-12-14 12:08:04 +0100990 /* set master volume and direct control */
991 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500992 {}
993};
994
995static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
996 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
997 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100998 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
999 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +01001000 {}
1001};
1002
Tobin Davis8e21c342007-01-08 11:04:17 +01001003static struct hda_verb stac925x_core_init[] = {
1004 /* set dac0mux for dac converter */
1005 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaic9280d62009-01-15 17:31:00 +01001006 /* mute the master volume */
1007 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Tobin Davis8e21c342007-01-08 11:04:17 +01001008 {}
1009};
1010
Mattc7d4b2f2005-06-27 14:59:41 +02001011static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +02001012 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +02001013 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +02001014 {}
1015};
1016
Tobin Davis93ed1502006-09-01 21:03:12 +02001017static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +02001018 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +02001019 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +02001020 /* unmute node 0x1b */
1021 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1022 /* select node 0x03 as DAC */
1023 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
1024 {}
1025};
1026
Matt Porter3cc08dc2006-01-23 15:27:49 +01001027static struct hda_verb stac927x_core_init[] = {
1028 /* set master volume and direct control */
1029 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001030 /* enable analog pc beep path */
1031 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +01001032 {}
1033};
1034
Matt Porterf3302a52006-07-31 12:49:34 +02001035static struct hda_verb stac9205_core_init[] = {
1036 /* set master volume and direct control */
1037 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001038 /* enable analog pc beep path */
1039 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +02001040 {}
1041};
1042
Matthew Ranostayb22b4822008-01-22 12:32:30 +01001043#define STAC_MONO_MUX \
1044 { \
1045 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1046 .name = "Mono Mux", \
1047 .count = 1, \
1048 .info = stac92xx_mono_mux_enum_info, \
1049 .get = stac92xx_mono_mux_enum_get, \
1050 .put = stac92xx_mono_mux_enum_put, \
1051 }
1052
Matthew Ranostay89385032008-09-11 09:49:39 -04001053#define STAC_AMP_MUX \
1054 { \
1055 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1056 .name = "Amp Selector Capture Switch", \
1057 .count = 1, \
1058 .info = stac92xx_amp_mux_enum_info, \
1059 .get = stac92xx_amp_mux_enum_get, \
1060 .put = stac92xx_amp_mux_enum_put, \
1061 }
1062
1063#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
1064 { \
1065 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1066 .name = xname, \
1067 .index = 0, \
1068 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1069 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1070 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
1071 .info = stac92xx_amp_volume_info, \
1072 .get = stac92xx_amp_volume_get, \
1073 .put = stac92xx_amp_volume_put, \
1074 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
1075 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
1076 }
1077
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001078#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +02001079 { \
1080 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1081 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001082 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +02001083 .info = stac92xx_aloopback_info, \
1084 .get = stac92xx_aloopback_get, \
1085 .put = stac92xx_aloopback_put, \
1086 .private_value = verb_read | (verb_write << 16), \
1087 }
1088
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02001089#define DC_BIAS(xname, idx, nid) \
1090 { \
1091 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1092 .name = xname, \
1093 .index = idx, \
1094 .info = stac92xx_dc_bias_info, \
1095 .get = stac92xx_dc_bias_get, \
1096 .put = stac92xx_dc_bias_put, \
1097 .private_value = nid, \
1098 }
1099
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001100static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +02001101 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
1102 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001103 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
1104 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001105 { } /* end */
1106};
1107
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04001108#define DELL_M6_MIXER 6
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001109static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04001110 /* start of config #1 */
1111 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1112 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1113
1114 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1115 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1116
1117 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1118 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1119
1120 /* start of config #2 */
1121 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1122 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1123
1124 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1125 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1126
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001127 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1128 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1129
1130 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1131 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1132
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001133 { } /* end */
1134};
1135
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001136static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
1137 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1138 {}
1139};
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001140
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001141static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
1142 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1143 {}
1144};
1145
1146static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
1147 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1148 {}
1149};
1150
1151static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001152 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1153 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1154
1155 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1156 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1157
1158 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1159 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1160
1161 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1162 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1163
1164 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1165 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1166
1167 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1168 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1169
1170 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1171 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1172 { } /* end */
1173};
1174
1175static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001176 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1177 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1178
1179 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1180 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1181
1182 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1183 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1184
1185 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1186 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1187
1188 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1189 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1190
1191 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1192 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1193
1194 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1195 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1196 { } /* end */
1197};
1198
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001199
1200static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1201 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1202 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1203
1204 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1205 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1206
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001207 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT),
1208 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001209
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001210 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT),
1211 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001212
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001213 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT),
1214 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001215
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001216 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT),
1217 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001218
1219 /*
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001220 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT),
1221 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001222 */
1223 { } /* end */
1224};
1225
Matthew Ranostay541eee82007-12-14 12:08:04 +01001226static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostay9b359472007-11-07 13:03:12 +01001227 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1228 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay9b359472007-11-07 13:03:12 +01001229
1230 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1231 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001232 /* analog pc-beep replaced with digital beep support */
1233 /*
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001234 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1235 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001236 */
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001237
Matthew Ranostay687cb982008-10-11 13:52:43 -04001238 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1239 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001240
Matthew Ranostay687cb982008-10-11 13:52:43 -04001241 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1242 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001243
1244 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1245 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1246
1247 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1248 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001249 { } /* end */
1250};
1251
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001252static struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
1253 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1254};
Matthew Ranostay541eee82007-12-14 12:08:04 +01001255
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001256static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +01001257 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1258 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001259
1260 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1261 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001262 { } /* end */
1263};
1264
Tobin Davis8e21c342007-01-08 11:04:17 +01001265static struct snd_kcontrol_new stac925x_mixer[] = {
Takashi Iwaic9280d62009-01-15 17:31:00 +01001266 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
1267 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001268 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +02001269 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001270 { } /* end */
1271};
1272
Takashi Iwaid1d985f2006-11-23 19:27:12 +01001273static struct snd_kcontrol_new stac9205_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001274 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1275 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001276
1277 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1278 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001279 { } /* end */
1280};
1281
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001282static struct snd_kcontrol_new stac9205_loopback[] = {
1283 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1284 {}
1285};
1286
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001287/* This needs to be generated dynamically based on sequence */
1288static struct snd_kcontrol_new stac922x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001289 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1290 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001291
1292 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1293 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001294 { } /* end */
1295};
1296
1297
1298static struct snd_kcontrol_new stac927x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001299 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1300 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001301
1302 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1303 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001304
1305 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1306 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
Matt Porterf3302a52006-07-31 12:49:34 +02001307 { } /* end */
1308};
1309
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001310static struct snd_kcontrol_new stac927x_loopback[] = {
1311 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1312 {}
1313};
1314
Takashi Iwai1697055e2007-12-18 18:05:52 +01001315static struct snd_kcontrol_new stac_dmux_mixer = {
1316 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1317 .name = "Digital Input Source",
1318 /* count set later */
1319 .info = stac92xx_dmux_enum_info,
1320 .get = stac92xx_dmux_enum_get,
1321 .put = stac92xx_dmux_enum_put,
1322};
1323
Matthew Ranostayd9737752008-09-07 12:03:41 +02001324static struct snd_kcontrol_new stac_smux_mixer = {
1325 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001326 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001327 /* count set later */
1328 .info = stac92xx_smux_enum_info,
1329 .get = stac92xx_smux_enum_get,
1330 .put = stac92xx_smux_enum_put,
1331};
1332
Takashi Iwai2134ea42008-01-10 16:53:55 +01001333static const char *slave_vols[] = {
1334 "Front Playback Volume",
1335 "Surround Playback Volume",
1336 "Center Playback Volume",
1337 "LFE Playback Volume",
1338 "Side Playback Volume",
1339 "Headphone Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001340 "Speaker Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001341 NULL
1342};
1343
1344static const char *slave_sws[] = {
1345 "Front Playback Switch",
1346 "Surround Playback Switch",
1347 "Center Playback Switch",
1348 "LFE Playback Switch",
1349 "Side Playback Switch",
1350 "Headphone Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001351 "Speaker Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001352 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001353 NULL
1354};
1355
Takashi Iwai603c4012008-07-30 15:01:44 +02001356static void stac92xx_free_kctls(struct hda_codec *codec);
Takashi Iwaie4973e12008-11-18 09:32:42 +01001357static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
Takashi Iwai603c4012008-07-30 15:01:44 +02001358
Matt2f2f4252005-04-13 14:45:30 +02001359static int stac92xx_build_controls(struct hda_codec *codec)
1360{
1361 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaie4973e12008-11-18 09:32:42 +01001362 struct auto_pin_cfg *cfg = &spec->autocfg;
1363 hda_nid_t nid;
Matt2f2f4252005-04-13 14:45:30 +02001364 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001365 int i;
Matt2f2f4252005-04-13 14:45:30 +02001366
1367 err = snd_hda_add_new_ctls(codec, spec->mixer);
1368 if (err < 0)
1369 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001370
1371 for (i = 0; i < spec->num_mixers; i++) {
1372 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1373 if (err < 0)
1374 return err;
1375 }
Takashi Iwai1697055e2007-12-18 18:05:52 +01001376 if (spec->num_dmuxes > 0) {
1377 stac_dmux_mixer.count = spec->num_dmuxes;
Takashi Iwaid13bd412008-07-30 15:01:45 +02001378 err = snd_hda_ctl_add(codec,
Takashi Iwai1697055e2007-12-18 18:05:52 +01001379 snd_ctl_new1(&stac_dmux_mixer, codec));
1380 if (err < 0)
1381 return err;
1382 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001383 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001384 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1385 struct hda_input_mux *smux = &spec->private_smux;
1386 /* check for mute support on SPDIF out */
1387 if (wcaps & AC_WCAP_OUT_AMP) {
1388 smux->items[smux->num_items].label = "Off";
1389 smux->items[smux->num_items].index = 0;
1390 smux->num_items++;
1391 spec->spdif_mute = 1;
1392 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001393 stac_smux_mixer.count = spec->num_smuxes;
Takashi Iwai4f2d23e2008-12-19 10:14:13 +01001394 err = snd_hda_ctl_add(codec,
Matthew Ranostayd9737752008-09-07 12:03:41 +02001395 snd_ctl_new1(&stac_smux_mixer, codec));
1396 if (err < 0)
1397 return err;
1398 }
Mattc7d4b2f2005-06-27 14:59:41 +02001399
Mattdabbed62005-06-14 10:19:34 +02001400 if (spec->multiout.dig_out_nid) {
1401 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1402 if (err < 0)
1403 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001404 err = snd_hda_create_spdif_share_sw(codec,
1405 &spec->multiout);
1406 if (err < 0)
1407 return err;
1408 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001409 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001410 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001411 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1412 if (err < 0)
1413 return err;
1414 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001415
1416 /* if we have no master control, let's create it */
1417 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001418 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001419 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001420 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai7c7767e2009-01-20 15:28:38 +01001421 /* correct volume offset */
1422 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
Takashi Iwai2134ea42008-01-10 16:53:55 +01001423 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001424 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001425 if (err < 0)
1426 return err;
1427 }
1428 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1429 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1430 NULL, slave_sws);
1431 if (err < 0)
1432 return err;
1433 }
1434
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001435 if (spec->aloopback_ctl &&
1436 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1437 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1438 if (err < 0)
1439 return err;
1440 }
1441
Takashi Iwai603c4012008-07-30 15:01:44 +02001442 stac92xx_free_kctls(codec); /* no longer needed */
Takashi Iwaie4973e12008-11-18 09:32:42 +01001443
1444 /* create jack input elements */
1445 if (spec->hp_detect) {
1446 for (i = 0; i < cfg->hp_outs; i++) {
1447 int type = SND_JACK_HEADPHONE;
1448 nid = cfg->hp_pins[i];
1449 /* jack detection */
1450 if (cfg->hp_outs == i)
1451 type |= SND_JACK_LINEOUT;
1452 err = stac92xx_add_jack(codec, nid, type);
1453 if (err < 0)
1454 return err;
1455 }
1456 }
1457 for (i = 0; i < cfg->line_outs; i++) {
1458 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1459 SND_JACK_LINEOUT);
1460 if (err < 0)
1461 return err;
1462 }
1463 for (i = 0; i < AUTO_PIN_LAST; i++) {
1464 nid = cfg->input_pins[i];
1465 if (nid) {
1466 err = stac92xx_add_jack(codec, nid,
1467 SND_JACK_MICROPHONE);
1468 if (err < 0)
1469 return err;
1470 }
1471 }
1472
Mattdabbed62005-06-14 10:19:34 +02001473 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001474}
1475
Matt Porter403d1942005-11-29 15:00:51 +01001476static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001477 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001478 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1479};
1480
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001481static unsigned int gateway9200_m4_pin_configs[8] = {
1482 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1483 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1484};
1485static unsigned int gateway9200_m4_2_pin_configs[8] = {
1486 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1487 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1488};
1489
1490/*
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001491 STAC 9200 pin configs for
1492 102801A8
1493 102801DE
1494 102801E8
1495*/
1496static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001497 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1498 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001499};
1500
1501/*
1502 STAC 9200 pin configs for
1503 102801C0
1504 102801C1
1505*/
1506static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001507 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1508 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001509};
1510
1511/*
1512 STAC 9200 pin configs for
1513 102801C4 (Dell Dimension E310)
1514 102801C5
1515 102801C7
1516 102801D9
1517 102801DA
1518 102801E3
1519*/
1520static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001521 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1522 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001523};
1524
1525
1526/*
1527 STAC 9200-32 pin configs for
1528 102801B5 (Dell Inspiron 630m)
1529 102801D8 (Dell Inspiron 640m)
1530*/
1531static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001532 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1533 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001534};
1535
1536/*
1537 STAC 9200-32 pin configs for
1538 102801C2 (Dell Latitude D620)
1539 102801C8
1540 102801CC (Dell Latitude D820)
1541 102801D4
1542 102801D6
1543*/
1544static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001545 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1546 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001547};
1548
1549/*
1550 STAC 9200-32 pin configs for
1551 102801CE (Dell XPS M1710)
1552 102801CF (Dell Precision M90)
1553*/
1554static unsigned int dell9200_m23_pin_configs[8] = {
1555 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1556 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1557};
1558
1559/*
1560 STAC 9200-32 pin configs for
1561 102801C9
1562 102801CA
1563 102801CB (Dell Latitude 120L)
1564 102801D3
1565*/
1566static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001567 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1568 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001569};
1570
1571/*
1572 STAC 9200-32 pin configs for
1573 102801BD (Dell Inspiron E1505n)
1574 102801EE
1575 102801EF
1576*/
1577static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001578 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1579 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001580};
1581
1582/*
1583 STAC 9200-32 pin configs for
1584 102801F5 (Dell Inspiron 1501)
1585 102801F6
1586*/
1587static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001588 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1589 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001590};
1591
1592/*
1593 STAC 9200-32
1594 102801CD (Dell Inspiron E1705/9400)
1595*/
1596static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001597 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1598 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001599};
1600
Tobin Davisbf277782008-02-03 20:31:47 +01001601static unsigned int oqo9200_pin_configs[8] = {
1602 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1603 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1604};
1605
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001606
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001607static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1608 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001609 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001610 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1611 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1612 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1613 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1614 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1615 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1616 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1617 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1618 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1619 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001620 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1621 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001622 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001623};
1624
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001625static const char *stac9200_models[STAC_9200_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001626 [STAC_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001627 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001628 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001629 [STAC_9200_DELL_D21] = "dell-d21",
1630 [STAC_9200_DELL_D22] = "dell-d22",
1631 [STAC_9200_DELL_D23] = "dell-d23",
1632 [STAC_9200_DELL_M21] = "dell-m21",
1633 [STAC_9200_DELL_M22] = "dell-m22",
1634 [STAC_9200_DELL_M23] = "dell-m23",
1635 [STAC_9200_DELL_M24] = "dell-m24",
1636 [STAC_9200_DELL_M25] = "dell-m25",
1637 [STAC_9200_DELL_M26] = "dell-m26",
1638 [STAC_9200_DELL_M27] = "dell-m27",
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001639 [STAC_9200_M4] = "gateway-m4",
1640 [STAC_9200_M4_2] = "gateway-m4-2",
Takashi Iwai117f2572008-03-18 09:53:23 +01001641 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001642};
1643
1644static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1645 /* SigmaTel reference board */
1646 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1647 "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001648 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1649 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001650 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001651 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1652 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001653 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001654 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1655 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1656 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1657 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1658 "unknown Dell", STAC_9200_DELL_D22),
1659 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1660 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001661 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001662 "Dell Latitude D620", STAC_9200_DELL_M22),
1663 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1664 "unknown Dell", STAC_9200_DELL_D23),
1665 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1666 "unknown Dell", STAC_9200_DELL_D23),
1667 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1668 "unknown Dell", STAC_9200_DELL_M22),
1669 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1670 "unknown Dell", STAC_9200_DELL_M24),
1671 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1672 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001673 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001674 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001675 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001676 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001677 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001678 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001679 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001680 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001681 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001682 "Dell Precision M90", STAC_9200_DELL_M23),
1683 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1684 "unknown Dell", STAC_9200_DELL_M22),
1685 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1686 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001687 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001688 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001689 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001690 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1691 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1692 "unknown Dell", STAC_9200_DELL_D23),
1693 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1694 "unknown Dell", STAC_9200_DELL_D23),
1695 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1696 "unknown Dell", STAC_9200_DELL_D21),
1697 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1698 "unknown Dell", STAC_9200_DELL_D23),
1699 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1700 "unknown Dell", STAC_9200_DELL_D21),
1701 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1702 "unknown Dell", STAC_9200_DELL_M25),
1703 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1704 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001705 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001706 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1707 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1708 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001709 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001710 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001711 /* Gateway machines needs EAPD to be set on resume */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001712 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1713 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1714 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
Tobin Davisbf277782008-02-03 20:31:47 +01001715 /* OQO Mobile */
1716 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001717 {} /* terminator */
1718};
1719
Tobin Davis8e21c342007-01-08 11:04:17 +01001720static unsigned int ref925x_pin_configs[8] = {
1721 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001722 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001723};
1724
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001725static unsigned int stac925xM1_pin_configs[8] = {
1726 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1727 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001728};
1729
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001730static unsigned int stac925xM1_2_pin_configs[8] = {
1731 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1732 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1733};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001734
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001735static unsigned int stac925xM2_pin_configs[8] = {
1736 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1737 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis2c11f952007-05-17 09:36:34 +02001738};
1739
Tobin Davis8e21c342007-01-08 11:04:17 +01001740static unsigned int stac925xM2_2_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001741 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1742 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1743};
1744
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001745static unsigned int stac925xM3_pin_configs[8] = {
1746 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1747 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1748};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001749
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001750static unsigned int stac925xM5_pin_configs[8] = {
1751 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1752 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1753};
1754
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001755static unsigned int stac925xM6_pin_configs[8] = {
1756 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1757 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
Tobin Davis8e21c342007-01-08 11:04:17 +01001758};
1759
1760static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1761 [STAC_REF] = ref925x_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001762 [STAC_M1] = stac925xM1_pin_configs,
1763 [STAC_M1_2] = stac925xM1_2_pin_configs,
1764 [STAC_M2] = stac925xM2_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001765 [STAC_M2_2] = stac925xM2_2_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001766 [STAC_M3] = stac925xM3_pin_configs,
1767 [STAC_M5] = stac925xM5_pin_configs,
1768 [STAC_M6] = stac925xM6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001769};
1770
1771static const char *stac925x_models[STAC_925x_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001772 [STAC_925x_AUTO] = "auto",
Tobin Davis8e21c342007-01-08 11:04:17 +01001773 [STAC_REF] = "ref",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001774 [STAC_M1] = "m1",
1775 [STAC_M1_2] = "m1-2",
1776 [STAC_M2] = "m2",
Tobin Davis8e21c342007-01-08 11:04:17 +01001777 [STAC_M2_2] = "m2-2",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001778 [STAC_M3] = "m3",
1779 [STAC_M5] = "m5",
1780 [STAC_M6] = "m6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001781};
1782
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001783static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001784 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1785 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1786 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1787 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001788 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001789 /* Not sure about the brand name for those */
1790 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1791 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1792 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1793 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001794 {} /* terminator */
Tobin Davis8e21c342007-01-08 11:04:17 +01001795};
1796
1797static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1798 /* SigmaTel reference board */
1799 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001800 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001801 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001802
1803 /* Default table for unknown ID */
1804 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1805
Tobin Davis8e21c342007-01-08 11:04:17 +01001806 {} /* terminator */
1807};
1808
Matthew Ranostaya7662642008-02-21 07:51:14 +01001809static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001810 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1811 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1812 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001813 0x01452050,
1814};
1815
1816static unsigned int dell_m6_pin_configs[13] = {
1817 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001818 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001819 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1820 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001821};
1822
1823static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001824 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001825 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1826 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1827 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001828 [STAC_DELL_EQ] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001829};
1830
1831static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001832 [STAC_92HD73XX_AUTO] = "auto",
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01001833 [STAC_92HD73XX_NO_JD] = "no-jd",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001834 [STAC_92HD73XX_REF] = "ref",
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001835 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1836 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1837 [STAC_DELL_M6_BOTH] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001838 [STAC_DELL_EQ] = "dell-eq",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001839};
1840
1841static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1842 /* SigmaTel reference board */
1843 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001844 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001845 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1846 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001847 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001848 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001849 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001850 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001851 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001852 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001853 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001854 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001855 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001856 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001857 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001858 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001859 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001860 "unknown Dell", STAC_DELL_M6_DMIC),
1861 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1862 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01001863 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001864 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Joerg Schirottkefa620e92008-12-19 08:13:49 +01001865 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1866 "Dell Studio 17", STAC_DELL_M6_DMIC),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001867 {} /* terminator */
1868};
1869
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001870static unsigned int ref92hd83xxx_pin_configs[10] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001871 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1872 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001873 0x01451160, 0x98560170,
1874};
1875
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001876static unsigned int dell_s14_pin_configs[10] = {
1877 0x02214030, 0x02211010, 0x02a19020, 0x01014050,
1878 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160,
1879 0x40f000f0, 0x40f000f0,
1880};
1881
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001882static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1883 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001884 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001885 [STAC_DELL_S14] = dell_s14_pin_configs,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001886};
1887
1888static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001889 [STAC_92HD83XXX_AUTO] = "auto",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001890 [STAC_92HD83XXX_REF] = "ref",
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001891 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001892 [STAC_DELL_S14] = "dell-s14",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001893};
1894
1895static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1896 /* SigmaTel reference board */
1897 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Takashi Iwaif9d088b2009-01-13 11:54:49 +01001898 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001899 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1900 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001901 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1902 "unknown Dell", STAC_DELL_S14),
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -02001903 {} /* terminator */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001904};
1905
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001906static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001907 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001908 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001909 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1910 0x00000000
Matthew Ranostaye035b842007-11-06 11:53:55 +01001911};
1912
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001913static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001914 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001915 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001916 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1917 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001918};
1919
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001920static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001921 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1922 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001923 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1924 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001925};
1926
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001927static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001928 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1929 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001930 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1931 0x00000000
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001932};
1933
Matthew Ranostaye035b842007-11-06 11:53:55 +01001934static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1935 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001936 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1937 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001938 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001939 [STAC_HP_M4] = NULL,
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001940 [STAC_HP_DV5] = NULL,
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001941 [STAC_HP_HDX] = NULL,
James Gardiner514bf542009-05-03 04:00:44 -04001942 [STAC_HP_DV4_1222NR] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001943};
1944
1945static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001946 [STAC_92HD71BXX_AUTO] = "auto",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001947 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001948 [STAC_DELL_M4_1] = "dell-m4-1",
1949 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001950 [STAC_DELL_M4_3] = "dell-m4-3",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001951 [STAC_HP_M4] = "hp-m4",
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001952 [STAC_HP_DV5] = "hp-dv5",
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001953 [STAC_HP_HDX] = "hp-hdx",
James Gardiner514bf542009-05-03 04:00:44 -04001954 [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001955};
1956
1957static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1958 /* SigmaTel reference board */
1959 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1960 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001961 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1962 "DFI LanParty", STAC_92HD71BXX_REF),
James Gardiner514bf542009-05-03 04:00:44 -04001963 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
1964 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
Takashi Iwai58d83952009-03-13 17:04:34 +01001965 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1966 "HP", STAC_HP_DV5),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001967 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
1968 "HP dv4-7", STAC_HP_DV5),
1969 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1970 "HP dv4-7", STAC_HP_DV5),
Takashi Iwai6fce61a2009-03-10 07:48:57 +01001971 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1972 "HP HDX", STAC_HP_HDX), /* HDX18 */
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001973 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001974 "HP mini 1000", STAC_HP_M4),
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001975 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
Takashi Iwai6fce61a2009-03-10 07:48:57 +01001976 "HP HDX", STAC_HP_HDX), /* HDX16 */
Matthew Ranostaya7662642008-02-21 07:51:14 +01001977 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1978 "unknown Dell", STAC_DELL_M4_1),
1979 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1980 "unknown Dell", STAC_DELL_M4_1),
1981 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1982 "unknown Dell", STAC_DELL_M4_1),
1983 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1984 "unknown Dell", STAC_DELL_M4_1),
1985 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1986 "unknown Dell", STAC_DELL_M4_1),
1987 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1988 "unknown Dell", STAC_DELL_M4_1),
1989 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1990 "unknown Dell", STAC_DELL_M4_1),
1991 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1992 "unknown Dell", STAC_DELL_M4_2),
1993 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1994 "unknown Dell", STAC_DELL_M4_2),
1995 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1996 "unknown Dell", STAC_DELL_M4_2),
1997 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1998 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001999 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
2000 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01002001 {} /* terminator */
2002};
2003
Matt Porter403d1942005-11-29 15:00:51 +01002004static unsigned int ref922x_pin_configs[10] = {
2005 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
2006 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02002007 0x40000100, 0x40000100,
2008};
2009
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002010/*
2011 STAC 922X pin configs for
2012 102801A7
2013 102801AB
2014 102801A9
2015 102801D1
2016 102801D2
2017*/
2018static unsigned int dell_922x_d81_pin_configs[10] = {
2019 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
2020 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
2021 0x01813122, 0x400001f2,
2022};
2023
2024/*
2025 STAC 922X pin configs for
2026 102801AC
2027 102801D0
2028*/
2029static unsigned int dell_922x_d82_pin_configs[10] = {
2030 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
2031 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
2032 0x01813122, 0x400001f1,
2033};
2034
2035/*
2036 STAC 922X pin configs for
2037 102801BF
2038*/
2039static unsigned int dell_922x_m81_pin_configs[10] = {
2040 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
2041 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
2042 0x40C003f1, 0x405003f0,
2043};
2044
2045/*
2046 STAC 9221 A1 pin configs for
2047 102801D7 (Dell XPS M1210)
2048*/
2049static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01002050 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
2051 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002052 0x508003f3, 0x405003f4,
2053};
2054
Matt Porter403d1942005-11-29 15:00:51 +01002055static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01002056 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01002057 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2058 0x02a19120, 0x40000100,
2059};
2060
2061static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01002062 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
2063 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01002064 0x02a19320, 0x40000100,
2065};
2066
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002067static unsigned int intel_mac_v1_pin_configs[10] = {
2068 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
2069 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01002070 0x400000fc, 0x400000fb,
2071};
2072
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002073static unsigned int intel_mac_v2_pin_configs[10] = {
2074 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
2075 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02002076 0x400000fc, 0x400000fb,
2077};
2078
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002079static unsigned int intel_mac_v3_pin_configs[10] = {
2080 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
2081 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
2082 0x400000fc, 0x400000fb,
2083};
2084
2085static unsigned int intel_mac_v4_pin_configs[10] = {
2086 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
2087 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
2088 0x400000fc, 0x400000fb,
2089};
2090
2091static unsigned int intel_mac_v5_pin_configs[10] = {
2092 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
2093 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
2094 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02002095};
2096
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002097static unsigned int ecs202_pin_configs[10] = {
2098 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
2099 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
2100 0x9037012e, 0x40e000f2,
2101};
Takashi Iwai76c08822007-06-19 12:17:42 +02002102
Takashi Iwai19039bd2006-06-28 15:52:16 +02002103static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002104 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02002105 [STAC_D945GTP3] = d945gtp3_pin_configs,
2106 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002107 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
2108 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
2109 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
2110 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
2111 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08002112 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002113 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002114 [STAC_MACMINI] = intel_mac_v3_pin_configs,
2115 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
2116 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
2117 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
2118 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
2119 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002120 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002121 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
2122 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
2123 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
2124 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01002125};
2126
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002127static const char *stac922x_models[STAC_922X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002128 [STAC_922X_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002129 [STAC_D945_REF] = "ref",
2130 [STAC_D945GTP5] = "5stack",
2131 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002132 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
2133 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
2134 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
2135 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
2136 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08002137 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002138 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002139 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01002140 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01002141 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
2142 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02002143 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02002144 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002145 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002146 [STAC_922X_DELL_D81] = "dell-d81",
2147 [STAC_922X_DELL_D82] = "dell-d82",
2148 [STAC_922X_DELL_M81] = "dell-m81",
2149 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002150};
2151
2152static struct snd_pci_quirk stac922x_cfg_tbl[] = {
2153 /* SigmaTel reference board */
2154 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2155 "DFI LanParty", STAC_D945_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002156 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2157 "DFI LanParty", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002158 /* Intel 945G based systems */
2159 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2160 "Intel D945G", STAC_D945GTP3),
2161 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2162 "Intel D945G", STAC_D945GTP3),
2163 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2164 "Intel D945G", STAC_D945GTP3),
2165 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2166 "Intel D945G", STAC_D945GTP3),
2167 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2168 "Intel D945G", STAC_D945GTP3),
2169 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2170 "Intel D945G", STAC_D945GTP3),
2171 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2172 "Intel D945G", STAC_D945GTP3),
2173 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2174 "Intel D945G", STAC_D945GTP3),
2175 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2176 "Intel D945G", STAC_D945GTP3),
2177 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2178 "Intel D945G", STAC_D945GTP3),
2179 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2180 "Intel D945G", STAC_D945GTP3),
2181 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2182 "Intel D945G", STAC_D945GTP3),
2183 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2184 "Intel D945G", STAC_D945GTP3),
2185 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2186 "Intel D945G", STAC_D945GTP3),
2187 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2188 "Intel D945G", STAC_D945GTP3),
2189 /* Intel D945G 5-stack systems */
2190 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2191 "Intel D945G", STAC_D945GTP5),
2192 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2193 "Intel D945G", STAC_D945GTP5),
2194 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2195 "Intel D945G", STAC_D945GTP5),
2196 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2197 "Intel D945G", STAC_D945GTP5),
2198 /* Intel 945P based systems */
2199 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2200 "Intel D945P", STAC_D945GTP3),
2201 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2202 "Intel D945P", STAC_D945GTP3),
2203 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2204 "Intel D945P", STAC_D945GTP3),
2205 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2206 "Intel D945P", STAC_D945GTP3),
2207 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2208 "Intel D945P", STAC_D945GTP3),
2209 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2210 "Intel D945P", STAC_D945GTP5),
Takashi Iwai8056d472009-01-23 09:09:43 +01002211 /* other intel */
2212 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2213 "Intel D945", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002214 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08002215 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002216 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08002217 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002218 /* Dell systems */
2219 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2220 "unknown Dell", STAC_922X_DELL_D81),
2221 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2222 "unknown Dell", STAC_922X_DELL_D81),
2223 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2224 "unknown Dell", STAC_922X_DELL_D81),
2225 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2226 "unknown Dell", STAC_922X_DELL_D82),
2227 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2228 "unknown Dell", STAC_922X_DELL_M81),
2229 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2230 "unknown Dell", STAC_922X_DELL_D82),
2231 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2232 "unknown Dell", STAC_922X_DELL_D81),
2233 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2234 "unknown Dell", STAC_922X_DELL_D81),
2235 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2236 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002237 /* ECS/PC Chips boards */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002238 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
Herton Ronaldo Krzesinski8663ae52009-02-08 19:50:34 -02002239 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01002240 {} /* terminator */
2241};
2242
Matt Porter3cc08dc2006-01-23 15:27:49 +01002243static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002244 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2245 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2246 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2247 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002248};
2249
Tobin Davis93ed1502006-09-01 21:03:12 +02002250static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002251 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2252 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2253 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2254 0x40000100, 0x40000100
2255};
2256
Tobin Davis93ed1502006-09-01 21:03:12 +02002257static unsigned int d965_5st_pin_configs[14] = {
2258 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2259 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2260 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2261 0x40000100, 0x40000100
2262};
2263
Tobin Davis4ff076e2007-08-07 11:48:12 +02002264static unsigned int dell_3st_pin_configs[14] = {
2265 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2266 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002267 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002268 0x40c003fc, 0x40000100
2269};
2270
Tobin Davis93ed1502006-09-01 21:03:12 +02002271static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002272 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002273 [STAC_D965_REF] = ref927x_pin_configs,
2274 [STAC_D965_3ST] = d965_3st_pin_configs,
2275 [STAC_D965_5ST] = d965_5st_pin_configs,
2276 [STAC_DELL_3ST] = dell_3st_pin_configs,
2277 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002278};
2279
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002280static const char *stac927x_models[STAC_927X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002281 [STAC_927X_AUTO] = "auto",
Takashi Iwaie28d8322008-12-17 13:48:29 +01002282 [STAC_D965_REF_NO_JD] = "ref-no-jd",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002283 [STAC_D965_REF] = "ref",
2284 [STAC_D965_3ST] = "3stack",
2285 [STAC_D965_5ST] = "5stack",
2286 [STAC_DELL_3ST] = "dell-3stack",
2287 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002288};
2289
2290static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2291 /* SigmaTel reference board */
2292 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2293 "DFI LanParty", STAC_D965_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002294 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2295 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002296 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002297 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2298 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002299 /* 965 based 3 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002300 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2301 "Intel D965", STAC_D965_3ST),
2302 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2303 "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002304 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002305 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002306 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002307 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2308 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002309 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002310 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2311 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002312 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02002313 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002314 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2315 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2316 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2317 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002318 /* 965 based 5 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002319 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2320 "Intel D965", STAC_D965_5ST),
2321 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2322 "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002323 {} /* terminator */
2324};
2325
Matt Porterf3302a52006-07-31 12:49:34 +02002326static unsigned int ref9205_pin_configs[12] = {
2327 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002328 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002329 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002330};
2331
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002332/*
2333 STAC 9205 pin configs for
2334 102801F1
2335 102801F2
2336 102801FC
2337 102801FD
2338 10280204
2339 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002340 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002341*/
2342static unsigned int dell_9205_m42_pin_configs[12] = {
2343 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2344 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2345 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2346};
2347
2348/*
2349 STAC 9205 pin configs for
2350 102801F9
2351 102801FA
2352 102801FE
2353 102801FF (Dell Precision M4300)
2354 10280206
2355 10280200
2356 10280201
2357*/
2358static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002359 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2360 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2361 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2362};
2363
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002364static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002365 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2366 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2367 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2368};
2369
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002370static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002371 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002372 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2373 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2374 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Takashi Iwaid9a42682009-01-22 17:40:18 +01002375 [STAC_9205_EAPD] = NULL,
Matt Porterf3302a52006-07-31 12:49:34 +02002376};
2377
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002378static const char *stac9205_models[STAC_9205_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002379 [STAC_9205_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002380 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002381 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002382 [STAC_9205_DELL_M43] = "dell-m43",
2383 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaid9a42682009-01-22 17:40:18 +01002384 [STAC_9205_EAPD] = "eapd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002385};
2386
2387static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2388 /* SigmaTel reference board */
2389 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2390 "DFI LanParty", STAC_9205_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002391 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2392 "DFI LanParty", STAC_9205_REF),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002393 /* Dell */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002394 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2395 "unknown Dell", STAC_9205_DELL_M42),
2396 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2397 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002398 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002399 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002400 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2401 "Dell Precision", STAC_9205_DELL_M43),
2402 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2403 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002404 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2405 "unknown Dell", STAC_9205_DELL_M42),
2406 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2407 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002408 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2409 "Dell Precision", STAC_9205_DELL_M43),
2410 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002411 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002412 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2413 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002414 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2415 "Dell Precision", STAC_9205_DELL_M43),
2416 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2417 "Dell Precision", STAC_9205_DELL_M43),
2418 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2419 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002420 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2421 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002422 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2423 "Dell Vostro 1500", STAC_9205_DELL_M42),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002424 /* Gateway */
2425 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
Matt Porterf3302a52006-07-31 12:49:34 +02002426 {} /* terminator */
2427};
2428
Takashi Iwai330ee992009-02-20 14:33:36 +01002429static void stac92xx_set_config_regs(struct hda_codec *codec,
2430 unsigned int *pincfgs)
Matt2f2f4252005-04-13 14:45:30 +02002431{
2432 int i;
2433 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002434
Takashi Iwai330ee992009-02-20 14:33:36 +01002435 if (!pincfgs)
2436 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002437
Matthew Ranostay87d48362007-07-17 11:52:24 +02002438 for (i = 0; i < spec->num_pins; i++)
Takashi Iwai330ee992009-02-20 14:33:36 +01002439 if (spec->pin_nids[i] && pincfgs[i])
2440 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2441 pincfgs[i]);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002442}
2443
Matt2f2f4252005-04-13 14:45:30 +02002444/*
2445 * Analog playback callbacks
2446 */
2447static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2448 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002449 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002450{
2451 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002452 if (spec->stream_delay)
2453 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002454 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2455 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002456}
2457
2458static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2459 struct hda_codec *codec,
2460 unsigned int stream_tag,
2461 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002462 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002463{
2464 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002465 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002466}
2467
2468static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2469 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002470 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002471{
2472 struct sigmatel_spec *spec = codec->spec;
2473 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2474}
2475
2476/*
Mattdabbed62005-06-14 10:19:34 +02002477 * Digital playback callbacks
2478 */
2479static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2480 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002481 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002482{
2483 struct sigmatel_spec *spec = codec->spec;
2484 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2485}
2486
2487static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2488 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002489 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002490{
2491 struct sigmatel_spec *spec = codec->spec;
2492 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2493}
2494
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002495static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2496 struct hda_codec *codec,
2497 unsigned int stream_tag,
2498 unsigned int format,
2499 struct snd_pcm_substream *substream)
2500{
2501 struct sigmatel_spec *spec = codec->spec;
2502 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2503 stream_tag, format, substream);
2504}
2505
Takashi Iwai9411e212009-02-13 11:32:28 +01002506static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2507 struct hda_codec *codec,
2508 struct snd_pcm_substream *substream)
2509{
2510 struct sigmatel_spec *spec = codec->spec;
2511 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2512}
2513
Mattdabbed62005-06-14 10:19:34 +02002514
2515/*
Matt2f2f4252005-04-13 14:45:30 +02002516 * Analog capture callbacks
2517 */
2518static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2519 struct hda_codec *codec,
2520 unsigned int stream_tag,
2521 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002522 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002523{
2524 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002525 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002526
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002527 if (spec->powerdown_adcs) {
2528 msleep(40);
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002529 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002530 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2531 }
2532 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002533 return 0;
2534}
2535
2536static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2537 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002538 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002539{
2540 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002541 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002542
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002543 snd_hda_codec_cleanup_stream(codec, nid);
2544 if (spec->powerdown_adcs)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002545 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002546 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002547 return 0;
2548}
2549
Mattdabbed62005-06-14 10:19:34 +02002550static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2551 .substreams = 1,
2552 .channels_min = 2,
2553 .channels_max = 2,
2554 /* NID is set in stac92xx_build_pcms */
2555 .ops = {
2556 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002557 .close = stac92xx_dig_playback_pcm_close,
Takashi Iwai9411e212009-02-13 11:32:28 +01002558 .prepare = stac92xx_dig_playback_pcm_prepare,
2559 .cleanup = stac92xx_dig_playback_pcm_cleanup
Mattdabbed62005-06-14 10:19:34 +02002560 },
2561};
2562
2563static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2564 .substreams = 1,
2565 .channels_min = 2,
2566 .channels_max = 2,
2567 /* NID is set in stac92xx_build_pcms */
2568};
2569
Matt2f2f4252005-04-13 14:45:30 +02002570static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2571 .substreams = 1,
2572 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002573 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002574 .nid = 0x02, /* NID to query formats and rates */
2575 .ops = {
2576 .open = stac92xx_playback_pcm_open,
2577 .prepare = stac92xx_playback_pcm_prepare,
2578 .cleanup = stac92xx_playback_pcm_cleanup
2579 },
2580};
2581
Matt Porter3cc08dc2006-01-23 15:27:49 +01002582static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2583 .substreams = 1,
2584 .channels_min = 2,
2585 .channels_max = 2,
2586 .nid = 0x06, /* NID to query formats and rates */
2587 .ops = {
2588 .open = stac92xx_playback_pcm_open,
2589 .prepare = stac92xx_playback_pcm_prepare,
2590 .cleanup = stac92xx_playback_pcm_cleanup
2591 },
2592};
2593
Matt2f2f4252005-04-13 14:45:30 +02002594static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002595 .channels_min = 2,
2596 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002597 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002598 .ops = {
2599 .prepare = stac92xx_capture_pcm_prepare,
2600 .cleanup = stac92xx_capture_pcm_cleanup
2601 },
2602};
2603
2604static int stac92xx_build_pcms(struct hda_codec *codec)
2605{
2606 struct sigmatel_spec *spec = codec->spec;
2607 struct hda_pcm *info = spec->pcm_rec;
2608
2609 codec->num_pcms = 1;
2610 codec->pcm_info = info;
2611
Mattc7d4b2f2005-06-27 14:59:41 +02002612 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002613 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Takashi Iwai00a602d2009-01-23 11:55:42 +01002614 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2615 spec->multiout.dac_nids[0];
Matt2f2f4252005-04-13 14:45:30 +02002616 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002617 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002618 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002619
2620 if (spec->alt_switch) {
2621 codec->num_pcms++;
2622 info++;
2623 info->name = "STAC92xx Analog Alt";
2624 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2625 }
Matt2f2f4252005-04-13 14:45:30 +02002626
Mattdabbed62005-06-14 10:19:34 +02002627 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2628 codec->num_pcms++;
2629 info++;
2630 info->name = "STAC92xx Digital";
Takashi Iwai0852d7a2009-02-11 11:35:15 +01002631 info->pcm_type = spec->autocfg.dig_out_type[0];
Mattdabbed62005-06-14 10:19:34 +02002632 if (spec->multiout.dig_out_nid) {
2633 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2634 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2635 }
2636 if (spec->dig_in_nid) {
2637 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2638 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2639 }
2640 }
2641
Matt2f2f4252005-04-13 14:45:30 +02002642 return 0;
2643}
2644
Takashi Iwaic960a032006-03-23 17:06:28 +01002645static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2646{
Takashi Iwai1327a322009-03-23 13:07:47 +01002647 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01002648 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2649 if (pincap & AC_PINCAP_VREF_100)
2650 return AC_PINCTL_VREF_100;
2651 if (pincap & AC_PINCAP_VREF_80)
2652 return AC_PINCTL_VREF_80;
2653 if (pincap & AC_PINCAP_VREF_50)
2654 return AC_PINCTL_VREF_50;
2655 if (pincap & AC_PINCAP_VREF_GRD)
2656 return AC_PINCTL_VREF_GRD;
2657 return 0;
2658}
2659
Matt Porter403d1942005-11-29 15:00:51 +01002660static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2661
2662{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002663 snd_hda_codec_write_cache(codec, nid, 0,
2664 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002665}
2666
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002667#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2668
2669static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2670 struct snd_ctl_elem_value *ucontrol)
2671{
2672 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2673 struct sigmatel_spec *spec = codec->spec;
2674
Takashi Iwaid7a89432008-11-12 09:48:04 +01002675 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002676 return 0;
2677}
2678
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002679static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
2680 unsigned char type);
2681
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002682static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2683 struct snd_ctl_elem_value *ucontrol)
2684{
2685 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2686 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002687 int nid = kcontrol->private_value;
2688
2689 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002690
2691 /* check to be sure that the ports are upto date with
2692 * switch changes
2693 */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002694 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002695
2696 return 1;
2697}
2698
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002699#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002700
2701static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2702{
2703 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2704 struct sigmatel_spec *spec = codec->spec;
2705 int io_idx = kcontrol-> private_value & 0xff;
2706
2707 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2708 return 0;
2709}
2710
2711static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2712{
2713 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2714 struct sigmatel_spec *spec = codec->spec;
2715 hda_nid_t nid = kcontrol->private_value >> 8;
2716 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002717 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002718
2719 spec->io_switch[io_idx] = val;
2720
2721 if (val)
2722 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002723 else {
2724 unsigned int pinctl = AC_PINCTL_IN_EN;
2725 if (io_idx) /* set VREF for mic */
2726 pinctl |= stac92xx_get_vref(codec, nid);
2727 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2728 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002729
2730 /* check the auto-mute again: we need to mute/unmute the speaker
2731 * appropriately according to the pin direction
2732 */
2733 if (spec->hp_detect)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002734 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
Jiang Zhe40c1d302007-11-12 13:05:16 +01002735
Matt Porter403d1942005-11-29 15:00:51 +01002736 return 1;
2737}
2738
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002739#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2740
2741static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2742 struct snd_ctl_elem_value *ucontrol)
2743{
2744 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2745 struct sigmatel_spec *spec = codec->spec;
2746
2747 ucontrol->value.integer.value[0] = spec->clfe_swap;
2748 return 0;
2749}
2750
2751static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2752 struct snd_ctl_elem_value *ucontrol)
2753{
2754 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2755 struct sigmatel_spec *spec = codec->spec;
2756 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002757 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002758
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002759 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002760 return 0;
2761
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002762 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002763
2764 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2765 spec->clfe_swap ? 0x4 : 0x0);
2766
2767 return 1;
2768}
2769
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002770#define STAC_CODEC_HP_SWITCH(xname) \
2771 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2772 .name = xname, \
2773 .index = 0, \
2774 .info = stac92xx_hp_switch_info, \
2775 .get = stac92xx_hp_switch_get, \
2776 .put = stac92xx_hp_switch_put, \
2777 }
2778
Matt Porter403d1942005-11-29 15:00:51 +01002779#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2780 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2781 .name = xname, \
2782 .index = 0, \
2783 .info = stac92xx_io_switch_info, \
2784 .get = stac92xx_io_switch_get, \
2785 .put = stac92xx_io_switch_put, \
2786 .private_value = xpval, \
2787 }
2788
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002789#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2790 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2791 .name = xname, \
2792 .index = 0, \
2793 .info = stac92xx_clfe_switch_info, \
2794 .get = stac92xx_clfe_switch_get, \
2795 .put = stac92xx_clfe_switch_put, \
2796 .private_value = xpval, \
2797 }
Matt Porter403d1942005-11-29 15:00:51 +01002798
Mattc7d4b2f2005-06-27 14:59:41 +02002799enum {
2800 STAC_CTL_WIDGET_VOL,
2801 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002802 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002803 STAC_CTL_WIDGET_AMP_MUX,
2804 STAC_CTL_WIDGET_AMP_VOL,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002805 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002806 STAC_CTL_WIDGET_IO_SWITCH,
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02002807 STAC_CTL_WIDGET_CLFE_SWITCH,
2808 STAC_CTL_WIDGET_DC_BIAS
Mattc7d4b2f2005-06-27 14:59:41 +02002809};
2810
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002811static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002812 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2813 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002814 STAC_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002815 STAC_AMP_MUX,
2816 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002817 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002818 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002819 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02002820 DC_BIAS(NULL, 0, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002821};
2822
2823/* add dynamic controls */
Takashi Iwaie3c75962009-01-23 11:57:22 +01002824static struct snd_kcontrol_new *
2825stac_control_new(struct sigmatel_spec *spec,
2826 struct snd_kcontrol_new *ktemp,
2827 const char *name)
Mattc7d4b2f2005-06-27 14:59:41 +02002828{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002829 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002830
Takashi Iwai603c4012008-07-30 15:01:44 +02002831 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2832 knew = snd_array_new(&spec->kctls);
2833 if (!knew)
Takashi Iwaie3c75962009-01-23 11:57:22 +01002834 return NULL;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002835 *knew = *ktemp;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002836 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002837 if (!knew->name) {
2838 /* roolback */
2839 memset(knew, 0, sizeof(*knew));
2840 spec->kctls.alloced--;
2841 return NULL;
2842 }
2843 return knew;
2844}
2845
2846static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2847 struct snd_kcontrol_new *ktemp,
2848 int idx, const char *name,
2849 unsigned long val)
2850{
2851 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
2852 if (!knew)
Mattc7d4b2f2005-06-27 14:59:41 +02002853 return -ENOMEM;
Takashi Iwaie3c75962009-01-23 11:57:22 +01002854 knew->index = idx;
Mattc7d4b2f2005-06-27 14:59:41 +02002855 knew->private_value = val;
Mattc7d4b2f2005-06-27 14:59:41 +02002856 return 0;
2857}
2858
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002859static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2860 int type, int idx, const char *name,
2861 unsigned long val)
2862{
2863 return stac92xx_add_control_temp(spec,
2864 &stac92xx_control_templates[type],
2865 idx, name, val);
2866}
2867
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002868
2869/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002870static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2871 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002872{
2873 return stac92xx_add_control_idx(spec, type, 0, name, val);
2874}
2875
Takashi Iwaie3c75962009-01-23 11:57:22 +01002876static struct snd_kcontrol_new stac_input_src_temp = {
2877 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2878 .name = "Input Source",
2879 .info = stac92xx_mux_enum_info,
2880 .get = stac92xx_mux_enum_get,
2881 .put = stac92xx_mux_enum_put,
2882};
2883
2884static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2885{
2886 struct snd_kcontrol_new *knew;
2887 struct hda_input_mux *imux = &spec->private_imux;
2888
2889 if (!spec->num_adcs || imux->num_items <= 1)
2890 return 0; /* no need for input source control */
2891 knew = stac_control_new(spec, &stac_input_src_temp,
2892 stac_input_src_temp.name);
2893 if (!knew)
2894 return -ENOMEM;
2895 knew->count = spec->num_adcs;
2896 return 0;
2897}
2898
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002899/* check whether the line-input can be used as line-out */
2900static hda_nid_t check_line_out_switch(struct hda_codec *codec)
Matt Porter403d1942005-11-29 15:00:51 +01002901{
2902 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002903 struct auto_pin_cfg *cfg = &spec->autocfg;
2904 hda_nid_t nid;
2905 unsigned int pincap;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002906
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002907 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2908 return 0;
2909 nid = cfg->input_pins[AUTO_PIN_LINE];
Takashi Iwai1327a322009-03-23 13:07:47 +01002910 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002911 if (pincap & AC_PINCAP_OUT)
2912 return nid;
Matt Porter403d1942005-11-29 15:00:51 +01002913 return 0;
2914}
2915
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002916/* check whether the mic-input can be used as line-out */
2917static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2918{
2919 struct sigmatel_spec *spec = codec->spec;
2920 struct auto_pin_cfg *cfg = &spec->autocfg;
2921 unsigned int def_conf, pincap;
2922 unsigned int mic_pin;
2923
2924 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2925 return 0;
2926 mic_pin = AUTO_PIN_MIC;
2927 for (;;) {
2928 hda_nid_t nid = cfg->input_pins[mic_pin];
Takashi Iwai330ee992009-02-20 14:33:36 +01002929 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002930 /* some laptops have an internal analog microphone
2931 * which can't be used as a output */
2932 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
Takashi Iwai1327a322009-03-23 13:07:47 +01002933 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002934 if (pincap & AC_PINCAP_OUT)
2935 return nid;
2936 }
2937 if (mic_pin == AUTO_PIN_MIC)
2938 mic_pin = AUTO_PIN_FRONT_MIC;
2939 else
2940 break;
2941 }
2942 return 0;
2943}
Steve Longerbeam7b043892007-05-03 20:50:03 +02002944
2945static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2946{
2947 int i;
2948
2949 for (i = 0; i < spec->multiout.num_dacs; i++) {
2950 if (spec->multiout.dac_nids[i] == nid)
2951 return 1;
2952 }
2953
2954 return 0;
2955}
2956
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002957static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2958{
2959 int i;
2960 if (is_in_dac_nids(spec, nid))
2961 return 1;
2962 for (i = 0; i < spec->autocfg.hp_outs; i++)
2963 if (spec->hp_dacs[i] == nid)
2964 return 1;
2965 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2966 if (spec->speaker_dacs[i] == nid)
2967 return 1;
2968 return 0;
2969}
2970
2971static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2972{
2973 struct sigmatel_spec *spec = codec->spec;
2974 int j, conn_len;
2975 hda_nid_t conn[HDA_MAX_CONNECTIONS];
2976 unsigned int wcaps, wtype;
2977
2978 conn_len = snd_hda_get_connections(codec, nid, conn,
2979 HDA_MAX_CONNECTIONS);
2980 for (j = 0; j < conn_len; j++) {
Takashi Iwai14bafe32009-03-23 16:35:39 +01002981 wcaps = get_wcaps(codec, conn[j]);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002982 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2983 /* we check only analog outputs */
2984 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2985 continue;
2986 /* if this route has a free DAC, assign it */
2987 if (!check_all_dac_nids(spec, conn[j])) {
2988 if (conn_len > 1) {
2989 /* select this DAC in the pin's input mux */
2990 snd_hda_codec_write_cache(codec, nid, 0,
2991 AC_VERB_SET_CONNECT_SEL, j);
2992 }
2993 return conn[j];
2994 }
2995 }
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01002996 /* if all DACs are already assigned, connect to the primary DAC */
2997 if (conn_len > 1) {
2998 for (j = 0; j < conn_len; j++) {
2999 if (conn[j] == spec->multiout.dac_nids[0]) {
3000 snd_hda_codec_write_cache(codec, nid, 0,
3001 AC_VERB_SET_CONNECT_SEL, j);
3002 break;
3003 }
3004 }
3005 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003006 return 0;
3007}
3008
3009static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3010static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3011
Matt Porter3cc08dc2006-01-23 15:27:49 +01003012/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02003013 * Fill in the dac_nids table from the parsed pin configuration
3014 * This function only works when every pin in line_out_pins[]
3015 * contains atleast one DAC in its connection list. Some 92xx
3016 * codecs are not connected directly to a DAC, such as the 9200
3017 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01003018 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003019static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02003020{
3021 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003022 struct auto_pin_cfg *cfg = &spec->autocfg;
3023 int i;
3024 hda_nid_t nid, dac;
Steve Longerbeam7b043892007-05-03 20:50:03 +02003025
Mattc7d4b2f2005-06-27 14:59:41 +02003026 for (i = 0; i < cfg->line_outs; i++) {
3027 nid = cfg->line_out_pins[i];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003028 dac = get_unassigned_dac(codec, nid);
3029 if (!dac) {
Takashi Iwaidf802952007-07-02 19:18:00 +02003030 if (spec->multiout.num_dacs > 0) {
3031 /* we have already working output pins,
3032 * so let's drop the broken ones again
3033 */
3034 cfg->line_outs = spec->multiout.num_dacs;
3035 break;
3036 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02003037 /* error out, no available DAC found */
3038 snd_printk(KERN_ERR
3039 "%s: No available DAC for pin 0x%x\n",
3040 __func__, nid);
3041 return -ENODEV;
3042 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003043 add_spec_dacs(spec, dac);
3044 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02003045
Takashi Iwai139e0712009-03-06 12:10:41 +01003046 for (i = 0; i < cfg->hp_outs; i++) {
3047 nid = cfg->hp_pins[i];
3048 dac = get_unassigned_dac(codec, nid);
3049 if (dac) {
3050 if (!spec->multiout.hp_nid)
3051 spec->multiout.hp_nid = dac;
3052 else
3053 add_spec_extra_dacs(spec, dac);
3054 }
3055 spec->hp_dacs[i] = dac;
3056 }
3057
3058 for (i = 0; i < cfg->speaker_outs; i++) {
3059 nid = cfg->speaker_pins[i];
3060 dac = get_unassigned_dac(codec, nid);
3061 if (dac)
3062 add_spec_extra_dacs(spec, dac);
3063 spec->speaker_dacs[i] = dac;
3064 }
3065
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003066 /* add line-in as output */
3067 nid = check_line_out_switch(codec);
3068 if (nid) {
3069 dac = get_unassigned_dac(codec, nid);
3070 if (dac) {
3071 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
3072 nid, cfg->line_outs);
3073 cfg->line_out_pins[cfg->line_outs] = nid;
3074 cfg->line_outs++;
3075 spec->line_switch = nid;
3076 add_spec_dacs(spec, dac);
3077 }
3078 }
3079 /* add mic as output */
3080 nid = check_mic_out_switch(codec);
3081 if (nid) {
3082 dac = get_unassigned_dac(codec, nid);
3083 if (dac) {
3084 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
3085 nid, cfg->line_outs);
3086 cfg->line_out_pins[cfg->line_outs] = nid;
3087 cfg->line_outs++;
3088 spec->mic_switch = nid;
3089 add_spec_dacs(spec, dac);
Steve Longerbeam7b043892007-05-03 20:50:03 +02003090 }
Mattc7d4b2f2005-06-27 14:59:41 +02003091 }
3092
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003093 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
Steve Longerbeam7b043892007-05-03 20:50:03 +02003094 spec->multiout.num_dacs,
3095 spec->multiout.dac_nids[0],
3096 spec->multiout.dac_nids[1],
3097 spec->multiout.dac_nids[2],
3098 spec->multiout.dac_nids[3],
3099 spec->multiout.dac_nids[4]);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003100
Mattc7d4b2f2005-06-27 14:59:41 +02003101 return 0;
3102}
3103
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003104/* create volume control/switch for the given prefx type */
Takashi Iwai668b9652009-03-06 10:13:24 +01003105static int create_controls_idx(struct hda_codec *codec, const char *pfx,
3106 int idx, hda_nid_t nid, int chs)
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003107{
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003108 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003109 char name[32];
3110 int err;
3111
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003112 if (!spec->check_volume_offset) {
3113 unsigned int caps, step, nums, db_scale;
3114 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3115 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3116 AC_AMPCAP_STEP_SIZE_SHIFT;
3117 step = (step + 1) * 25; /* in .01dB unit */
3118 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3119 AC_AMPCAP_NUM_STEPS_SHIFT;
3120 db_scale = nums * step;
3121 /* if dB scale is over -64dB, and finer enough,
3122 * let's reduce it to half
3123 */
3124 if (db_scale > 6400 && nums >= 0x1f)
3125 spec->volume_offset = nums / 2;
3126 spec->check_volume_offset = 1;
3127 }
3128
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003129 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01003130 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003131 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3132 spec->volume_offset));
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003133 if (err < 0)
3134 return err;
3135 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01003136 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003137 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3138 if (err < 0)
3139 return err;
3140 return 0;
3141}
3142
Takashi Iwai668b9652009-03-06 10:13:24 +01003143#define create_controls(codec, pfx, nid, chs) \
3144 create_controls_idx(codec, pfx, 0, nid, chs)
3145
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003146static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3147{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003148 if (spec->multiout.num_dacs > 4) {
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003149 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3150 return 1;
3151 } else {
3152 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
3153 spec->multiout.num_dacs++;
3154 }
3155 return 0;
3156}
3157
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003158static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003159{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003160 int i;
3161 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3162 if (!spec->multiout.extra_out_nid[i]) {
3163 spec->multiout.extra_out_nid[i] = nid;
3164 return 0;
3165 }
3166 }
3167 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3168 return 1;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003169}
3170
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003171/* Create output controls
3172 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3173 */
3174static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3175 const hda_nid_t *pins,
3176 const hda_nid_t *dac_nids,
3177 int type)
Mattc7d4b2f2005-06-27 14:59:41 +02003178{
Takashi Iwai76624532008-12-19 10:09:47 +01003179 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003180 static const char *chname[4] = {
3181 "Front", "Surround", NULL /*CLFE*/, "Side"
3182 };
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003183 hda_nid_t nid;
Takashi Iwai91589232008-12-19 15:59:40 +01003184 int i, err;
3185 unsigned int wid_caps;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003186
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003187 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
Takashi Iwaiffd0e562009-04-16 12:20:24 +02003188 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
3189 wid_caps = get_wcaps(codec, pins[i]);
3190 if (wid_caps & AC_WCAP_UNSOL_CAP)
3191 spec->hp_detect = 1;
3192 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003193 nid = dac_nids[i];
3194 if (!nid)
3195 continue;
3196 if (type != AUTO_PIN_HP_OUT && i == 2) {
Mattc7d4b2f2005-06-27 14:59:41 +02003197 /* Center/LFE */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003198 err = create_controls(codec, "Center", nid, 1);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003199 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003200 return err;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003201 err = create_controls(codec, "LFE", nid, 2);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003202 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003203 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003204
3205 wid_caps = get_wcaps(codec, nid);
3206
3207 if (wid_caps & AC_WCAP_LR_SWAP) {
3208 err = stac92xx_add_control(spec,
3209 STAC_CTL_WIDGET_CLFE_SWITCH,
3210 "Swap Center/LFE Playback Switch", nid);
3211
3212 if (err < 0)
3213 return err;
3214 }
3215
Mattc7d4b2f2005-06-27 14:59:41 +02003216 } else {
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003217 const char *name;
Takashi Iwai668b9652009-03-06 10:13:24 +01003218 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003219 switch (type) {
3220 case AUTO_PIN_HP_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01003221 name = "Headphone";
3222 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003223 break;
3224 case AUTO_PIN_SPEAKER_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01003225 name = "Speaker";
3226 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003227 break;
3228 default:
3229 name = chname[i];
Takashi Iwai668b9652009-03-06 10:13:24 +01003230 idx = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003231 break;
Takashi Iwai76624532008-12-19 10:09:47 +01003232 }
Takashi Iwai668b9652009-03-06 10:13:24 +01003233 err = create_controls_idx(codec, name, idx, nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003234 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003235 return err;
3236 }
3237 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003238 return 0;
3239}
3240
3241/* add playback controls from the parsed DAC table */
3242static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3243 const struct auto_pin_cfg *cfg)
3244{
3245 struct sigmatel_spec *spec = codec->spec;
3246 int err;
3247
3248 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3249 spec->multiout.dac_nids,
3250 cfg->line_out_type);
3251 if (err < 0)
3252 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003253
Takashi Iwaia9cb5c92008-11-24 07:51:11 +01003254 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003255 err = stac92xx_add_control(spec,
3256 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01003257 "Headphone as Line Out Switch",
3258 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003259 if (err < 0)
3260 return err;
3261 }
3262
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003263 if (spec->line_switch) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003264 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
3265 "Line In as Output Switch",
3266 spec->line_switch << 8);
3267 if (err < 0)
3268 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003269 }
Matt Porter403d1942005-11-29 15:00:51 +01003270
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003271 if (spec->mic_switch) {
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02003272 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_DC_BIAS,
3273 "Mic Jack Mode",
3274 spec->mic_switch);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003275 if (err < 0)
3276 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003277 }
Matt Porter403d1942005-11-29 15:00:51 +01003278
Mattc7d4b2f2005-06-27 14:59:41 +02003279 return 0;
3280}
3281
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003282/* add playback controls for Speaker and HP outputs */
3283static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3284 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003285{
3286 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003287 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02003288
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003289 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3290 spec->hp_dacs, AUTO_PIN_HP_OUT);
3291 if (err < 0)
3292 return err;
3293
3294 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3295 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3296 if (err < 0)
3297 return err;
3298
Mattc7d4b2f2005-06-27 14:59:41 +02003299 return 0;
3300}
3301
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003302/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003303static const char *stac92xx_mono_labels[4] = {
3304 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003305};
3306
3307/* create mono mux for mono out on capable codecs */
3308static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3309{
3310 struct sigmatel_spec *spec = codec->spec;
3311 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3312 int i, num_cons;
3313 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3314
3315 num_cons = snd_hda_get_connections(codec,
3316 spec->mono_nid,
3317 con_lst,
3318 HDA_MAX_NUM_INPUTS);
3319 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3320 return -EINVAL;
3321
3322 for (i = 0; i < num_cons; i++) {
3323 mono_mux->items[mono_mux->num_items].label =
3324 stac92xx_mono_labels[i];
3325 mono_mux->items[mono_mux->num_items].index = i;
3326 mono_mux->num_items++;
3327 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003328
3329 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3330 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003331}
3332
Matthew Ranostay89385032008-09-11 09:49:39 -04003333/* labels for amp mux outputs */
3334static const char *stac92xx_amp_labels[3] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04003335 "Front Microphone", "Microphone", "Line In",
Matthew Ranostay89385032008-09-11 09:49:39 -04003336};
3337
3338/* create amp out controls mux on capable codecs */
3339static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3340{
3341 struct sigmatel_spec *spec = codec->spec;
3342 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3343 int i, err;
3344
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003345 for (i = 0; i < spec->num_amps; i++) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003346 amp_mux->items[amp_mux->num_items].label =
3347 stac92xx_amp_labels[i];
3348 amp_mux->items[amp_mux->num_items].index = i;
3349 amp_mux->num_items++;
3350 }
3351
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003352 if (spec->num_amps > 1) {
3353 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3354 "Amp Selector Capture Switch", 0);
3355 if (err < 0)
3356 return err;
3357 }
Matthew Ranostay89385032008-09-11 09:49:39 -04003358 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3359 "Amp Capture Volume",
3360 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3361}
3362
3363
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003364/* create PC beep volume controls */
3365static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3366 hda_nid_t nid)
3367{
3368 struct sigmatel_spec *spec = codec->spec;
3369 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3370 int err;
3371
3372 /* check for mute support for the the amp */
3373 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3374 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3375 "PC Beep Playback Switch",
3376 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3377 if (err < 0)
3378 return err;
3379 }
3380
3381 /* check to see if there is volume support for the amp */
3382 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3383 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3384 "PC Beep Playback Volume",
3385 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3386 if (err < 0)
3387 return err;
3388 }
3389 return 0;
3390}
3391
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003392#ifdef CONFIG_SND_HDA_INPUT_BEEP
3393#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3394
3395static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3396 struct snd_ctl_elem_value *ucontrol)
3397{
3398 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3399 ucontrol->value.integer.value[0] = codec->beep->enabled;
3400 return 0;
3401}
3402
3403static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3404 struct snd_ctl_elem_value *ucontrol)
3405{
3406 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3407 int enabled = !!ucontrol->value.integer.value[0];
3408 if (codec->beep->enabled != enabled) {
3409 codec->beep->enabled = enabled;
3410 return 1;
3411 }
3412 return 0;
3413}
3414
3415static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3416 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3417 .info = stac92xx_dig_beep_switch_info,
3418 .get = stac92xx_dig_beep_switch_get,
3419 .put = stac92xx_dig_beep_switch_put,
3420};
3421
3422static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3423{
3424 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3425 0, "PC Beep Playback Switch", 0);
3426}
3427#endif
3428
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003429static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3430{
3431 struct sigmatel_spec *spec = codec->spec;
3432 int wcaps, nid, i, err = 0;
3433
3434 for (i = 0; i < spec->num_muxes; i++) {
3435 nid = spec->mux_nids[i];
3436 wcaps = get_wcaps(codec, nid);
3437
3438 if (wcaps & AC_WCAP_OUT_AMP) {
3439 err = stac92xx_add_control_idx(spec,
3440 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3441 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3442 if (err < 0)
3443 return err;
3444 }
3445 }
3446 return 0;
3447};
3448
Matthew Ranostayd9737752008-09-07 12:03:41 +02003449static const char *stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003450 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003451};
3452
3453static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3454{
3455 struct sigmatel_spec *spec = codec->spec;
3456 struct hda_input_mux *spdif_mux = &spec->private_smux;
Matthew Ranostay65973632008-09-16 10:39:37 -04003457 const char **labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003458 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003459 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003460
3461 num_cons = snd_hda_get_connections(codec,
3462 spec->smux_nids[0],
3463 con_lst,
3464 HDA_MAX_NUM_INPUTS);
Matthew Ranostay65973632008-09-16 10:39:37 -04003465 if (!num_cons)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003466 return -EINVAL;
3467
Matthew Ranostay65973632008-09-16 10:39:37 -04003468 if (!labels)
3469 labels = stac92xx_spdif_labels;
3470
Matthew Ranostayd9737752008-09-07 12:03:41 +02003471 for (i = 0; i < num_cons; i++) {
Matthew Ranostay65973632008-09-16 10:39:37 -04003472 spdif_mux->items[spdif_mux->num_items].label = labels[i];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003473 spdif_mux->items[spdif_mux->num_items].index = i;
3474 spdif_mux->num_items++;
3475 }
3476
3477 return 0;
3478}
3479
Matt Porter8b657272006-10-26 17:12:59 +02003480/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003481static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003482 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3483 "Digital Mic 3", "Digital Mic 4"
3484};
3485
3486/* create playback/capture controls for input pins on dmic capable codecs */
3487static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3488 const struct auto_pin_cfg *cfg)
3489{
3490 struct sigmatel_spec *spec = codec->spec;
3491 struct hda_input_mux *dimux = &spec->private_dimux;
3492 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003493 int err, i, j;
3494 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02003495
3496 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3497 dimux->items[dimux->num_items].index = 0;
3498 dimux->num_items++;
3499
3500 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003501 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003502 int index;
3503 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003504 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02003505 unsigned int def_conf;
3506
Takashi Iwai330ee992009-02-20 14:33:36 +01003507 def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
Matt Porter8b657272006-10-26 17:12:59 +02003508 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3509 continue;
3510
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003511 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02003512 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003513 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02003514 con_lst,
3515 HDA_MAX_NUM_INPUTS);
3516 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003517 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02003518 index = j;
3519 goto found;
3520 }
3521 continue;
3522found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003523 wcaps = get_wcaps(codec, nid) &
3524 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003525
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003526 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003527 sprintf(name, "%s Capture Volume",
3528 stac92xx_dmic_labels[dimux->num_items]);
3529
3530 err = stac92xx_add_control(spec,
3531 STAC_CTL_WIDGET_VOL,
3532 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003533 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3534 (wcaps & AC_WCAP_OUT_AMP) ?
3535 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003536 if (err < 0)
3537 return err;
3538 }
3539
Matt Porter8b657272006-10-26 17:12:59 +02003540 dimux->items[dimux->num_items].label =
3541 stac92xx_dmic_labels[dimux->num_items];
3542 dimux->items[dimux->num_items].index = index;
3543 dimux->num_items++;
3544 }
3545
3546 return 0;
3547}
3548
Mattc7d4b2f2005-06-27 14:59:41 +02003549/* create playback/capture controls for input pins */
3550static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3551{
3552 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003553 struct hda_input_mux *imux = &spec->private_imux;
3554 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3555 int i, j, k;
3556
3557 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003558 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02003559
Takashi Iwai314634b2006-09-21 11:56:18 +02003560 if (!cfg->input_pins[i])
3561 continue;
3562 index = -1;
3563 for (j = 0; j < spec->num_muxes; j++) {
3564 int num_cons;
3565 num_cons = snd_hda_get_connections(codec,
3566 spec->mux_nids[j],
3567 con_lst,
3568 HDA_MAX_NUM_INPUTS);
3569 for (k = 0; k < num_cons; k++)
3570 if (con_lst[k] == cfg->input_pins[i]) {
3571 index = k;
3572 goto found;
3573 }
Mattc7d4b2f2005-06-27 14:59:41 +02003574 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003575 continue;
3576 found:
3577 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3578 imux->items[imux->num_items].index = index;
3579 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003580 }
3581
Steve Longerbeam7b043892007-05-03 20:50:03 +02003582 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003583 /*
3584 * Set the current input for the muxes.
3585 * The STAC9221 has two input muxes with identical source
3586 * NID lists. Hopefully this won't get confused.
3587 */
3588 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003589 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3590 AC_VERB_SET_CONNECT_SEL,
3591 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003592 }
3593 }
3594
Mattc7d4b2f2005-06-27 14:59:41 +02003595 return 0;
3596}
3597
Mattc7d4b2f2005-06-27 14:59:41 +02003598static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3599{
3600 struct sigmatel_spec *spec = codec->spec;
3601 int i;
3602
3603 for (i = 0; i < spec->autocfg.line_outs; i++) {
3604 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3605 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3606 }
3607}
3608
3609static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3610{
3611 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003612 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003613
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003614 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3615 hda_nid_t pin;
3616 pin = spec->autocfg.hp_pins[i];
3617 if (pin) /* connect to front */
3618 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3619 }
3620 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3621 hda_nid_t pin;
3622 pin = spec->autocfg.speaker_pins[i];
3623 if (pin) /* connect to front */
3624 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3625 }
Mattc7d4b2f2005-06-27 14:59:41 +02003626}
3627
Matt Porter3cc08dc2006-01-23 15:27:49 +01003628static 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 +02003629{
3630 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003631 int hp_swap = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003632 int err;
3633
Matt Porter8b657272006-10-26 17:12:59 +02003634 if ((err = snd_hda_parse_pin_def_config(codec,
3635 &spec->autocfg,
3636 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003637 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003638 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003639 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003640
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003641 /* If we have no real line-out pin and multiple hp-outs, HPs should
3642 * be set up as multi-channel outputs.
3643 */
3644 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3645 spec->autocfg.hp_outs > 1) {
3646 /* Copy hp_outs to line_outs, backup line_outs in
3647 * speaker_outs so that the following routines can handle
3648 * HP pins as primary outputs.
3649 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003650 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003651 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3652 sizeof(spec->autocfg.line_out_pins));
3653 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3654 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3655 sizeof(spec->autocfg.hp_pins));
3656 spec->autocfg.line_outs = spec->autocfg.hp_outs;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003657 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3658 spec->autocfg.hp_outs = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003659 hp_swap = 1;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003660 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003661 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003662 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3663 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003664 u32 caps = query_amp_caps(codec,
3665 spec->autocfg.mono_out_pin, dir);
3666 hda_nid_t conn_list[1];
3667
3668 /* get the mixer node and then the mono mux if it exists */
3669 if (snd_hda_get_connections(codec,
3670 spec->autocfg.mono_out_pin, conn_list, 1) &&
3671 snd_hda_get_connections(codec, conn_list[0],
3672 conn_list, 1)) {
3673
3674 int wcaps = get_wcaps(codec, conn_list[0]);
3675 int wid_type = (wcaps & AC_WCAP_TYPE)
3676 >> AC_WCAP_TYPE_SHIFT;
3677 /* LR swap check, some stac925x have a mux that
3678 * changes the DACs output path instead of the
3679 * mono-mux path.
3680 */
3681 if (wid_type == AC_WID_AUD_SEL &&
3682 !(wcaps & AC_WCAP_LR_SWAP))
3683 spec->mono_nid = conn_list[0];
3684 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003685 if (dir) {
3686 hda_nid_t nid = spec->autocfg.mono_out_pin;
3687
3688 /* most mono outs have a least a mute/unmute switch */
3689 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3690 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3691 "Mono Playback Switch",
3692 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003693 if (err < 0)
3694 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003695 /* check for volume support for the amp */
3696 if ((caps & AC_AMPCAP_NUM_STEPS)
3697 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3698 err = stac92xx_add_control(spec,
3699 STAC_CTL_WIDGET_VOL,
3700 "Mono Playback Volume",
3701 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3702 if (err < 0)
3703 return err;
3704 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003705 }
3706
3707 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3708 AC_PINCTL_OUT_EN);
3709 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003710
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003711 if (!spec->multiout.num_dacs) {
3712 err = stac92xx_auto_fill_dac_nids(codec);
3713 if (err < 0)
Takashi Iwai19039bd2006-06-28 15:52:16 +02003714 return err;
Takashi Iwaic9280d62009-01-15 17:31:00 +01003715 err = stac92xx_auto_create_multi_out_ctls(codec,
3716 &spec->autocfg);
3717 if (err < 0)
3718 return err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003719 }
Mattc7d4b2f2005-06-27 14:59:41 +02003720
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003721 /* setup analog beep controls */
3722 if (spec->anabeep_nid > 0) {
3723 err = stac92xx_auto_create_beep_ctls(codec,
3724 spec->anabeep_nid);
3725 if (err < 0)
3726 return err;
3727 }
3728
3729 /* setup digital beep controls and input device */
3730#ifdef CONFIG_SND_HDA_INPUT_BEEP
3731 if (spec->digbeep_nid > 0) {
3732 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003733 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003734
3735 err = stac92xx_auto_create_beep_ctls(codec, nid);
3736 if (err < 0)
3737 return err;
3738 err = snd_hda_attach_beep_device(codec, nid);
3739 if (err < 0)
3740 return err;
Takashi Iwaifa797962009-05-19 12:50:04 +02003741 /* IDT/STAC codecs have linear beep tone parameter */
3742 codec->beep->linear_tone = 1;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003743 /* if no beep switch is available, make its own one */
3744 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3745 if (codec->beep &&
3746 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3747 err = stac92xx_beep_switch_ctl(codec);
3748 if (err < 0)
3749 return err;
3750 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003751 }
3752#endif
3753
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003754 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003755 if (err < 0)
3756 return err;
3757
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003758 /* All output parsing done, now restore the swapped hp pins */
3759 if (hp_swap) {
3760 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3761 sizeof(spec->autocfg.hp_pins));
3762 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3763 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3764 spec->autocfg.line_outs = 0;
3765 }
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003766
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003767 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003768 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003769 return err;
3770
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003771 if (spec->mono_nid > 0) {
3772 err = stac92xx_auto_create_mono_output_ctls(codec);
3773 if (err < 0)
3774 return err;
3775 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003776 if (spec->num_amps > 0) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003777 err = stac92xx_auto_create_amp_output_ctls(codec);
3778 if (err < 0)
3779 return err;
3780 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003781 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003782 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3783 &spec->autocfg)) < 0)
3784 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003785 if (spec->num_muxes > 0) {
3786 err = stac92xx_auto_create_mux_input_ctls(codec);
3787 if (err < 0)
3788 return err;
3789 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003790 if (spec->num_smuxes > 0) {
3791 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3792 if (err < 0)
3793 return err;
3794 }
Matt Porter8b657272006-10-26 17:12:59 +02003795
Takashi Iwaie3c75962009-01-23 11:57:22 +01003796 err = stac92xx_add_input_source(spec);
3797 if (err < 0)
3798 return err;
3799
Mattc7d4b2f2005-06-27 14:59:41 +02003800 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003801 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003802 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003803
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003804 if (spec->autocfg.dig_outs)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003805 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003806 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003807 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003808
Takashi Iwai603c4012008-07-30 15:01:44 +02003809 if (spec->kctls.list)
3810 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003811
3812 spec->input_mux = &spec->private_imux;
Matthew Ranostayf8ccbf62008-12-20 17:36:28 -05003813 if (!spec->dinput_mux)
3814 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003815 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003816 spec->mono_mux = &spec->private_mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -04003817 spec->amp_mux = &spec->private_amp_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003818 return 1;
3819}
3820
Takashi Iwai82bc9552006-03-21 11:24:42 +01003821/* add playback controls for HP output */
3822static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3823 struct auto_pin_cfg *cfg)
3824{
3825 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003826 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003827 unsigned int wid_caps;
3828
3829 if (! pin)
3830 return 0;
3831
3832 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003833 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003834 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003835
3836 return 0;
3837}
3838
Richard Fish160ea0d2006-09-06 13:58:25 +02003839/* add playback controls for LFE output */
3840static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3841 struct auto_pin_cfg *cfg)
3842{
3843 struct sigmatel_spec *spec = codec->spec;
3844 int err;
3845 hda_nid_t lfe_pin = 0x0;
3846 int i;
3847
3848 /*
3849 * search speaker outs and line outs for a mono speaker pin
3850 * with an amp. If one is found, add LFE controls
3851 * for it.
3852 */
3853 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3854 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003855 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003856 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3857 if (wcaps == AC_WCAP_OUT_AMP)
3858 /* found a mono speaker with an amp, must be lfe */
3859 lfe_pin = pin;
3860 }
3861
3862 /* if speaker_outs is 0, then speakers may be in line_outs */
3863 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3864 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3865 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003866 unsigned int defcfg;
Takashi Iwai330ee992009-02-20 14:33:36 +01003867 defcfg = snd_hda_codec_get_pincfg(codec, pin);
Harvey Harrison8b551782008-02-29 11:56:48 +01003868 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003869 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003870 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3871 if (wcaps == AC_WCAP_OUT_AMP)
3872 /* found a mono speaker with an amp,
3873 must be lfe */
3874 lfe_pin = pin;
3875 }
3876 }
3877 }
3878
3879 if (lfe_pin) {
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003880 err = create_controls(codec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003881 if (err < 0)
3882 return err;
3883 }
3884
3885 return 0;
3886}
3887
Mattc7d4b2f2005-06-27 14:59:41 +02003888static int stac9200_parse_auto_config(struct hda_codec *codec)
3889{
3890 struct sigmatel_spec *spec = codec->spec;
3891 int err;
3892
Kailang Yangdf694da2005-12-05 19:42:22 +01003893 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003894 return err;
3895
3896 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3897 return err;
3898
Takashi Iwai82bc9552006-03-21 11:24:42 +01003899 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3900 return err;
3901
Richard Fish160ea0d2006-09-06 13:58:25 +02003902 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3903 return err;
3904
Takashi Iwai355a0ec2008-11-11 16:46:19 +01003905 if (spec->num_muxes > 0) {
3906 err = stac92xx_auto_create_mux_input_ctls(codec);
3907 if (err < 0)
3908 return err;
3909 }
3910
Takashi Iwaie3c75962009-01-23 11:57:22 +01003911 err = stac92xx_add_input_source(spec);
3912 if (err < 0)
3913 return err;
3914
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003915 if (spec->autocfg.dig_outs)
Mattc7d4b2f2005-06-27 14:59:41 +02003916 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003917 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003918 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003919
Takashi Iwai603c4012008-07-30 15:01:44 +02003920 if (spec->kctls.list)
3921 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003922
3923 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003924 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003925
3926 return 1;
3927}
3928
Sam Revitch62fe78e2006-05-10 15:09:17 +02003929/*
3930 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3931 * funky external mute control using GPIO pins.
3932 */
3933
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003934static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003935 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003936{
3937 unsigned int gpiostate, gpiomask, gpiodir;
3938
3939 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3940 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003941 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003942
3943 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3944 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003945 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003946
3947 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3948 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003949 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003950
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003951 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003952 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3953
3954 snd_hda_codec_write(codec, codec->afg, 0,
3955 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003956 snd_hda_codec_read(codec, codec->afg, 0,
3957 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003958
3959 msleep(1);
3960
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003961 snd_hda_codec_read(codec, codec->afg, 0,
3962 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003963}
3964
Takashi Iwai95c09092009-04-14 16:15:29 +02003965#ifdef CONFIG_SND_JACK
3966static void stac92xx_free_jack_priv(struct snd_jack *jack)
3967{
3968 struct sigmatel_jack *jacks = jack->private_data;
3969 jacks->nid = 0;
3970 jacks->jack = NULL;
3971}
3972#endif
3973
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003974static int stac92xx_add_jack(struct hda_codec *codec,
3975 hda_nid_t nid, int type)
3976{
Takashi Iwaie4973e12008-11-18 09:32:42 +01003977#ifdef CONFIG_SND_JACK
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003978 struct sigmatel_spec *spec = codec->spec;
3979 struct sigmatel_jack *jack;
Takashi Iwai330ee992009-02-20 14:33:36 +01003980 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003981 int connectivity = get_defcfg_connect(def_conf);
3982 char name[32];
Takashi Iwai95c09092009-04-14 16:15:29 +02003983 int err;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003984
3985 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
3986 return 0;
3987
3988 snd_array_init(&spec->jacks, sizeof(*jack), 32);
3989 jack = snd_array_new(&spec->jacks);
3990 if (!jack)
3991 return -ENOMEM;
3992 jack->nid = nid;
3993 jack->type = type;
3994
3995 sprintf(name, "%s at %s %s Jack",
3996 snd_hda_get_jack_type(def_conf),
3997 snd_hda_get_jack_connectivity(def_conf),
3998 snd_hda_get_jack_location(def_conf));
3999
Takashi Iwai95c09092009-04-14 16:15:29 +02004000 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
4001 if (err < 0) {
4002 jack->nid = 0;
4003 return err;
4004 }
4005 jack->jack->private_data = jack;
4006 jack->jack->private_free = stac92xx_free_jack_priv;
Takashi Iwaie4973e12008-11-18 09:32:42 +01004007#endif
Takashi Iwai95c09092009-04-14 16:15:29 +02004008 return 0;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004009}
4010
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004011static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
4012 unsigned char type, int data)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004013{
4014 struct sigmatel_event *event;
4015
4016 snd_array_init(&spec->events, sizeof(*event), 32);
4017 event = snd_array_new(&spec->events);
4018 if (!event)
4019 return -ENOMEM;
4020 event->nid = nid;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004021 event->type = type;
4022 event->tag = spec->events.used;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004023 event->data = data;
4024
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004025 return event->tag;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004026}
4027
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004028static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
4029 hda_nid_t nid, unsigned char type)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004030{
4031 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004032 struct sigmatel_event *event = spec->events.list;
4033 int i;
4034
4035 for (i = 0; i < spec->events.used; i++, event++) {
4036 if (event->nid == nid && event->type == type)
4037 return event;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004038 }
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004039 return NULL;
4040}
4041
4042static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
4043 unsigned char tag)
4044{
4045 struct sigmatel_spec *spec = codec->spec;
4046 struct sigmatel_event *event = spec->events.list;
4047 int i;
4048
4049 for (i = 0; i < spec->events.used; i++, event++) {
4050 if (event->tag == tag)
4051 return event;
4052 }
4053 return NULL;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004054}
4055
Takashi Iwai314634b2006-09-21 11:56:18 +02004056static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004057 unsigned int type)
Takashi Iwai314634b2006-09-21 11:56:18 +02004058{
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004059 struct sigmatel_event *event;
4060 int tag;
4061
4062 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
4063 return;
4064 event = stac_get_event(codec, nid, type);
4065 if (event)
4066 tag = event->tag;
4067 else
4068 tag = stac_add_event(codec->spec, nid, type, 0);
4069 if (tag < 0)
4070 return;
4071 snd_hda_codec_write_cache(codec, nid, 0,
4072 AC_VERB_SET_UNSOLICITED_ENABLE,
4073 AC_USRSP_EN | tag);
Takashi Iwai314634b2006-09-21 11:56:18 +02004074}
4075
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004076static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
4077{
4078 int i;
4079 for (i = 0; i < cfg->hp_outs; i++)
4080 if (cfg->hp_pins[i] == nid)
4081 return 1; /* nid is a HP-Out */
4082
4083 return 0; /* nid is not a HP-Out */
4084};
4085
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004086static void stac92xx_power_down(struct hda_codec *codec)
4087{
4088 struct sigmatel_spec *spec = codec->spec;
4089
4090 /* power down inactive DACs */
4091 hda_nid_t *dac;
4092 for (dac = spec->dac_list; *dac; dac++)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004093 if (!check_all_dac_nids(spec, *dac))
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004094 snd_hda_codec_write(codec, *dac, 0,
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004095 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4096}
4097
Takashi Iwaif73d3582008-11-25 08:21:51 +01004098static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4099 int enable);
4100
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004101/* override some hints from the hwdep entry */
4102static void stac_store_hints(struct hda_codec *codec)
4103{
4104 struct sigmatel_spec *spec = codec->spec;
4105 const char *p;
4106 int val;
4107
4108 val = snd_hda_get_bool_hint(codec, "hp_detect");
4109 if (val >= 0)
4110 spec->hp_detect = val;
4111 p = snd_hda_get_hint(codec, "gpio_mask");
4112 if (p) {
4113 spec->gpio_mask = simple_strtoul(p, NULL, 0);
4114 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
4115 spec->gpio_mask;
4116 }
4117 p = snd_hda_get_hint(codec, "gpio_dir");
4118 if (p)
4119 spec->gpio_dir = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4120 p = snd_hda_get_hint(codec, "gpio_data");
4121 if (p)
4122 spec->gpio_data = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4123 p = snd_hda_get_hint(codec, "eapd_mask");
4124 if (p)
4125 spec->eapd_mask = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4126 val = snd_hda_get_bool_hint(codec, "eapd_switch");
4127 if (val >= 0)
4128 spec->eapd_switch = val;
4129}
4130
Mattc7d4b2f2005-06-27 14:59:41 +02004131static int stac92xx_init(struct hda_codec *codec)
4132{
4133 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004134 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004135 unsigned int gpio;
Takashi Iwaie4973e12008-11-18 09:32:42 +01004136 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02004137
Mattc7d4b2f2005-06-27 14:59:41 +02004138 snd_hda_sequence_write(codec, spec->init);
4139
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004140 /* power down adcs initially */
4141 if (spec->powerdown_adcs)
4142 for (i = 0; i < spec->num_adcs; i++)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004143 snd_hda_codec_write(codec,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004144 spec->adc_nids[i], 0,
4145 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004146
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004147 /* override some hints */
4148 stac_store_hints(codec);
4149
Takashi Iwaif73d3582008-11-25 08:21:51 +01004150 /* set up GPIO */
4151 gpio = spec->gpio_data;
4152 /* turn on EAPD statically when spec->eapd_switch isn't set.
4153 * otherwise, unsol event will turn it on/off dynamically
4154 */
4155 if (!spec->eapd_switch)
4156 gpio |= spec->eapd_mask;
4157 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4158
Takashi Iwai82bc9552006-03-21 11:24:42 +01004159 /* set up pins */
4160 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02004161 /* Enable unsolicited responses on the HP widget */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004162 for (i = 0; i < cfg->hp_outs; i++) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004163 hda_nid_t nid = cfg->hp_pins[i];
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004164 enable_pin_detect(codec, nid, STAC_HP_EVENT);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004165 }
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01004166 /* force to enable the first line-out; the others are set up
4167 * in unsol_event
4168 */
4169 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004170 AC_PINCTL_OUT_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004171 /* fake event to set up pins */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004172 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4173 STAC_HP_EVENT);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004174 } else {
4175 stac92xx_auto_init_multi_out(codec);
4176 stac92xx_auto_init_hp_out(codec);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004177 for (i = 0; i < cfg->hp_outs; i++)
4178 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004179 }
4180 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01004181 hda_nid_t nid = cfg->input_pins[i];
4182 if (nid) {
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004183 unsigned int pinctl, conf;
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004184 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
4185 /* for mic pins, force to initialize */
4186 pinctl = stac92xx_get_vref(codec, nid);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004187 pinctl |= AC_PINCTL_IN_EN;
4188 stac92xx_auto_set_pinctl(codec, nid, pinctl);
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004189 } else {
4190 pinctl = snd_hda_codec_read(codec, nid, 0,
4191 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4192 /* if PINCTL already set then skip */
Takashi Iwai5dd17cb2009-05-07 16:22:53 +02004193 /* Also, if both INPUT and OUTPUT are set,
4194 * it must be a BIOS bug; need to override, too
4195 */
4196 if (!(pinctl & AC_PINCTL_IN_EN) ||
4197 (pinctl & AC_PINCTL_OUT_EN)) {
4198 pinctl &= ~AC_PINCTL_OUT_EN;
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004199 pinctl |= AC_PINCTL_IN_EN;
4200 stac92xx_auto_set_pinctl(codec, nid,
4201 pinctl);
4202 }
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004203 }
Takashi Iwai330ee992009-02-20 14:33:36 +01004204 conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004205 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4206 enable_pin_detect(codec, nid,
4207 STAC_INSERT_EVENT);
4208 stac_issue_unsol_event(codec, nid,
4209 STAC_INSERT_EVENT);
4210 }
Takashi Iwaic960a032006-03-23 17:06:28 +01004211 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01004212 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004213 for (i = 0; i < spec->num_dmics; i++)
4214 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4215 AC_PINCTL_IN_EN);
Takashi Iwai0852d7a2009-02-11 11:35:15 +01004216 if (cfg->dig_out_pins[0])
4217 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
Takashi Iwai82bc9552006-03-21 11:24:42 +01004218 AC_PINCTL_OUT_EN);
4219 if (cfg->dig_in_pin)
4220 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4221 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004222 for (i = 0; i < spec->num_pwrs; i++) {
4223 hda_nid_t nid = spec->pwr_nids[i];
4224 int pinctl, def_conf;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004225
Takashi Iwaieb632122008-12-19 16:39:48 +01004226 /* power on when no jack detection is available */
4227 if (!spec->hp_detect) {
4228 stac_toggle_power_map(codec, nid, 1);
4229 continue;
4230 }
4231
4232 if (is_nid_hp_pin(cfg, nid))
Takashi Iwaif73d3582008-11-25 08:21:51 +01004233 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004234
Takashi Iwaif73d3582008-11-25 08:21:51 +01004235 pinctl = snd_hda_codec_read(codec, nid, 0,
4236 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4237 /* outputs are only ports capable of power management
4238 * any attempts on powering down a input port cause the
4239 * referenced VREF to act quirky.
4240 */
Takashi Iwaieb632122008-12-19 16:39:48 +01004241 if (pinctl & AC_PINCTL_IN_EN) {
4242 stac_toggle_power_map(codec, nid, 1);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004243 continue;
Takashi Iwaieb632122008-12-19 16:39:48 +01004244 }
Takashi Iwai330ee992009-02-20 14:33:36 +01004245 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004246 def_conf = get_defcfg_connect(def_conf);
4247 /* skip any ports that don't have jacks since presence
4248 * detection is useless */
4249 if (def_conf != AC_JACK_PORT_COMPLEX) {
4250 if (def_conf != AC_JACK_PORT_NONE)
4251 stac_toggle_power_map(codec, nid, 1);
4252 continue;
4253 }
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004254 if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) {
4255 enable_pin_detect(codec, nid, STAC_PWR_EVENT);
4256 stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT);
4257 }
Takashi Iwaif73d3582008-11-25 08:21:51 +01004258 }
4259 if (spec->dac_list)
4260 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02004261 return 0;
4262}
4263
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004264static void stac92xx_free_jacks(struct hda_codec *codec)
4265{
Takashi Iwaie4973e12008-11-18 09:32:42 +01004266#ifdef CONFIG_SND_JACK
Takashi Iwaib94d35392008-11-21 09:08:06 +01004267 /* free jack instances manually when clearing/reconfiguring */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004268 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaib94d35392008-11-21 09:08:06 +01004269 if (!codec->bus->shutdown && spec->jacks.list) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004270 struct sigmatel_jack *jacks = spec->jacks.list;
4271 int i;
Takashi Iwai95c09092009-04-14 16:15:29 +02004272 for (i = 0; i < spec->jacks.used; i++, jacks++) {
4273 if (jacks->jack)
4274 snd_device_free(codec->bus->card, jacks->jack);
4275 }
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004276 }
4277 snd_array_free(&spec->jacks);
Takashi Iwaie4973e12008-11-18 09:32:42 +01004278#endif
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004279}
4280
Takashi Iwai603c4012008-07-30 15:01:44 +02004281static void stac92xx_free_kctls(struct hda_codec *codec)
4282{
4283 struct sigmatel_spec *spec = codec->spec;
4284
4285 if (spec->kctls.list) {
4286 struct snd_kcontrol_new *kctl = spec->kctls.list;
4287 int i;
4288 for (i = 0; i < spec->kctls.used; i++)
4289 kfree(kctl[i].name);
4290 }
4291 snd_array_free(&spec->kctls);
4292}
4293
Matt2f2f4252005-04-13 14:45:30 +02004294static void stac92xx_free(struct hda_codec *codec)
4295{
Mattc7d4b2f2005-06-27 14:59:41 +02004296 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004297
4298 if (! spec)
4299 return;
4300
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004301 stac92xx_free_jacks(codec);
4302 snd_array_free(&spec->events);
Richard Fish11b44bb2006-08-23 18:31:34 +02004303
Mattc7d4b2f2005-06-27 14:59:41 +02004304 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004305 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02004306}
4307
Matt4e550962005-07-04 17:51:39 +02004308static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4309 unsigned int flag)
4310{
Takashi Iwai8ce84192009-01-22 16:59:20 +01004311 unsigned int old_ctl, pin_ctl;
4312
4313 pin_ctl = snd_hda_codec_read(codec, nid,
Matt4e550962005-07-04 17:51:39 +02004314 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02004315
Takashi Iwaif9acba42007-05-29 18:01:06 +02004316 if (pin_ctl & AC_PINCTL_IN_EN) {
4317 /*
4318 * we need to check the current set-up direction of
4319 * shared input pins since they can be switched via
4320 * "xxx as Output" mixer switch
4321 */
4322 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004323 if (nid == spec->line_switch || nid == spec->mic_switch)
Takashi Iwaif9acba42007-05-29 18:01:06 +02004324 return;
4325 }
4326
Takashi Iwai8ce84192009-01-22 16:59:20 +01004327 old_ctl = pin_ctl;
Steve Longerbeam7b043892007-05-03 20:50:03 +02004328 /* if setting pin direction bits, clear the current
4329 direction bits first */
4330 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4331 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4332
Takashi Iwai8ce84192009-01-22 16:59:20 +01004333 pin_ctl |= flag;
4334 if (old_ctl != pin_ctl)
4335 snd_hda_codec_write_cache(codec, nid, 0,
4336 AC_VERB_SET_PIN_WIDGET_CONTROL,
4337 pin_ctl);
Matt4e550962005-07-04 17:51:39 +02004338}
4339
4340static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4341 unsigned int flag)
4342{
4343 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4344 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai8ce84192009-01-22 16:59:20 +01004345 if (pin_ctl & flag)
4346 snd_hda_codec_write_cache(codec, nid, 0,
4347 AC_VERB_SET_PIN_WIDGET_CONTROL,
4348 pin_ctl & ~flag);
Matt4e550962005-07-04 17:51:39 +02004349}
4350
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004351static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02004352{
4353 if (!nid)
4354 return 0;
4355 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004356 & (1 << 31))
4357 return 1;
Takashi Iwai314634b2006-09-21 11:56:18 +02004358 return 0;
4359}
4360
Takashi Iwaid7a89432008-11-12 09:48:04 +01004361/* return non-zero if the hp-pin of the given array index isn't
4362 * a jack-detection target
4363 */
4364static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4365{
4366 struct auto_pin_cfg *cfg = &spec->autocfg;
4367
4368 /* ignore sensing of shared line and mic jacks */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004369 if (cfg->hp_pins[i] == spec->line_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004370 return 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004371 if (cfg->hp_pins[i] == spec->mic_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004372 return 1;
4373 /* ignore if the pin is set as line-out */
4374 if (cfg->hp_pins[i] == spec->hp_switch)
4375 return 1;
4376 return 0;
4377}
4378
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004379static void stac92xx_hp_detect(struct hda_codec *codec)
Matt4e550962005-07-04 17:51:39 +02004380{
4381 struct sigmatel_spec *spec = codec->spec;
4382 struct auto_pin_cfg *cfg = &spec->autocfg;
4383 int i, presence;
4384
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004385 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004386 if (spec->gpio_mute)
4387 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4388 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4389
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004390 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004391 if (presence)
4392 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01004393 if (no_hp_sensing(spec, i))
4394 continue;
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004395 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4396 if (presence) {
4397 unsigned int pinctl;
4398 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4399 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4400 if (pinctl & AC_PINCTL_IN_EN)
4401 presence = 0; /* mic- or line-input */
4402 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004403 }
Matt4e550962005-07-04 17:51:39 +02004404
4405 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004406 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004407 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004408 stac92xx_reset_pinctl(codec, spec->hp_switch,
4409 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004410 for (i = 0; i < cfg->line_outs; i++)
4411 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4412 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004413 for (i = 0; i < cfg->speaker_outs; i++)
4414 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4415 AC_PINCTL_OUT_EN);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004416 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004417 stac_gpio_set(codec, spec->gpio_mask,
4418 spec->gpio_dir, spec->gpio_data &
4419 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02004420 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004421 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004422 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004423 stac92xx_set_pinctl(codec, spec->hp_switch,
4424 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004425 for (i = 0; i < cfg->line_outs; i++)
4426 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4427 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004428 for (i = 0; i < cfg->speaker_outs; i++)
4429 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4430 AC_PINCTL_OUT_EN);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004431 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004432 stac_gpio_set(codec, spec->gpio_mask,
4433 spec->gpio_dir, spec->gpio_data |
4434 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02004435 }
Takashi Iwaid7a89432008-11-12 09:48:04 +01004436 /* toggle hp outs */
4437 for (i = 0; i < cfg->hp_outs; i++) {
4438 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4439 if (no_hp_sensing(spec, i))
4440 continue;
4441 if (presence)
4442 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004443#if 0 /* FIXME */
4444/* Resetting the pinctl like below may lead to (a sort of) regressions
4445 * on some devices since they use the HP pin actually for line/speaker
4446 * outs although the default pin config shows a different pin (that is
4447 * wrong and useless).
4448 *
4449 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4450 * But, disabling the code below just works around it, and I'm too tired of
4451 * bug reports with such devices...
4452 */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004453 else
4454 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004455#endif /* FIXME */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004456 }
Matt4e550962005-07-04 17:51:39 +02004457}
4458
Takashi Iwaif73d3582008-11-25 08:21:51 +01004459static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4460 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004461{
4462 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004463 unsigned int idx, val;
4464
4465 for (idx = 0; idx < spec->num_pwrs; idx++) {
4466 if (spec->pwr_nids[idx] == nid)
4467 break;
4468 }
4469 if (idx >= spec->num_pwrs)
4470 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004471
4472 /* several codecs have two power down bits */
4473 if (spec->pwr_mapping)
4474 idx = spec->pwr_mapping[idx];
4475 else
4476 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004477
Takashi Iwaif73d3582008-11-25 08:21:51 +01004478 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4479 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004480 val &= ~idx;
4481 else
4482 val |= idx;
4483
4484 /* power down unused output ports */
4485 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004486}
4487
Takashi Iwaif73d3582008-11-25 08:21:51 +01004488static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4489{
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004490 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
Takashi Iwaif73d3582008-11-25 08:21:51 +01004491}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004492
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004493static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4494{
4495 struct sigmatel_spec *spec = codec->spec;
4496 struct sigmatel_jack *jacks = spec->jacks.list;
4497
4498 if (jacks) {
4499 int i;
4500 for (i = 0; i < spec->jacks.used; i++) {
4501 if (jacks->nid == nid) {
4502 unsigned int pin_ctl =
4503 snd_hda_codec_read(codec, nid,
4504 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4505 0x00);
4506 int type = jacks->type;
4507 if (type == (SND_JACK_LINEOUT
4508 | SND_JACK_HEADPHONE))
4509 type = (pin_ctl & AC_PINCTL_HP_EN)
4510 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4511 snd_jack_report(jacks->jack,
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004512 get_pin_presence(codec, nid)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004513 ? type : 0);
4514 }
4515 jacks++;
4516 }
4517 }
4518}
Matt2f2f4252005-04-13 14:45:30 +02004519
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004520static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
4521 unsigned char type)
4522{
4523 struct sigmatel_event *event = stac_get_event(codec, nid, type);
4524 if (!event)
4525 return;
4526 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4527}
4528
Takashi Iwai314634b2006-09-21 11:56:18 +02004529static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4530{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004531 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004532 struct sigmatel_event *event;
4533 int tag, data;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004534
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004535 tag = (res >> 26) & 0x7f;
4536 event = stac_get_event_from_tag(codec, tag);
4537 if (!event)
4538 return;
4539
4540 switch (event->type) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004541 case STAC_HP_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004542 stac92xx_hp_detect(codec);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004543 /* fallthru */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004544 case STAC_INSERT_EVENT:
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004545 case STAC_PWR_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004546 if (spec->num_pwrs > 0)
4547 stac92xx_pin_sense(codec, event->nid);
4548 stac92xx_report_jack(codec, event->nid);
Matthew Ranostayfd60cc82009-04-06 09:30:46 -04004549
4550 switch (codec->subsystem_id) {
4551 case 0x103c308f:
4552 if (event->nid == 0xb) {
4553 int pin = AC_PINCTL_IN_EN;
4554
4555 if (get_pin_presence(codec, 0xa)
4556 && get_pin_presence(codec, 0xb))
4557 pin |= AC_PINCTL_VREF_80;
4558 if (!get_pin_presence(codec, 0xb))
4559 pin |= AC_PINCTL_VREF_80;
4560
4561 /* toggle VREF state based on mic + hp pin
4562 * status
4563 */
4564 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
4565 }
4566 }
Matthew Ranostay72474be2008-10-09 09:32:17 -04004567 break;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004568 case STAC_VREF_EVENT:
4569 data = snd_hda_codec_read(codec, codec->afg, 0,
4570 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004571 /* toggle VREF state based on GPIOx status */
4572 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004573 !!(data & (1 << event->data)));
Matthew Ranostay72474be2008-10-09 09:32:17 -04004574 break;
Takashi Iwai314634b2006-09-21 11:56:18 +02004575 }
4576}
4577
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004578#ifdef CONFIG_PROC_FS
4579static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4580 struct hda_codec *codec, hda_nid_t nid)
4581{
4582 if (nid == codec->afg)
4583 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4584 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4585}
4586
4587static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4588 struct hda_codec *codec,
4589 unsigned int verb)
4590{
4591 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4592 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4593}
4594
4595/* stac92hd71bxx, stac92hd73xx */
4596static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4597 struct hda_codec *codec, hda_nid_t nid)
4598{
4599 stac92hd_proc_hook(buffer, codec, nid);
4600 if (nid == codec->afg)
4601 analog_loop_proc_hook(buffer, codec, 0xfa0);
4602}
4603
4604static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4605 struct hda_codec *codec, hda_nid_t nid)
4606{
4607 if (nid == codec->afg)
4608 analog_loop_proc_hook(buffer, codec, 0xfe0);
4609}
4610
4611static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4612 struct hda_codec *codec, hda_nid_t nid)
4613{
4614 if (nid == codec->afg)
4615 analog_loop_proc_hook(buffer, codec, 0xfeb);
4616}
4617#else
4618#define stac92hd_proc_hook NULL
4619#define stac92hd7x_proc_hook NULL
4620#define stac9205_proc_hook NULL
4621#define stac927x_proc_hook NULL
4622#endif
4623
Takashi Iwaicb53c622007-08-10 17:21:45 +02004624#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004625static int stac92xx_resume(struct hda_codec *codec)
4626{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004627 struct sigmatel_spec *spec = codec->spec;
4628
Takashi Iwai2c885872008-11-18 09:36:55 +01004629 stac92xx_init(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004630 snd_hda_codec_resume_amp(codec);
4631 snd_hda_codec_resume_cache(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01004632 /* fake event to set up pins again to override cached values */
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004633 if (spec->hp_detect)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004634 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4635 STAC_HP_EVENT);
Mattff6fdc32005-06-27 15:06:52 +02004636 return 0;
4637}
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004638
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004639/*
James Gardiner514bf542009-05-03 04:00:44 -04004640 * using power check for controlling mute led of HP notebooks
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004641 * check for mute state only on Speakers (nid = 0x10)
4642 *
4643 * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise
4644 * the LED is NOT working properly !
James Gardiner514bf542009-05-03 04:00:44 -04004645 *
4646 * Changed name to reflect that it now works for any designated
4647 * model, not just HP HDX.
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004648 */
4649
4650#ifdef CONFIG_SND_HDA_POWER_SAVE
James Gardiner514bf542009-05-03 04:00:44 -04004651static int stac92xx_hp_check_power_status(struct hda_codec *codec,
Takashi Iwai6fce61a2009-03-10 07:48:57 +01004652 hda_nid_t nid)
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004653{
4654 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai6fce61a2009-03-10 07:48:57 +01004655
4656 if (nid == 0x10) {
4657 if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004658 HDA_AMP_MUTE)
Takashi Iwai86d190e2009-05-26 15:18:58 +02004659 spec->gpio_data |= spec->gpio_led; /* white */
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004660 else
Takashi Iwai86d190e2009-05-26 15:18:58 +02004661 spec->gpio_data &= ~spec->gpio_led; /* orange */
Takashi Iwai6fce61a2009-03-10 07:48:57 +01004662
4663 stac_gpio_set(codec, spec->gpio_mask,
4664 spec->gpio_dir,
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004665 spec->gpio_data);
4666 }
4667
4668 return 0;
4669}
4670#endif
4671
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004672static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4673{
4674 struct sigmatel_spec *spec = codec->spec;
4675 if (spec->eapd_mask)
4676 stac_gpio_set(codec, spec->gpio_mask,
4677 spec->gpio_dir, spec->gpio_data &
4678 ~spec->eapd_mask);
4679 return 0;
4680}
Mattff6fdc32005-06-27 15:06:52 +02004681#endif
4682
Matt2f2f4252005-04-13 14:45:30 +02004683static struct hda_codec_ops stac92xx_patch_ops = {
4684 .build_controls = stac92xx_build_controls,
4685 .build_pcms = stac92xx_build_pcms,
4686 .init = stac92xx_init,
4687 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02004688 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004689#ifdef SND_HDA_NEEDS_RESUME
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004690 .suspend = stac92xx_suspend,
Mattff6fdc32005-06-27 15:06:52 +02004691 .resume = stac92xx_resume,
4692#endif
Matt2f2f4252005-04-13 14:45:30 +02004693};
4694
4695static int patch_stac9200(struct hda_codec *codec)
4696{
4697 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004698 int err;
Matt2f2f4252005-04-13 14:45:30 +02004699
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004700 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004701 if (spec == NULL)
4702 return -ENOMEM;
4703
4704 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004705 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004706 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004707 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4708 stac9200_models,
4709 stac9200_cfg_tbl);
Takashi Iwai330ee992009-02-20 14:33:36 +01004710 if (spec->board_config < 0)
Richard Fish11b44bb2006-08-23 18:31:34 +02004711 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01004712 else
4713 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004714 stac9200_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02004715
4716 spec->multiout.max_channels = 2;
4717 spec->multiout.num_dacs = 1;
4718 spec->multiout.dac_nids = stac9200_dac_nids;
4719 spec->adc_nids = stac9200_adc_nids;
4720 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02004721 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02004722 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004723 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004724 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004725
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02004726 if (spec->board_config == STAC_9200_M4 ||
4727 spec->board_config == STAC_9200_M4_2 ||
Tobin Davisbf277782008-02-03 20:31:47 +01004728 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02004729 spec->init = stac9200_eapd_init;
4730 else
4731 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004732 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004733
Takashi Iwai117f2572008-03-18 09:53:23 +01004734 if (spec->board_config == STAC_9200_PANASONIC) {
4735 spec->gpio_mask = spec->gpio_dir = 0x09;
4736 spec->gpio_data = 0x00;
4737 }
4738
Mattc7d4b2f2005-06-27 14:59:41 +02004739 err = stac9200_parse_auto_config(codec);
4740 if (err < 0) {
4741 stac92xx_free(codec);
4742 return err;
4743 }
Matt2f2f4252005-04-13 14:45:30 +02004744
Takashi Iwai2acc9dc2009-01-09 16:57:14 +01004745 /* CF-74 has no headphone detection, and the driver should *NOT*
4746 * do detection and HP/speaker toggle because the hardware does it.
4747 */
4748 if (spec->board_config == STAC_9200_PANASONIC)
4749 spec->hp_detect = 0;
4750
Matt2f2f4252005-04-13 14:45:30 +02004751 codec->patch_ops = stac92xx_patch_ops;
4752
4753 return 0;
4754}
4755
Tobin Davis8e21c342007-01-08 11:04:17 +01004756static int patch_stac925x(struct hda_codec *codec)
4757{
4758 struct sigmatel_spec *spec;
4759 int err;
4760
4761 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4762 if (spec == NULL)
4763 return -ENOMEM;
4764
4765 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004766 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01004767 spec->pin_nids = stac925x_pin_nids;
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02004768
4769 /* Check first for codec ID */
4770 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
4771 STAC_925x_MODELS,
4772 stac925x_models,
4773 stac925x_codec_id_cfg_tbl);
4774
4775 /* Now checks for PCI ID, if codec ID is not found */
4776 if (spec->board_config < 0)
4777 spec->board_config = snd_hda_check_board_config(codec,
4778 STAC_925x_MODELS,
Tobin Davis8e21c342007-01-08 11:04:17 +01004779 stac925x_models,
4780 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004781 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01004782 if (spec->board_config < 0)
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02004783 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
Tobin Davis2c11f952007-05-17 09:36:34 +02004784 "using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01004785 else
4786 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004787 stac925x_brd_tbl[spec->board_config]);
Tobin Davis8e21c342007-01-08 11:04:17 +01004788
4789 spec->multiout.max_channels = 2;
4790 spec->multiout.num_dacs = 1;
4791 spec->multiout.dac_nids = stac925x_dac_nids;
4792 spec->adc_nids = stac925x_adc_nids;
4793 spec->mux_nids = stac925x_mux_nids;
4794 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004795 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004796 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02004797 switch (codec->vendor_id) {
4798 case 0x83847632: /* STAC9202 */
4799 case 0x83847633: /* STAC9202D */
4800 case 0x83847636: /* STAC9251 */
4801 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02004802 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02004803 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004804 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4805 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02004806 break;
4807 default:
4808 spec->num_dmics = 0;
4809 break;
4810 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004811
4812 spec->init = stac925x_core_init;
4813 spec->mixer = stac925x_mixer;
4814
4815 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004816 if (!err) {
4817 if (spec->board_config < 0) {
4818 printk(KERN_WARNING "hda_codec: No auto-config is "
4819 "available, default to model=ref\n");
4820 spec->board_config = STAC_925x_REF;
4821 goto again;
4822 }
4823 err = -EINVAL;
4824 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004825 if (err < 0) {
4826 stac92xx_free(codec);
4827 return err;
4828 }
4829
4830 codec->patch_ops = stac92xx_patch_ops;
4831
4832 return 0;
4833}
4834
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004835static struct hda_input_mux stac92hd73xx_dmux = {
4836 .num_items = 4,
4837 .items = {
4838 { "Analog Inputs", 0x0b },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004839 { "Digital Mic 1", 0x09 },
4840 { "Digital Mic 2", 0x0a },
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004841 { "CD", 0x08 },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004842 }
4843};
4844
4845static int patch_stac92hd73xx(struct hda_codec *codec)
4846{
4847 struct sigmatel_spec *spec;
4848 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4849 int err = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004850 int num_dacs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004851
4852 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4853 if (spec == NULL)
4854 return -ENOMEM;
4855
4856 codec->spec = spec;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02004857 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004858 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4859 spec->pin_nids = stac92hd73xx_pin_nids;
4860 spec->board_config = snd_hda_check_board_config(codec,
4861 STAC_92HD73XX_MODELS,
4862 stac92hd73xx_models,
4863 stac92hd73xx_cfg_tbl);
4864again:
Takashi Iwai330ee992009-02-20 14:33:36 +01004865 if (spec->board_config < 0)
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004866 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4867 " STAC92HD73XX, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01004868 else
4869 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004870 stac92hd73xx_brd_tbl[spec->board_config]);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004871
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004872 num_dacs = snd_hda_get_connections(codec, 0x0a,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004873 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4874
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004875 if (num_dacs < 3 || num_dacs > 5) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004876 printk(KERN_WARNING "hda_codec: Could not determine "
4877 "number of channels defaulting to DAC count\n");
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004878 num_dacs = STAC92HD73_DAC_COUNT;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004879 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004880 switch (num_dacs) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004881 case 0x3: /* 6 Channel */
4882 spec->mixer = stac92hd73xx_6ch_mixer;
4883 spec->init = stac92hd73xx_6ch_core_init;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01004884 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004885 break;
4886 case 0x4: /* 8 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004887 spec->mixer = stac92hd73xx_8ch_mixer;
4888 spec->init = stac92hd73xx_8ch_core_init;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01004889 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004890 break;
4891 case 0x5: /* 10 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004892 spec->mixer = stac92hd73xx_10ch_mixer;
4893 spec->init = stac92hd73xx_10ch_core_init;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01004894 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
4895 break;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004896 }
4897 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004898
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004899 spec->aloopback_mask = 0x01;
4900 spec->aloopback_shift = 8;
4901
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004902 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004903 spec->mux_nids = stac92hd73xx_mux_nids;
4904 spec->adc_nids = stac92hd73xx_adc_nids;
4905 spec->dmic_nids = stac92hd73xx_dmic_nids;
4906 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004907 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostay89385032008-09-11 09:49:39 -04004908 spec->amp_nids = stac92hd73xx_amp_nids;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004909 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004910
4911 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4912 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01004913 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004914 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4915 sizeof(stac92hd73xx_dmux));
4916
Matthew Ranostaya7662642008-02-21 07:51:14 +01004917 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004918 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004919 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004920 /* fallthru */
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004921 case STAC_DELL_M6_AMIC:
4922 case STAC_DELL_M6_DMIC:
4923 case STAC_DELL_M6_BOTH:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004924 spec->num_smuxes = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004925 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4926 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004927 spec->eapd_switch = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004928 spec->num_amps = 1;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004929
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004930 if (spec->board_config != STAC_DELL_EQ)
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004931 spec->init = dell_m6_core_init;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004932 switch (spec->board_config) {
4933 case STAC_DELL_M6_AMIC: /* Analog Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01004934 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
Matthew Ranostaya7662642008-02-21 07:51:14 +01004935 spec->num_dmics = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004936 spec->private_dimux.num_items = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004937 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004938 case STAC_DELL_M6_DMIC: /* Digital Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01004939 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01004940 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004941 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004942 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004943 case STAC_DELL_M6_BOTH: /* Both */
Takashi Iwai330ee992009-02-20 14:33:36 +01004944 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
4945 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01004946 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004947 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004948 break;
4949 }
4950 break;
4951 default:
4952 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004953 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004954 spec->eapd_switch = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004955 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004956 if (spec->board_config > STAC_92HD73XX_REF) {
4957 /* GPIO0 High = Enable EAPD */
4958 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4959 spec->gpio_data = 0x01;
4960 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004961 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004962
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004963 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4964 spec->pwr_nids = stac92hd73xx_pwr_nids;
4965
Matthew Ranostayd9737752008-09-07 12:03:41 +02004966 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004967
4968 if (!err) {
4969 if (spec->board_config < 0) {
4970 printk(KERN_WARNING "hda_codec: No auto-config is "
4971 "available, default to model=ref\n");
4972 spec->board_config = STAC_92HD73XX_REF;
4973 goto again;
4974 }
4975 err = -EINVAL;
4976 }
4977
4978 if (err < 0) {
4979 stac92xx_free(codec);
4980 return err;
4981 }
4982
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01004983 if (spec->board_config == STAC_92HD73XX_NO_JD)
4984 spec->hp_detect = 0;
4985
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004986 codec->patch_ops = stac92xx_patch_ops;
4987
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004988 codec->proc_widget_hook = stac92hd7x_proc_hook;
4989
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004990 return 0;
4991}
4992
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004993static struct hda_input_mux stac92hd83xxx_dmux = {
4994 .num_items = 3,
4995 .items = {
4996 { "Analog Inputs", 0x03 },
4997 { "Digital Mic 1", 0x04 },
4998 { "Digital Mic 2", 0x05 },
4999 }
5000};
5001
5002static int patch_stac92hd83xxx(struct hda_codec *codec)
5003{
5004 struct sigmatel_spec *spec;
Matthew Ranostay65557f32009-01-20 16:50:25 -05005005 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005006 int err;
Matthew Ranostay65557f32009-01-20 16:50:25 -05005007 int num_dacs;
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05005008 hda_nid_t nid;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005009
5010 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5011 if (spec == NULL)
5012 return -ENOMEM;
5013
5014 codec->spec = spec;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005015 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005016 spec->mono_nid = 0x19;
5017 spec->digbeep_nid = 0x21;
5018 spec->dmic_nids = stac92hd83xxx_dmic_nids;
5019 spec->dmux_nids = stac92hd83xxx_dmux_nids;
5020 spec->adc_nids = stac92hd83xxx_adc_nids;
5021 spec->pwr_nids = stac92hd83xxx_pwr_nids;
Matthew Ranostayc15c5062009-01-13 13:30:07 -05005022 spec->amp_nids = stac92hd83xxx_amp_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005023 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
5024 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005025 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005026
5027 spec->init = stac92hd83xxx_core_init;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005028 spec->mixer = stac92hd83xxx_mixer;
5029 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
5030 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
5031 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
Matthew Ranostayc15c5062009-01-13 13:30:07 -05005032 spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005033 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
5034 spec->dinput_mux = &stac92hd83xxx_dmux;
5035 spec->pin_nids = stac92hd83xxx_pin_nids;
5036 spec->board_config = snd_hda_check_board_config(codec,
5037 STAC_92HD83XXX_MODELS,
5038 stac92hd83xxx_models,
5039 stac92hd83xxx_cfg_tbl);
5040again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005041 if (spec->board_config < 0)
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005042 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
5043 " STAC92HD83XXX, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01005044 else
5045 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005046 stac92hd83xxx_brd_tbl[spec->board_config]);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005047
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05005048 switch (codec->vendor_id) {
5049 case 0x111d7604:
5050 case 0x111d7605:
Matthew Ranostayff2e7332009-04-01 14:49:48 -04005051 case 0x111d76d5:
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05005052 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
5053 break;
5054 spec->num_pwrs = 0;
5055 break;
5056 }
5057
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005058 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
5059 if (!err) {
5060 if (spec->board_config < 0) {
5061 printk(KERN_WARNING "hda_codec: No auto-config is "
5062 "available, default to model=ref\n");
5063 spec->board_config = STAC_92HD83XXX_REF;
5064 goto again;
5065 }
5066 err = -EINVAL;
5067 }
5068
5069 if (err < 0) {
5070 stac92xx_free(codec);
5071 return err;
5072 }
5073
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05005074 switch (spec->board_config) {
5075 case STAC_DELL_S14:
5076 nid = 0xf;
5077 break;
5078 default:
5079 nid = 0xe;
5080 break;
5081 }
5082
5083 num_dacs = snd_hda_get_connections(codec, nid,
5084 conn, STAC92HD83_DAC_COUNT + 1) - 1;
5085
5086 /* set port X to select the last DAC
5087 */
5088 snd_hda_codec_write_cache(codec, nid, 0,
5089 AC_VERB_SET_CONNECT_SEL, num_dacs);
5090
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005091 codec->patch_ops = stac92xx_patch_ops;
5092
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005093 codec->proc_widget_hook = stac92hd_proc_hook;
5094
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005095 return 0;
5096}
5097
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005098static struct hda_input_mux stac92hd71bxx_dmux_nomixer = {
5099 .num_items = 3,
5100 .items = {
5101 { "Analog Inputs", 0x00 },
5102 { "Digital Mic 1", 0x02 },
5103 { "Digital Mic 2", 0x03 },
5104 }
5105};
5106
5107static struct hda_input_mux stac92hd71bxx_dmux_amixer = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005108 .num_items = 4,
5109 .items = {
5110 { "Analog Inputs", 0x00 },
5111 { "Mixer", 0x01 },
5112 { "Digital Mic 1", 0x02 },
5113 { "Digital Mic 2", 0x03 },
5114 }
5115};
5116
Takashi Iwai330ee992009-02-20 14:33:36 +01005117/* get the pin connection (fixed, none, etc) */
5118static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
5119{
5120 struct sigmatel_spec *spec = codec->spec;
5121 unsigned int cfg;
5122
5123 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
5124 return get_defcfg_connect(cfg);
5125}
5126
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005127static int stac92hd71bxx_connected_ports(struct hda_codec *codec,
5128 hda_nid_t *nids, int num_nids)
5129{
5130 struct sigmatel_spec *spec = codec->spec;
5131 int idx, num;
5132 unsigned int def_conf;
5133
5134 for (num = 0; num < num_nids; num++) {
5135 for (idx = 0; idx < spec->num_pins; idx++)
5136 if (spec->pin_nids[idx] == nids[num])
5137 break;
5138 if (idx >= spec->num_pins)
5139 break;
Takashi Iwai330ee992009-02-20 14:33:36 +01005140 def_conf = stac_get_defcfg_connect(codec, idx);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005141 if (def_conf == AC_JACK_PORT_NONE)
5142 break;
5143 }
5144 return num;
5145}
5146
5147static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
5148 hda_nid_t dig0pin)
5149{
5150 struct sigmatel_spec *spec = codec->spec;
5151 int idx;
5152
5153 for (idx = 0; idx < spec->num_pins; idx++)
5154 if (spec->pin_nids[idx] == dig0pin)
5155 break;
5156 if ((idx + 2) >= spec->num_pins)
5157 return 0;
5158
5159 /* dig1pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01005160 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005161 return 2;
5162
5163 /* dig0pin + dig2pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01005164 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005165 return 2;
Takashi Iwai330ee992009-02-20 14:33:36 +01005166 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005167 return 1;
5168 else
5169 return 0;
5170}
5171
Matthew Ranostaye035b842007-11-06 11:53:55 +01005172static int patch_stac92hd71bxx(struct hda_codec *codec)
5173{
5174 struct sigmatel_spec *spec;
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005175 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005176 int err = 0;
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005177 unsigned int ndmic_nids = 0;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005178
5179 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5180 if (spec == NULL)
5181 return -ENOMEM;
5182
5183 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005184 codec->patch_ops = stac92xx_patch_ops;
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05005185 spec->num_pins = STAC92HD71BXX_NUM_PINS;
5186 switch (codec->vendor_id) {
5187 case 0x111d76b6:
5188 case 0x111d76b7:
5189 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
5190 break;
5191 case 0x111d7603:
5192 case 0x111d7608:
5193 /* On 92HD75Bx 0x27 isn't a pin nid */
5194 spec->num_pins--;
5195 /* fallthrough */
5196 default:
5197 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
5198 }
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005199 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005200 spec->board_config = snd_hda_check_board_config(codec,
5201 STAC_92HD71BXX_MODELS,
5202 stac92hd71bxx_models,
5203 stac92hd71bxx_cfg_tbl);
5204again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005205 if (spec->board_config < 0)
Matthew Ranostaye035b842007-11-06 11:53:55 +01005206 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
5207 " STAC92HD71BXX, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01005208 else
5209 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005210 stac92hd71bxx_brd_tbl[spec->board_config]);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005211
Takashi Iwai41c3b642008-11-18 10:45:15 +01005212 if (spec->board_config > STAC_92HD71BXX_REF) {
5213 /* GPIO0 = EAPD */
5214 spec->gpio_mask = 0x01;
5215 spec->gpio_dir = 0x01;
5216 spec->gpio_data = 0x01;
5217 }
5218
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005219 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5220 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5221
Matthew Ranostay541eee82007-12-14 12:08:04 +01005222 switch (codec->vendor_id) {
5223 case 0x111d76b6: /* 4 Port without Analog Mixer */
5224 case 0x111d76b7:
Herton Ronaldo Krzesinski23c7b522009-02-08 19:51:28 -02005225 unmute_init++;
5226 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005227 case 0x111d76b4: /* 6 Port without Analog Mixer */
5228 case 0x111d76b5:
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005229 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_nomixer,
5230 sizeof(stac92hd71bxx_dmux_nomixer));
Matthew Ranostay541eee82007-12-14 12:08:04 +01005231 spec->mixer = stac92hd71bxx_mixer;
5232 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005233 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005234 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5235 stac92hd71bxx_dmic_nids,
5236 STAC92HD71BXX_NUM_DMICS);
5237 if (spec->num_dmics) {
5238 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5239 spec->dinput_mux = &spec->private_dimux;
5240 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
5241 }
Matthew Ranostay541eee82007-12-14 12:08:04 +01005242 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005243 case 0x111d7608: /* 5 Port with Analog Mixer */
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005244 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
5245 sizeof(stac92hd71bxx_dmux_amixer));
5246 spec->private_dimux.num_items--;
Takashi Iwai8e5f2622008-11-15 19:28:54 +01005247 switch (spec->board_config) {
5248 case STAC_HP_M4:
Matthew Ranostay72474be2008-10-09 09:32:17 -04005249 /* Enable VREF power saving on GPIO1 detect */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005250 err = stac_add_event(spec, codec->afg,
5251 STAC_VREF_EVENT, 0x02);
5252 if (err < 0)
5253 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005254 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay72474be2008-10-09 09:32:17 -04005255 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
5256 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005257 AC_VERB_SET_UNSOLICITED_ENABLE,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005258 AC_USRSP_EN | err);
Matthew Ranostay72474be2008-10-09 09:32:17 -04005259 spec->gpio_mask |= 0x02;
5260 break;
5261 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005262 if ((codec->revision_id & 0xf) == 0 ||
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005263 (codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005264 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005265
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005266 /* no output amps */
5267 spec->num_pwrs = 0;
5268 spec->mixer = stac92hd71bxx_analog_mixer;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005269 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005270
5271 /* disable VSW */
5272 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005273 unmute_init++;
Takashi Iwai330ee992009-02-20 14:33:36 +01005274 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5275 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005276 stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0;
5277 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5278 stac92hd71bxx_dmic_nids,
5279 STAC92HD71BXX_NUM_DMICS - 1);
5280 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5281 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 2;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005282 break;
5283 case 0x111d7603: /* 6 Port with Analog Mixer */
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005284 if ((codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005285 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005286
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005287 /* no output amps */
5288 spec->num_pwrs = 0;
5289 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005290 default:
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005291 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
5292 sizeof(stac92hd71bxx_dmux_amixer));
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005293 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005294 spec->mixer = stac92hd71bxx_analog_mixer;
5295 spec->init = stac92hd71bxx_analog_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005296 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005297 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5298 stac92hd71bxx_dmic_nids,
5299 STAC92HD71BXX_NUM_DMICS);
5300 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5301 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005302 }
5303
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005304 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5305 snd_hda_sequence_write_cache(codec, unmute_init);
5306
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005307 spec->aloopback_ctl = stac92hd71bxx_loopback;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005308 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005309 spec->aloopback_shift = 0;
5310
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005311 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005312 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005313 spec->mux_nids = stac92hd71bxx_mux_nids;
5314 spec->adc_nids = stac92hd71bxx_adc_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005315 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005316 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005317
5318 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5319 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005320 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005321
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005322 switch (spec->board_config) {
5323 case STAC_HP_M4:
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005324 /* enable internal microphone */
Takashi Iwai330ee992009-02-20 14:33:36 +01005325 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
Matthew Ranostayb9aea712008-10-09 08:37:28 -04005326 stac92xx_auto_set_pinctl(codec, 0x0e,
5327 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05005328 /* fallthru */
5329 case STAC_DELL_M4_2:
5330 spec->num_dmics = 0;
5331 spec->num_smuxes = 0;
5332 spec->num_dmuxes = 0;
5333 break;
5334 case STAC_DELL_M4_1:
5335 case STAC_DELL_M4_3:
5336 spec->num_dmics = 1;
5337 spec->num_smuxes = 0;
Takashi Iwaiea18aa42009-02-27 17:36:33 +01005338 spec->num_dmuxes = 1;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005339 break;
James Gardiner514bf542009-05-03 04:00:44 -04005340 case STAC_HP_DV4_1222NR:
5341 spec->num_dmics = 1;
5342 /* I don't know if it needs 1 or 2 smuxes - will wait for
5343 * bug reports to fix if needed
5344 */
5345 spec->num_smuxes = 1;
5346 spec->num_dmuxes = 1;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005347 spec->gpio_led = 0x01;
James Gardiner514bf542009-05-03 04:00:44 -04005348 /* fallthrough */
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005349 case STAC_HP_DV5:
Takashi Iwai330ee992009-02-20 14:33:36 +01005350 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005351 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
5352 break;
Christoph Plattnerae6241f2009-03-08 23:19:05 +01005353 case STAC_HP_HDX:
5354 spec->num_dmics = 1;
5355 spec->num_dmuxes = 1;
5356 spec->num_smuxes = 1;
Christoph Plattner443e26d2009-03-10 00:05:56 +01005357 /* orange/white mute led on GPIO3, orange=0, white=1 */
Takashi Iwai86d190e2009-05-26 15:18:58 +02005358 spec->gpio_led = 0x08;
5359 break;
5360 }
Christoph Plattner443e26d2009-03-10 00:05:56 +01005361
Takashi Iwai86d190e2009-05-26 15:18:58 +02005362#ifdef CONFIG_SND_HDA_POWER_SAVE
5363 if (spec->gpio_led) {
5364 spec->gpio_mask |= spec->gpio_led;
5365 spec->gpio_dir |= spec->gpio_led;
5366 spec->gpio_data |= spec->gpio_led;
Christoph Plattner443e26d2009-03-10 00:05:56 +01005367 /* register check_power_status callback. */
Takashi Iwai6fce61a2009-03-10 07:48:57 +01005368 codec->patch_ops.check_power_status =
Takashi Iwai86d190e2009-05-26 15:18:58 +02005369 stac92xx_hp_check_power_status;
5370 }
Christoph Plattner443e26d2009-03-10 00:05:56 +01005371#endif
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005372
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005373 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005374 if (spec->dinput_mux)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005375 spec->private_dimux.num_items += spec->num_dmics - ndmic_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005376
Herton Ronaldo Krzesinski29d4ab42009-02-04 11:37:27 -05005377 err = stac92xx_parse_auto_config(codec, 0x21, 0);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005378 if (!err) {
5379 if (spec->board_config < 0) {
5380 printk(KERN_WARNING "hda_codec: No auto-config is "
5381 "available, default to model=ref\n");
5382 spec->board_config = STAC_92HD71BXX_REF;
5383 goto again;
5384 }
5385 err = -EINVAL;
5386 }
5387
5388 if (err < 0) {
5389 stac92xx_free(codec);
5390 return err;
5391 }
5392
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005393 codec->proc_widget_hook = stac92hd7x_proc_hook;
5394
Matthew Ranostaye035b842007-11-06 11:53:55 +01005395 return 0;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005396}
Matthew Ranostaye035b842007-11-06 11:53:55 +01005397
Matt2f2f4252005-04-13 14:45:30 +02005398static int patch_stac922x(struct hda_codec *codec)
5399{
5400 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005401 int err;
Matt2f2f4252005-04-13 14:45:30 +02005402
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005403 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02005404 if (spec == NULL)
5405 return -ENOMEM;
5406
5407 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005408 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005409 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005410 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5411 stac922x_models,
5412 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08005413 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005414 spec->gpio_mask = spec->gpio_dir = 0x03;
5415 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005416 /* Intel Macs have all same PCI SSID, so we need to check
5417 * codec SSID to distinguish the exact models
5418 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005419 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005420 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005421
5422 case 0x106b0800:
5423 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02005424 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005425 case 0x106b0600:
5426 case 0x106b0700:
5427 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005428 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005429 case 0x106b0e00:
5430 case 0x106b0f00:
5431 case 0x106b1600:
5432 case 0x106b1700:
5433 case 0x106b0200:
5434 case 0x106b1e00:
5435 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005436 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005437 case 0x106b1a00:
5438 case 0x00000100:
5439 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02005440 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005441 case 0x106b0a00:
5442 case 0x106b2200:
5443 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02005444 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08005445 default:
5446 spec->board_config = STAC_INTEL_MAC_V3;
5447 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005448 }
5449 }
5450
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005451 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005452 if (spec->board_config < 0)
Richard Fish11b44bb2006-08-23 18:31:34 +02005453 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
5454 "using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01005455 else
5456 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005457 stac922x_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02005458
Matt2f2f4252005-04-13 14:45:30 +02005459 spec->adc_nids = stac922x_adc_nids;
5460 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005461 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005462 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005463 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005464 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02005465
5466 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02005467 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02005468
5469 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02005470
Matt Porter3cc08dc2006-01-23 15:27:49 +01005471 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005472 if (!err) {
5473 if (spec->board_config < 0) {
5474 printk(KERN_WARNING "hda_codec: No auto-config is "
5475 "available, default to model=ref\n");
5476 spec->board_config = STAC_D945_REF;
5477 goto again;
5478 }
5479 err = -EINVAL;
5480 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005481 if (err < 0) {
5482 stac92xx_free(codec);
5483 return err;
5484 }
5485
5486 codec->patch_ops = stac92xx_patch_ops;
5487
Takashi Iwai807a46362007-05-29 19:01:37 +02005488 /* Fix Mux capture level; max to 2 */
5489 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
5490 (0 << AC_AMPCAP_OFFSET_SHIFT) |
5491 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5492 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5493 (0 << AC_AMPCAP_MUTE_SHIFT));
5494
Matt Porter3cc08dc2006-01-23 15:27:49 +01005495 return 0;
5496}
5497
5498static int patch_stac927x(struct hda_codec *codec)
5499{
5500 struct sigmatel_spec *spec;
5501 int err;
5502
5503 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5504 if (spec == NULL)
5505 return -ENOMEM;
5506
5507 codec->spec = spec;
Matthew Ranostay45c1d852009-02-04 17:49:41 -05005508 codec->slave_dig_outs = stac927x_slave_dig_outs;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005509 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005510 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005511 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5512 stac927x_models,
5513 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005514 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005515 if (spec->board_config < 0)
Herton Ronaldo Krzesinskic98041f2009-02-11 20:33:15 -02005516 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
5517 "STAC927x, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01005518 else
5519 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005520 stac927x_brd_tbl[spec->board_config]);
Matt Porter3cc08dc2006-01-23 15:27:49 +01005521
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005522 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005523 spec->adc_nids = stac927x_adc_nids;
5524 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
5525 spec->mux_nids = stac927x_mux_nids;
5526 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005527 spec->smux_nids = stac927x_smux_nids;
5528 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04005529 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005530 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005531 spec->multiout.dac_nids = spec->dac_nids;
5532
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005533 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02005534 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005535 case STAC_D965_5ST:
5536 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005537 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005538 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005539 spec->num_dmics = 0;
5540
Tobin Davis93ed1502006-09-01 21:03:12 +02005541 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005542 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005543 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005544 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02005545 switch (codec->subsystem_id) {
5546 case 0x10280209:
5547 case 0x1028022e:
5548 /* correct the device field to SPDIF out */
Takashi Iwai330ee992009-02-20 14:33:36 +01005549 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
Matthew Ranostay780c8be2008-04-14 13:32:27 +02005550 break;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005551 }
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01005552 /* configure the analog microphone on some laptops */
Takashi Iwai330ee992009-02-20 14:33:36 +01005553 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01005554 /* correct the front output jack as a hp out */
Takashi Iwai330ee992009-02-20 14:33:36 +01005555 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01005556 /* correct the front input jack as a mic */
Takashi Iwai330ee992009-02-20 14:33:36 +01005557 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01005558 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005559 case STAC_DELL_3ST:
5560 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005561 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005562 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005563 spec->dmic_nids = stac927x_dmic_nids;
5564 spec->num_dmics = STAC927X_NUM_DMICS;
5565
Tobin Davis93ed1502006-09-01 21:03:12 +02005566 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005567 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005568 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005569 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005570 break;
5571 default:
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005572 if (spec->board_config > STAC_D965_REF) {
5573 /* GPIO0 High = Enable EAPD */
5574 spec->eapd_mask = spec->gpio_mask = 0x01;
5575 spec->gpio_dir = spec->gpio_data = 0x01;
5576 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005577 spec->num_dmics = 0;
5578
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005579 spec->init = stac927x_core_init;
5580 spec->mixer = stac927x_mixer;
5581 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005582
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005583 spec->num_pwrs = 0;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005584 spec->aloopback_ctl = stac927x_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005585 spec->aloopback_mask = 0x40;
5586 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005587 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005588
Matt Porter3cc08dc2006-01-23 15:27:49 +01005589 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005590 if (!err) {
5591 if (spec->board_config < 0) {
5592 printk(KERN_WARNING "hda_codec: No auto-config is "
5593 "available, default to model=ref\n");
5594 spec->board_config = STAC_D965_REF;
5595 goto again;
5596 }
5597 err = -EINVAL;
5598 }
Mattc7d4b2f2005-06-27 14:59:41 +02005599 if (err < 0) {
5600 stac92xx_free(codec);
5601 return err;
5602 }
Matt2f2f4252005-04-13 14:45:30 +02005603
5604 codec->patch_ops = stac92xx_patch_ops;
5605
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005606 codec->proc_widget_hook = stac927x_proc_hook;
5607
Takashi Iwai52987652008-01-16 16:09:47 +01005608 /*
5609 * !!FIXME!!
5610 * The STAC927x seem to require fairly long delays for certain
5611 * command sequences. With too short delays (even if the answer
5612 * is set to RIRB properly), it results in the silence output
5613 * on some hardwares like Dell.
5614 *
5615 * The below flag enables the longer delay (see get_response
5616 * in hda_intel.c).
5617 */
5618 codec->bus->needs_damn_long_delay = 1;
5619
Takashi Iwaie28d8322008-12-17 13:48:29 +01005620 /* no jack detecion for ref-no-jd model */
5621 if (spec->board_config == STAC_D965_REF_NO_JD)
5622 spec->hp_detect = 0;
5623
Matt2f2f4252005-04-13 14:45:30 +02005624 return 0;
5625}
5626
Matt Porterf3302a52006-07-31 12:49:34 +02005627static int patch_stac9205(struct hda_codec *codec)
5628{
5629 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02005630 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02005631
5632 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5633 if (spec == NULL)
5634 return -ENOMEM;
5635
5636 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005637 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005638 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005639 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
5640 stac9205_models,
5641 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005642 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005643 if (spec->board_config < 0)
Richard Fish11b44bb2006-08-23 18:31:34 +02005644 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01005645 else
5646 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005647 stac9205_brd_tbl[spec->board_config]);
Matt Porterf3302a52006-07-31 12:49:34 +02005648
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005649 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02005650 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005651 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02005652 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005653 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005654 spec->smux_nids = stac9205_smux_nids;
5655 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005656 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02005657 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005658 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005659 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005660 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02005661
5662 spec->init = stac9205_core_init;
5663 spec->mixer = stac9205_mixer;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005664 spec->aloopback_ctl = stac9205_loopback;
Matt Porterf3302a52006-07-31 12:49:34 +02005665
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005666 spec->aloopback_mask = 0x40;
5667 spec->aloopback_shift = 0;
Takashi Iwaid9a42682009-01-22 17:40:18 +01005668 /* Turn on/off EAPD per HP plugging */
5669 if (spec->board_config != STAC_9205_EAPD)
5670 spec->eapd_switch = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02005671 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02005672
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005673 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005674 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02005675 /* Enable SPDIF in/out */
Takashi Iwai330ee992009-02-20 14:33:36 +01005676 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
5677 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01005678
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005679 /* Enable unsol response for GPIO4/Dock HP connection */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005680 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
5681 if (err < 0)
5682 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005683 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005684 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
5685 snd_hda_codec_write_cache(codec, codec->afg, 0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005686 AC_VERB_SET_UNSOLICITED_ENABLE,
5687 AC_USRSP_EN | err);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005688
5689 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005690 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005691 spec->gpio_mask = 0x1b;
5692 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01005693 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005694 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02005695 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005696 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005697 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005698 case STAC_9205_REF:
5699 /* SPDIF-In enabled */
5700 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005701 default:
5702 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005703 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005704 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005705 break;
5706 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02005707
Matt Porterf3302a52006-07-31 12:49:34 +02005708 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005709 if (!err) {
5710 if (spec->board_config < 0) {
5711 printk(KERN_WARNING "hda_codec: No auto-config is "
5712 "available, default to model=ref\n");
5713 spec->board_config = STAC_9205_REF;
5714 goto again;
5715 }
5716 err = -EINVAL;
5717 }
Matt Porterf3302a52006-07-31 12:49:34 +02005718 if (err < 0) {
5719 stac92xx_free(codec);
5720 return err;
5721 }
5722
5723 codec->patch_ops = stac92xx_patch_ops;
5724
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005725 codec->proc_widget_hook = stac9205_proc_hook;
5726
Matt Porterf3302a52006-07-31 12:49:34 +02005727 return 0;
5728}
5729
Matt2f2f4252005-04-13 14:45:30 +02005730/*
Guillaume Munch6d859062006-08-22 17:15:47 +02005731 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01005732 */
5733
Takashi Iwai1e137f92009-01-21 07:41:22 +01005734static struct hda_verb stac9872_core_init[] = {
Takashi Iwai1624cb92007-07-05 13:10:51 +02005735 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005736 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5737 {}
5738};
5739
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005740static struct snd_kcontrol_new stac9872_mixer[] = {
5741 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5742 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005743 { } /* end */
5744};
5745
5746static hda_nid_t stac9872_pin_nids[] = {
5747 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
5748 0x11, 0x13, 0x14,
5749};
5750
5751static hda_nid_t stac9872_adc_nids[] = {
5752 0x8 /*,0x6*/
5753};
5754
5755static hda_nid_t stac9872_mux_nids[] = {
5756 0x15
5757};
5758
Takashi Iwai307282c2009-03-12 18:17:58 +01005759static unsigned int stac9872_vaio_pin_configs[9] = {
5760 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
5761 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
5762 0x90a7013e
5763};
5764
5765static const char *stac9872_models[STAC_9872_MODELS] = {
5766 [STAC_9872_AUTO] = "auto",
5767 [STAC_9872_VAIO] = "vaio",
5768};
5769
5770static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
5771 [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
5772};
5773
5774static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5775 {} /* terminator */
5776};
5777
Guillaume Munch6d859062006-08-22 17:15:47 +02005778static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01005779{
5780 struct sigmatel_spec *spec;
Takashi Iwai1e137f92009-01-21 07:41:22 +01005781 int err;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005782
Takashi Iwaidb064e52006-03-16 16:04:58 +01005783 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5784 if (spec == NULL)
5785 return -ENOMEM;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005786 codec->spec = spec;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005787
5788 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5789 stac9872_models,
5790 stac9872_cfg_tbl);
Takashi Iwai307282c2009-03-12 18:17:58 +01005791 if (spec->board_config < 0)
5792 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9872, "
5793 "using BIOS defaults\n");
5794 else
5795 stac92xx_set_config_regs(codec,
5796 stac9872_brd_tbl[spec->board_config]);
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005797
Takashi Iwai1e137f92009-01-21 07:41:22 +01005798 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
5799 spec->pin_nids = stac9872_pin_nids;
5800 spec->multiout.dac_nids = spec->dac_nids;
5801 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
5802 spec->adc_nids = stac9872_adc_nids;
5803 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
5804 spec->mux_nids = stac9872_mux_nids;
5805 spec->mixer = stac9872_mixer;
5806 spec->init = stac9872_core_init;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005807
Takashi Iwai1e137f92009-01-21 07:41:22 +01005808 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
5809 if (err < 0) {
5810 stac92xx_free(codec);
5811 return -EINVAL;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005812 }
Takashi Iwai1e137f92009-01-21 07:41:22 +01005813 spec->input_mux = &spec->private_imux;
5814 codec->patch_ops = stac92xx_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005815 return 0;
5816}
5817
5818
5819/*
Matt2f2f4252005-04-13 14:45:30 +02005820 * patch entries
5821 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +01005822static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
Matt2f2f4252005-04-13 14:45:30 +02005823 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5824 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5825 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5826 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5827 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5828 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5829 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02005830 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5831 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5832 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5833 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5834 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5835 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01005836 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5837 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5838 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5839 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5840 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5841 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5842 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5843 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5844 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5845 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01005846 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5847 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5848 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5849 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5850 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5851 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02005852 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5853 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02005854 /* The following does not take into account .id=0x83847661 when subsys =
5855 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5856 * currently not fully supported.
5857 */
5858 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5859 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5860 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02005861 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5862 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5863 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5864 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5865 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5866 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5867 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5868 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005869 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005870 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5871 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayff2e7332009-04-01 14:49:48 -04005872 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005873 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01005874 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5875 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005876 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01005877 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5878 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5879 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5880 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5881 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5882 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5883 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5884 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02005885 {} /* terminator */
5886};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01005887
5888MODULE_ALIAS("snd-hda-codec-id:8384*");
5889MODULE_ALIAS("snd-hda-codec-id:111d*");
5890
5891MODULE_LICENSE("GPL");
5892MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
5893
5894static struct hda_codec_preset_list sigmatel_list = {
5895 .preset = snd_hda_preset_sigmatel,
5896 .owner = THIS_MODULE,
5897};
5898
5899static int __init patch_sigmatel_init(void)
5900{
5901 return snd_hda_add_codec_preset(&sigmatel_list);
5902}
5903
5904static void __exit patch_sigmatel_exit(void)
5905{
5906 snd_hda_delete_codec_preset(&sigmatel_list);
5907}
5908
5909module_init(patch_sigmatel_init)
5910module_exit(patch_sigmatel_exit)