blob: 17310814f12145384374ee62db743a65534a4388 [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 Iwaic8b6bf9b2005-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;
196
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200197 /* stream */
198 unsigned int stream_delay;
199
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100200 /* analog loopback */
Takashi Iwaid78d7a92009-03-02 14:26:25 +0100201 struct snd_kcontrol_new *aloopback_ctl;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100202 unsigned char aloopback_mask;
203 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200204
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100205 /* power management */
206 unsigned int num_pwrs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200207 unsigned int *pwr_mapping;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100208 hda_nid_t *pwr_nids;
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100209 hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100210
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400211 /* jack detection */
212 struct snd_array jacks;
213
214 /* events */
215 struct snd_array events;
216
Matt2f2f4252005-04-13 14:45:30 +0200217 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100218 struct hda_input_mux *mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400219 struct hda_input_mux *amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100220 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200221 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100222 hda_nid_t dac_nids[5];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100223 hda_nid_t hp_dacs[5];
224 hda_nid_t speaker_dacs[5];
Matt2f2f4252005-04-13 14:45:30 +0200225
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100226 int volume_offset;
227
Matt2f2f4252005-04-13 14:45:30 +0200228 /* capture */
229 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200230 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200231 hda_nid_t *mux_nids;
232 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200233 hda_nid_t *dmic_nids;
234 unsigned int num_dmics;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100235 hda_nid_t *dmux_nids;
Takashi Iwai16970552007-12-18 18:05:52 +0100236 unsigned int num_dmuxes;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200237 hda_nid_t *smux_nids;
238 unsigned int num_smuxes;
Matthew Ranostay65973632008-09-16 10:39:37 -0400239 const char **spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200240
Mattdabbed62005-06-14 10:19:34 +0200241 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100242 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200243 hda_nid_t anabeep_nid;
244 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200245
Matt2f2f4252005-04-13 14:45:30 +0200246 /* pin widgets */
247 hda_nid_t *pin_nids;
248 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200249
250 /* codec specific stuff */
251 struct hda_verb *init;
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100252 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200253
254 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200255 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100256 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200257 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100258 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200259 struct hda_input_mux *sinput_mux;
260 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400261 unsigned int cur_amux;
262 hda_nid_t *amp_nids;
263 unsigned int num_amps;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200264 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200265
Matt Porter403d1942005-11-29 15:00:51 +0100266 /* i/o switches */
267 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200268 unsigned int clfe_swap;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100269 hda_nid_t line_switch; /* shared line-in for input and output */
270 hda_nid_t mic_switch; /* shared mic-in for input and output */
271 hda_nid_t hp_switch; /* NID of HP as line-out */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200272 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200273
Mattc7d4b2f2005-06-27 14:59:41 +0200274 struct hda_pcm pcm_rec[2]; /* PCM information */
275
276 /* dynamic controls and input_mux */
277 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200278 struct snd_array kctls;
Matt Porter8b657272006-10-26 17:12:59 +0200279 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200280 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200281 struct hda_input_mux private_smux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400282 struct hda_input_mux private_amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100283 struct hda_input_mux private_mono_mux;
Matt2f2f4252005-04-13 14:45:30 +0200284};
285
286static hda_nid_t stac9200_adc_nids[1] = {
287 0x03,
288};
289
290static hda_nid_t stac9200_mux_nids[1] = {
291 0x0c,
292};
293
294static hda_nid_t stac9200_dac_nids[1] = {
295 0x02,
296};
297
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100298static hda_nid_t stac92hd73xx_pwr_nids[8] = {
299 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
300 0x0f, 0x10, 0x11
301};
302
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400303static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
304 0x26, 0,
305};
306
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100307static hda_nid_t stac92hd73xx_adc_nids[2] = {
308 0x1a, 0x1b
309};
310
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400311#define DELL_M6_AMP 2
312static hda_nid_t stac92hd73xx_amp_nids[3] = {
313 0x0b, 0x0c, 0x0e
Matthew Ranostay89385032008-09-11 09:49:39 -0400314};
315
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100316#define STAC92HD73XX_NUM_DMICS 2
317static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
318 0x13, 0x14, 0
319};
320
321#define STAC92HD73_DAC_COUNT 5
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100322
323static hda_nid_t stac92hd73xx_mux_nids[4] = {
324 0x28, 0x29, 0x2a, 0x2b,
325};
326
327static hda_nid_t stac92hd73xx_dmux_nids[2] = {
328 0x20, 0x21,
329};
330
Matthew Ranostayd9737752008-09-07 12:03:41 +0200331static hda_nid_t stac92hd73xx_smux_nids[2] = {
332 0x22, 0x23,
333};
334
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200335#define STAC92HD83XXX_NUM_DMICS 2
336static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
337 0x11, 0x12, 0
338};
339
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200340#define STAC92HD83_DAC_COUNT 3
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200341
342static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
343 0x17, 0x18,
344};
345
346static hda_nid_t stac92hd83xxx_adc_nids[2] = {
347 0x15, 0x16,
348};
349
350static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
351 0xa, 0xb, 0xd, 0xe,
352};
353
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400354static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
355 0x1e, 0,
356};
357
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200358static unsigned int stac92hd83xxx_pwr_mapping[4] = {
Matthew Ranostay87e88a72009-01-22 20:38:42 -0500359 0x03, 0x0c, 0x20, 0x40,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200360};
361
Takashi Iwai9248f262009-01-14 09:40:25 +0100362static hda_nid_t stac92hd83xxx_amp_nids[1] = {
Matthew Ranostayc15c5062009-01-13 13:30:07 -0500363 0xc,
364};
365
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100366static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
367 0x0a, 0x0d, 0x0f
368};
369
Matthew Ranostaye035b842007-11-06 11:53:55 +0100370static hda_nid_t stac92hd71bxx_adc_nids[2] = {
371 0x12, 0x13,
372};
373
374static hda_nid_t stac92hd71bxx_mux_nids[2] = {
375 0x1a, 0x1b
376};
377
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400378static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
379 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100380};
381
Matthew Ranostayd9737752008-09-07 12:03:41 +0200382static hda_nid_t stac92hd71bxx_smux_nids[2] = {
383 0x24, 0x25,
384};
385
Matthew Ranostaye035b842007-11-06 11:53:55 +0100386#define STAC92HD71BXX_NUM_DMICS 2
387static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
388 0x18, 0x19, 0
389};
390
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400391static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
392 0x22, 0
393};
394
Tobin Davis8e21c342007-01-08 11:04:17 +0100395static hda_nid_t stac925x_adc_nids[1] = {
396 0x03,
397};
398
399static hda_nid_t stac925x_mux_nids[1] = {
400 0x0f,
401};
402
403static hda_nid_t stac925x_dac_nids[1] = {
404 0x02,
405};
406
Takashi Iwaif6e98522007-10-16 14:27:04 +0200407#define STAC925X_NUM_DMICS 1
408static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
409 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200410};
411
Takashi Iwai16970552007-12-18 18:05:52 +0100412static hda_nid_t stac925x_dmux_nids[1] = {
413 0x14,
414};
415
Matt2f2f4252005-04-13 14:45:30 +0200416static hda_nid_t stac922x_adc_nids[2] = {
417 0x06, 0x07,
418};
419
420static hda_nid_t stac922x_mux_nids[2] = {
421 0x12, 0x13,
422};
423
Matthew Ranostay45c1d852009-02-04 17:49:41 -0500424static hda_nid_t stac927x_slave_dig_outs[2] = {
425 0x1f, 0,
426};
427
Matt Porter3cc08dc2006-01-23 15:27:49 +0100428static hda_nid_t stac927x_adc_nids[3] = {
429 0x07, 0x08, 0x09
430};
431
432static hda_nid_t stac927x_mux_nids[3] = {
433 0x15, 0x16, 0x17
434};
435
Matthew Ranostayd9737752008-09-07 12:03:41 +0200436static hda_nid_t stac927x_smux_nids[1] = {
437 0x21,
438};
439
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100440static hda_nid_t stac927x_dac_nids[6] = {
441 0x02, 0x03, 0x04, 0x05, 0x06, 0
442};
443
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100444static hda_nid_t stac927x_dmux_nids[1] = {
445 0x1b,
446};
447
Matthew Ranostay7f168592007-10-18 17:38:17 +0200448#define STAC927X_NUM_DMICS 2
449static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
450 0x13, 0x14, 0
451};
452
Matthew Ranostay65973632008-09-16 10:39:37 -0400453static const char *stac927x_spdif_labels[5] = {
454 "Digital Playback", "ADAT", "Analog Mux 1",
455 "Analog Mux 2", "Analog Mux 3"
456};
457
Matt Porterf3302a592006-07-31 12:49:34 +0200458static hda_nid_t stac9205_adc_nids[2] = {
459 0x12, 0x13
460};
461
462static hda_nid_t stac9205_mux_nids[2] = {
463 0x19, 0x1a
464};
465
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100466static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai16970552007-12-18 18:05:52 +0100467 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100468};
469
Matthew Ranostayd9737752008-09-07 12:03:41 +0200470static hda_nid_t stac9205_smux_nids[1] = {
471 0x21,
472};
473
Takashi Iwaif6e98522007-10-16 14:27:04 +0200474#define STAC9205_NUM_DMICS 2
475static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
476 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200477};
478
Mattc7d4b2f2005-06-27 14:59:41 +0200479static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200480 0x08, 0x09, 0x0d, 0x0e,
481 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200482};
483
Tobin Davis8e21c342007-01-08 11:04:17 +0100484static hda_nid_t stac925x_pin_nids[8] = {
485 0x07, 0x08, 0x0a, 0x0b,
486 0x0c, 0x0d, 0x10, 0x11,
487};
488
Matt2f2f4252005-04-13 14:45:30 +0200489static hda_nid_t stac922x_pin_nids[10] = {
490 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
491 0x0f, 0x10, 0x11, 0x15, 0x1b,
492};
493
Matthew Ranostaya7662642008-02-21 07:51:14 +0100494static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100495 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
496 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200497 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100498};
499
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -0500500static hda_nid_t stac92hd83xxx_pin_nids[10] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200501 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -0500502 0x0f, 0x10, 0x11, 0x1f, 0x20,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200503};
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500504
505#define STAC92HD71BXX_NUM_PINS 13
506static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
507 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
508 0x00, 0x14, 0x18, 0x19, 0x1e,
509 0x1f, 0x20, 0x27
510};
511static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100512 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
513 0x0f, 0x14, 0x18, 0x19, 0x1e,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500514 0x1f, 0x20, 0x27
Matthew Ranostaye035b842007-11-06 11:53:55 +0100515};
516
Matt Porter3cc08dc2006-01-23 15:27:49 +0100517static hda_nid_t stac927x_pin_nids[14] = {
518 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
519 0x0f, 0x10, 0x11, 0x12, 0x13,
520 0x14, 0x21, 0x22, 0x23,
521};
522
Matt Porterf3302a592006-07-31 12:49:34 +0200523static hda_nid_t stac9205_pin_nids[12] = {
524 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
525 0x0f, 0x14, 0x16, 0x17, 0x18,
526 0x21, 0x22,
Matt Porterf3302a592006-07-31 12:49:34 +0200527};
528
Matthew Ranostay89385032008-09-11 09:49:39 -0400529#define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
530
531static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
532 struct snd_ctl_elem_value *ucontrol)
533{
534 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
535 struct sigmatel_spec *spec = codec->spec;
536 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
537
538 kcontrol->private_value ^= get_amp_nid(kcontrol);
539 kcontrol->private_value |= nid;
540
541 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
542}
543
544static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
545 struct snd_ctl_elem_value *ucontrol)
546{
547 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
548 struct sigmatel_spec *spec = codec->spec;
549 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
550
551 kcontrol->private_value ^= get_amp_nid(kcontrol);
552 kcontrol->private_value |= nid;
553
554 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
555}
556
Matt Porter8b657272006-10-26 17:12:59 +0200557static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
558 struct snd_ctl_elem_info *uinfo)
559{
560 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
561 struct sigmatel_spec *spec = codec->spec;
562 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
563}
564
565static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
566 struct snd_ctl_elem_value *ucontrol)
567{
568 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
569 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100570 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200571
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100572 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200573 return 0;
574}
575
576static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
577 struct snd_ctl_elem_value *ucontrol)
578{
579 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
580 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100581 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200582
583 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100584 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200585}
586
Matthew Ranostayd9737752008-09-07 12:03:41 +0200587static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
588 struct snd_ctl_elem_info *uinfo)
589{
590 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
591 struct sigmatel_spec *spec = codec->spec;
592 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
593}
594
595static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
596 struct snd_ctl_elem_value *ucontrol)
597{
598 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
599 struct sigmatel_spec *spec = codec->spec;
600 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
601
602 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
603 return 0;
604}
605
606static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
607 struct snd_ctl_elem_value *ucontrol)
608{
609 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
610 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400611 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200612 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400613 int err, val;
614 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200615
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400616 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200617 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400618 if (err < 0)
619 return err;
620
621 if (spec->spdif_mute) {
622 if (smux_idx == 0)
623 nid = spec->multiout.dig_out_nid;
624 else
625 nid = codec->slave_dig_outs[smux_idx - 1];
626 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100627 val = HDA_AMP_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400628 else
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100629 val = 0;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400630 /* un/mute SPDIF out */
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100631 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
632 HDA_AMP_MUTE, val);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400633 }
634 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200635}
636
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200637static unsigned int stac92xx_vref_set(struct hda_codec *codec,
638 hda_nid_t nid, unsigned int new_vref)
639{
640 unsigned int error;
641 unsigned int pincfg;
642 pincfg = snd_hda_codec_read(codec, nid, 0,
643 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
644
645 pincfg &= 0xff;
646 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
647 pincfg |= new_vref;
648
649 if (new_vref == AC_PINCTL_VREF_HIZ)
650 pincfg |= AC_PINCTL_OUT_EN;
651 else
652 pincfg |= AC_PINCTL_IN_EN;
653
654 error = snd_hda_codec_write_cache(codec, nid, 0,
655 AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg);
656 if (error < 0)
657 return error;
658 else
659 return 1;
660}
661
662static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
663{
664 unsigned int vref;
665 vref = snd_hda_codec_read(codec, nid, 0,
666 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
667 vref &= AC_PINCTL_VREFEN;
668 return vref;
669}
670
671static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
672 struct snd_ctl_elem_value *ucontrol)
673{
674 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
675 unsigned int new_vref;
676 unsigned int error;
677
678 if (ucontrol->value.enumerated.item[0] == 0)
679 new_vref = AC_PINCTL_VREF_80;
680 else if (ucontrol->value.enumerated.item[0] == 1)
681 new_vref = AC_PINCTL_VREF_GRD;
682 else
683 new_vref = AC_PINCTL_VREF_HIZ;
684
685 if (new_vref != stac92xx_vref_get(codec, kcontrol->private_value)) {
686 error = stac92xx_vref_set(codec,
687 kcontrol->private_value, new_vref);
688 return error;
689 }
690
691 return 0;
692}
693
694static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
695 struct snd_ctl_elem_value *ucontrol)
696{
697 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
698 unsigned int vref = stac92xx_vref_get(codec, kcontrol->private_value);
699 if (vref == AC_PINCTL_VREF_80)
700 ucontrol->value.enumerated.item[0] = 0;
701 else if (vref == AC_PINCTL_VREF_GRD)
702 ucontrol->value.enumerated.item[0] = 1;
703 else if (vref == AC_PINCTL_VREF_HIZ)
704 ucontrol->value.enumerated.item[0] = 2;
705
706 return 0;
707}
708
709static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
710 struct snd_ctl_elem_info *uinfo)
711{
712 static char *texts[] = {
713 "Mic In", "Line In", "Line Out"
714 };
715
716 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
717 uinfo->value.enumerated.items = 3;
718 uinfo->count = 1;
719 if (uinfo->value.enumerated.item >= 3)
720 uinfo->value.enumerated.item = 2;
721 strcpy(uinfo->value.enumerated.name,
722 texts[uinfo->value.enumerated.item]);
723
724 return 0;
725}
726
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100727static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200728{
729 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
730 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200731 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200732}
733
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100734static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200735{
736 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
737 struct sigmatel_spec *spec = codec->spec;
738 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
739
740 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
741 return 0;
742}
743
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100744static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200745{
746 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
747 struct sigmatel_spec *spec = codec->spec;
748 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
749
Mattc7d4b2f2005-06-27 14:59:41 +0200750 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200751 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
752}
753
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100754static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
755 struct snd_ctl_elem_info *uinfo)
756{
757 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
758 struct sigmatel_spec *spec = codec->spec;
759 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
760}
761
762static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
763 struct snd_ctl_elem_value *ucontrol)
764{
765 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
766 struct sigmatel_spec *spec = codec->spec;
767
768 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
769 return 0;
770}
771
772static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
773 struct snd_ctl_elem_value *ucontrol)
774{
775 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
776 struct sigmatel_spec *spec = codec->spec;
777
778 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
779 spec->mono_nid, &spec->cur_mmux);
780}
781
Matthew Ranostay89385032008-09-11 09:49:39 -0400782static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
783 struct snd_ctl_elem_info *uinfo)
784{
785 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
786 struct sigmatel_spec *spec = codec->spec;
787 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
788}
789
790static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
791 struct snd_ctl_elem_value *ucontrol)
792{
793 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
794 struct sigmatel_spec *spec = codec->spec;
795
796 ucontrol->value.enumerated.item[0] = spec->cur_amux;
797 return 0;
798}
799
800static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
801 struct snd_ctl_elem_value *ucontrol)
802{
803 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
804 struct sigmatel_spec *spec = codec->spec;
805 struct snd_kcontrol *ctl =
806 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
807 if (!ctl)
808 return -EINVAL;
809
810 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
811 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
812
813 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
814 0, &spec->cur_amux);
815}
816
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200817#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
818
819static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
820 struct snd_ctl_elem_value *ucontrol)
821{
822 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100823 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200824 struct sigmatel_spec *spec = codec->spec;
825
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100826 ucontrol->value.integer.value[0] = !!(spec->aloopback &
827 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200828 return 0;
829}
830
831static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
832 struct snd_ctl_elem_value *ucontrol)
833{
834 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
835 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100836 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200837 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100838 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200839
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100840 idx_val = spec->aloopback_mask << idx;
841 if (ucontrol->value.integer.value[0])
842 val = spec->aloopback | idx_val;
843 else
844 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100845 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200846 return 0;
847
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100848 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200849
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100850 /* Only return the bits defined by the shift value of the
851 * first two bytes of the mask
852 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200853 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100854 kcontrol->private_value & 0xFFFF, 0x0);
855 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200856
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100857 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200858 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100859 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200860 } else {
861 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100862 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200863 }
864
865 snd_hda_codec_write_cache(codec, codec->afg, 0,
866 kcontrol->private_value >> 16, dac_mode);
867
868 return 1;
869}
870
Mattc7d4b2f2005-06-27 14:59:41 +0200871static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200872 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200873 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200874 {}
875};
876
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200877static struct hda_verb stac9200_eapd_init[] = {
878 /* set dac0mux for dac converter */
879 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
880 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
881 {}
882};
883
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100884static struct hda_verb stac92hd73xx_6ch_core_init[] = {
885 /* set master volume and direct control */
886 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100887 /* setup adcs to point to mixer */
888 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
889 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100890 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
891 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
892 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
893 /* setup import muxs */
894 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
895 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
896 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
897 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
898 {}
899};
900
Matthew Ranostayd654a662008-03-14 08:46:51 +0100901static struct hda_verb dell_eq_core_init[] = {
902 /* set master volume to max value without distortion
903 * and direct control */
904 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100905 /* setup adcs to point to mixer */
906 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
907 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
908 /* setup import muxs */
909 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
910 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
911 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
912 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
913 {}
914};
915
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100916static struct hda_verb dell_m6_core_init[] = {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -0500917 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100918 /* setup adcs to point to mixer */
919 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
920 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
921 /* setup import muxs */
922 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
923 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
924 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
925 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
926 {}
927};
928
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100929static struct hda_verb stac92hd73xx_8ch_core_init[] = {
930 /* set master volume and direct control */
931 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100932 /* setup adcs to point to mixer */
933 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
934 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100935 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
936 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
937 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
938 /* setup import muxs */
939 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
940 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
941 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
942 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
943 {}
944};
945
946static struct hda_verb stac92hd73xx_10ch_core_init[] = {
947 /* set master volume and direct control */
948 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100949 /* dac3 is connected to import3 mux */
950 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100951 /* setup adcs to point to mixer */
952 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
953 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100954 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
955 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
956 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
957 /* setup import muxs */
958 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
959 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
960 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
961 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
962 {}
963};
964
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200965static struct hda_verb stac92hd83xxx_core_init[] = {
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -0500966 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1},
967 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1},
968 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200969
970 /* power state controls amps */
971 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200972 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200973};
974
Matthew Ranostaye035b842007-11-06 11:53:55 +0100975static struct hda_verb stac92hd71bxx_core_init[] = {
976 /* set master volume and direct control */
977 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200978 {}
Matthew Ranostay541eee82007-12-14 12:08:04 +0100979};
980
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500981#define HD_DISABLE_PORTF 1
Matthew Ranostay541eee82007-12-14 12:08:04 +0100982static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200983 /* start of config #1 */
984
985 /* connect port 0f to audio mixer */
986 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200987 /* start of config #2 */
988
Matthew Ranostay541eee82007-12-14 12:08:04 +0100989 /* set master volume and direct control */
990 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500991 {}
992};
993
994static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
995 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
996 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100997 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
998 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100999 {}
1000};
1001
Tobin Davis8e21c342007-01-08 11:04:17 +01001002static struct hda_verb stac925x_core_init[] = {
1003 /* set dac0mux for dac converter */
1004 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaic9280d62009-01-15 17:31:00 +01001005 /* mute the master volume */
1006 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Tobin Davis8e21c342007-01-08 11:04:17 +01001007 {}
1008};
1009
Mattc7d4b2f2005-06-27 14:59:41 +02001010static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +02001011 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +02001012 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +02001013 {}
1014};
1015
Tobin Davis93ed1502006-09-01 21:03:12 +02001016static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +02001017 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +02001018 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +02001019 /* unmute node 0x1b */
1020 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1021 /* select node 0x03 as DAC */
1022 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
1023 {}
1024};
1025
Matt Porter3cc08dc2006-01-23 15:27:49 +01001026static struct hda_verb stac927x_core_init[] = {
1027 /* set master volume and direct control */
1028 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001029 /* enable analog pc beep path */
1030 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +01001031 {}
1032};
1033
Matt Porterf3302a592006-07-31 12:49:34 +02001034static struct hda_verb stac9205_core_init[] = {
1035 /* set master volume and direct control */
1036 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001037 /* enable analog pc beep path */
1038 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a592006-07-31 12:49:34 +02001039 {}
1040};
1041
Matthew Ranostayb22b4822008-01-22 12:32:30 +01001042#define STAC_MONO_MUX \
1043 { \
1044 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1045 .name = "Mono Mux", \
1046 .count = 1, \
1047 .info = stac92xx_mono_mux_enum_info, \
1048 .get = stac92xx_mono_mux_enum_get, \
1049 .put = stac92xx_mono_mux_enum_put, \
1050 }
1051
Matthew Ranostay89385032008-09-11 09:49:39 -04001052#define STAC_AMP_MUX \
1053 { \
1054 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1055 .name = "Amp Selector Capture Switch", \
1056 .count = 1, \
1057 .info = stac92xx_amp_mux_enum_info, \
1058 .get = stac92xx_amp_mux_enum_get, \
1059 .put = stac92xx_amp_mux_enum_put, \
1060 }
1061
1062#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
1063 { \
1064 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1065 .name = xname, \
1066 .index = 0, \
1067 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1068 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1069 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
1070 .info = stac92xx_amp_volume_info, \
1071 .get = stac92xx_amp_volume_get, \
1072 .put = stac92xx_amp_volume_put, \
1073 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
1074 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
1075 }
1076
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001077#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +02001078 { \
1079 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1080 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001081 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +02001082 .info = stac92xx_aloopback_info, \
1083 .get = stac92xx_aloopback_get, \
1084 .put = stac92xx_aloopback_put, \
1085 .private_value = verb_read | (verb_write << 16), \
1086 }
1087
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02001088#define DC_BIAS(xname, idx, nid) \
1089 { \
1090 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1091 .name = xname, \
1092 .index = idx, \
1093 .info = stac92xx_dc_bias_info, \
1094 .get = stac92xx_dc_bias_get, \
1095 .put = stac92xx_dc_bias_put, \
1096 .private_value = nid, \
1097 }
1098
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001099static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +02001100 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
1101 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001102 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
1103 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001104 { } /* end */
1105};
1106
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04001107#define DELL_M6_MIXER 6
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001108static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04001109 /* start of config #1 */
1110 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1111 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1112
1113 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1114 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1115
1116 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1117 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1118
1119 /* start of config #2 */
1120 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1121 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1122
1123 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1124 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1125
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001126 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1127 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1128
1129 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1130 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1131
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001132 { } /* end */
1133};
1134
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001135static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
1136 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1137 {}
1138};
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001139
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001140static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
1141 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1142 {}
1143};
1144
1145static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
1146 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1147 {}
1148};
1149
1150static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001151 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1152 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1153
1154 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1155 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1156
1157 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1158 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1159
1160 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1161 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1162
1163 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1164 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1165
1166 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1167 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1168
1169 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1170 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1171 { } /* end */
1172};
1173
1174static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001175 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1176 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1177
1178 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1179 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1180
1181 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1182 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1183
1184 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1185 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1186
1187 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1188 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1189
1190 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1191 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1192
1193 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1194 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1195 { } /* end */
1196};
1197
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001198
1199static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1200 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1201 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1202
1203 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1204 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1205
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001206 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT),
1207 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001208
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001209 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT),
1210 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001211
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001212 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT),
1213 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001214
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001215 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT),
1216 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001217
1218 /*
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001219 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT),
1220 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001221 */
1222 { } /* end */
1223};
1224
Matthew Ranostay541eee82007-12-14 12:08:04 +01001225static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostay9b359472007-11-07 13:03:12 +01001226 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1227 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay9b359472007-11-07 13:03:12 +01001228
1229 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1230 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001231 /* analog pc-beep replaced with digital beep support */
1232 /*
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001233 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1234 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001235 */
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001236
Matthew Ranostay687cb982008-10-11 13:52:43 -04001237 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1238 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001239
Matthew Ranostay687cb982008-10-11 13:52:43 -04001240 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1241 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001242
1243 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1244 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1245
1246 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1247 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001248 { } /* end */
1249};
1250
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001251static struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
1252 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1253};
Matthew Ranostay541eee82007-12-14 12:08:04 +01001254
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001255static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +01001256 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1257 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001258
1259 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1260 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001261 { } /* end */
1262};
1263
Tobin Davis8e21c342007-01-08 11:04:17 +01001264static struct snd_kcontrol_new stac925x_mixer[] = {
Takashi Iwaic9280d62009-01-15 17:31:00 +01001265 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
1266 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001267 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +02001268 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001269 { } /* end */
1270};
1271
Takashi Iwaid1d985f2006-11-23 19:27:12 +01001272static struct snd_kcontrol_new stac9205_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001273 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1274 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001275
1276 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1277 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001278 { } /* end */
1279};
1280
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001281static struct snd_kcontrol_new stac9205_loopback[] = {
1282 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1283 {}
1284};
1285
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001286/* This needs to be generated dynamically based on sequence */
1287static struct snd_kcontrol_new stac922x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001288 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1289 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001290
1291 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1292 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001293 { } /* end */
1294};
1295
1296
1297static struct snd_kcontrol_new stac927x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001298 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1299 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001300
1301 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1302 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001303
1304 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1305 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
Matt Porterf3302a592006-07-31 12:49:34 +02001306 { } /* end */
1307};
1308
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001309static struct snd_kcontrol_new stac927x_loopback[] = {
1310 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1311 {}
1312};
1313
Takashi Iwai16970552007-12-18 18:05:52 +01001314static struct snd_kcontrol_new stac_dmux_mixer = {
1315 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1316 .name = "Digital Input Source",
1317 /* count set later */
1318 .info = stac92xx_dmux_enum_info,
1319 .get = stac92xx_dmux_enum_get,
1320 .put = stac92xx_dmux_enum_put,
1321};
1322
Matthew Ranostayd9737752008-09-07 12:03:41 +02001323static struct snd_kcontrol_new stac_smux_mixer = {
1324 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001325 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001326 /* count set later */
1327 .info = stac92xx_smux_enum_info,
1328 .get = stac92xx_smux_enum_get,
1329 .put = stac92xx_smux_enum_put,
1330};
1331
Takashi Iwai2134ea42008-01-10 16:53:55 +01001332static const char *slave_vols[] = {
1333 "Front Playback Volume",
1334 "Surround Playback Volume",
1335 "Center Playback Volume",
1336 "LFE Playback Volume",
1337 "Side Playback Volume",
1338 "Headphone Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001339 "Speaker Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001340 NULL
1341};
1342
1343static const char *slave_sws[] = {
1344 "Front Playback Switch",
1345 "Surround Playback Switch",
1346 "Center Playback Switch",
1347 "LFE Playback Switch",
1348 "Side Playback Switch",
1349 "Headphone Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001350 "Speaker Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001351 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001352 NULL
1353};
1354
Takashi Iwai603c4012008-07-30 15:01:44 +02001355static void stac92xx_free_kctls(struct hda_codec *codec);
Takashi Iwaie4973e12008-11-18 09:32:42 +01001356static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
Takashi Iwai603c4012008-07-30 15:01:44 +02001357
Matt2f2f4252005-04-13 14:45:30 +02001358static int stac92xx_build_controls(struct hda_codec *codec)
1359{
1360 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaie4973e12008-11-18 09:32:42 +01001361 struct auto_pin_cfg *cfg = &spec->autocfg;
1362 hda_nid_t nid;
Matt2f2f4252005-04-13 14:45:30 +02001363 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001364 int i;
Matt2f2f4252005-04-13 14:45:30 +02001365
1366 err = snd_hda_add_new_ctls(codec, spec->mixer);
1367 if (err < 0)
1368 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001369
1370 for (i = 0; i < spec->num_mixers; i++) {
1371 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1372 if (err < 0)
1373 return err;
1374 }
Takashi Iwai16970552007-12-18 18:05:52 +01001375 if (spec->num_dmuxes > 0) {
1376 stac_dmux_mixer.count = spec->num_dmuxes;
Takashi Iwaid13bd412008-07-30 15:01:45 +02001377 err = snd_hda_ctl_add(codec,
Takashi Iwai16970552007-12-18 18:05:52 +01001378 snd_ctl_new1(&stac_dmux_mixer, codec));
1379 if (err < 0)
1380 return err;
1381 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001382 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001383 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1384 struct hda_input_mux *smux = &spec->private_smux;
1385 /* check for mute support on SPDIF out */
1386 if (wcaps & AC_WCAP_OUT_AMP) {
1387 smux->items[smux->num_items].label = "Off";
1388 smux->items[smux->num_items].index = 0;
1389 smux->num_items++;
1390 spec->spdif_mute = 1;
1391 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001392 stac_smux_mixer.count = spec->num_smuxes;
Takashi Iwai4f2d23e2008-12-19 10:14:13 +01001393 err = snd_hda_ctl_add(codec,
Matthew Ranostayd9737752008-09-07 12:03:41 +02001394 snd_ctl_new1(&stac_smux_mixer, codec));
1395 if (err < 0)
1396 return err;
1397 }
Mattc7d4b2f2005-06-27 14:59:41 +02001398
Mattdabbed62005-06-14 10:19:34 +02001399 if (spec->multiout.dig_out_nid) {
1400 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1401 if (err < 0)
1402 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001403 err = snd_hda_create_spdif_share_sw(codec,
1404 &spec->multiout);
1405 if (err < 0)
1406 return err;
1407 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001408 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001409 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001410 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1411 if (err < 0)
1412 return err;
1413 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001414
1415 /* if we have no master control, let's create it */
1416 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001417 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001418 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001419 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai7c7767e2009-01-20 15:28:38 +01001420 /* correct volume offset */
1421 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
Takashi Iwai2134ea42008-01-10 16:53:55 +01001422 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001423 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001424 if (err < 0)
1425 return err;
1426 }
1427 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1428 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1429 NULL, slave_sws);
1430 if (err < 0)
1431 return err;
1432 }
1433
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001434 if (spec->aloopback_ctl &&
1435 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1436 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1437 if (err < 0)
1438 return err;
1439 }
1440
Takashi Iwai603c4012008-07-30 15:01:44 +02001441 stac92xx_free_kctls(codec); /* no longer needed */
Takashi Iwaie4973e12008-11-18 09:32:42 +01001442
1443 /* create jack input elements */
1444 if (spec->hp_detect) {
1445 for (i = 0; i < cfg->hp_outs; i++) {
1446 int type = SND_JACK_HEADPHONE;
1447 nid = cfg->hp_pins[i];
1448 /* jack detection */
1449 if (cfg->hp_outs == i)
1450 type |= SND_JACK_LINEOUT;
1451 err = stac92xx_add_jack(codec, nid, type);
1452 if (err < 0)
1453 return err;
1454 }
1455 }
1456 for (i = 0; i < cfg->line_outs; i++) {
1457 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1458 SND_JACK_LINEOUT);
1459 if (err < 0)
1460 return err;
1461 }
1462 for (i = 0; i < AUTO_PIN_LAST; i++) {
1463 nid = cfg->input_pins[i];
1464 if (nid) {
1465 err = stac92xx_add_jack(codec, nid,
1466 SND_JACK_MICROPHONE);
1467 if (err < 0)
1468 return err;
1469 }
1470 }
1471
Mattdabbed62005-06-14 10:19:34 +02001472 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001473}
1474
Matt Porter403d1942005-11-29 15:00:51 +01001475static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001476 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001477 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1478};
1479
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001480static unsigned int gateway9200_m4_pin_configs[8] = {
1481 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1482 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1483};
1484static unsigned int gateway9200_m4_2_pin_configs[8] = {
1485 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1486 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1487};
1488
1489/*
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001490 STAC 9200 pin configs for
1491 102801A8
1492 102801DE
1493 102801E8
1494*/
1495static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001496 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1497 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001498};
1499
1500/*
1501 STAC 9200 pin configs for
1502 102801C0
1503 102801C1
1504*/
1505static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001506 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1507 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001508};
1509
1510/*
1511 STAC 9200 pin configs for
1512 102801C4 (Dell Dimension E310)
1513 102801C5
1514 102801C7
1515 102801D9
1516 102801DA
1517 102801E3
1518*/
1519static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001520 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1521 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001522};
1523
1524
1525/*
1526 STAC 9200-32 pin configs for
1527 102801B5 (Dell Inspiron 630m)
1528 102801D8 (Dell Inspiron 640m)
1529*/
1530static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001531 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1532 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001533};
1534
1535/*
1536 STAC 9200-32 pin configs for
1537 102801C2 (Dell Latitude D620)
1538 102801C8
1539 102801CC (Dell Latitude D820)
1540 102801D4
1541 102801D6
1542*/
1543static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001544 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1545 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001546};
1547
1548/*
1549 STAC 9200-32 pin configs for
1550 102801CE (Dell XPS M1710)
1551 102801CF (Dell Precision M90)
1552*/
1553static unsigned int dell9200_m23_pin_configs[8] = {
1554 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1555 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1556};
1557
1558/*
1559 STAC 9200-32 pin configs for
1560 102801C9
1561 102801CA
1562 102801CB (Dell Latitude 120L)
1563 102801D3
1564*/
1565static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001566 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1567 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001568};
1569
1570/*
1571 STAC 9200-32 pin configs for
1572 102801BD (Dell Inspiron E1505n)
1573 102801EE
1574 102801EF
1575*/
1576static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001577 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1578 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001579};
1580
1581/*
1582 STAC 9200-32 pin configs for
1583 102801F5 (Dell Inspiron 1501)
1584 102801F6
1585*/
1586static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001587 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1588 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001589};
1590
1591/*
1592 STAC 9200-32
1593 102801CD (Dell Inspiron E1705/9400)
1594*/
1595static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001596 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1597 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001598};
1599
Tobin Davisbf277782008-02-03 20:31:47 +01001600static unsigned int oqo9200_pin_configs[8] = {
1601 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1602 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1603};
1604
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001605
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001606static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1607 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001608 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001609 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1610 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1611 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1612 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1613 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1614 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1615 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1616 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1617 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1618 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001619 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1620 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001621 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001622};
1623
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001624static const char *stac9200_models[STAC_9200_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001625 [STAC_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001626 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001627 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001628 [STAC_9200_DELL_D21] = "dell-d21",
1629 [STAC_9200_DELL_D22] = "dell-d22",
1630 [STAC_9200_DELL_D23] = "dell-d23",
1631 [STAC_9200_DELL_M21] = "dell-m21",
1632 [STAC_9200_DELL_M22] = "dell-m22",
1633 [STAC_9200_DELL_M23] = "dell-m23",
1634 [STAC_9200_DELL_M24] = "dell-m24",
1635 [STAC_9200_DELL_M25] = "dell-m25",
1636 [STAC_9200_DELL_M26] = "dell-m26",
1637 [STAC_9200_DELL_M27] = "dell-m27",
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001638 [STAC_9200_M4] = "gateway-m4",
1639 [STAC_9200_M4_2] = "gateway-m4-2",
Takashi Iwai117f2572008-03-18 09:53:23 +01001640 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001641};
1642
1643static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1644 /* SigmaTel reference board */
1645 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1646 "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001647 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1648 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001649 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001650 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1651 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001652 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001653 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1654 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1655 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1656 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1657 "unknown Dell", STAC_9200_DELL_D22),
1658 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1659 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001660 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001661 "Dell Latitude D620", STAC_9200_DELL_M22),
1662 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1663 "unknown Dell", STAC_9200_DELL_D23),
1664 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1665 "unknown Dell", STAC_9200_DELL_D23),
1666 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1667 "unknown Dell", STAC_9200_DELL_M22),
1668 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1669 "unknown Dell", STAC_9200_DELL_M24),
1670 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1671 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001672 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001673 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001674 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001675 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001676 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001677 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001678 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001679 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001680 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001681 "Dell Precision M90", STAC_9200_DELL_M23),
1682 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1683 "unknown Dell", STAC_9200_DELL_M22),
1684 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1685 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001686 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001687 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001688 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001689 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1690 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1691 "unknown Dell", STAC_9200_DELL_D23),
1692 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1693 "unknown Dell", STAC_9200_DELL_D23),
1694 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1695 "unknown Dell", STAC_9200_DELL_D21),
1696 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1697 "unknown Dell", STAC_9200_DELL_D23),
1698 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1699 "unknown Dell", STAC_9200_DELL_D21),
1700 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1701 "unknown Dell", STAC_9200_DELL_M25),
1702 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1703 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001704 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001705 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1706 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1707 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001708 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001709 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001710 /* Gateway machines needs EAPD to be set on resume */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001711 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1712 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1713 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
Tobin Davisbf277782008-02-03 20:31:47 +01001714 /* OQO Mobile */
1715 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001716 {} /* terminator */
1717};
1718
Tobin Davis8e21c342007-01-08 11:04:17 +01001719static unsigned int ref925x_pin_configs[8] = {
1720 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001721 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001722};
1723
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001724static unsigned int stac925xM1_pin_configs[8] = {
1725 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1726 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001727};
1728
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001729static unsigned int stac925xM1_2_pin_configs[8] = {
1730 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1731 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1732};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001733
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001734static unsigned int stac925xM2_pin_configs[8] = {
1735 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1736 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis2c11f952007-05-17 09:36:34 +02001737};
1738
Tobin Davis8e21c342007-01-08 11:04:17 +01001739static unsigned int stac925xM2_2_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001740 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1741 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1742};
1743
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001744static unsigned int stac925xM3_pin_configs[8] = {
1745 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1746 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1747};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001748
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001749static unsigned int stac925xM5_pin_configs[8] = {
1750 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1751 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1752};
1753
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001754static unsigned int stac925xM6_pin_configs[8] = {
1755 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1756 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
Tobin Davis8e21c342007-01-08 11:04:17 +01001757};
1758
1759static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1760 [STAC_REF] = ref925x_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001761 [STAC_M1] = stac925xM1_pin_configs,
1762 [STAC_M1_2] = stac925xM1_2_pin_configs,
1763 [STAC_M2] = stac925xM2_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001764 [STAC_M2_2] = stac925xM2_2_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001765 [STAC_M3] = stac925xM3_pin_configs,
1766 [STAC_M5] = stac925xM5_pin_configs,
1767 [STAC_M6] = stac925xM6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001768};
1769
1770static const char *stac925x_models[STAC_925x_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001771 [STAC_925x_AUTO] = "auto",
Tobin Davis8e21c342007-01-08 11:04:17 +01001772 [STAC_REF] = "ref",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001773 [STAC_M1] = "m1",
1774 [STAC_M1_2] = "m1-2",
1775 [STAC_M2] = "m2",
Tobin Davis8e21c342007-01-08 11:04:17 +01001776 [STAC_M2_2] = "m2-2",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001777 [STAC_M3] = "m3",
1778 [STAC_M5] = "m5",
1779 [STAC_M6] = "m6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001780};
1781
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001782static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001783 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1784 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1785 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1786 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001787 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001788 /* Not sure about the brand name for those */
1789 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1790 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1791 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1792 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001793 {} /* terminator */
Tobin Davis8e21c342007-01-08 11:04:17 +01001794};
1795
1796static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1797 /* SigmaTel reference board */
1798 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001799 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001800 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001801
1802 /* Default table for unknown ID */
1803 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1804
Tobin Davis8e21c342007-01-08 11:04:17 +01001805 {} /* terminator */
1806};
1807
Matthew Ranostaya7662642008-02-21 07:51:14 +01001808static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001809 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1810 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1811 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001812 0x01452050,
1813};
1814
1815static unsigned int dell_m6_pin_configs[13] = {
1816 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001817 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001818 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1819 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001820};
1821
1822static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001823 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001824 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1825 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1826 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001827 [STAC_DELL_EQ] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001828};
1829
1830static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001831 [STAC_92HD73XX_AUTO] = "auto",
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01001832 [STAC_92HD73XX_NO_JD] = "no-jd",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001833 [STAC_92HD73XX_REF] = "ref",
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001834 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1835 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1836 [STAC_DELL_M6_BOTH] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001837 [STAC_DELL_EQ] = "dell-eq",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001838};
1839
1840static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1841 /* SigmaTel reference board */
1842 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001843 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001844 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1845 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001846 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001847 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001848 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001849 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001850 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001851 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001852 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001853 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001854 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001855 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001856 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001857 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001858 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001859 "unknown Dell", STAC_DELL_M6_DMIC),
1860 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1861 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01001862 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001863 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Joerg Schirottkefa620e92008-12-19 08:13:49 +01001864 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1865 "Dell Studio 17", STAC_DELL_M6_DMIC),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001866 {} /* terminator */
1867};
1868
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001869static unsigned int ref92hd83xxx_pin_configs[10] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001870 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1871 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001872 0x01451160, 0x98560170,
1873};
1874
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001875static unsigned int dell_s14_pin_configs[10] = {
1876 0x02214030, 0x02211010, 0x02a19020, 0x01014050,
1877 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160,
1878 0x40f000f0, 0x40f000f0,
1879};
1880
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001881static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1882 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001883 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001884 [STAC_DELL_S14] = dell_s14_pin_configs,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001885};
1886
1887static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001888 [STAC_92HD83XXX_AUTO] = "auto",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001889 [STAC_92HD83XXX_REF] = "ref",
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001890 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001891 [STAC_DELL_S14] = "dell-s14",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001892};
1893
1894static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1895 /* SigmaTel reference board */
1896 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Takashi Iwaif9d088b2009-01-13 11:54:49 +01001897 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001898 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1899 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001900 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1901 "unknown Dell", STAC_DELL_S14),
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -02001902 {} /* terminator */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001903};
1904
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001905static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001906 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001907 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001908 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1909 0x00000000
Matthew Ranostaye035b842007-11-06 11:53:55 +01001910};
1911
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001912static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001913 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001914 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001915 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1916 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001917};
1918
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001919static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001920 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1921 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001922 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1923 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001924};
1925
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001926static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001927 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1928 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001929 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1930 0x00000000
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001931};
1932
Matthew Ranostaye035b842007-11-06 11:53:55 +01001933static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1934 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001935 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1936 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001937 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001938 [STAC_HP_M4] = NULL,
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001939 [STAC_HP_DV5] = NULL,
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001940 [STAC_HP_HDX] = NULL,
James Gardiner514bf542009-05-03 04:00:44 -04001941 [STAC_HP_DV4_1222NR] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001942};
1943
1944static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001945 [STAC_92HD71BXX_AUTO] = "auto",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001946 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001947 [STAC_DELL_M4_1] = "dell-m4-1",
1948 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001949 [STAC_DELL_M4_3] = "dell-m4-3",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001950 [STAC_HP_M4] = "hp-m4",
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001951 [STAC_HP_DV5] = "hp-dv5",
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001952 [STAC_HP_HDX] = "hp-hdx",
James Gardiner514bf542009-05-03 04:00:44 -04001953 [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001954};
1955
1956static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1957 /* SigmaTel reference board */
1958 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1959 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001960 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1961 "DFI LanParty", STAC_92HD71BXX_REF),
James Gardiner514bf542009-05-03 04:00:44 -04001962 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
1963 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
Takashi Iwai58d83952009-03-13 17:04:34 +01001964 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1965 "HP", STAC_HP_DV5),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001966 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
1967 "HP dv4-7", STAC_HP_DV5),
1968 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1969 "HP dv4-7", STAC_HP_DV5),
Takashi Iwai6fce61a2009-03-10 07:48:57 +01001970 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1971 "HP HDX", STAC_HP_HDX), /* HDX18 */
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001972 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001973 "HP mini 1000", STAC_HP_M4),
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001974 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
Takashi Iwai6fce61a2009-03-10 07:48:57 +01001975 "HP HDX", STAC_HP_HDX), /* HDX16 */
Matthew Ranostaya7662642008-02-21 07:51:14 +01001976 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1977 "unknown Dell", STAC_DELL_M4_1),
1978 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1979 "unknown Dell", STAC_DELL_M4_1),
1980 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1981 "unknown Dell", STAC_DELL_M4_1),
1982 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1983 "unknown Dell", STAC_DELL_M4_1),
1984 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1985 "unknown Dell", STAC_DELL_M4_1),
1986 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1987 "unknown Dell", STAC_DELL_M4_1),
1988 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1989 "unknown Dell", STAC_DELL_M4_1),
1990 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1991 "unknown Dell", STAC_DELL_M4_2),
1992 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1993 "unknown Dell", STAC_DELL_M4_2),
1994 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1995 "unknown Dell", STAC_DELL_M4_2),
1996 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1997 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001998 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1999 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01002000 {} /* terminator */
2001};
2002
Matt Porter403d1942005-11-29 15:00:51 +01002003static unsigned int ref922x_pin_configs[10] = {
2004 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
2005 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02002006 0x40000100, 0x40000100,
2007};
2008
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002009/*
2010 STAC 922X pin configs for
2011 102801A7
2012 102801AB
2013 102801A9
2014 102801D1
2015 102801D2
2016*/
2017static unsigned int dell_922x_d81_pin_configs[10] = {
2018 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
2019 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
2020 0x01813122, 0x400001f2,
2021};
2022
2023/*
2024 STAC 922X pin configs for
2025 102801AC
2026 102801D0
2027*/
2028static unsigned int dell_922x_d82_pin_configs[10] = {
2029 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
2030 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
2031 0x01813122, 0x400001f1,
2032};
2033
2034/*
2035 STAC 922X pin configs for
2036 102801BF
2037*/
2038static unsigned int dell_922x_m81_pin_configs[10] = {
2039 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
2040 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
2041 0x40C003f1, 0x405003f0,
2042};
2043
2044/*
2045 STAC 9221 A1 pin configs for
2046 102801D7 (Dell XPS M1210)
2047*/
2048static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01002049 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
2050 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002051 0x508003f3, 0x405003f4,
2052};
2053
Matt Porter403d1942005-11-29 15:00:51 +01002054static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01002055 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01002056 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2057 0x02a19120, 0x40000100,
2058};
2059
2060static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01002061 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
2062 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01002063 0x02a19320, 0x40000100,
2064};
2065
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002066static unsigned int intel_mac_v1_pin_configs[10] = {
2067 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
2068 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01002069 0x400000fc, 0x400000fb,
2070};
2071
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002072static unsigned int intel_mac_v2_pin_configs[10] = {
2073 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
2074 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02002075 0x400000fc, 0x400000fb,
2076};
2077
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002078static unsigned int intel_mac_v3_pin_configs[10] = {
2079 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
2080 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
2081 0x400000fc, 0x400000fb,
2082};
2083
2084static unsigned int intel_mac_v4_pin_configs[10] = {
2085 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
2086 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
2087 0x400000fc, 0x400000fb,
2088};
2089
2090static unsigned int intel_mac_v5_pin_configs[10] = {
2091 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
2092 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
2093 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02002094};
2095
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002096static unsigned int ecs202_pin_configs[10] = {
2097 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
2098 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
2099 0x9037012e, 0x40e000f2,
2100};
Takashi Iwai76c08822007-06-19 12:17:42 +02002101
Takashi Iwai19039bd2006-06-28 15:52:16 +02002102static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002103 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02002104 [STAC_D945GTP3] = d945gtp3_pin_configs,
2105 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002106 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
2107 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
2108 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
2109 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
2110 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08002111 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002112 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002113 [STAC_MACMINI] = intel_mac_v3_pin_configs,
2114 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
2115 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
2116 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
2117 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
2118 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002119 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002120 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
2121 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
2122 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
2123 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01002124};
2125
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002126static const char *stac922x_models[STAC_922X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002127 [STAC_922X_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002128 [STAC_D945_REF] = "ref",
2129 [STAC_D945GTP5] = "5stack",
2130 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002131 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
2132 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
2133 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
2134 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
2135 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08002136 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002137 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002138 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01002139 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01002140 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
2141 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02002142 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02002143 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002144 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002145 [STAC_922X_DELL_D81] = "dell-d81",
2146 [STAC_922X_DELL_D82] = "dell-d82",
2147 [STAC_922X_DELL_M81] = "dell-m81",
2148 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002149};
2150
2151static struct snd_pci_quirk stac922x_cfg_tbl[] = {
2152 /* SigmaTel reference board */
2153 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2154 "DFI LanParty", STAC_D945_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002155 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2156 "DFI LanParty", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002157 /* Intel 945G based systems */
2158 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2159 "Intel D945G", STAC_D945GTP3),
2160 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2161 "Intel D945G", STAC_D945GTP3),
2162 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2163 "Intel D945G", STAC_D945GTP3),
2164 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2165 "Intel D945G", STAC_D945GTP3),
2166 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2167 "Intel D945G", STAC_D945GTP3),
2168 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2169 "Intel D945G", STAC_D945GTP3),
2170 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2171 "Intel D945G", STAC_D945GTP3),
2172 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2173 "Intel D945G", STAC_D945GTP3),
2174 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2175 "Intel D945G", STAC_D945GTP3),
2176 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2177 "Intel D945G", STAC_D945GTP3),
2178 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2179 "Intel D945G", STAC_D945GTP3),
2180 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2181 "Intel D945G", STAC_D945GTP3),
2182 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2183 "Intel D945G", STAC_D945GTP3),
2184 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2185 "Intel D945G", STAC_D945GTP3),
2186 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2187 "Intel D945G", STAC_D945GTP3),
2188 /* Intel D945G 5-stack systems */
2189 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2190 "Intel D945G", STAC_D945GTP5),
2191 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2192 "Intel D945G", STAC_D945GTP5),
2193 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2194 "Intel D945G", STAC_D945GTP5),
2195 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2196 "Intel D945G", STAC_D945GTP5),
2197 /* Intel 945P based systems */
2198 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2199 "Intel D945P", STAC_D945GTP3),
2200 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2201 "Intel D945P", STAC_D945GTP3),
2202 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2203 "Intel D945P", STAC_D945GTP3),
2204 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2205 "Intel D945P", STAC_D945GTP3),
2206 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2207 "Intel D945P", STAC_D945GTP3),
2208 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2209 "Intel D945P", STAC_D945GTP5),
Takashi Iwai8056d472009-01-23 09:09:43 +01002210 /* other intel */
2211 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2212 "Intel D945", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002213 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08002214 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002215 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08002216 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002217 /* Dell systems */
2218 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2219 "unknown Dell", STAC_922X_DELL_D81),
2220 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2221 "unknown Dell", STAC_922X_DELL_D81),
2222 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2223 "unknown Dell", STAC_922X_DELL_D81),
2224 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2225 "unknown Dell", STAC_922X_DELL_D82),
2226 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2227 "unknown Dell", STAC_922X_DELL_M81),
2228 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2229 "unknown Dell", STAC_922X_DELL_D82),
2230 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2231 "unknown Dell", STAC_922X_DELL_D81),
2232 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2233 "unknown Dell", STAC_922X_DELL_D81),
2234 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2235 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002236 /* ECS/PC Chips boards */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002237 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
Herton Ronaldo Krzesinski8663ae52009-02-08 19:50:34 -02002238 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01002239 {} /* terminator */
2240};
2241
Matt Porter3cc08dc2006-01-23 15:27:49 +01002242static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002243 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2244 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2245 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2246 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002247};
2248
Tobin Davis93ed1502006-09-01 21:03:12 +02002249static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002250 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2251 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2252 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2253 0x40000100, 0x40000100
2254};
2255
Tobin Davis93ed1502006-09-01 21:03:12 +02002256static unsigned int d965_5st_pin_configs[14] = {
2257 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2258 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2259 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2260 0x40000100, 0x40000100
2261};
2262
Tobin Davis4ff076e2007-08-07 11:48:12 +02002263static unsigned int dell_3st_pin_configs[14] = {
2264 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2265 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002266 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002267 0x40c003fc, 0x40000100
2268};
2269
Tobin Davis93ed1502006-09-01 21:03:12 +02002270static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002271 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002272 [STAC_D965_REF] = ref927x_pin_configs,
2273 [STAC_D965_3ST] = d965_3st_pin_configs,
2274 [STAC_D965_5ST] = d965_5st_pin_configs,
2275 [STAC_DELL_3ST] = dell_3st_pin_configs,
2276 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002277};
2278
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002279static const char *stac927x_models[STAC_927X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002280 [STAC_927X_AUTO] = "auto",
Takashi Iwaie28d8322008-12-17 13:48:29 +01002281 [STAC_D965_REF_NO_JD] = "ref-no-jd",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002282 [STAC_D965_REF] = "ref",
2283 [STAC_D965_3ST] = "3stack",
2284 [STAC_D965_5ST] = "5stack",
2285 [STAC_DELL_3ST] = "dell-3stack",
2286 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002287};
2288
2289static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2290 /* SigmaTel reference board */
2291 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2292 "DFI LanParty", STAC_D965_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002293 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2294 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002295 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002296 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2297 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002298 /* 965 based 3 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002299 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2300 "Intel D965", STAC_D965_3ST),
2301 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2302 "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002303 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002304 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002305 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002306 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2307 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002308 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002309 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2310 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002311 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02002312 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002313 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2314 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2315 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2316 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002317 /* 965 based 5 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002318 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2319 "Intel D965", STAC_D965_5ST),
2320 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2321 "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002322 {} /* terminator */
2323};
2324
Matt Porterf3302a592006-07-31 12:49:34 +02002325static unsigned int ref9205_pin_configs[12] = {
2326 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002327 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002328 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a592006-07-31 12:49:34 +02002329};
2330
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002331/*
2332 STAC 9205 pin configs for
2333 102801F1
2334 102801F2
2335 102801FC
2336 102801FD
2337 10280204
2338 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002339 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002340*/
2341static unsigned int dell_9205_m42_pin_configs[12] = {
2342 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2343 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2344 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2345};
2346
2347/*
2348 STAC 9205 pin configs for
2349 102801F9
2350 102801FA
2351 102801FE
2352 102801FF (Dell Precision M4300)
2353 10280206
2354 10280200
2355 10280201
2356*/
2357static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002358 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2359 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2360 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2361};
2362
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002363static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002364 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2365 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2366 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2367};
2368
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002369static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002370 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002371 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2372 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2373 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Takashi Iwaid9a42682009-01-22 17:40:18 +01002374 [STAC_9205_EAPD] = NULL,
Matt Porterf3302a592006-07-31 12:49:34 +02002375};
2376
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002377static const char *stac9205_models[STAC_9205_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002378 [STAC_9205_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002379 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002380 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002381 [STAC_9205_DELL_M43] = "dell-m43",
2382 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaid9a42682009-01-22 17:40:18 +01002383 [STAC_9205_EAPD] = "eapd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002384};
2385
2386static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2387 /* SigmaTel reference board */
2388 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2389 "DFI LanParty", STAC_9205_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002390 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2391 "DFI LanParty", STAC_9205_REF),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002392 /* Dell */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002393 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2394 "unknown Dell", STAC_9205_DELL_M42),
2395 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2396 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002397 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002398 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002399 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2400 "Dell Precision", STAC_9205_DELL_M43),
2401 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2402 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002403 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2404 "unknown Dell", STAC_9205_DELL_M42),
2405 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2406 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002407 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2408 "Dell Precision", STAC_9205_DELL_M43),
2409 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002410 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002411 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2412 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002413 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2414 "Dell Precision", STAC_9205_DELL_M43),
2415 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2416 "Dell Precision", STAC_9205_DELL_M43),
2417 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2418 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002419 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2420 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002421 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2422 "Dell Vostro 1500", STAC_9205_DELL_M42),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002423 /* Gateway */
2424 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
Matt Porterf3302a592006-07-31 12:49:34 +02002425 {} /* terminator */
2426};
2427
Takashi Iwai330ee992009-02-20 14:33:36 +01002428static void stac92xx_set_config_regs(struct hda_codec *codec,
2429 unsigned int *pincfgs)
Matt2f2f4252005-04-13 14:45:30 +02002430{
2431 int i;
2432 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002433
Takashi Iwai330ee992009-02-20 14:33:36 +01002434 if (!pincfgs)
2435 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002436
Matthew Ranostay87d48362007-07-17 11:52:24 +02002437 for (i = 0; i < spec->num_pins; i++)
Takashi Iwai330ee992009-02-20 14:33:36 +01002438 if (spec->pin_nids[i] && pincfgs[i])
2439 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2440 pincfgs[i]);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002441}
2442
Matt2f2f4252005-04-13 14:45:30 +02002443/*
2444 * Analog playback callbacks
2445 */
2446static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2447 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002448 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002449{
2450 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002451 if (spec->stream_delay)
2452 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002453 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2454 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002455}
2456
2457static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2458 struct hda_codec *codec,
2459 unsigned int stream_tag,
2460 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002461 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002462{
2463 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002464 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002465}
2466
2467static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2468 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002469 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002470{
2471 struct sigmatel_spec *spec = codec->spec;
2472 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2473}
2474
2475/*
Mattdabbed62005-06-14 10:19:34 +02002476 * Digital playback callbacks
2477 */
2478static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2479 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002480 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002481{
2482 struct sigmatel_spec *spec = codec->spec;
2483 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2484}
2485
2486static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2487 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002488 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002489{
2490 struct sigmatel_spec *spec = codec->spec;
2491 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2492}
2493
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002494static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2495 struct hda_codec *codec,
2496 unsigned int stream_tag,
2497 unsigned int format,
2498 struct snd_pcm_substream *substream)
2499{
2500 struct sigmatel_spec *spec = codec->spec;
2501 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2502 stream_tag, format, substream);
2503}
2504
Takashi Iwai9411e212009-02-13 11:32:28 +01002505static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2506 struct hda_codec *codec,
2507 struct snd_pcm_substream *substream)
2508{
2509 struct sigmatel_spec *spec = codec->spec;
2510 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2511}
2512
Mattdabbed62005-06-14 10:19:34 +02002513
2514/*
Matt2f2f4252005-04-13 14:45:30 +02002515 * Analog capture callbacks
2516 */
2517static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2518 struct hda_codec *codec,
2519 unsigned int stream_tag,
2520 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002521 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002522{
2523 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002524 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002525
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002526 if (spec->powerdown_adcs) {
2527 msleep(40);
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002528 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002529 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2530 }
2531 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002532 return 0;
2533}
2534
2535static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2536 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002537 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002538{
2539 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002540 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002541
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002542 snd_hda_codec_cleanup_stream(codec, nid);
2543 if (spec->powerdown_adcs)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002544 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002545 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002546 return 0;
2547}
2548
Mattdabbed62005-06-14 10:19:34 +02002549static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2550 .substreams = 1,
2551 .channels_min = 2,
2552 .channels_max = 2,
2553 /* NID is set in stac92xx_build_pcms */
2554 .ops = {
2555 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002556 .close = stac92xx_dig_playback_pcm_close,
Takashi Iwai9411e212009-02-13 11:32:28 +01002557 .prepare = stac92xx_dig_playback_pcm_prepare,
2558 .cleanup = stac92xx_dig_playback_pcm_cleanup
Mattdabbed62005-06-14 10:19:34 +02002559 },
2560};
2561
2562static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2563 .substreams = 1,
2564 .channels_min = 2,
2565 .channels_max = 2,
2566 /* NID is set in stac92xx_build_pcms */
2567};
2568
Matt2f2f4252005-04-13 14:45:30 +02002569static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2570 .substreams = 1,
2571 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002572 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002573 .nid = 0x02, /* NID to query formats and rates */
2574 .ops = {
2575 .open = stac92xx_playback_pcm_open,
2576 .prepare = stac92xx_playback_pcm_prepare,
2577 .cleanup = stac92xx_playback_pcm_cleanup
2578 },
2579};
2580
Matt Porter3cc08dc2006-01-23 15:27:49 +01002581static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2582 .substreams = 1,
2583 .channels_min = 2,
2584 .channels_max = 2,
2585 .nid = 0x06, /* NID to query formats and rates */
2586 .ops = {
2587 .open = stac92xx_playback_pcm_open,
2588 .prepare = stac92xx_playback_pcm_prepare,
2589 .cleanup = stac92xx_playback_pcm_cleanup
2590 },
2591};
2592
Matt2f2f4252005-04-13 14:45:30 +02002593static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002594 .channels_min = 2,
2595 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002596 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002597 .ops = {
2598 .prepare = stac92xx_capture_pcm_prepare,
2599 .cleanup = stac92xx_capture_pcm_cleanup
2600 },
2601};
2602
2603static int stac92xx_build_pcms(struct hda_codec *codec)
2604{
2605 struct sigmatel_spec *spec = codec->spec;
2606 struct hda_pcm *info = spec->pcm_rec;
2607
2608 codec->num_pcms = 1;
2609 codec->pcm_info = info;
2610
Mattc7d4b2f2005-06-27 14:59:41 +02002611 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002612 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Takashi Iwai00a602d2009-01-23 11:55:42 +01002613 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2614 spec->multiout.dac_nids[0];
Matt2f2f4252005-04-13 14:45:30 +02002615 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002616 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002617 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002618
2619 if (spec->alt_switch) {
2620 codec->num_pcms++;
2621 info++;
2622 info->name = "STAC92xx Analog Alt";
2623 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2624 }
Matt2f2f4252005-04-13 14:45:30 +02002625
Mattdabbed62005-06-14 10:19:34 +02002626 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2627 codec->num_pcms++;
2628 info++;
2629 info->name = "STAC92xx Digital";
Takashi Iwai0852d7a2009-02-11 11:35:15 +01002630 info->pcm_type = spec->autocfg.dig_out_type[0];
Mattdabbed62005-06-14 10:19:34 +02002631 if (spec->multiout.dig_out_nid) {
2632 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2633 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2634 }
2635 if (spec->dig_in_nid) {
2636 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2637 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2638 }
2639 }
2640
Matt2f2f4252005-04-13 14:45:30 +02002641 return 0;
2642}
2643
Takashi Iwaic960a032006-03-23 17:06:28 +01002644static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2645{
Takashi Iwai1327a322009-03-23 13:07:47 +01002646 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01002647 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2648 if (pincap & AC_PINCAP_VREF_100)
2649 return AC_PINCTL_VREF_100;
2650 if (pincap & AC_PINCAP_VREF_80)
2651 return AC_PINCTL_VREF_80;
2652 if (pincap & AC_PINCAP_VREF_50)
2653 return AC_PINCTL_VREF_50;
2654 if (pincap & AC_PINCAP_VREF_GRD)
2655 return AC_PINCTL_VREF_GRD;
2656 return 0;
2657}
2658
Matt Porter403d1942005-11-29 15:00:51 +01002659static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2660
2661{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002662 snd_hda_codec_write_cache(codec, nid, 0,
2663 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002664}
2665
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002666#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2667
2668static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2669 struct snd_ctl_elem_value *ucontrol)
2670{
2671 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2672 struct sigmatel_spec *spec = codec->spec;
2673
Takashi Iwaid7a89432008-11-12 09:48:04 +01002674 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002675 return 0;
2676}
2677
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002678static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
2679 unsigned char type);
2680
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002681static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2682 struct snd_ctl_elem_value *ucontrol)
2683{
2684 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2685 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002686 int nid = kcontrol->private_value;
2687
2688 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002689
2690 /* check to be sure that the ports are upto date with
2691 * switch changes
2692 */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002693 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002694
2695 return 1;
2696}
2697
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002698#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002699
2700static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2701{
2702 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2703 struct sigmatel_spec *spec = codec->spec;
2704 int io_idx = kcontrol-> private_value & 0xff;
2705
2706 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2707 return 0;
2708}
2709
2710static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2711{
2712 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2713 struct sigmatel_spec *spec = codec->spec;
2714 hda_nid_t nid = kcontrol->private_value >> 8;
2715 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002716 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002717
2718 spec->io_switch[io_idx] = val;
2719
2720 if (val)
2721 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002722 else {
2723 unsigned int pinctl = AC_PINCTL_IN_EN;
2724 if (io_idx) /* set VREF for mic */
2725 pinctl |= stac92xx_get_vref(codec, nid);
2726 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2727 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002728
2729 /* check the auto-mute again: we need to mute/unmute the speaker
2730 * appropriately according to the pin direction
2731 */
2732 if (spec->hp_detect)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002733 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
Jiang Zhe40c1d302007-11-12 13:05:16 +01002734
Matt Porter403d1942005-11-29 15:00:51 +01002735 return 1;
2736}
2737
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002738#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2739
2740static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2741 struct snd_ctl_elem_value *ucontrol)
2742{
2743 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2744 struct sigmatel_spec *spec = codec->spec;
2745
2746 ucontrol->value.integer.value[0] = spec->clfe_swap;
2747 return 0;
2748}
2749
2750static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2751 struct snd_ctl_elem_value *ucontrol)
2752{
2753 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2754 struct sigmatel_spec *spec = codec->spec;
2755 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002756 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002757
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002758 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002759 return 0;
2760
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002761 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002762
2763 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2764 spec->clfe_swap ? 0x4 : 0x0);
2765
2766 return 1;
2767}
2768
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002769#define STAC_CODEC_HP_SWITCH(xname) \
2770 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2771 .name = xname, \
2772 .index = 0, \
2773 .info = stac92xx_hp_switch_info, \
2774 .get = stac92xx_hp_switch_get, \
2775 .put = stac92xx_hp_switch_put, \
2776 }
2777
Matt Porter403d1942005-11-29 15:00:51 +01002778#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2779 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2780 .name = xname, \
2781 .index = 0, \
2782 .info = stac92xx_io_switch_info, \
2783 .get = stac92xx_io_switch_get, \
2784 .put = stac92xx_io_switch_put, \
2785 .private_value = xpval, \
2786 }
2787
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002788#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2789 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2790 .name = xname, \
2791 .index = 0, \
2792 .info = stac92xx_clfe_switch_info, \
2793 .get = stac92xx_clfe_switch_get, \
2794 .put = stac92xx_clfe_switch_put, \
2795 .private_value = xpval, \
2796 }
Matt Porter403d1942005-11-29 15:00:51 +01002797
Mattc7d4b2f2005-06-27 14:59:41 +02002798enum {
2799 STAC_CTL_WIDGET_VOL,
2800 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002801 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002802 STAC_CTL_WIDGET_AMP_MUX,
2803 STAC_CTL_WIDGET_AMP_VOL,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002804 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002805 STAC_CTL_WIDGET_IO_SWITCH,
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02002806 STAC_CTL_WIDGET_CLFE_SWITCH,
2807 STAC_CTL_WIDGET_DC_BIAS
Mattc7d4b2f2005-06-27 14:59:41 +02002808};
2809
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002810static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002811 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2812 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002813 STAC_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002814 STAC_AMP_MUX,
2815 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002816 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002817 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002818 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02002819 DC_BIAS(NULL, 0, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002820};
2821
2822/* add dynamic controls */
Takashi Iwaie3c75962009-01-23 11:57:22 +01002823static struct snd_kcontrol_new *
2824stac_control_new(struct sigmatel_spec *spec,
2825 struct snd_kcontrol_new *ktemp,
2826 const char *name)
Mattc7d4b2f2005-06-27 14:59:41 +02002827{
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002828 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002829
Takashi Iwai603c4012008-07-30 15:01:44 +02002830 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2831 knew = snd_array_new(&spec->kctls);
2832 if (!knew)
Takashi Iwaie3c75962009-01-23 11:57:22 +01002833 return NULL;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002834 *knew = *ktemp;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002835 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002836 if (!knew->name) {
2837 /* roolback */
2838 memset(knew, 0, sizeof(*knew));
2839 spec->kctls.alloced--;
2840 return NULL;
2841 }
2842 return knew;
2843}
2844
2845static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2846 struct snd_kcontrol_new *ktemp,
2847 int idx, const char *name,
2848 unsigned long val)
2849{
2850 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
2851 if (!knew)
Mattc7d4b2f2005-06-27 14:59:41 +02002852 return -ENOMEM;
Takashi Iwaie3c75962009-01-23 11:57:22 +01002853 knew->index = idx;
Mattc7d4b2f2005-06-27 14:59:41 +02002854 knew->private_value = val;
Mattc7d4b2f2005-06-27 14:59:41 +02002855 return 0;
2856}
2857
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002858static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2859 int type, int idx, const char *name,
2860 unsigned long val)
2861{
2862 return stac92xx_add_control_temp(spec,
2863 &stac92xx_control_templates[type],
2864 idx, name, val);
2865}
2866
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002867
2868/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002869static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2870 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002871{
2872 return stac92xx_add_control_idx(spec, type, 0, name, val);
2873}
2874
Takashi Iwaie3c75962009-01-23 11:57:22 +01002875static struct snd_kcontrol_new stac_input_src_temp = {
2876 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2877 .name = "Input Source",
2878 .info = stac92xx_mux_enum_info,
2879 .get = stac92xx_mux_enum_get,
2880 .put = stac92xx_mux_enum_put,
2881};
2882
2883static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2884{
2885 struct snd_kcontrol_new *knew;
2886 struct hda_input_mux *imux = &spec->private_imux;
2887
2888 if (!spec->num_adcs || imux->num_items <= 1)
2889 return 0; /* no need for input source control */
2890 knew = stac_control_new(spec, &stac_input_src_temp,
2891 stac_input_src_temp.name);
2892 if (!knew)
2893 return -ENOMEM;
2894 knew->count = spec->num_adcs;
2895 return 0;
2896}
2897
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002898/* check whether the line-input can be used as line-out */
2899static hda_nid_t check_line_out_switch(struct hda_codec *codec)
Matt Porter403d1942005-11-29 15:00:51 +01002900{
2901 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002902 struct auto_pin_cfg *cfg = &spec->autocfg;
2903 hda_nid_t nid;
2904 unsigned int pincap;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002905
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002906 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2907 return 0;
2908 nid = cfg->input_pins[AUTO_PIN_LINE];
Takashi Iwai1327a322009-03-23 13:07:47 +01002909 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002910 if (pincap & AC_PINCAP_OUT)
2911 return nid;
Matt Porter403d1942005-11-29 15:00:51 +01002912 return 0;
2913}
2914
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002915/* check whether the mic-input can be used as line-out */
2916static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2917{
2918 struct sigmatel_spec *spec = codec->spec;
2919 struct auto_pin_cfg *cfg = &spec->autocfg;
2920 unsigned int def_conf, pincap;
2921 unsigned int mic_pin;
2922
2923 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2924 return 0;
2925 mic_pin = AUTO_PIN_MIC;
2926 for (;;) {
2927 hda_nid_t nid = cfg->input_pins[mic_pin];
Takashi Iwai330ee992009-02-20 14:33:36 +01002928 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002929 /* some laptops have an internal analog microphone
2930 * which can't be used as a output */
2931 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
Takashi Iwai1327a322009-03-23 13:07:47 +01002932 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002933 if (pincap & AC_PINCAP_OUT)
2934 return nid;
2935 }
2936 if (mic_pin == AUTO_PIN_MIC)
2937 mic_pin = AUTO_PIN_FRONT_MIC;
2938 else
2939 break;
2940 }
2941 return 0;
2942}
Steve Longerbeam7b043892007-05-03 20:50:03 +02002943
2944static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2945{
2946 int i;
2947
2948 for (i = 0; i < spec->multiout.num_dacs; i++) {
2949 if (spec->multiout.dac_nids[i] == nid)
2950 return 1;
2951 }
2952
2953 return 0;
2954}
2955
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002956static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2957{
2958 int i;
2959 if (is_in_dac_nids(spec, nid))
2960 return 1;
2961 for (i = 0; i < spec->autocfg.hp_outs; i++)
2962 if (spec->hp_dacs[i] == nid)
2963 return 1;
2964 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2965 if (spec->speaker_dacs[i] == nid)
2966 return 1;
2967 return 0;
2968}
2969
2970static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2971{
2972 struct sigmatel_spec *spec = codec->spec;
2973 int j, conn_len;
2974 hda_nid_t conn[HDA_MAX_CONNECTIONS];
2975 unsigned int wcaps, wtype;
2976
2977 conn_len = snd_hda_get_connections(codec, nid, conn,
2978 HDA_MAX_CONNECTIONS);
2979 for (j = 0; j < conn_len; j++) {
Takashi Iwai14bafe32009-03-23 16:35:39 +01002980 wcaps = get_wcaps(codec, conn[j]);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002981 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2982 /* we check only analog outputs */
2983 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2984 continue;
2985 /* if this route has a free DAC, assign it */
2986 if (!check_all_dac_nids(spec, conn[j])) {
2987 if (conn_len > 1) {
2988 /* select this DAC in the pin's input mux */
2989 snd_hda_codec_write_cache(codec, nid, 0,
2990 AC_VERB_SET_CONNECT_SEL, j);
2991 }
2992 return conn[j];
2993 }
2994 }
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01002995 /* if all DACs are already assigned, connect to the primary DAC */
2996 if (conn_len > 1) {
2997 for (j = 0; j < conn_len; j++) {
2998 if (conn[j] == spec->multiout.dac_nids[0]) {
2999 snd_hda_codec_write_cache(codec, nid, 0,
3000 AC_VERB_SET_CONNECT_SEL, j);
3001 break;
3002 }
3003 }
3004 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003005 return 0;
3006}
3007
3008static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3009static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3010
Matt Porter3cc08dc2006-01-23 15:27:49 +01003011/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02003012 * Fill in the dac_nids table from the parsed pin configuration
3013 * This function only works when every pin in line_out_pins[]
3014 * contains atleast one DAC in its connection list. Some 92xx
3015 * codecs are not connected directly to a DAC, such as the 9200
3016 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01003017 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003018static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02003019{
3020 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003021 struct auto_pin_cfg *cfg = &spec->autocfg;
3022 int i;
3023 hda_nid_t nid, dac;
Steve Longerbeam7b043892007-05-03 20:50:03 +02003024
Mattc7d4b2f2005-06-27 14:59:41 +02003025 for (i = 0; i < cfg->line_outs; i++) {
3026 nid = cfg->line_out_pins[i];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003027 dac = get_unassigned_dac(codec, nid);
3028 if (!dac) {
Takashi Iwaidf802952007-07-02 19:18:00 +02003029 if (spec->multiout.num_dacs > 0) {
3030 /* we have already working output pins,
3031 * so let's drop the broken ones again
3032 */
3033 cfg->line_outs = spec->multiout.num_dacs;
3034 break;
3035 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02003036 /* error out, no available DAC found */
3037 snd_printk(KERN_ERR
3038 "%s: No available DAC for pin 0x%x\n",
3039 __func__, nid);
3040 return -ENODEV;
3041 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003042 add_spec_dacs(spec, dac);
3043 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02003044
Takashi Iwai139e0712009-03-06 12:10:41 +01003045 for (i = 0; i < cfg->hp_outs; i++) {
3046 nid = cfg->hp_pins[i];
3047 dac = get_unassigned_dac(codec, nid);
3048 if (dac) {
3049 if (!spec->multiout.hp_nid)
3050 spec->multiout.hp_nid = dac;
3051 else
3052 add_spec_extra_dacs(spec, dac);
3053 }
3054 spec->hp_dacs[i] = dac;
3055 }
3056
3057 for (i = 0; i < cfg->speaker_outs; i++) {
3058 nid = cfg->speaker_pins[i];
3059 dac = get_unassigned_dac(codec, nid);
3060 if (dac)
3061 add_spec_extra_dacs(spec, dac);
3062 spec->speaker_dacs[i] = dac;
3063 }
3064
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003065 /* add line-in as output */
3066 nid = check_line_out_switch(codec);
3067 if (nid) {
3068 dac = get_unassigned_dac(codec, nid);
3069 if (dac) {
3070 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
3071 nid, cfg->line_outs);
3072 cfg->line_out_pins[cfg->line_outs] = nid;
3073 cfg->line_outs++;
3074 spec->line_switch = nid;
3075 add_spec_dacs(spec, dac);
3076 }
3077 }
3078 /* add mic as output */
3079 nid = check_mic_out_switch(codec);
3080 if (nid) {
3081 dac = get_unassigned_dac(codec, nid);
3082 if (dac) {
3083 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
3084 nid, cfg->line_outs);
3085 cfg->line_out_pins[cfg->line_outs] = nid;
3086 cfg->line_outs++;
3087 spec->mic_switch = nid;
3088 add_spec_dacs(spec, dac);
Steve Longerbeam7b043892007-05-03 20:50:03 +02003089 }
Mattc7d4b2f2005-06-27 14:59:41 +02003090 }
3091
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003092 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
Steve Longerbeam7b043892007-05-03 20:50:03 +02003093 spec->multiout.num_dacs,
3094 spec->multiout.dac_nids[0],
3095 spec->multiout.dac_nids[1],
3096 spec->multiout.dac_nids[2],
3097 spec->multiout.dac_nids[3],
3098 spec->multiout.dac_nids[4]);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003099
Mattc7d4b2f2005-06-27 14:59:41 +02003100 return 0;
3101}
3102
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003103/* create volume control/switch for the given prefx type */
Takashi Iwai668b9652009-03-06 10:13:24 +01003104static int create_controls_idx(struct hda_codec *codec, const char *pfx,
3105 int idx, hda_nid_t nid, int chs)
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003106{
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003107 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003108 char name[32];
3109 int err;
3110
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003111 if (!spec->check_volume_offset) {
3112 unsigned int caps, step, nums, db_scale;
3113 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3114 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3115 AC_AMPCAP_STEP_SIZE_SHIFT;
3116 step = (step + 1) * 25; /* in .01dB unit */
3117 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3118 AC_AMPCAP_NUM_STEPS_SHIFT;
3119 db_scale = nums * step;
3120 /* if dB scale is over -64dB, and finer enough,
3121 * let's reduce it to half
3122 */
3123 if (db_scale > 6400 && nums >= 0x1f)
3124 spec->volume_offset = nums / 2;
3125 spec->check_volume_offset = 1;
3126 }
3127
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003128 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01003129 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003130 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3131 spec->volume_offset));
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003132 if (err < 0)
3133 return err;
3134 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01003135 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003136 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3137 if (err < 0)
3138 return err;
3139 return 0;
3140}
3141
Takashi Iwai668b9652009-03-06 10:13:24 +01003142#define create_controls(codec, pfx, nid, chs) \
3143 create_controls_idx(codec, pfx, 0, nid, chs)
3144
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003145static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3146{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003147 if (spec->multiout.num_dacs > 4) {
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003148 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3149 return 1;
3150 } else {
3151 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
3152 spec->multiout.num_dacs++;
3153 }
3154 return 0;
3155}
3156
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003157static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003158{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003159 int i;
3160 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3161 if (!spec->multiout.extra_out_nid[i]) {
3162 spec->multiout.extra_out_nid[i] = nid;
3163 return 0;
3164 }
3165 }
3166 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3167 return 1;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003168}
3169
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003170/* Create output controls
3171 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3172 */
3173static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3174 const hda_nid_t *pins,
3175 const hda_nid_t *dac_nids,
3176 int type)
Mattc7d4b2f2005-06-27 14:59:41 +02003177{
Takashi Iwai76624532008-12-19 10:09:47 +01003178 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003179 static const char *chname[4] = {
3180 "Front", "Surround", NULL /*CLFE*/, "Side"
3181 };
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003182 hda_nid_t nid;
Takashi Iwai91589232008-12-19 15:59:40 +01003183 int i, err;
3184 unsigned int wid_caps;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003185
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003186 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
Takashi Iwaiffd0e562009-04-16 12:20:24 +02003187 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
3188 wid_caps = get_wcaps(codec, pins[i]);
3189 if (wid_caps & AC_WCAP_UNSOL_CAP)
3190 spec->hp_detect = 1;
3191 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003192 nid = dac_nids[i];
3193 if (!nid)
3194 continue;
3195 if (type != AUTO_PIN_HP_OUT && i == 2) {
Mattc7d4b2f2005-06-27 14:59:41 +02003196 /* Center/LFE */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003197 err = create_controls(codec, "Center", nid, 1);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003198 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003199 return err;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003200 err = create_controls(codec, "LFE", nid, 2);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003201 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003202 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003203
3204 wid_caps = get_wcaps(codec, nid);
3205
3206 if (wid_caps & AC_WCAP_LR_SWAP) {
3207 err = stac92xx_add_control(spec,
3208 STAC_CTL_WIDGET_CLFE_SWITCH,
3209 "Swap Center/LFE Playback Switch", nid);
3210
3211 if (err < 0)
3212 return err;
3213 }
3214
Mattc7d4b2f2005-06-27 14:59:41 +02003215 } else {
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003216 const char *name;
Takashi Iwai668b9652009-03-06 10:13:24 +01003217 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003218 switch (type) {
3219 case AUTO_PIN_HP_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01003220 name = "Headphone";
3221 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003222 break;
3223 case AUTO_PIN_SPEAKER_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01003224 name = "Speaker";
3225 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003226 break;
3227 default:
3228 name = chname[i];
Takashi Iwai668b9652009-03-06 10:13:24 +01003229 idx = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003230 break;
Takashi Iwai76624532008-12-19 10:09:47 +01003231 }
Takashi Iwai668b9652009-03-06 10:13:24 +01003232 err = create_controls_idx(codec, name, idx, nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003233 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003234 return err;
3235 }
3236 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003237 return 0;
3238}
3239
3240/* add playback controls from the parsed DAC table */
3241static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3242 const struct auto_pin_cfg *cfg)
3243{
3244 struct sigmatel_spec *spec = codec->spec;
3245 int err;
3246
3247 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3248 spec->multiout.dac_nids,
3249 cfg->line_out_type);
3250 if (err < 0)
3251 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003252
Takashi Iwaia9cb5c92008-11-24 07:51:11 +01003253 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003254 err = stac92xx_add_control(spec,
3255 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01003256 "Headphone as Line Out Switch",
3257 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003258 if (err < 0)
3259 return err;
3260 }
3261
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003262 if (spec->line_switch) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003263 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
3264 "Line In as Output Switch",
3265 spec->line_switch << 8);
3266 if (err < 0)
3267 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003268 }
Matt Porter403d1942005-11-29 15:00:51 +01003269
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003270 if (spec->mic_switch) {
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02003271 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_DC_BIAS,
3272 "Mic Jack Mode",
3273 spec->mic_switch);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003274 if (err < 0)
3275 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003276 }
Matt Porter403d1942005-11-29 15:00:51 +01003277
Mattc7d4b2f2005-06-27 14:59:41 +02003278 return 0;
3279}
3280
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003281/* add playback controls for Speaker and HP outputs */
3282static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3283 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003284{
3285 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003286 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02003287
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003288 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3289 spec->hp_dacs, AUTO_PIN_HP_OUT);
3290 if (err < 0)
3291 return err;
3292
3293 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3294 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3295 if (err < 0)
3296 return err;
3297
Mattc7d4b2f2005-06-27 14:59:41 +02003298 return 0;
3299}
3300
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003301/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003302static const char *stac92xx_mono_labels[4] = {
3303 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003304};
3305
3306/* create mono mux for mono out on capable codecs */
3307static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3308{
3309 struct sigmatel_spec *spec = codec->spec;
3310 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3311 int i, num_cons;
3312 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3313
3314 num_cons = snd_hda_get_connections(codec,
3315 spec->mono_nid,
3316 con_lst,
3317 HDA_MAX_NUM_INPUTS);
3318 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3319 return -EINVAL;
3320
3321 for (i = 0; i < num_cons; i++) {
3322 mono_mux->items[mono_mux->num_items].label =
3323 stac92xx_mono_labels[i];
3324 mono_mux->items[mono_mux->num_items].index = i;
3325 mono_mux->num_items++;
3326 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003327
3328 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3329 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003330}
3331
Matthew Ranostay89385032008-09-11 09:49:39 -04003332/* labels for amp mux outputs */
3333static const char *stac92xx_amp_labels[3] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04003334 "Front Microphone", "Microphone", "Line In",
Matthew Ranostay89385032008-09-11 09:49:39 -04003335};
3336
3337/* create amp out controls mux on capable codecs */
3338static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3339{
3340 struct sigmatel_spec *spec = codec->spec;
3341 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3342 int i, err;
3343
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003344 for (i = 0; i < spec->num_amps; i++) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003345 amp_mux->items[amp_mux->num_items].label =
3346 stac92xx_amp_labels[i];
3347 amp_mux->items[amp_mux->num_items].index = i;
3348 amp_mux->num_items++;
3349 }
3350
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003351 if (spec->num_amps > 1) {
3352 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3353 "Amp Selector Capture Switch", 0);
3354 if (err < 0)
3355 return err;
3356 }
Matthew Ranostay89385032008-09-11 09:49:39 -04003357 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3358 "Amp Capture Volume",
3359 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3360}
3361
3362
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003363/* create PC beep volume controls */
3364static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3365 hda_nid_t nid)
3366{
3367 struct sigmatel_spec *spec = codec->spec;
3368 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3369 int err;
3370
3371 /* check for mute support for the the amp */
3372 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3373 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3374 "PC Beep Playback Switch",
3375 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3376 if (err < 0)
3377 return err;
3378 }
3379
3380 /* check to see if there is volume support for the amp */
3381 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3382 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3383 "PC Beep Playback Volume",
3384 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3385 if (err < 0)
3386 return err;
3387 }
3388 return 0;
3389}
3390
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003391#ifdef CONFIG_SND_HDA_INPUT_BEEP
3392#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3393
3394static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3395 struct snd_ctl_elem_value *ucontrol)
3396{
3397 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3398 ucontrol->value.integer.value[0] = codec->beep->enabled;
3399 return 0;
3400}
3401
3402static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3403 struct snd_ctl_elem_value *ucontrol)
3404{
3405 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3406 int enabled = !!ucontrol->value.integer.value[0];
3407 if (codec->beep->enabled != enabled) {
3408 codec->beep->enabled = enabled;
3409 return 1;
3410 }
3411 return 0;
3412}
3413
3414static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3415 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3416 .info = stac92xx_dig_beep_switch_info,
3417 .get = stac92xx_dig_beep_switch_get,
3418 .put = stac92xx_dig_beep_switch_put,
3419};
3420
3421static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3422{
3423 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3424 0, "PC Beep Playback Switch", 0);
3425}
3426#endif
3427
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003428static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3429{
3430 struct sigmatel_spec *spec = codec->spec;
3431 int wcaps, nid, i, err = 0;
3432
3433 for (i = 0; i < spec->num_muxes; i++) {
3434 nid = spec->mux_nids[i];
3435 wcaps = get_wcaps(codec, nid);
3436
3437 if (wcaps & AC_WCAP_OUT_AMP) {
3438 err = stac92xx_add_control_idx(spec,
3439 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3440 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3441 if (err < 0)
3442 return err;
3443 }
3444 }
3445 return 0;
3446};
3447
Matthew Ranostayd9737752008-09-07 12:03:41 +02003448static const char *stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003449 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003450};
3451
3452static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3453{
3454 struct sigmatel_spec *spec = codec->spec;
3455 struct hda_input_mux *spdif_mux = &spec->private_smux;
Matthew Ranostay65973632008-09-16 10:39:37 -04003456 const char **labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003457 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003458 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003459
3460 num_cons = snd_hda_get_connections(codec,
3461 spec->smux_nids[0],
3462 con_lst,
3463 HDA_MAX_NUM_INPUTS);
Matthew Ranostay65973632008-09-16 10:39:37 -04003464 if (!num_cons)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003465 return -EINVAL;
3466
Matthew Ranostay65973632008-09-16 10:39:37 -04003467 if (!labels)
3468 labels = stac92xx_spdif_labels;
3469
Matthew Ranostayd9737752008-09-07 12:03:41 +02003470 for (i = 0; i < num_cons; i++) {
Matthew Ranostay65973632008-09-16 10:39:37 -04003471 spdif_mux->items[spdif_mux->num_items].label = labels[i];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003472 spdif_mux->items[spdif_mux->num_items].index = i;
3473 spdif_mux->num_items++;
3474 }
3475
3476 return 0;
3477}
3478
Matt Porter8b657272006-10-26 17:12:59 +02003479/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003480static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003481 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3482 "Digital Mic 3", "Digital Mic 4"
3483};
3484
3485/* create playback/capture controls for input pins on dmic capable codecs */
3486static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3487 const struct auto_pin_cfg *cfg)
3488{
3489 struct sigmatel_spec *spec = codec->spec;
3490 struct hda_input_mux *dimux = &spec->private_dimux;
3491 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003492 int err, i, j;
3493 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02003494
3495 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3496 dimux->items[dimux->num_items].index = 0;
3497 dimux->num_items++;
3498
3499 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003500 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003501 int index;
3502 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003503 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02003504 unsigned int def_conf;
3505
Takashi Iwai330ee992009-02-20 14:33:36 +01003506 def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
Matt Porter8b657272006-10-26 17:12:59 +02003507 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3508 continue;
3509
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003510 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02003511 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003512 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02003513 con_lst,
3514 HDA_MAX_NUM_INPUTS);
3515 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003516 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02003517 index = j;
3518 goto found;
3519 }
3520 continue;
3521found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003522 wcaps = get_wcaps(codec, nid) &
3523 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003524
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003525 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003526 sprintf(name, "%s Capture Volume",
3527 stac92xx_dmic_labels[dimux->num_items]);
3528
3529 err = stac92xx_add_control(spec,
3530 STAC_CTL_WIDGET_VOL,
3531 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003532 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3533 (wcaps & AC_WCAP_OUT_AMP) ?
3534 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003535 if (err < 0)
3536 return err;
3537 }
3538
Matt Porter8b657272006-10-26 17:12:59 +02003539 dimux->items[dimux->num_items].label =
3540 stac92xx_dmic_labels[dimux->num_items];
3541 dimux->items[dimux->num_items].index = index;
3542 dimux->num_items++;
3543 }
3544
3545 return 0;
3546}
3547
Mattc7d4b2f2005-06-27 14:59:41 +02003548/* create playback/capture controls for input pins */
3549static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3550{
3551 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003552 struct hda_input_mux *imux = &spec->private_imux;
3553 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3554 int i, j, k;
3555
3556 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003557 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02003558
Takashi Iwai314634b2006-09-21 11:56:18 +02003559 if (!cfg->input_pins[i])
3560 continue;
3561 index = -1;
3562 for (j = 0; j < spec->num_muxes; j++) {
3563 int num_cons;
3564 num_cons = snd_hda_get_connections(codec,
3565 spec->mux_nids[j],
3566 con_lst,
3567 HDA_MAX_NUM_INPUTS);
3568 for (k = 0; k < num_cons; k++)
3569 if (con_lst[k] == cfg->input_pins[i]) {
3570 index = k;
3571 goto found;
3572 }
Mattc7d4b2f2005-06-27 14:59:41 +02003573 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003574 continue;
3575 found:
3576 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3577 imux->items[imux->num_items].index = index;
3578 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003579 }
3580
Steve Longerbeam7b043892007-05-03 20:50:03 +02003581 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003582 /*
3583 * Set the current input for the muxes.
3584 * The STAC9221 has two input muxes with identical source
3585 * NID lists. Hopefully this won't get confused.
3586 */
3587 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003588 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3589 AC_VERB_SET_CONNECT_SEL,
3590 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003591 }
3592 }
3593
Mattc7d4b2f2005-06-27 14:59:41 +02003594 return 0;
3595}
3596
Mattc7d4b2f2005-06-27 14:59:41 +02003597static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3598{
3599 struct sigmatel_spec *spec = codec->spec;
3600 int i;
3601
3602 for (i = 0; i < spec->autocfg.line_outs; i++) {
3603 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3604 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3605 }
3606}
3607
3608static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3609{
3610 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003611 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003612
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003613 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3614 hda_nid_t pin;
3615 pin = spec->autocfg.hp_pins[i];
3616 if (pin) /* connect to front */
3617 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3618 }
3619 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3620 hda_nid_t pin;
3621 pin = spec->autocfg.speaker_pins[i];
3622 if (pin) /* connect to front */
3623 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3624 }
Mattc7d4b2f2005-06-27 14:59:41 +02003625}
3626
Matt Porter3cc08dc2006-01-23 15:27:49 +01003627static 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 +02003628{
3629 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003630 int hp_swap = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003631 int err;
3632
Matt Porter8b657272006-10-26 17:12:59 +02003633 if ((err = snd_hda_parse_pin_def_config(codec,
3634 &spec->autocfg,
3635 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003636 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003637 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003638 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003639
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003640 /* If we have no real line-out pin and multiple hp-outs, HPs should
3641 * be set up as multi-channel outputs.
3642 */
3643 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3644 spec->autocfg.hp_outs > 1) {
3645 /* Copy hp_outs to line_outs, backup line_outs in
3646 * speaker_outs so that the following routines can handle
3647 * HP pins as primary outputs.
3648 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003649 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003650 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3651 sizeof(spec->autocfg.line_out_pins));
3652 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3653 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3654 sizeof(spec->autocfg.hp_pins));
3655 spec->autocfg.line_outs = spec->autocfg.hp_outs;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003656 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3657 spec->autocfg.hp_outs = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003658 hp_swap = 1;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003659 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003660 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003661 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3662 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003663 u32 caps = query_amp_caps(codec,
3664 spec->autocfg.mono_out_pin, dir);
3665 hda_nid_t conn_list[1];
3666
3667 /* get the mixer node and then the mono mux if it exists */
3668 if (snd_hda_get_connections(codec,
3669 spec->autocfg.mono_out_pin, conn_list, 1) &&
3670 snd_hda_get_connections(codec, conn_list[0],
3671 conn_list, 1)) {
3672
3673 int wcaps = get_wcaps(codec, conn_list[0]);
3674 int wid_type = (wcaps & AC_WCAP_TYPE)
3675 >> AC_WCAP_TYPE_SHIFT;
3676 /* LR swap check, some stac925x have a mux that
3677 * changes the DACs output path instead of the
3678 * mono-mux path.
3679 */
3680 if (wid_type == AC_WID_AUD_SEL &&
3681 !(wcaps & AC_WCAP_LR_SWAP))
3682 spec->mono_nid = conn_list[0];
3683 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003684 if (dir) {
3685 hda_nid_t nid = spec->autocfg.mono_out_pin;
3686
3687 /* most mono outs have a least a mute/unmute switch */
3688 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3689 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3690 "Mono Playback Switch",
3691 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003692 if (err < 0)
3693 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003694 /* check for volume support for the amp */
3695 if ((caps & AC_AMPCAP_NUM_STEPS)
3696 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3697 err = stac92xx_add_control(spec,
3698 STAC_CTL_WIDGET_VOL,
3699 "Mono Playback Volume",
3700 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3701 if (err < 0)
3702 return err;
3703 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003704 }
3705
3706 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3707 AC_PINCTL_OUT_EN);
3708 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003709
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003710 if (!spec->multiout.num_dacs) {
3711 err = stac92xx_auto_fill_dac_nids(codec);
3712 if (err < 0)
Takashi Iwai19039bd2006-06-28 15:52:16 +02003713 return err;
Takashi Iwaic9280d62009-01-15 17:31:00 +01003714 err = stac92xx_auto_create_multi_out_ctls(codec,
3715 &spec->autocfg);
3716 if (err < 0)
3717 return err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003718 }
Mattc7d4b2f2005-06-27 14:59:41 +02003719
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003720 /* setup analog beep controls */
3721 if (spec->anabeep_nid > 0) {
3722 err = stac92xx_auto_create_beep_ctls(codec,
3723 spec->anabeep_nid);
3724 if (err < 0)
3725 return err;
3726 }
3727
3728 /* setup digital beep controls and input device */
3729#ifdef CONFIG_SND_HDA_INPUT_BEEP
3730 if (spec->digbeep_nid > 0) {
3731 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003732 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003733
3734 err = stac92xx_auto_create_beep_ctls(codec, nid);
3735 if (err < 0)
3736 return err;
3737 err = snd_hda_attach_beep_device(codec, nid);
3738 if (err < 0)
3739 return err;
Takashi Iwaifa797962009-05-19 12:50:04 +02003740 /* IDT/STAC codecs have linear beep tone parameter */
3741 codec->beep->linear_tone = 1;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003742 /* if no beep switch is available, make its own one */
3743 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3744 if (codec->beep &&
3745 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3746 err = stac92xx_beep_switch_ctl(codec);
3747 if (err < 0)
3748 return err;
3749 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003750 }
3751#endif
3752
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003753 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003754 if (err < 0)
3755 return err;
3756
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003757 /* All output parsing done, now restore the swapped hp pins */
3758 if (hp_swap) {
3759 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3760 sizeof(spec->autocfg.hp_pins));
3761 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3762 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3763 spec->autocfg.line_outs = 0;
3764 }
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003765
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003766 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003767 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003768 return err;
3769
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003770 if (spec->mono_nid > 0) {
3771 err = stac92xx_auto_create_mono_output_ctls(codec);
3772 if (err < 0)
3773 return err;
3774 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003775 if (spec->num_amps > 0) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003776 err = stac92xx_auto_create_amp_output_ctls(codec);
3777 if (err < 0)
3778 return err;
3779 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003780 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003781 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3782 &spec->autocfg)) < 0)
3783 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003784 if (spec->num_muxes > 0) {
3785 err = stac92xx_auto_create_mux_input_ctls(codec);
3786 if (err < 0)
3787 return err;
3788 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003789 if (spec->num_smuxes > 0) {
3790 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3791 if (err < 0)
3792 return err;
3793 }
Matt Porter8b657272006-10-26 17:12:59 +02003794
Takashi Iwaie3c75962009-01-23 11:57:22 +01003795 err = stac92xx_add_input_source(spec);
3796 if (err < 0)
3797 return err;
3798
Mattc7d4b2f2005-06-27 14:59:41 +02003799 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003800 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003801 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003802
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003803 if (spec->autocfg.dig_outs)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003804 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003805 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003806 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003807
Takashi Iwai603c4012008-07-30 15:01:44 +02003808 if (spec->kctls.list)
3809 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003810
3811 spec->input_mux = &spec->private_imux;
Matthew Ranostayf8ccbf62008-12-20 17:36:28 -05003812 if (!spec->dinput_mux)
3813 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003814 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003815 spec->mono_mux = &spec->private_mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -04003816 spec->amp_mux = &spec->private_amp_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003817 return 1;
3818}
3819
Takashi Iwai82bc9552006-03-21 11:24:42 +01003820/* add playback controls for HP output */
3821static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3822 struct auto_pin_cfg *cfg)
3823{
3824 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003825 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003826 unsigned int wid_caps;
3827
3828 if (! pin)
3829 return 0;
3830
3831 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003832 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003833 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003834
3835 return 0;
3836}
3837
Richard Fish160ea0d2006-09-06 13:58:25 +02003838/* add playback controls for LFE output */
3839static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3840 struct auto_pin_cfg *cfg)
3841{
3842 struct sigmatel_spec *spec = codec->spec;
3843 int err;
3844 hda_nid_t lfe_pin = 0x0;
3845 int i;
3846
3847 /*
3848 * search speaker outs and line outs for a mono speaker pin
3849 * with an amp. If one is found, add LFE controls
3850 * for it.
3851 */
3852 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3853 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003854 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003855 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3856 if (wcaps == AC_WCAP_OUT_AMP)
3857 /* found a mono speaker with an amp, must be lfe */
3858 lfe_pin = pin;
3859 }
3860
3861 /* if speaker_outs is 0, then speakers may be in line_outs */
3862 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3863 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3864 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003865 unsigned int defcfg;
Takashi Iwai330ee992009-02-20 14:33:36 +01003866 defcfg = snd_hda_codec_get_pincfg(codec, pin);
Harvey Harrison8b551782008-02-29 11:56:48 +01003867 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003868 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003869 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3870 if (wcaps == AC_WCAP_OUT_AMP)
3871 /* found a mono speaker with an amp,
3872 must be lfe */
3873 lfe_pin = pin;
3874 }
3875 }
3876 }
3877
3878 if (lfe_pin) {
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003879 err = create_controls(codec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003880 if (err < 0)
3881 return err;
3882 }
3883
3884 return 0;
3885}
3886
Mattc7d4b2f2005-06-27 14:59:41 +02003887static int stac9200_parse_auto_config(struct hda_codec *codec)
3888{
3889 struct sigmatel_spec *spec = codec->spec;
3890 int err;
3891
Kailang Yangdf694da2005-12-05 19:42:22 +01003892 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003893 return err;
3894
3895 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3896 return err;
3897
Takashi Iwai82bc9552006-03-21 11:24:42 +01003898 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3899 return err;
3900
Richard Fish160ea0d2006-09-06 13:58:25 +02003901 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3902 return err;
3903
Takashi Iwai355a0ec2008-11-11 16:46:19 +01003904 if (spec->num_muxes > 0) {
3905 err = stac92xx_auto_create_mux_input_ctls(codec);
3906 if (err < 0)
3907 return err;
3908 }
3909
Takashi Iwaie3c75962009-01-23 11:57:22 +01003910 err = stac92xx_add_input_source(spec);
3911 if (err < 0)
3912 return err;
3913
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003914 if (spec->autocfg.dig_outs)
Mattc7d4b2f2005-06-27 14:59:41 +02003915 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003916 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003917 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003918
Takashi Iwai603c4012008-07-30 15:01:44 +02003919 if (spec->kctls.list)
3920 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003921
3922 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003923 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003924
3925 return 1;
3926}
3927
Sam Revitch62fe78e2006-05-10 15:09:17 +02003928/*
3929 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3930 * funky external mute control using GPIO pins.
3931 */
3932
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003933static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003934 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003935{
3936 unsigned int gpiostate, gpiomask, gpiodir;
3937
3938 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3939 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003940 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003941
3942 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3943 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003944 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003945
3946 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3947 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003948 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003949
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003950 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003951 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3952
3953 snd_hda_codec_write(codec, codec->afg, 0,
3954 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003955 snd_hda_codec_read(codec, codec->afg, 0,
3956 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003957
3958 msleep(1);
3959
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003960 snd_hda_codec_read(codec, codec->afg, 0,
3961 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003962}
3963
Takashi Iwai95c09092009-04-14 16:15:29 +02003964#ifdef CONFIG_SND_JACK
3965static void stac92xx_free_jack_priv(struct snd_jack *jack)
3966{
3967 struct sigmatel_jack *jacks = jack->private_data;
3968 jacks->nid = 0;
3969 jacks->jack = NULL;
3970}
3971#endif
3972
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003973static int stac92xx_add_jack(struct hda_codec *codec,
3974 hda_nid_t nid, int type)
3975{
Takashi Iwaie4973e12008-11-18 09:32:42 +01003976#ifdef CONFIG_SND_JACK
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003977 struct sigmatel_spec *spec = codec->spec;
3978 struct sigmatel_jack *jack;
Takashi Iwai330ee992009-02-20 14:33:36 +01003979 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003980 int connectivity = get_defcfg_connect(def_conf);
3981 char name[32];
Takashi Iwai95c09092009-04-14 16:15:29 +02003982 int err;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003983
3984 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
3985 return 0;
3986
3987 snd_array_init(&spec->jacks, sizeof(*jack), 32);
3988 jack = snd_array_new(&spec->jacks);
3989 if (!jack)
3990 return -ENOMEM;
3991 jack->nid = nid;
3992 jack->type = type;
3993
3994 sprintf(name, "%s at %s %s Jack",
3995 snd_hda_get_jack_type(def_conf),
3996 snd_hda_get_jack_connectivity(def_conf),
3997 snd_hda_get_jack_location(def_conf));
3998
Takashi Iwai95c09092009-04-14 16:15:29 +02003999 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
4000 if (err < 0) {
4001 jack->nid = 0;
4002 return err;
4003 }
4004 jack->jack->private_data = jack;
4005 jack->jack->private_free = stac92xx_free_jack_priv;
Takashi Iwaie4973e12008-11-18 09:32:42 +01004006#endif
Takashi Iwai95c09092009-04-14 16:15:29 +02004007 return 0;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004008}
4009
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004010static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
4011 unsigned char type, int data)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004012{
4013 struct sigmatel_event *event;
4014
4015 snd_array_init(&spec->events, sizeof(*event), 32);
4016 event = snd_array_new(&spec->events);
4017 if (!event)
4018 return -ENOMEM;
4019 event->nid = nid;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004020 event->type = type;
4021 event->tag = spec->events.used;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004022 event->data = data;
4023
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004024 return event->tag;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004025}
4026
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004027static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
4028 hda_nid_t nid, unsigned char type)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004029{
4030 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004031 struct sigmatel_event *event = spec->events.list;
4032 int i;
4033
4034 for (i = 0; i < spec->events.used; i++, event++) {
4035 if (event->nid == nid && event->type == type)
4036 return event;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004037 }
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004038 return NULL;
4039}
4040
4041static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
4042 unsigned char tag)
4043{
4044 struct sigmatel_spec *spec = codec->spec;
4045 struct sigmatel_event *event = spec->events.list;
4046 int i;
4047
4048 for (i = 0; i < spec->events.used; i++, event++) {
4049 if (event->tag == tag)
4050 return event;
4051 }
4052 return NULL;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004053}
4054
Takashi Iwai314634b2006-09-21 11:56:18 +02004055static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004056 unsigned int type)
Takashi Iwai314634b2006-09-21 11:56:18 +02004057{
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004058 struct sigmatel_event *event;
4059 int tag;
4060
4061 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
4062 return;
4063 event = stac_get_event(codec, nid, type);
4064 if (event)
4065 tag = event->tag;
4066 else
4067 tag = stac_add_event(codec->spec, nid, type, 0);
4068 if (tag < 0)
4069 return;
4070 snd_hda_codec_write_cache(codec, nid, 0,
4071 AC_VERB_SET_UNSOLICITED_ENABLE,
4072 AC_USRSP_EN | tag);
Takashi Iwai314634b2006-09-21 11:56:18 +02004073}
4074
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004075static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
4076{
4077 int i;
4078 for (i = 0; i < cfg->hp_outs; i++)
4079 if (cfg->hp_pins[i] == nid)
4080 return 1; /* nid is a HP-Out */
4081
4082 return 0; /* nid is not a HP-Out */
4083};
4084
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004085static void stac92xx_power_down(struct hda_codec *codec)
4086{
4087 struct sigmatel_spec *spec = codec->spec;
4088
4089 /* power down inactive DACs */
4090 hda_nid_t *dac;
4091 for (dac = spec->dac_list; *dac; dac++)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004092 if (!check_all_dac_nids(spec, *dac))
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004093 snd_hda_codec_write(codec, *dac, 0,
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004094 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4095}
4096
Takashi Iwaif73d3582008-11-25 08:21:51 +01004097static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4098 int enable);
4099
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004100/* override some hints from the hwdep entry */
4101static void stac_store_hints(struct hda_codec *codec)
4102{
4103 struct sigmatel_spec *spec = codec->spec;
4104 const char *p;
4105 int val;
4106
4107 val = snd_hda_get_bool_hint(codec, "hp_detect");
4108 if (val >= 0)
4109 spec->hp_detect = val;
4110 p = snd_hda_get_hint(codec, "gpio_mask");
4111 if (p) {
4112 spec->gpio_mask = simple_strtoul(p, NULL, 0);
4113 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
4114 spec->gpio_mask;
4115 }
4116 p = snd_hda_get_hint(codec, "gpio_dir");
4117 if (p)
4118 spec->gpio_dir = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4119 p = snd_hda_get_hint(codec, "gpio_data");
4120 if (p)
4121 spec->gpio_data = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4122 p = snd_hda_get_hint(codec, "eapd_mask");
4123 if (p)
4124 spec->eapd_mask = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4125 val = snd_hda_get_bool_hint(codec, "eapd_switch");
4126 if (val >= 0)
4127 spec->eapd_switch = val;
4128}
4129
Mattc7d4b2f2005-06-27 14:59:41 +02004130static int stac92xx_init(struct hda_codec *codec)
4131{
4132 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004133 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004134 unsigned int gpio;
Takashi Iwaie4973e12008-11-18 09:32:42 +01004135 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02004136
Mattc7d4b2f2005-06-27 14:59:41 +02004137 snd_hda_sequence_write(codec, spec->init);
4138
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004139 /* power down adcs initially */
4140 if (spec->powerdown_adcs)
4141 for (i = 0; i < spec->num_adcs; i++)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004142 snd_hda_codec_write(codec,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004143 spec->adc_nids[i], 0,
4144 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004145
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004146 /* override some hints */
4147 stac_store_hints(codec);
4148
Takashi Iwaif73d3582008-11-25 08:21:51 +01004149 /* set up GPIO */
4150 gpio = spec->gpio_data;
4151 /* turn on EAPD statically when spec->eapd_switch isn't set.
4152 * otherwise, unsol event will turn it on/off dynamically
4153 */
4154 if (!spec->eapd_switch)
4155 gpio |= spec->eapd_mask;
4156 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4157
Takashi Iwai82bc9552006-03-21 11:24:42 +01004158 /* set up pins */
4159 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02004160 /* Enable unsolicited responses on the HP widget */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004161 for (i = 0; i < cfg->hp_outs; i++) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004162 hda_nid_t nid = cfg->hp_pins[i];
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004163 enable_pin_detect(codec, nid, STAC_HP_EVENT);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004164 }
Takashi Iwai0a07aca2007-03-13 10:40:23 +01004165 /* force to enable the first line-out; the others are set up
4166 * in unsol_event
4167 */
4168 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004169 AC_PINCTL_OUT_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004170 /* fake event to set up pins */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004171 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4172 STAC_HP_EVENT);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004173 } else {
4174 stac92xx_auto_init_multi_out(codec);
4175 stac92xx_auto_init_hp_out(codec);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004176 for (i = 0; i < cfg->hp_outs; i++)
4177 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004178 }
4179 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01004180 hda_nid_t nid = cfg->input_pins[i];
4181 if (nid) {
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004182 unsigned int pinctl, conf;
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004183 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
4184 /* for mic pins, force to initialize */
4185 pinctl = stac92xx_get_vref(codec, nid);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004186 pinctl |= AC_PINCTL_IN_EN;
4187 stac92xx_auto_set_pinctl(codec, nid, pinctl);
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004188 } else {
4189 pinctl = snd_hda_codec_read(codec, nid, 0,
4190 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4191 /* if PINCTL already set then skip */
Takashi Iwai5dd17cb2009-05-07 16:22:53 +02004192 /* Also, if both INPUT and OUTPUT are set,
4193 * it must be a BIOS bug; need to override, too
4194 */
4195 if (!(pinctl & AC_PINCTL_IN_EN) ||
4196 (pinctl & AC_PINCTL_OUT_EN)) {
4197 pinctl &= ~AC_PINCTL_OUT_EN;
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004198 pinctl |= AC_PINCTL_IN_EN;
4199 stac92xx_auto_set_pinctl(codec, nid,
4200 pinctl);
4201 }
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004202 }
Takashi Iwai330ee992009-02-20 14:33:36 +01004203 conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004204 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4205 enable_pin_detect(codec, nid,
4206 STAC_INSERT_EVENT);
4207 stac_issue_unsol_event(codec, nid,
4208 STAC_INSERT_EVENT);
4209 }
Takashi Iwaic960a032006-03-23 17:06:28 +01004210 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01004211 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004212 for (i = 0; i < spec->num_dmics; i++)
4213 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4214 AC_PINCTL_IN_EN);
Takashi Iwai0852d7a2009-02-11 11:35:15 +01004215 if (cfg->dig_out_pins[0])
4216 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
Takashi Iwai82bc9552006-03-21 11:24:42 +01004217 AC_PINCTL_OUT_EN);
4218 if (cfg->dig_in_pin)
4219 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4220 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004221 for (i = 0; i < spec->num_pwrs; i++) {
4222 hda_nid_t nid = spec->pwr_nids[i];
4223 int pinctl, def_conf;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004224
Takashi Iwaieb632122008-12-19 16:39:48 +01004225 /* power on when no jack detection is available */
4226 if (!spec->hp_detect) {
4227 stac_toggle_power_map(codec, nid, 1);
4228 continue;
4229 }
4230
4231 if (is_nid_hp_pin(cfg, nid))
Takashi Iwaif73d3582008-11-25 08:21:51 +01004232 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004233
Takashi Iwaif73d3582008-11-25 08:21:51 +01004234 pinctl = snd_hda_codec_read(codec, nid, 0,
4235 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4236 /* outputs are only ports capable of power management
4237 * any attempts on powering down a input port cause the
4238 * referenced VREF to act quirky.
4239 */
Takashi Iwaieb632122008-12-19 16:39:48 +01004240 if (pinctl & AC_PINCTL_IN_EN) {
4241 stac_toggle_power_map(codec, nid, 1);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004242 continue;
Takashi Iwaieb632122008-12-19 16:39:48 +01004243 }
Takashi Iwai330ee992009-02-20 14:33:36 +01004244 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004245 def_conf = get_defcfg_connect(def_conf);
4246 /* skip any ports that don't have jacks since presence
4247 * detection is useless */
4248 if (def_conf != AC_JACK_PORT_COMPLEX) {
4249 if (def_conf != AC_JACK_PORT_NONE)
4250 stac_toggle_power_map(codec, nid, 1);
4251 continue;
4252 }
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004253 if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) {
4254 enable_pin_detect(codec, nid, STAC_PWR_EVENT);
4255 stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT);
4256 }
Takashi Iwaif73d3582008-11-25 08:21:51 +01004257 }
4258 if (spec->dac_list)
4259 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02004260 return 0;
4261}
4262
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004263static void stac92xx_free_jacks(struct hda_codec *codec)
4264{
Takashi Iwaie4973e12008-11-18 09:32:42 +01004265#ifdef CONFIG_SND_JACK
Takashi Iwaib94d3532008-11-21 09:08:06 +01004266 /* free jack instances manually when clearing/reconfiguring */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004267 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaib94d3532008-11-21 09:08:06 +01004268 if (!codec->bus->shutdown && spec->jacks.list) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004269 struct sigmatel_jack *jacks = spec->jacks.list;
4270 int i;
Takashi Iwai95c09092009-04-14 16:15:29 +02004271 for (i = 0; i < spec->jacks.used; i++, jacks++) {
4272 if (jacks->jack)
4273 snd_device_free(codec->bus->card, jacks->jack);
4274 }
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004275 }
4276 snd_array_free(&spec->jacks);
Takashi Iwaie4973e12008-11-18 09:32:42 +01004277#endif
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004278}
4279
Takashi Iwai603c4012008-07-30 15:01:44 +02004280static void stac92xx_free_kctls(struct hda_codec *codec)
4281{
4282 struct sigmatel_spec *spec = codec->spec;
4283
4284 if (spec->kctls.list) {
4285 struct snd_kcontrol_new *kctl = spec->kctls.list;
4286 int i;
4287 for (i = 0; i < spec->kctls.used; i++)
4288 kfree(kctl[i].name);
4289 }
4290 snd_array_free(&spec->kctls);
4291}
4292
Matt2f2f4252005-04-13 14:45:30 +02004293static void stac92xx_free(struct hda_codec *codec)
4294{
Mattc7d4b2f2005-06-27 14:59:41 +02004295 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004296
4297 if (! spec)
4298 return;
4299
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004300 stac92xx_free_jacks(codec);
4301 snd_array_free(&spec->events);
Richard Fish11b44bb2006-08-23 18:31:34 +02004302
Mattc7d4b2f2005-06-27 14:59:41 +02004303 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004304 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02004305}
4306
Matt4e550962005-07-04 17:51:39 +02004307static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4308 unsigned int flag)
4309{
Takashi Iwai8ce84192009-01-22 16:59:20 +01004310 unsigned int old_ctl, pin_ctl;
4311
4312 pin_ctl = snd_hda_codec_read(codec, nid,
Matt4e550962005-07-04 17:51:39 +02004313 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02004314
Takashi Iwaif9acba42007-05-29 18:01:06 +02004315 if (pin_ctl & AC_PINCTL_IN_EN) {
4316 /*
4317 * we need to check the current set-up direction of
4318 * shared input pins since they can be switched via
4319 * "xxx as Output" mixer switch
4320 */
4321 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004322 if (nid == spec->line_switch || nid == spec->mic_switch)
Takashi Iwaif9acba42007-05-29 18:01:06 +02004323 return;
4324 }
4325
Takashi Iwai8ce84192009-01-22 16:59:20 +01004326 old_ctl = pin_ctl;
Steve Longerbeam7b043892007-05-03 20:50:03 +02004327 /* if setting pin direction bits, clear the current
4328 direction bits first */
4329 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4330 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4331
Takashi Iwai8ce84192009-01-22 16:59:20 +01004332 pin_ctl |= flag;
4333 if (old_ctl != pin_ctl)
4334 snd_hda_codec_write_cache(codec, nid, 0,
4335 AC_VERB_SET_PIN_WIDGET_CONTROL,
4336 pin_ctl);
Matt4e550962005-07-04 17:51:39 +02004337}
4338
4339static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4340 unsigned int flag)
4341{
4342 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4343 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai8ce84192009-01-22 16:59:20 +01004344 if (pin_ctl & flag)
4345 snd_hda_codec_write_cache(codec, nid, 0,
4346 AC_VERB_SET_PIN_WIDGET_CONTROL,
4347 pin_ctl & ~flag);
Matt4e550962005-07-04 17:51:39 +02004348}
4349
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004350static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02004351{
4352 if (!nid)
4353 return 0;
4354 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004355 & (1 << 31))
4356 return 1;
Takashi Iwai314634b2006-09-21 11:56:18 +02004357 return 0;
4358}
4359
Takashi Iwaid7a89432008-11-12 09:48:04 +01004360/* return non-zero if the hp-pin of the given array index isn't
4361 * a jack-detection target
4362 */
4363static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4364{
4365 struct auto_pin_cfg *cfg = &spec->autocfg;
4366
4367 /* ignore sensing of shared line and mic jacks */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004368 if (cfg->hp_pins[i] == spec->line_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004369 return 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004370 if (cfg->hp_pins[i] == spec->mic_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004371 return 1;
4372 /* ignore if the pin is set as line-out */
4373 if (cfg->hp_pins[i] == spec->hp_switch)
4374 return 1;
4375 return 0;
4376}
4377
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004378static void stac92xx_hp_detect(struct hda_codec *codec)
Matt4e550962005-07-04 17:51:39 +02004379{
4380 struct sigmatel_spec *spec = codec->spec;
4381 struct auto_pin_cfg *cfg = &spec->autocfg;
4382 int i, presence;
4383
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004384 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004385 if (spec->gpio_mute)
4386 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4387 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4388
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004389 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004390 if (presence)
4391 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01004392 if (no_hp_sensing(spec, i))
4393 continue;
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004394 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4395 if (presence) {
4396 unsigned int pinctl;
4397 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4398 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4399 if (pinctl & AC_PINCTL_IN_EN)
4400 presence = 0; /* mic- or line-input */
4401 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004402 }
Matt4e550962005-07-04 17:51:39 +02004403
4404 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004405 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004406 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004407 stac92xx_reset_pinctl(codec, spec->hp_switch,
4408 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004409 for (i = 0; i < cfg->line_outs; i++)
4410 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4411 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004412 for (i = 0; i < cfg->speaker_outs; i++)
4413 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4414 AC_PINCTL_OUT_EN);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004415 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004416 stac_gpio_set(codec, spec->gpio_mask,
4417 spec->gpio_dir, spec->gpio_data &
4418 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02004419 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004420 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004421 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004422 stac92xx_set_pinctl(codec, spec->hp_switch,
4423 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004424 for (i = 0; i < cfg->line_outs; i++)
4425 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4426 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004427 for (i = 0; i < cfg->speaker_outs; i++)
4428 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4429 AC_PINCTL_OUT_EN);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004430 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004431 stac_gpio_set(codec, spec->gpio_mask,
4432 spec->gpio_dir, spec->gpio_data |
4433 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02004434 }
Takashi Iwaid7a89432008-11-12 09:48:04 +01004435 /* toggle hp outs */
4436 for (i = 0; i < cfg->hp_outs; i++) {
4437 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4438 if (no_hp_sensing(spec, i))
4439 continue;
4440 if (presence)
4441 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004442#if 0 /* FIXME */
4443/* Resetting the pinctl like below may lead to (a sort of) regressions
4444 * on some devices since they use the HP pin actually for line/speaker
4445 * outs although the default pin config shows a different pin (that is
4446 * wrong and useless).
4447 *
4448 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4449 * But, disabling the code below just works around it, and I'm too tired of
4450 * bug reports with such devices...
4451 */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004452 else
4453 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004454#endif /* FIXME */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004455 }
Matt4e550962005-07-04 17:51:39 +02004456}
4457
Takashi Iwaif73d3582008-11-25 08:21:51 +01004458static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4459 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004460{
4461 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004462 unsigned int idx, val;
4463
4464 for (idx = 0; idx < spec->num_pwrs; idx++) {
4465 if (spec->pwr_nids[idx] == nid)
4466 break;
4467 }
4468 if (idx >= spec->num_pwrs)
4469 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004470
4471 /* several codecs have two power down bits */
4472 if (spec->pwr_mapping)
4473 idx = spec->pwr_mapping[idx];
4474 else
4475 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004476
Takashi Iwaif73d3582008-11-25 08:21:51 +01004477 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4478 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004479 val &= ~idx;
4480 else
4481 val |= idx;
4482
4483 /* power down unused output ports */
4484 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004485}
4486
Takashi Iwaif73d3582008-11-25 08:21:51 +01004487static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4488{
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004489 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
Takashi Iwaif73d3582008-11-25 08:21:51 +01004490}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004491
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004492static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4493{
4494 struct sigmatel_spec *spec = codec->spec;
4495 struct sigmatel_jack *jacks = spec->jacks.list;
4496
4497 if (jacks) {
4498 int i;
4499 for (i = 0; i < spec->jacks.used; i++) {
4500 if (jacks->nid == nid) {
4501 unsigned int pin_ctl =
4502 snd_hda_codec_read(codec, nid,
4503 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4504 0x00);
4505 int type = jacks->type;
4506 if (type == (SND_JACK_LINEOUT
4507 | SND_JACK_HEADPHONE))
4508 type = (pin_ctl & AC_PINCTL_HP_EN)
4509 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4510 snd_jack_report(jacks->jack,
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004511 get_pin_presence(codec, nid)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004512 ? type : 0);
4513 }
4514 jacks++;
4515 }
4516 }
4517}
Matt2f2f4252005-04-13 14:45:30 +02004518
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004519static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
4520 unsigned char type)
4521{
4522 struct sigmatel_event *event = stac_get_event(codec, nid, type);
4523 if (!event)
4524 return;
4525 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4526}
4527
Takashi Iwai314634b2006-09-21 11:56:18 +02004528static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4529{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004530 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004531 struct sigmatel_event *event;
4532 int tag, data;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004533
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004534 tag = (res >> 26) & 0x7f;
4535 event = stac_get_event_from_tag(codec, tag);
4536 if (!event)
4537 return;
4538
4539 switch (event->type) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004540 case STAC_HP_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004541 stac92xx_hp_detect(codec);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004542 /* fallthru */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004543 case STAC_INSERT_EVENT:
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004544 case STAC_PWR_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004545 if (spec->num_pwrs > 0)
4546 stac92xx_pin_sense(codec, event->nid);
4547 stac92xx_report_jack(codec, event->nid);
Matthew Ranostayfd60cc82009-04-06 09:30:46 -04004548
4549 switch (codec->subsystem_id) {
4550 case 0x103c308f:
4551 if (event->nid == 0xb) {
4552 int pin = AC_PINCTL_IN_EN;
4553
4554 if (get_pin_presence(codec, 0xa)
4555 && get_pin_presence(codec, 0xb))
4556 pin |= AC_PINCTL_VREF_80;
4557 if (!get_pin_presence(codec, 0xb))
4558 pin |= AC_PINCTL_VREF_80;
4559
4560 /* toggle VREF state based on mic + hp pin
4561 * status
4562 */
4563 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
4564 }
4565 }
Matthew Ranostay72474be2008-10-09 09:32:17 -04004566 break;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004567 case STAC_VREF_EVENT:
4568 data = snd_hda_codec_read(codec, codec->afg, 0,
4569 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004570 /* toggle VREF state based on GPIOx status */
4571 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004572 !!(data & (1 << event->data)));
Matthew Ranostay72474be2008-10-09 09:32:17 -04004573 break;
Takashi Iwai314634b2006-09-21 11:56:18 +02004574 }
4575}
4576
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004577#ifdef CONFIG_PROC_FS
4578static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4579 struct hda_codec *codec, hda_nid_t nid)
4580{
4581 if (nid == codec->afg)
4582 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4583 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4584}
4585
4586static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4587 struct hda_codec *codec,
4588 unsigned int verb)
4589{
4590 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4591 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4592}
4593
4594/* stac92hd71bxx, stac92hd73xx */
4595static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4596 struct hda_codec *codec, hda_nid_t nid)
4597{
4598 stac92hd_proc_hook(buffer, codec, nid);
4599 if (nid == codec->afg)
4600 analog_loop_proc_hook(buffer, codec, 0xfa0);
4601}
4602
4603static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4604 struct hda_codec *codec, hda_nid_t nid)
4605{
4606 if (nid == codec->afg)
4607 analog_loop_proc_hook(buffer, codec, 0xfe0);
4608}
4609
4610static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4611 struct hda_codec *codec, hda_nid_t nid)
4612{
4613 if (nid == codec->afg)
4614 analog_loop_proc_hook(buffer, codec, 0xfeb);
4615}
4616#else
4617#define stac92hd_proc_hook NULL
4618#define stac92hd7x_proc_hook NULL
4619#define stac9205_proc_hook NULL
4620#define stac927x_proc_hook NULL
4621#endif
4622
Takashi Iwaicb53c622007-08-10 17:21:45 +02004623#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004624static int stac92xx_resume(struct hda_codec *codec)
4625{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004626 struct sigmatel_spec *spec = codec->spec;
4627
Takashi Iwai2c885872008-11-18 09:36:55 +01004628 stac92xx_init(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004629 snd_hda_codec_resume_amp(codec);
4630 snd_hda_codec_resume_cache(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01004631 /* fake event to set up pins again to override cached values */
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004632 if (spec->hp_detect)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004633 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4634 STAC_HP_EVENT);
Mattff6fdc32005-06-27 15:06:52 +02004635 return 0;
4636}
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004637
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004638/*
James Gardiner514bf542009-05-03 04:00:44 -04004639 * using power check for controlling mute led of HP notebooks
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004640 * check for mute state only on Speakers (nid = 0x10)
4641 *
4642 * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise
4643 * the LED is NOT working properly !
James Gardiner514bf542009-05-03 04:00:44 -04004644 *
4645 * Changed name to reflect that it now works for any designated
4646 * model, not just HP HDX.
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004647 */
4648
4649#ifdef CONFIG_SND_HDA_POWER_SAVE
James Gardiner514bf542009-05-03 04:00:44 -04004650static int stac92xx_hp_check_power_status(struct hda_codec *codec,
Takashi Iwai6fce61a2009-03-10 07:48:57 +01004651 hda_nid_t nid)
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004652{
4653 struct sigmatel_spec *spec = codec->spec;
James Gardiner514bf542009-05-03 04:00:44 -04004654 unsigned int gpio_bit = 0; /* gets rid of compiler warning */
4655
4656 switch (spec->board_config) {
4657 case STAC_HP_DV4_1222NR:
4658 gpio_bit = 0x01;
4659 break;
4660 case STAC_HP_HDX:
4661 gpio_bit = 0x08;
4662 }
Takashi Iwai6fce61a2009-03-10 07:48:57 +01004663
4664 if (nid == 0x10) {
4665 if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004666 HDA_AMP_MUTE)
James Gardiner514bf542009-05-03 04:00:44 -04004667 spec->gpio_data &= ~gpio_bit; /* orange */
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004668 else
James Gardiner514bf542009-05-03 04:00:44 -04004669 spec->gpio_data |= gpio_bit; /* white */
Takashi Iwai6fce61a2009-03-10 07:48:57 +01004670
4671 stac_gpio_set(codec, spec->gpio_mask,
4672 spec->gpio_dir,
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004673 spec->gpio_data);
4674 }
4675
4676 return 0;
4677}
4678#endif
4679
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004680static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4681{
4682 struct sigmatel_spec *spec = codec->spec;
4683 if (spec->eapd_mask)
4684 stac_gpio_set(codec, spec->gpio_mask,
4685 spec->gpio_dir, spec->gpio_data &
4686 ~spec->eapd_mask);
4687 return 0;
4688}
Mattff6fdc32005-06-27 15:06:52 +02004689#endif
4690
Matt2f2f4252005-04-13 14:45:30 +02004691static struct hda_codec_ops stac92xx_patch_ops = {
4692 .build_controls = stac92xx_build_controls,
4693 .build_pcms = stac92xx_build_pcms,
4694 .init = stac92xx_init,
4695 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02004696 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004697#ifdef SND_HDA_NEEDS_RESUME
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004698 .suspend = stac92xx_suspend,
Mattff6fdc32005-06-27 15:06:52 +02004699 .resume = stac92xx_resume,
4700#endif
Matt2f2f4252005-04-13 14:45:30 +02004701};
4702
4703static int patch_stac9200(struct hda_codec *codec)
4704{
4705 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004706 int err;
Matt2f2f4252005-04-13 14:45:30 +02004707
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004708 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004709 if (spec == NULL)
4710 return -ENOMEM;
4711
4712 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004713 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004714 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004715 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4716 stac9200_models,
4717 stac9200_cfg_tbl);
Takashi Iwai330ee992009-02-20 14:33:36 +01004718 if (spec->board_config < 0)
Richard Fish11b44bb2006-08-23 18:31:34 +02004719 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01004720 else
4721 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004722 stac9200_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02004723
4724 spec->multiout.max_channels = 2;
4725 spec->multiout.num_dacs = 1;
4726 spec->multiout.dac_nids = stac9200_dac_nids;
4727 spec->adc_nids = stac9200_adc_nids;
4728 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02004729 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02004730 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004731 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004732 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004733
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02004734 if (spec->board_config == STAC_9200_M4 ||
4735 spec->board_config == STAC_9200_M4_2 ||
Tobin Davisbf277782008-02-03 20:31:47 +01004736 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02004737 spec->init = stac9200_eapd_init;
4738 else
4739 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004740 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004741
Takashi Iwai117f2572008-03-18 09:53:23 +01004742 if (spec->board_config == STAC_9200_PANASONIC) {
4743 spec->gpio_mask = spec->gpio_dir = 0x09;
4744 spec->gpio_data = 0x00;
4745 }
4746
Mattc7d4b2f2005-06-27 14:59:41 +02004747 err = stac9200_parse_auto_config(codec);
4748 if (err < 0) {
4749 stac92xx_free(codec);
4750 return err;
4751 }
Matt2f2f4252005-04-13 14:45:30 +02004752
Takashi Iwai2acc9dc2009-01-09 16:57:14 +01004753 /* CF-74 has no headphone detection, and the driver should *NOT*
4754 * do detection and HP/speaker toggle because the hardware does it.
4755 */
4756 if (spec->board_config == STAC_9200_PANASONIC)
4757 spec->hp_detect = 0;
4758
Matt2f2f4252005-04-13 14:45:30 +02004759 codec->patch_ops = stac92xx_patch_ops;
4760
4761 return 0;
4762}
4763
Tobin Davis8e21c342007-01-08 11:04:17 +01004764static int patch_stac925x(struct hda_codec *codec)
4765{
4766 struct sigmatel_spec *spec;
4767 int err;
4768
4769 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4770 if (spec == NULL)
4771 return -ENOMEM;
4772
4773 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004774 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01004775 spec->pin_nids = stac925x_pin_nids;
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02004776
4777 /* Check first for codec ID */
4778 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
4779 STAC_925x_MODELS,
4780 stac925x_models,
4781 stac925x_codec_id_cfg_tbl);
4782
4783 /* Now checks for PCI ID, if codec ID is not found */
4784 if (spec->board_config < 0)
4785 spec->board_config = snd_hda_check_board_config(codec,
4786 STAC_925x_MODELS,
Tobin Davis8e21c342007-01-08 11:04:17 +01004787 stac925x_models,
4788 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004789 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01004790 if (spec->board_config < 0)
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02004791 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
Tobin Davis2c11f952007-05-17 09:36:34 +02004792 "using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01004793 else
4794 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004795 stac925x_brd_tbl[spec->board_config]);
Tobin Davis8e21c342007-01-08 11:04:17 +01004796
4797 spec->multiout.max_channels = 2;
4798 spec->multiout.num_dacs = 1;
4799 spec->multiout.dac_nids = stac925x_dac_nids;
4800 spec->adc_nids = stac925x_adc_nids;
4801 spec->mux_nids = stac925x_mux_nids;
4802 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004803 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004804 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02004805 switch (codec->vendor_id) {
4806 case 0x83847632: /* STAC9202 */
4807 case 0x83847633: /* STAC9202D */
4808 case 0x83847636: /* STAC9251 */
4809 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02004810 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02004811 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai16970552007-12-18 18:05:52 +01004812 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4813 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02004814 break;
4815 default:
4816 spec->num_dmics = 0;
4817 break;
4818 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004819
4820 spec->init = stac925x_core_init;
4821 spec->mixer = stac925x_mixer;
4822
4823 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004824 if (!err) {
4825 if (spec->board_config < 0) {
4826 printk(KERN_WARNING "hda_codec: No auto-config is "
4827 "available, default to model=ref\n");
4828 spec->board_config = STAC_925x_REF;
4829 goto again;
4830 }
4831 err = -EINVAL;
4832 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004833 if (err < 0) {
4834 stac92xx_free(codec);
4835 return err;
4836 }
4837
4838 codec->patch_ops = stac92xx_patch_ops;
4839
4840 return 0;
4841}
4842
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004843static struct hda_input_mux stac92hd73xx_dmux = {
4844 .num_items = 4,
4845 .items = {
4846 { "Analog Inputs", 0x0b },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004847 { "Digital Mic 1", 0x09 },
4848 { "Digital Mic 2", 0x0a },
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004849 { "CD", 0x08 },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004850 }
4851};
4852
4853static int patch_stac92hd73xx(struct hda_codec *codec)
4854{
4855 struct sigmatel_spec *spec;
4856 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4857 int err = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004858 int num_dacs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004859
4860 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4861 if (spec == NULL)
4862 return -ENOMEM;
4863
4864 codec->spec = spec;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02004865 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004866 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4867 spec->pin_nids = stac92hd73xx_pin_nids;
4868 spec->board_config = snd_hda_check_board_config(codec,
4869 STAC_92HD73XX_MODELS,
4870 stac92hd73xx_models,
4871 stac92hd73xx_cfg_tbl);
4872again:
Takashi Iwai330ee992009-02-20 14:33:36 +01004873 if (spec->board_config < 0)
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004874 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4875 " STAC92HD73XX, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01004876 else
4877 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004878 stac92hd73xx_brd_tbl[spec->board_config]);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004879
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004880 num_dacs = snd_hda_get_connections(codec, 0x0a,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004881 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4882
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004883 if (num_dacs < 3 || num_dacs > 5) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004884 printk(KERN_WARNING "hda_codec: Could not determine "
4885 "number of channels defaulting to DAC count\n");
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004886 num_dacs = STAC92HD73_DAC_COUNT;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004887 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004888 switch (num_dacs) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004889 case 0x3: /* 6 Channel */
4890 spec->mixer = stac92hd73xx_6ch_mixer;
4891 spec->init = stac92hd73xx_6ch_core_init;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01004892 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004893 break;
4894 case 0x4: /* 8 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004895 spec->mixer = stac92hd73xx_8ch_mixer;
4896 spec->init = stac92hd73xx_8ch_core_init;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01004897 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004898 break;
4899 case 0x5: /* 10 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004900 spec->mixer = stac92hd73xx_10ch_mixer;
4901 spec->init = stac92hd73xx_10ch_core_init;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01004902 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
4903 break;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004904 }
4905 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004906
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004907 spec->aloopback_mask = 0x01;
4908 spec->aloopback_shift = 8;
4909
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004910 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004911 spec->mux_nids = stac92hd73xx_mux_nids;
4912 spec->adc_nids = stac92hd73xx_adc_nids;
4913 spec->dmic_nids = stac92hd73xx_dmic_nids;
4914 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004915 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostay89385032008-09-11 09:49:39 -04004916 spec->amp_nids = stac92hd73xx_amp_nids;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004917 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004918
4919 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4920 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai16970552007-12-18 18:05:52 +01004921 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004922 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4923 sizeof(stac92hd73xx_dmux));
4924
Matthew Ranostaya7662642008-02-21 07:51:14 +01004925 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004926 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004927 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004928 /* fallthru */
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004929 case STAC_DELL_M6_AMIC:
4930 case STAC_DELL_M6_DMIC:
4931 case STAC_DELL_M6_BOTH:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004932 spec->num_smuxes = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004933 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4934 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004935 spec->eapd_switch = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004936 spec->num_amps = 1;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004937
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004938 if (spec->board_config != STAC_DELL_EQ)
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004939 spec->init = dell_m6_core_init;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004940 switch (spec->board_config) {
4941 case STAC_DELL_M6_AMIC: /* Analog Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01004942 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
Matthew Ranostaya7662642008-02-21 07:51:14 +01004943 spec->num_dmics = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004944 spec->private_dimux.num_items = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004945 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004946 case STAC_DELL_M6_DMIC: /* Digital Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01004947 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01004948 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004949 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004950 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004951 case STAC_DELL_M6_BOTH: /* Both */
Takashi Iwai330ee992009-02-20 14:33:36 +01004952 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
4953 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01004954 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004955 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004956 break;
4957 }
4958 break;
4959 default:
4960 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004961 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004962 spec->eapd_switch = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004963 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004964 if (spec->board_config > STAC_92HD73XX_REF) {
4965 /* GPIO0 High = Enable EAPD */
4966 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4967 spec->gpio_data = 0x01;
4968 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004969 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004970
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004971 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4972 spec->pwr_nids = stac92hd73xx_pwr_nids;
4973
Matthew Ranostayd9737752008-09-07 12:03:41 +02004974 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004975
4976 if (!err) {
4977 if (spec->board_config < 0) {
4978 printk(KERN_WARNING "hda_codec: No auto-config is "
4979 "available, default to model=ref\n");
4980 spec->board_config = STAC_92HD73XX_REF;
4981 goto again;
4982 }
4983 err = -EINVAL;
4984 }
4985
4986 if (err < 0) {
4987 stac92xx_free(codec);
4988 return err;
4989 }
4990
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01004991 if (spec->board_config == STAC_92HD73XX_NO_JD)
4992 spec->hp_detect = 0;
4993
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004994 codec->patch_ops = stac92xx_patch_ops;
4995
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004996 codec->proc_widget_hook = stac92hd7x_proc_hook;
4997
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004998 return 0;
4999}
5000
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005001static struct hda_input_mux stac92hd83xxx_dmux = {
5002 .num_items = 3,
5003 .items = {
5004 { "Analog Inputs", 0x03 },
5005 { "Digital Mic 1", 0x04 },
5006 { "Digital Mic 2", 0x05 },
5007 }
5008};
5009
5010static int patch_stac92hd83xxx(struct hda_codec *codec)
5011{
5012 struct sigmatel_spec *spec;
Matthew Ranostay65557f32009-01-20 16:50:25 -05005013 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005014 int err;
Matthew Ranostay65557f32009-01-20 16:50:25 -05005015 int num_dacs;
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05005016 hda_nid_t nid;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005017
5018 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5019 if (spec == NULL)
5020 return -ENOMEM;
5021
5022 codec->spec = spec;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005023 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005024 spec->mono_nid = 0x19;
5025 spec->digbeep_nid = 0x21;
5026 spec->dmic_nids = stac92hd83xxx_dmic_nids;
5027 spec->dmux_nids = stac92hd83xxx_dmux_nids;
5028 spec->adc_nids = stac92hd83xxx_adc_nids;
5029 spec->pwr_nids = stac92hd83xxx_pwr_nids;
Matthew Ranostayc15c5062009-01-13 13:30:07 -05005030 spec->amp_nids = stac92hd83xxx_amp_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005031 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
5032 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005033 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005034
5035 spec->init = stac92hd83xxx_core_init;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005036 spec->mixer = stac92hd83xxx_mixer;
5037 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
5038 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
5039 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
Matthew Ranostayc15c5062009-01-13 13:30:07 -05005040 spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005041 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
5042 spec->dinput_mux = &stac92hd83xxx_dmux;
5043 spec->pin_nids = stac92hd83xxx_pin_nids;
5044 spec->board_config = snd_hda_check_board_config(codec,
5045 STAC_92HD83XXX_MODELS,
5046 stac92hd83xxx_models,
5047 stac92hd83xxx_cfg_tbl);
5048again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005049 if (spec->board_config < 0)
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005050 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
5051 " STAC92HD83XXX, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01005052 else
5053 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005054 stac92hd83xxx_brd_tbl[spec->board_config]);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005055
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05005056 switch (codec->vendor_id) {
5057 case 0x111d7604:
5058 case 0x111d7605:
Matthew Ranostayff2e7332009-04-01 14:49:48 -04005059 case 0x111d76d5:
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05005060 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
5061 break;
5062 spec->num_pwrs = 0;
5063 break;
5064 }
5065
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005066 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
5067 if (!err) {
5068 if (spec->board_config < 0) {
5069 printk(KERN_WARNING "hda_codec: No auto-config is "
5070 "available, default to model=ref\n");
5071 spec->board_config = STAC_92HD83XXX_REF;
5072 goto again;
5073 }
5074 err = -EINVAL;
5075 }
5076
5077 if (err < 0) {
5078 stac92xx_free(codec);
5079 return err;
5080 }
5081
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05005082 switch (spec->board_config) {
5083 case STAC_DELL_S14:
5084 nid = 0xf;
5085 break;
5086 default:
5087 nid = 0xe;
5088 break;
5089 }
5090
5091 num_dacs = snd_hda_get_connections(codec, nid,
5092 conn, STAC92HD83_DAC_COUNT + 1) - 1;
5093
5094 /* set port X to select the last DAC
5095 */
5096 snd_hda_codec_write_cache(codec, nid, 0,
5097 AC_VERB_SET_CONNECT_SEL, num_dacs);
5098
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005099 codec->patch_ops = stac92xx_patch_ops;
5100
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005101 codec->proc_widget_hook = stac92hd_proc_hook;
5102
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005103 return 0;
5104}
5105
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005106static struct hda_input_mux stac92hd71bxx_dmux_nomixer = {
5107 .num_items = 3,
5108 .items = {
5109 { "Analog Inputs", 0x00 },
5110 { "Digital Mic 1", 0x02 },
5111 { "Digital Mic 2", 0x03 },
5112 }
5113};
5114
5115static struct hda_input_mux stac92hd71bxx_dmux_amixer = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005116 .num_items = 4,
5117 .items = {
5118 { "Analog Inputs", 0x00 },
5119 { "Mixer", 0x01 },
5120 { "Digital Mic 1", 0x02 },
5121 { "Digital Mic 2", 0x03 },
5122 }
5123};
5124
Takashi Iwai330ee992009-02-20 14:33:36 +01005125/* get the pin connection (fixed, none, etc) */
5126static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
5127{
5128 struct sigmatel_spec *spec = codec->spec;
5129 unsigned int cfg;
5130
5131 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
5132 return get_defcfg_connect(cfg);
5133}
5134
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005135static int stac92hd71bxx_connected_ports(struct hda_codec *codec,
5136 hda_nid_t *nids, int num_nids)
5137{
5138 struct sigmatel_spec *spec = codec->spec;
5139 int idx, num;
5140 unsigned int def_conf;
5141
5142 for (num = 0; num < num_nids; num++) {
5143 for (idx = 0; idx < spec->num_pins; idx++)
5144 if (spec->pin_nids[idx] == nids[num])
5145 break;
5146 if (idx >= spec->num_pins)
5147 break;
Takashi Iwai330ee992009-02-20 14:33:36 +01005148 def_conf = stac_get_defcfg_connect(codec, idx);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005149 if (def_conf == AC_JACK_PORT_NONE)
5150 break;
5151 }
5152 return num;
5153}
5154
5155static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
5156 hda_nid_t dig0pin)
5157{
5158 struct sigmatel_spec *spec = codec->spec;
5159 int idx;
5160
5161 for (idx = 0; idx < spec->num_pins; idx++)
5162 if (spec->pin_nids[idx] == dig0pin)
5163 break;
5164 if ((idx + 2) >= spec->num_pins)
5165 return 0;
5166
5167 /* dig1pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01005168 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005169 return 2;
5170
5171 /* dig0pin + dig2pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01005172 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005173 return 2;
Takashi Iwai330ee992009-02-20 14:33:36 +01005174 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005175 return 1;
5176 else
5177 return 0;
5178}
5179
Matthew Ranostaye035b842007-11-06 11:53:55 +01005180static int patch_stac92hd71bxx(struct hda_codec *codec)
5181{
5182 struct sigmatel_spec *spec;
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005183 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005184 int err = 0;
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005185 unsigned int ndmic_nids = 0;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005186
5187 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5188 if (spec == NULL)
5189 return -ENOMEM;
5190
5191 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005192 codec->patch_ops = stac92xx_patch_ops;
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05005193 spec->num_pins = STAC92HD71BXX_NUM_PINS;
5194 switch (codec->vendor_id) {
5195 case 0x111d76b6:
5196 case 0x111d76b7:
5197 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
5198 break;
5199 case 0x111d7603:
5200 case 0x111d7608:
5201 /* On 92HD75Bx 0x27 isn't a pin nid */
5202 spec->num_pins--;
5203 /* fallthrough */
5204 default:
5205 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
5206 }
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005207 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005208 spec->board_config = snd_hda_check_board_config(codec,
5209 STAC_92HD71BXX_MODELS,
5210 stac92hd71bxx_models,
5211 stac92hd71bxx_cfg_tbl);
5212again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005213 if (spec->board_config < 0)
Matthew Ranostaye035b842007-11-06 11:53:55 +01005214 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
5215 " STAC92HD71BXX, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01005216 else
5217 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005218 stac92hd71bxx_brd_tbl[spec->board_config]);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005219
Takashi Iwai41c3b642008-11-18 10:45:15 +01005220 if (spec->board_config > STAC_92HD71BXX_REF) {
5221 /* GPIO0 = EAPD */
5222 spec->gpio_mask = 0x01;
5223 spec->gpio_dir = 0x01;
5224 spec->gpio_data = 0x01;
5225 }
5226
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005227 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5228 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5229
Matthew Ranostay541eee82007-12-14 12:08:04 +01005230 switch (codec->vendor_id) {
5231 case 0x111d76b6: /* 4 Port without Analog Mixer */
5232 case 0x111d76b7:
Herton Ronaldo Krzesinski23c7b522009-02-08 19:51:28 -02005233 unmute_init++;
5234 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005235 case 0x111d76b4: /* 6 Port without Analog Mixer */
5236 case 0x111d76b5:
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005237 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_nomixer,
5238 sizeof(stac92hd71bxx_dmux_nomixer));
Matthew Ranostay541eee82007-12-14 12:08:04 +01005239 spec->mixer = stac92hd71bxx_mixer;
5240 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005241 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005242 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5243 stac92hd71bxx_dmic_nids,
5244 STAC92HD71BXX_NUM_DMICS);
5245 if (spec->num_dmics) {
5246 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5247 spec->dinput_mux = &spec->private_dimux;
5248 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
5249 }
Matthew Ranostay541eee82007-12-14 12:08:04 +01005250 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005251 case 0x111d7608: /* 5 Port with Analog Mixer */
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005252 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
5253 sizeof(stac92hd71bxx_dmux_amixer));
5254 spec->private_dimux.num_items--;
Takashi Iwai8e5f2622008-11-15 19:28:54 +01005255 switch (spec->board_config) {
5256 case STAC_HP_M4:
Matthew Ranostay72474be2008-10-09 09:32:17 -04005257 /* Enable VREF power saving on GPIO1 detect */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005258 err = stac_add_event(spec, codec->afg,
5259 STAC_VREF_EVENT, 0x02);
5260 if (err < 0)
5261 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005262 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay72474be2008-10-09 09:32:17 -04005263 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
5264 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005265 AC_VERB_SET_UNSOLICITED_ENABLE,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005266 AC_USRSP_EN | err);
Matthew Ranostay72474be2008-10-09 09:32:17 -04005267 spec->gpio_mask |= 0x02;
5268 break;
5269 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005270 if ((codec->revision_id & 0xf) == 0 ||
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005271 (codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005272 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005273
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005274 /* no output amps */
5275 spec->num_pwrs = 0;
5276 spec->mixer = stac92hd71bxx_analog_mixer;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005277 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005278
5279 /* disable VSW */
5280 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005281 unmute_init++;
Takashi Iwai330ee992009-02-20 14:33:36 +01005282 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5283 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005284 stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0;
5285 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5286 stac92hd71bxx_dmic_nids,
5287 STAC92HD71BXX_NUM_DMICS - 1);
5288 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5289 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 2;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005290 break;
5291 case 0x111d7603: /* 6 Port with Analog Mixer */
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005292 if ((codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005293 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005294
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005295 /* no output amps */
5296 spec->num_pwrs = 0;
5297 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005298 default:
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005299 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
5300 sizeof(stac92hd71bxx_dmux_amixer));
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005301 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005302 spec->mixer = stac92hd71bxx_analog_mixer;
5303 spec->init = stac92hd71bxx_analog_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005304 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005305 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5306 stac92hd71bxx_dmic_nids,
5307 STAC92HD71BXX_NUM_DMICS);
5308 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5309 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005310 }
5311
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005312 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5313 snd_hda_sequence_write_cache(codec, unmute_init);
5314
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005315 spec->aloopback_ctl = stac92hd71bxx_loopback;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005316 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005317 spec->aloopback_shift = 0;
5318
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005319 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005320 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005321 spec->mux_nids = stac92hd71bxx_mux_nids;
5322 spec->adc_nids = stac92hd71bxx_adc_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005323 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005324 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005325
5326 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5327 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005328 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005329
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005330 switch (spec->board_config) {
5331 case STAC_HP_M4:
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005332 /* enable internal microphone */
Takashi Iwai330ee992009-02-20 14:33:36 +01005333 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
Matthew Ranostayb9aea712008-10-09 08:37:28 -04005334 stac92xx_auto_set_pinctl(codec, 0x0e,
5335 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05005336 /* fallthru */
5337 case STAC_DELL_M4_2:
5338 spec->num_dmics = 0;
5339 spec->num_smuxes = 0;
5340 spec->num_dmuxes = 0;
5341 break;
5342 case STAC_DELL_M4_1:
5343 case STAC_DELL_M4_3:
5344 spec->num_dmics = 1;
5345 spec->num_smuxes = 0;
Takashi Iwaiea18aa42009-02-27 17:36:33 +01005346 spec->num_dmuxes = 1;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005347 break;
James Gardiner514bf542009-05-03 04:00:44 -04005348 case STAC_HP_DV4_1222NR:
5349 spec->num_dmics = 1;
5350 /* I don't know if it needs 1 or 2 smuxes - will wait for
5351 * bug reports to fix if needed
5352 */
5353 spec->num_smuxes = 1;
5354 spec->num_dmuxes = 1;
5355#ifdef CONFIG_SND_HDA_POWER_SAVE
5356 /* This controls MUTE LED */
5357 spec->gpio_mask |= 0x01;
5358 spec->gpio_dir |= 0x01;
5359 spec->gpio_data |= 0x01;
5360 codec->patch_ops.check_power_status =
5361 stac92xx_hp_check_power_status;
5362#endif
5363 /* fallthrough */
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005364 case STAC_HP_DV5:
Takashi Iwai330ee992009-02-20 14:33:36 +01005365 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005366 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
5367 break;
Christoph Plattnerae6241f2009-03-08 23:19:05 +01005368 case STAC_HP_HDX:
5369 spec->num_dmics = 1;
5370 spec->num_dmuxes = 1;
5371 spec->num_smuxes = 1;
Takashi Iwai6fce61a2009-03-10 07:48:57 +01005372 /*
Christoph Plattner443e26d2009-03-10 00:05:56 +01005373 * For controlling MUTE LED on HP HDX16/HDX18 notebooks,
5374 * the CONFIG_SND_HDA_POWER_SAVE is needed to be set.
5375 */
5376#ifdef CONFIG_SND_HDA_POWER_SAVE
5377 /* orange/white mute led on GPIO3, orange=0, white=1 */
5378 spec->gpio_mask |= 0x08;
5379 spec->gpio_dir |= 0x08;
5380 spec->gpio_data |= 0x08; /* set to white */
5381
5382 /* register check_power_status callback. */
Takashi Iwai6fce61a2009-03-10 07:48:57 +01005383 codec->patch_ops.check_power_status =
James Gardiner514bf542009-05-03 04:00:44 -04005384 stac92xx_hp_check_power_status;
Christoph Plattner443e26d2009-03-10 00:05:56 +01005385#endif
Christoph Plattnerae6241f2009-03-08 23:19:05 +01005386 break;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005387 };
5388
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005389 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005390 if (spec->dinput_mux)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005391 spec->private_dimux.num_items += spec->num_dmics - ndmic_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005392
Herton Ronaldo Krzesinski29d4ab42009-02-04 11:37:27 -05005393 err = stac92xx_parse_auto_config(codec, 0x21, 0);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005394 if (!err) {
5395 if (spec->board_config < 0) {
5396 printk(KERN_WARNING "hda_codec: No auto-config is "
5397 "available, default to model=ref\n");
5398 spec->board_config = STAC_92HD71BXX_REF;
5399 goto again;
5400 }
5401 err = -EINVAL;
5402 }
5403
5404 if (err < 0) {
5405 stac92xx_free(codec);
5406 return err;
5407 }
5408
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005409 codec->proc_widget_hook = stac92hd7x_proc_hook;
5410
Matthew Ranostaye035b842007-11-06 11:53:55 +01005411 return 0;
5412};
5413
Matt2f2f4252005-04-13 14:45:30 +02005414static int patch_stac922x(struct hda_codec *codec)
5415{
5416 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005417 int err;
Matt2f2f4252005-04-13 14:45:30 +02005418
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005419 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02005420 if (spec == NULL)
5421 return -ENOMEM;
5422
5423 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005424 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005425 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005426 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5427 stac922x_models,
5428 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08005429 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005430 spec->gpio_mask = spec->gpio_dir = 0x03;
5431 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005432 /* Intel Macs have all same PCI SSID, so we need to check
5433 * codec SSID to distinguish the exact models
5434 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005435 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005436 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005437
5438 case 0x106b0800:
5439 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02005440 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005441 case 0x106b0600:
5442 case 0x106b0700:
5443 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005444 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005445 case 0x106b0e00:
5446 case 0x106b0f00:
5447 case 0x106b1600:
5448 case 0x106b1700:
5449 case 0x106b0200:
5450 case 0x106b1e00:
5451 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005452 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005453 case 0x106b1a00:
5454 case 0x00000100:
5455 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02005456 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005457 case 0x106b0a00:
5458 case 0x106b2200:
5459 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02005460 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08005461 default:
5462 spec->board_config = STAC_INTEL_MAC_V3;
5463 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005464 }
5465 }
5466
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005467 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005468 if (spec->board_config < 0)
Richard Fish11b44bb2006-08-23 18:31:34 +02005469 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
5470 "using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01005471 else
5472 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005473 stac922x_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02005474
Matt2f2f4252005-04-13 14:45:30 +02005475 spec->adc_nids = stac922x_adc_nids;
5476 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005477 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005478 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005479 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005480 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02005481
5482 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02005483 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02005484
5485 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02005486
Matt Porter3cc08dc2006-01-23 15:27:49 +01005487 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005488 if (!err) {
5489 if (spec->board_config < 0) {
5490 printk(KERN_WARNING "hda_codec: No auto-config is "
5491 "available, default to model=ref\n");
5492 spec->board_config = STAC_D945_REF;
5493 goto again;
5494 }
5495 err = -EINVAL;
5496 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005497 if (err < 0) {
5498 stac92xx_free(codec);
5499 return err;
5500 }
5501
5502 codec->patch_ops = stac92xx_patch_ops;
5503
Takashi Iwai807a46362007-05-29 19:01:37 +02005504 /* Fix Mux capture level; max to 2 */
5505 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
5506 (0 << AC_AMPCAP_OFFSET_SHIFT) |
5507 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5508 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5509 (0 << AC_AMPCAP_MUTE_SHIFT));
5510
Matt Porter3cc08dc2006-01-23 15:27:49 +01005511 return 0;
5512}
5513
5514static int patch_stac927x(struct hda_codec *codec)
5515{
5516 struct sigmatel_spec *spec;
5517 int err;
5518
5519 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5520 if (spec == NULL)
5521 return -ENOMEM;
5522
5523 codec->spec = spec;
Matthew Ranostay45c1d852009-02-04 17:49:41 -05005524 codec->slave_dig_outs = stac927x_slave_dig_outs;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005525 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005526 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005527 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5528 stac927x_models,
5529 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005530 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005531 if (spec->board_config < 0)
Herton Ronaldo Krzesinskic98041f2009-02-11 20:33:15 -02005532 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
5533 "STAC927x, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01005534 else
5535 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005536 stac927x_brd_tbl[spec->board_config]);
Matt Porter3cc08dc2006-01-23 15:27:49 +01005537
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005538 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005539 spec->adc_nids = stac927x_adc_nids;
5540 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
5541 spec->mux_nids = stac927x_mux_nids;
5542 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005543 spec->smux_nids = stac927x_smux_nids;
5544 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04005545 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005546 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005547 spec->multiout.dac_nids = spec->dac_nids;
5548
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005549 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02005550 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005551 case STAC_D965_5ST:
5552 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005553 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005554 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005555 spec->num_dmics = 0;
5556
Tobin Davis93ed1502006-09-01 21:03:12 +02005557 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005558 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005559 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005560 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02005561 switch (codec->subsystem_id) {
5562 case 0x10280209:
5563 case 0x1028022e:
5564 /* correct the device field to SPDIF out */
Takashi Iwai330ee992009-02-20 14:33:36 +01005565 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
Matthew Ranostay780c8be2008-04-14 13:32:27 +02005566 break;
5567 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01005568 /* configure the analog microphone on some laptops */
Takashi Iwai330ee992009-02-20 14:33:36 +01005569 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01005570 /* correct the front output jack as a hp out */
Takashi Iwai330ee992009-02-20 14:33:36 +01005571 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01005572 /* correct the front input jack as a mic */
Takashi Iwai330ee992009-02-20 14:33:36 +01005573 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01005574 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005575 case STAC_DELL_3ST:
5576 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005577 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005578 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005579 spec->dmic_nids = stac927x_dmic_nids;
5580 spec->num_dmics = STAC927X_NUM_DMICS;
5581
Tobin Davis93ed1502006-09-01 21:03:12 +02005582 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005583 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005584 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai16970552007-12-18 18:05:52 +01005585 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005586 break;
5587 default:
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005588 if (spec->board_config > STAC_D965_REF) {
5589 /* GPIO0 High = Enable EAPD */
5590 spec->eapd_mask = spec->gpio_mask = 0x01;
5591 spec->gpio_dir = spec->gpio_data = 0x01;
5592 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005593 spec->num_dmics = 0;
5594
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005595 spec->init = stac927x_core_init;
5596 spec->mixer = stac927x_mixer;
5597 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005598
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005599 spec->num_pwrs = 0;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005600 spec->aloopback_ctl = stac927x_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005601 spec->aloopback_mask = 0x40;
5602 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005603 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005604
Matt Porter3cc08dc2006-01-23 15:27:49 +01005605 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005606 if (!err) {
5607 if (spec->board_config < 0) {
5608 printk(KERN_WARNING "hda_codec: No auto-config is "
5609 "available, default to model=ref\n");
5610 spec->board_config = STAC_D965_REF;
5611 goto again;
5612 }
5613 err = -EINVAL;
5614 }
Mattc7d4b2f2005-06-27 14:59:41 +02005615 if (err < 0) {
5616 stac92xx_free(codec);
5617 return err;
5618 }
Matt2f2f4252005-04-13 14:45:30 +02005619
5620 codec->patch_ops = stac92xx_patch_ops;
5621
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005622 codec->proc_widget_hook = stac927x_proc_hook;
5623
Takashi Iwai52987652008-01-16 16:09:47 +01005624 /*
5625 * !!FIXME!!
5626 * The STAC927x seem to require fairly long delays for certain
5627 * command sequences. With too short delays (even if the answer
5628 * is set to RIRB properly), it results in the silence output
5629 * on some hardwares like Dell.
5630 *
5631 * The below flag enables the longer delay (see get_response
5632 * in hda_intel.c).
5633 */
5634 codec->bus->needs_damn_long_delay = 1;
5635
Takashi Iwaie28d8322008-12-17 13:48:29 +01005636 /* no jack detecion for ref-no-jd model */
5637 if (spec->board_config == STAC_D965_REF_NO_JD)
5638 spec->hp_detect = 0;
5639
Matt2f2f4252005-04-13 14:45:30 +02005640 return 0;
5641}
5642
Matt Porterf3302a592006-07-31 12:49:34 +02005643static int patch_stac9205(struct hda_codec *codec)
5644{
5645 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02005646 int err;
Matt Porterf3302a592006-07-31 12:49:34 +02005647
5648 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5649 if (spec == NULL)
5650 return -ENOMEM;
5651
5652 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005653 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005654 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005655 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
5656 stac9205_models,
5657 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005658 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005659 if (spec->board_config < 0)
Richard Fish11b44bb2006-08-23 18:31:34 +02005660 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01005661 else
5662 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005663 stac9205_brd_tbl[spec->board_config]);
Matt Porterf3302a592006-07-31 12:49:34 +02005664
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005665 spec->digbeep_nid = 0x23;
Matt Porterf3302a592006-07-31 12:49:34 +02005666 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005667 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a592006-07-31 12:49:34 +02005668 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005669 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005670 spec->smux_nids = stac9205_smux_nids;
5671 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005672 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02005673 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005674 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai16970552007-12-18 18:05:52 +01005675 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005676 spec->num_pwrs = 0;
Matt Porterf3302a592006-07-31 12:49:34 +02005677
5678 spec->init = stac9205_core_init;
5679 spec->mixer = stac9205_mixer;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005680 spec->aloopback_ctl = stac9205_loopback;
Matt Porterf3302a592006-07-31 12:49:34 +02005681
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005682 spec->aloopback_mask = 0x40;
5683 spec->aloopback_shift = 0;
Takashi Iwaid9a42682009-01-22 17:40:18 +01005684 /* Turn on/off EAPD per HP plugging */
5685 if (spec->board_config != STAC_9205_EAPD)
5686 spec->eapd_switch = 1;
Matt Porterf3302a592006-07-31 12:49:34 +02005687 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02005688
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005689 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005690 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02005691 /* Enable SPDIF in/out */
Takashi Iwai330ee992009-02-20 14:33:36 +01005692 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
5693 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01005694
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005695 /* Enable unsol response for GPIO4/Dock HP connection */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005696 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
5697 if (err < 0)
5698 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005699 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005700 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
5701 snd_hda_codec_write_cache(codec, codec->afg, 0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005702 AC_VERB_SET_UNSOLICITED_ENABLE,
5703 AC_USRSP_EN | err);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005704
5705 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005706 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005707 spec->gpio_mask = 0x1b;
5708 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01005709 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005710 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02005711 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005712 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005713 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005714 case STAC_9205_REF:
5715 /* SPDIF-In enabled */
5716 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005717 default:
5718 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005719 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005720 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005721 break;
5722 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02005723
Matt Porterf3302a592006-07-31 12:49:34 +02005724 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005725 if (!err) {
5726 if (spec->board_config < 0) {
5727 printk(KERN_WARNING "hda_codec: No auto-config is "
5728 "available, default to model=ref\n");
5729 spec->board_config = STAC_9205_REF;
5730 goto again;
5731 }
5732 err = -EINVAL;
5733 }
Matt Porterf3302a592006-07-31 12:49:34 +02005734 if (err < 0) {
5735 stac92xx_free(codec);
5736 return err;
5737 }
5738
5739 codec->patch_ops = stac92xx_patch_ops;
5740
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005741 codec->proc_widget_hook = stac9205_proc_hook;
5742
Matt Porterf3302a592006-07-31 12:49:34 +02005743 return 0;
5744}
5745
Matt2f2f4252005-04-13 14:45:30 +02005746/*
Guillaume Munch6d859062006-08-22 17:15:47 +02005747 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01005748 */
5749
Takashi Iwai1e137f92009-01-21 07:41:22 +01005750static struct hda_verb stac9872_core_init[] = {
Takashi Iwai1624cb92007-07-05 13:10:51 +02005751 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005752 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5753 {}
5754};
5755
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005756static struct snd_kcontrol_new stac9872_mixer[] = {
5757 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5758 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005759 { } /* end */
5760};
5761
5762static hda_nid_t stac9872_pin_nids[] = {
5763 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
5764 0x11, 0x13, 0x14,
5765};
5766
5767static hda_nid_t stac9872_adc_nids[] = {
5768 0x8 /*,0x6*/
5769};
5770
5771static hda_nid_t stac9872_mux_nids[] = {
5772 0x15
5773};
5774
Takashi Iwai307282c2009-03-12 18:17:58 +01005775static unsigned int stac9872_vaio_pin_configs[9] = {
5776 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
5777 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
5778 0x90a7013e
5779};
5780
5781static const char *stac9872_models[STAC_9872_MODELS] = {
5782 [STAC_9872_AUTO] = "auto",
5783 [STAC_9872_VAIO] = "vaio",
5784};
5785
5786static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
5787 [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
5788};
5789
5790static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5791 {} /* terminator */
5792};
5793
Guillaume Munch6d859062006-08-22 17:15:47 +02005794static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01005795{
5796 struct sigmatel_spec *spec;
Takashi Iwai1e137f92009-01-21 07:41:22 +01005797 int err;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005798
Takashi Iwaidb064e52006-03-16 16:04:58 +01005799 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5800 if (spec == NULL)
5801 return -ENOMEM;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005802 codec->spec = spec;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005803
5804 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5805 stac9872_models,
5806 stac9872_cfg_tbl);
Takashi Iwai307282c2009-03-12 18:17:58 +01005807 if (spec->board_config < 0)
5808 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9872, "
5809 "using BIOS defaults\n");
5810 else
5811 stac92xx_set_config_regs(codec,
5812 stac9872_brd_tbl[spec->board_config]);
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005813
Takashi Iwai1e137f92009-01-21 07:41:22 +01005814 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
5815 spec->pin_nids = stac9872_pin_nids;
5816 spec->multiout.dac_nids = spec->dac_nids;
5817 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
5818 spec->adc_nids = stac9872_adc_nids;
5819 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
5820 spec->mux_nids = stac9872_mux_nids;
5821 spec->mixer = stac9872_mixer;
5822 spec->init = stac9872_core_init;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005823
Takashi Iwai1e137f92009-01-21 07:41:22 +01005824 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
5825 if (err < 0) {
5826 stac92xx_free(codec);
5827 return -EINVAL;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005828 }
Takashi Iwai1e137f92009-01-21 07:41:22 +01005829 spec->input_mux = &spec->private_imux;
5830 codec->patch_ops = stac92xx_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005831 return 0;
5832}
5833
5834
5835/*
Matt2f2f4252005-04-13 14:45:30 +02005836 * patch entries
5837 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +01005838static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
Matt2f2f4252005-04-13 14:45:30 +02005839 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5840 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5841 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5842 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5843 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5844 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5845 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02005846 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5847 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5848 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5849 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5850 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5851 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01005852 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5853 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5854 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5855 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5856 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5857 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5858 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5859 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5860 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5861 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01005862 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5863 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5864 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5865 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5866 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5867 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02005868 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5869 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02005870 /* The following does not take into account .id=0x83847661 when subsys =
5871 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5872 * currently not fully supported.
5873 */
5874 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5875 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5876 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a592006-07-31 12:49:34 +02005877 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5878 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5879 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5880 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5881 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5882 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5883 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5884 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005885 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005886 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5887 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayff2e7332009-04-01 14:49:48 -04005888 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005889 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01005890 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5891 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005892 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01005893 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5894 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5895 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5896 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5897 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5898 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5899 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5900 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02005901 {} /* terminator */
5902};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01005903
5904MODULE_ALIAS("snd-hda-codec-id:8384*");
5905MODULE_ALIAS("snd-hda-codec-id:111d*");
5906
5907MODULE_LICENSE("GPL");
5908MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
5909
5910static struct hda_codec_preset_list sigmatel_list = {
5911 .preset = snd_hda_preset_sigmatel,
5912 .owner = THIS_MODULE,
5913};
5914
5915static int __init patch_sigmatel_init(void)
5916{
5917 return snd_hda_add_codec_preset(&sigmatel_list);
5918}
5919
5920static void __exit patch_sigmatel_exit(void)
5921{
5922 snd_hda_delete_codec_preset(&sigmatel_list);
5923}
5924
5925module_init(patch_sigmatel_init)
5926module_exit(patch_sigmatel_exit)