blob: 37ffd96a9ff20428299770a9e8a12ce5f18858d9 [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,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100102 STAC_92HD71BXX_MODELS
103};
104
105enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100106 STAC_925x_AUTO,
Tobin Davis8e21c342007-01-08 11:04:17 +0100107 STAC_925x_REF,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200108 STAC_M1,
109 STAC_M1_2,
110 STAC_M2,
Tobin Davis8e21c342007-01-08 11:04:17 +0100111 STAC_M2_2,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200112 STAC_M3,
113 STAC_M5,
114 STAC_M6,
Tobin Davis8e21c342007-01-08 11:04:17 +0100115 STAC_925x_MODELS
116};
117
118enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100119 STAC_922X_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100120 STAC_D945_REF,
121 STAC_D945GTP3,
122 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200123 STAC_INTEL_MAC_V1,
124 STAC_INTEL_MAC_V2,
125 STAC_INTEL_MAC_V3,
126 STAC_INTEL_MAC_V4,
127 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800128 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
129 * is given, one of the above models will be
130 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200131 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100132 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100133 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100134 STAC_MACBOOK_PRO_V1,
135 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200136 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200137 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300138 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200139 STAC_922X_DELL_D81,
140 STAC_922X_DELL_D82,
141 STAC_922X_DELL_M81,
142 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100143 STAC_922X_MODELS
144};
145
146enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100147 STAC_927X_AUTO,
Takashi Iwaie28d8322008-12-17 13:48:29 +0100148 STAC_D965_REF_NO_JD, /* no jack-detection */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100149 STAC_D965_REF,
150 STAC_D965_3ST,
151 STAC_D965_5ST,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200152 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100153 STAC_DELL_BIOS,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100154 STAC_927X_MODELS
155};
Matt Porter403d1942005-11-29 15:00:51 +0100156
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400157struct sigmatel_event {
158 hda_nid_t nid;
Takashi Iwaic6e4c662008-11-25 11:58:19 +0100159 unsigned char type;
160 unsigned char tag;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400161 int data;
162};
163
164struct sigmatel_jack {
165 hda_nid_t nid;
166 int type;
167 struct snd_jack *jack;
168};
169
Matt2f2f4252005-04-13 14:45:30 +0200170struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100171 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200172 unsigned int num_mixers;
173
Matt Porter403d1942005-11-29 15:00:51 +0100174 int board_config;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -0500175 unsigned int eapd_switch: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200176 unsigned int surr_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100177 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100178 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400179 unsigned int spdif_mute: 1;
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100180 unsigned int check_volume_offset:1;
Mattc7d4b2f2005-06-27 14:59:41 +0200181
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100182 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200183 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100184 unsigned int gpio_mask;
185 unsigned int gpio_dir;
186 unsigned int gpio_data;
187 unsigned int gpio_mute;
188
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200189 /* stream */
190 unsigned int stream_delay;
191
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100192 /* analog loopback */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100193 unsigned char aloopback_mask;
194 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200195
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100196 /* power management */
197 unsigned int num_pwrs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200198 unsigned int *pwr_mapping;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100199 hda_nid_t *pwr_nids;
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100200 hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100201
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400202 /* jack detection */
203 struct snd_array jacks;
204
205 /* events */
206 struct snd_array events;
207
Matt2f2f4252005-04-13 14:45:30 +0200208 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100209 struct hda_input_mux *mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400210 struct hda_input_mux *amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100211 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200212 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100213 hda_nid_t dac_nids[5];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100214 hda_nid_t hp_dacs[5];
215 hda_nid_t speaker_dacs[5];
Matt2f2f4252005-04-13 14:45:30 +0200216
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100217 int volume_offset;
218
Matt2f2f4252005-04-13 14:45:30 +0200219 /* capture */
220 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200221 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200222 hda_nid_t *mux_nids;
223 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200224 hda_nid_t *dmic_nids;
225 unsigned int num_dmics;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100226 hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100227 unsigned int num_dmuxes;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200228 hda_nid_t *smux_nids;
229 unsigned int num_smuxes;
Matthew Ranostay65973632008-09-16 10:39:37 -0400230 const char **spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200231
Mattdabbed62005-06-14 10:19:34 +0200232 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100233 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200234 hda_nid_t anabeep_nid;
235 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200236
Matt2f2f4252005-04-13 14:45:30 +0200237 /* pin widgets */
238 hda_nid_t *pin_nids;
239 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200240
241 /* codec specific stuff */
242 struct hda_verb *init;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100243 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200244
245 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200246 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100247 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200248 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100249 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200250 struct hda_input_mux *sinput_mux;
251 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400252 unsigned int cur_amux;
253 hda_nid_t *amp_nids;
254 unsigned int num_amps;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200255 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200256
Matt Porter403d1942005-11-29 15:00:51 +0100257 /* i/o switches */
258 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200259 unsigned int clfe_swap;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100260 hda_nid_t line_switch; /* shared line-in for input and output */
261 hda_nid_t mic_switch; /* shared mic-in for input and output */
262 hda_nid_t hp_switch; /* NID of HP as line-out */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200263 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200264
Mattc7d4b2f2005-06-27 14:59:41 +0200265 struct hda_pcm pcm_rec[2]; /* PCM information */
266
267 /* dynamic controls and input_mux */
268 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200269 struct snd_array kctls;
Matt Porter8b657272006-10-26 17:12:59 +0200270 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200271 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200272 struct hda_input_mux private_smux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400273 struct hda_input_mux private_amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100274 struct hda_input_mux private_mono_mux;
Matt2f2f4252005-04-13 14:45:30 +0200275};
276
277static hda_nid_t stac9200_adc_nids[1] = {
278 0x03,
279};
280
281static hda_nid_t stac9200_mux_nids[1] = {
282 0x0c,
283};
284
285static hda_nid_t stac9200_dac_nids[1] = {
286 0x02,
287};
288
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100289static hda_nid_t stac92hd73xx_pwr_nids[8] = {
290 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
291 0x0f, 0x10, 0x11
292};
293
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400294static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
295 0x26, 0,
296};
297
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100298static hda_nid_t stac92hd73xx_adc_nids[2] = {
299 0x1a, 0x1b
300};
301
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400302#define DELL_M6_AMP 2
303static hda_nid_t stac92hd73xx_amp_nids[3] = {
304 0x0b, 0x0c, 0x0e
Matthew Ranostay89385032008-09-11 09:49:39 -0400305};
306
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100307#define STAC92HD73XX_NUM_DMICS 2
308static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
309 0x13, 0x14, 0
310};
311
312#define STAC92HD73_DAC_COUNT 5
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100313
314static hda_nid_t stac92hd73xx_mux_nids[4] = {
315 0x28, 0x29, 0x2a, 0x2b,
316};
317
318static hda_nid_t stac92hd73xx_dmux_nids[2] = {
319 0x20, 0x21,
320};
321
Matthew Ranostayd9737752008-09-07 12:03:41 +0200322static hda_nid_t stac92hd73xx_smux_nids[2] = {
323 0x22, 0x23,
324};
325
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200326#define STAC92HD83XXX_NUM_DMICS 2
327static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
328 0x11, 0x12, 0
329};
330
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200331#define STAC92HD83_DAC_COUNT 3
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200332
333static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
334 0x17, 0x18,
335};
336
337static hda_nid_t stac92hd83xxx_adc_nids[2] = {
338 0x15, 0x16,
339};
340
341static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
342 0xa, 0xb, 0xd, 0xe,
343};
344
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400345static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
346 0x1e, 0,
347};
348
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200349static unsigned int stac92hd83xxx_pwr_mapping[4] = {
Matthew Ranostay87e88a72009-01-22 20:38:42 -0500350 0x03, 0x0c, 0x20, 0x40,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200351};
352
Takashi Iwai9248f262009-01-14 09:40:25 +0100353static hda_nid_t stac92hd83xxx_amp_nids[1] = {
Matthew Ranostayc15c5062009-01-13 13:30:07 -0500354 0xc,
355};
356
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100357static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
358 0x0a, 0x0d, 0x0f
359};
360
Matthew Ranostaye035b842007-11-06 11:53:55 +0100361static hda_nid_t stac92hd71bxx_adc_nids[2] = {
362 0x12, 0x13,
363};
364
365static hda_nid_t stac92hd71bxx_mux_nids[2] = {
366 0x1a, 0x1b
367};
368
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400369static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
370 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100371};
372
Matthew Ranostayd9737752008-09-07 12:03:41 +0200373static hda_nid_t stac92hd71bxx_smux_nids[2] = {
374 0x24, 0x25,
375};
376
Matthew Ranostaye035b842007-11-06 11:53:55 +0100377#define STAC92HD71BXX_NUM_DMICS 2
378static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
379 0x18, 0x19, 0
380};
381
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400382static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
383 0x22, 0
384};
385
Tobin Davis8e21c342007-01-08 11:04:17 +0100386static hda_nid_t stac925x_adc_nids[1] = {
387 0x03,
388};
389
390static hda_nid_t stac925x_mux_nids[1] = {
391 0x0f,
392};
393
394static hda_nid_t stac925x_dac_nids[1] = {
395 0x02,
396};
397
Takashi Iwaif6e98522007-10-16 14:27:04 +0200398#define STAC925X_NUM_DMICS 1
399static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
400 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200401};
402
Takashi Iwai1697055e2007-12-18 18:05:52 +0100403static hda_nid_t stac925x_dmux_nids[1] = {
404 0x14,
405};
406
Matt2f2f4252005-04-13 14:45:30 +0200407static hda_nid_t stac922x_adc_nids[2] = {
408 0x06, 0x07,
409};
410
411static hda_nid_t stac922x_mux_nids[2] = {
412 0x12, 0x13,
413};
414
Matthew Ranostay45c1d852009-02-04 17:49:41 -0500415static hda_nid_t stac927x_slave_dig_outs[2] = {
416 0x1f, 0,
417};
418
Matt Porter3cc08dc2006-01-23 15:27:49 +0100419static hda_nid_t stac927x_adc_nids[3] = {
420 0x07, 0x08, 0x09
421};
422
423static hda_nid_t stac927x_mux_nids[3] = {
424 0x15, 0x16, 0x17
425};
426
Matthew Ranostayd9737752008-09-07 12:03:41 +0200427static hda_nid_t stac927x_smux_nids[1] = {
428 0x21,
429};
430
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100431static hda_nid_t stac927x_dac_nids[6] = {
432 0x02, 0x03, 0x04, 0x05, 0x06, 0
433};
434
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100435static hda_nid_t stac927x_dmux_nids[1] = {
436 0x1b,
437};
438
Matthew Ranostay7f168592007-10-18 17:38:17 +0200439#define STAC927X_NUM_DMICS 2
440static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
441 0x13, 0x14, 0
442};
443
Matthew Ranostay65973632008-09-16 10:39:37 -0400444static const char *stac927x_spdif_labels[5] = {
445 "Digital Playback", "ADAT", "Analog Mux 1",
446 "Analog Mux 2", "Analog Mux 3"
447};
448
Matt Porterf3302a52006-07-31 12:49:34 +0200449static hda_nid_t stac9205_adc_nids[2] = {
450 0x12, 0x13
451};
452
453static hda_nid_t stac9205_mux_nids[2] = {
454 0x19, 0x1a
455};
456
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100457static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100458 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100459};
460
Matthew Ranostayd9737752008-09-07 12:03:41 +0200461static hda_nid_t stac9205_smux_nids[1] = {
462 0x21,
463};
464
Takashi Iwaif6e98522007-10-16 14:27:04 +0200465#define STAC9205_NUM_DMICS 2
466static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
467 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200468};
469
Mattc7d4b2f2005-06-27 14:59:41 +0200470static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200471 0x08, 0x09, 0x0d, 0x0e,
472 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200473};
474
Tobin Davis8e21c342007-01-08 11:04:17 +0100475static hda_nid_t stac925x_pin_nids[8] = {
476 0x07, 0x08, 0x0a, 0x0b,
477 0x0c, 0x0d, 0x10, 0x11,
478};
479
Matt2f2f4252005-04-13 14:45:30 +0200480static hda_nid_t stac922x_pin_nids[10] = {
481 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
482 0x0f, 0x10, 0x11, 0x15, 0x1b,
483};
484
Matthew Ranostaya7662642008-02-21 07:51:14 +0100485static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100486 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
487 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200488 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100489};
490
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -0500491static hda_nid_t stac92hd83xxx_pin_nids[10] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200492 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -0500493 0x0f, 0x10, 0x11, 0x1f, 0x20,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200494};
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500495
496#define STAC92HD71BXX_NUM_PINS 13
497static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
498 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
499 0x00, 0x14, 0x18, 0x19, 0x1e,
500 0x1f, 0x20, 0x27
501};
502static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100503 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
504 0x0f, 0x14, 0x18, 0x19, 0x1e,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500505 0x1f, 0x20, 0x27
Matthew Ranostaye035b842007-11-06 11:53:55 +0100506};
507
Matt Porter3cc08dc2006-01-23 15:27:49 +0100508static hda_nid_t stac927x_pin_nids[14] = {
509 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
510 0x0f, 0x10, 0x11, 0x12, 0x13,
511 0x14, 0x21, 0x22, 0x23,
512};
513
Matt Porterf3302a52006-07-31 12:49:34 +0200514static hda_nid_t stac9205_pin_nids[12] = {
515 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
516 0x0f, 0x14, 0x16, 0x17, 0x18,
517 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200518};
519
Matthew Ranostay89385032008-09-11 09:49:39 -0400520#define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
521
522static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
523 struct snd_ctl_elem_value *ucontrol)
524{
525 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
526 struct sigmatel_spec *spec = codec->spec;
527 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
528
529 kcontrol->private_value ^= get_amp_nid(kcontrol);
530 kcontrol->private_value |= nid;
531
532 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
533}
534
535static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
536 struct snd_ctl_elem_value *ucontrol)
537{
538 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
539 struct sigmatel_spec *spec = codec->spec;
540 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
541
542 kcontrol->private_value ^= get_amp_nid(kcontrol);
543 kcontrol->private_value |= nid;
544
545 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
546}
547
Matt Porter8b657272006-10-26 17:12:59 +0200548static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
549 struct snd_ctl_elem_info *uinfo)
550{
551 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
552 struct sigmatel_spec *spec = codec->spec;
553 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
554}
555
556static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
557 struct snd_ctl_elem_value *ucontrol)
558{
559 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
560 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100561 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200562
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100563 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200564 return 0;
565}
566
567static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
568 struct snd_ctl_elem_value *ucontrol)
569{
570 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
571 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100572 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200573
574 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100575 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200576}
577
Matthew Ranostayd9737752008-09-07 12:03:41 +0200578static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
579 struct snd_ctl_elem_info *uinfo)
580{
581 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
582 struct sigmatel_spec *spec = codec->spec;
583 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
584}
585
586static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
587 struct snd_ctl_elem_value *ucontrol)
588{
589 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
590 struct sigmatel_spec *spec = codec->spec;
591 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
592
593 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
594 return 0;
595}
596
597static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
598 struct snd_ctl_elem_value *ucontrol)
599{
600 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
601 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400602 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200603 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400604 int err, val;
605 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200606
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400607 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200608 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400609 if (err < 0)
610 return err;
611
612 if (spec->spdif_mute) {
613 if (smux_idx == 0)
614 nid = spec->multiout.dig_out_nid;
615 else
616 nid = codec->slave_dig_outs[smux_idx - 1];
617 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100618 val = HDA_AMP_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400619 else
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100620 val = 0;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400621 /* un/mute SPDIF out */
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100622 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
623 HDA_AMP_MUTE, val);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400624 }
625 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200626}
627
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100628static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200629{
630 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
631 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200632 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200633}
634
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100635static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200636{
637 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
638 struct sigmatel_spec *spec = codec->spec;
639 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
640
641 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
642 return 0;
643}
644
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100645static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200646{
647 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
648 struct sigmatel_spec *spec = codec->spec;
649 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
650
Mattc7d4b2f2005-06-27 14:59:41 +0200651 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200652 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
653}
654
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100655static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
656 struct snd_ctl_elem_info *uinfo)
657{
658 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
659 struct sigmatel_spec *spec = codec->spec;
660 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
661}
662
663static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
664 struct snd_ctl_elem_value *ucontrol)
665{
666 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
667 struct sigmatel_spec *spec = codec->spec;
668
669 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
670 return 0;
671}
672
673static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
674 struct snd_ctl_elem_value *ucontrol)
675{
676 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
677 struct sigmatel_spec *spec = codec->spec;
678
679 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
680 spec->mono_nid, &spec->cur_mmux);
681}
682
Matthew Ranostay89385032008-09-11 09:49:39 -0400683static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
684 struct snd_ctl_elem_info *uinfo)
685{
686 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
687 struct sigmatel_spec *spec = codec->spec;
688 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
689}
690
691static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
692 struct snd_ctl_elem_value *ucontrol)
693{
694 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
695 struct sigmatel_spec *spec = codec->spec;
696
697 ucontrol->value.enumerated.item[0] = spec->cur_amux;
698 return 0;
699}
700
701static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
702 struct snd_ctl_elem_value *ucontrol)
703{
704 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
705 struct sigmatel_spec *spec = codec->spec;
706 struct snd_kcontrol *ctl =
707 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
708 if (!ctl)
709 return -EINVAL;
710
711 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
712 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
713
714 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
715 0, &spec->cur_amux);
716}
717
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200718#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
719
720static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
721 struct snd_ctl_elem_value *ucontrol)
722{
723 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100724 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200725 struct sigmatel_spec *spec = codec->spec;
726
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100727 ucontrol->value.integer.value[0] = !!(spec->aloopback &
728 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200729 return 0;
730}
731
732static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
733 struct snd_ctl_elem_value *ucontrol)
734{
735 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
736 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100737 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200738 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100739 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200740
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100741 idx_val = spec->aloopback_mask << idx;
742 if (ucontrol->value.integer.value[0])
743 val = spec->aloopback | idx_val;
744 else
745 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100746 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200747 return 0;
748
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100749 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200750
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100751 /* Only return the bits defined by the shift value of the
752 * first two bytes of the mask
753 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200754 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100755 kcontrol->private_value & 0xFFFF, 0x0);
756 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200757
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100758 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200759 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100760 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200761 } else {
762 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100763 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200764 }
765
766 snd_hda_codec_write_cache(codec, codec->afg, 0,
767 kcontrol->private_value >> 16, dac_mode);
768
769 return 1;
770}
771
Mattc7d4b2f2005-06-27 14:59:41 +0200772static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200773 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200774 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200775 {}
776};
777
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200778static struct hda_verb stac9200_eapd_init[] = {
779 /* set dac0mux for dac converter */
780 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
781 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
782 {}
783};
784
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100785static struct hda_verb stac92hd73xx_6ch_core_init[] = {
786 /* set master volume and direct control */
787 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100788 /* setup adcs to point to mixer */
789 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
790 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100791 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
792 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
793 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
794 /* setup import muxs */
795 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
796 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
797 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
798 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
799 {}
800};
801
Matthew Ranostayd654a662008-03-14 08:46:51 +0100802static struct hda_verb dell_eq_core_init[] = {
803 /* set master volume to max value without distortion
804 * and direct control */
805 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100806 /* setup adcs to point to mixer */
807 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
808 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
809 /* setup import muxs */
810 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
811 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
812 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
813 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
814 {}
815};
816
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100817static struct hda_verb dell_m6_core_init[] = {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -0500818 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100819 /* setup adcs to point to mixer */
820 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
821 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
822 /* setup import muxs */
823 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
824 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
825 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
826 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
827 {}
828};
829
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100830static struct hda_verb stac92hd73xx_8ch_core_init[] = {
831 /* set master volume and direct control */
832 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100833 /* setup adcs to point to mixer */
834 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
835 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100836 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
837 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
838 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
839 /* setup import muxs */
840 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
841 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
842 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
843 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
844 {}
845};
846
847static struct hda_verb stac92hd73xx_10ch_core_init[] = {
848 /* set master volume and direct control */
849 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100850 /* dac3 is connected to import3 mux */
851 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100852 /* setup adcs to point to mixer */
853 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
854 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100855 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
856 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
857 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
858 /* setup import muxs */
859 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
860 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
861 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
862 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
863 {}
864};
865
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200866static struct hda_verb stac92hd83xxx_core_init[] = {
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -0500867 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1},
868 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1},
869 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200870
871 /* power state controls amps */
872 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200873 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200874};
875
Matthew Ranostaye035b842007-11-06 11:53:55 +0100876static struct hda_verb stac92hd71bxx_core_init[] = {
877 /* set master volume and direct control */
878 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200879 {}
Matthew Ranostay541eee82007-12-14 12:08:04 +0100880};
881
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500882#define HD_DISABLE_PORTF 1
Matthew Ranostay541eee82007-12-14 12:08:04 +0100883static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200884 /* start of config #1 */
885
886 /* connect port 0f to audio mixer */
887 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200888 /* start of config #2 */
889
Matthew Ranostay541eee82007-12-14 12:08:04 +0100890 /* set master volume and direct control */
891 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500892 {}
893};
894
895static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
896 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
897 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100898 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
899 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100900 {}
901};
902
Tobin Davis8e21c342007-01-08 11:04:17 +0100903static struct hda_verb stac925x_core_init[] = {
904 /* set dac0mux for dac converter */
905 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaic9280d62009-01-15 17:31:00 +0100906 /* mute the master volume */
907 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Tobin Davis8e21c342007-01-08 11:04:17 +0100908 {}
909};
910
Mattc7d4b2f2005-06-27 14:59:41 +0200911static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200912 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200913 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200914 {}
915};
916
Tobin Davis93ed1502006-09-01 21:03:12 +0200917static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200918 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200919 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200920 /* unmute node 0x1b */
921 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
922 /* select node 0x03 as DAC */
923 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
924 {}
925};
926
Matt Porter3cc08dc2006-01-23 15:27:49 +0100927static struct hda_verb stac927x_core_init[] = {
928 /* set master volume and direct control */
929 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200930 /* enable analog pc beep path */
931 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100932 {}
933};
934
Matt Porterf3302a52006-07-31 12:49:34 +0200935static struct hda_verb stac9205_core_init[] = {
936 /* set master volume and direct control */
937 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200938 /* enable analog pc beep path */
939 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200940 {}
941};
942
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100943#define STAC_MONO_MUX \
944 { \
945 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
946 .name = "Mono Mux", \
947 .count = 1, \
948 .info = stac92xx_mono_mux_enum_info, \
949 .get = stac92xx_mono_mux_enum_get, \
950 .put = stac92xx_mono_mux_enum_put, \
951 }
952
Matthew Ranostay89385032008-09-11 09:49:39 -0400953#define STAC_AMP_MUX \
954 { \
955 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
956 .name = "Amp Selector Capture Switch", \
957 .count = 1, \
958 .info = stac92xx_amp_mux_enum_info, \
959 .get = stac92xx_amp_mux_enum_get, \
960 .put = stac92xx_amp_mux_enum_put, \
961 }
962
963#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
964 { \
965 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
966 .name = xname, \
967 .index = 0, \
968 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
969 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
970 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
971 .info = stac92xx_amp_volume_info, \
972 .get = stac92xx_amp_volume_get, \
973 .put = stac92xx_amp_volume_put, \
974 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
975 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
976 }
977
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100978#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200979 { \
980 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
981 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100982 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200983 .info = stac92xx_aloopback_info, \
984 .get = stac92xx_aloopback_get, \
985 .put = stac92xx_aloopback_put, \
986 .private_value = verb_read | (verb_write << 16), \
987 }
988
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100989static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200990 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
991 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200992 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
993 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200994 { } /* end */
995};
996
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400997#define DELL_M6_MIXER 6
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100998static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400999 /* start of config #1 */
1000 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1001 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1002
1003 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1004 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1005
1006 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1007 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1008
1009 /* start of config #2 */
1010 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1011 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1012
1013 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1014 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1015
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001016 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1017
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001018 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1019 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1020
1021 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1022 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1023
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001024 { } /* end */
1025};
1026
1027static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001028 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1029
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001030 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1031 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1032
1033 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1034 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1035
1036 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1037 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1038
1039 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1040 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1041
1042 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1043 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1044
1045 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1046 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1047
1048 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1049 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1050 { } /* end */
1051};
1052
1053static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001054 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1055
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001056 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1057 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1058
1059 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1060 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1061
1062 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1063 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1064
1065 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1066 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1067
1068 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1069 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1070
1071 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1072 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1073
1074 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1075 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1076 { } /* end */
1077};
1078
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001079
1080static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1081 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1082 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1083
1084 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1085 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1086
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001087 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT),
1088 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001089
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001090 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT),
1091 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001092
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001093 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT),
1094 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001095
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001096 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT),
1097 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001098
1099 /*
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001100 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT),
1101 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001102 */
1103 { } /* end */
1104};
1105
Matthew Ranostay541eee82007-12-14 12:08:04 +01001106static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001107 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001108
Matthew Ranostay9b359472007-11-07 13:03:12 +01001109 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1110 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay9b359472007-11-07 13:03:12 +01001111
1112 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1113 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001114 /* analog pc-beep replaced with digital beep support */
1115 /*
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001116 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1117 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001118 */
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001119
Matthew Ranostay687cb982008-10-11 13:52:43 -04001120 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1121 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001122
Matthew Ranostay687cb982008-10-11 13:52:43 -04001123 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1124 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001125
1126 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1127 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1128
1129 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1130 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001131 { } /* end */
1132};
1133
Matthew Ranostay541eee82007-12-14 12:08:04 +01001134static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +01001135 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1136
Matthew Ranostay541eee82007-12-14 12:08:04 +01001137 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1138 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001139
1140 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1141 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001142 { } /* end */
1143};
1144
Tobin Davis8e21c342007-01-08 11:04:17 +01001145static struct snd_kcontrol_new stac925x_mixer[] = {
Takashi Iwaic9280d62009-01-15 17:31:00 +01001146 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
1147 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001148 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +02001149 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001150 { } /* end */
1151};
1152
Takashi Iwaid1d985f2006-11-23 19:27:12 +01001153static struct snd_kcontrol_new stac9205_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001154 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001155
1156 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1157 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001158
1159 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1160 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001161 { } /* end */
1162};
1163
1164/* This needs to be generated dynamically based on sequence */
1165static struct snd_kcontrol_new stac922x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001166 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1167 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001168
1169 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1170 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001171 { } /* end */
1172};
1173
1174
1175static struct snd_kcontrol_new stac927x_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001176 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001177
1178 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1179 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001180
1181 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1182 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001183
1184 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1185 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
Matt Porterf3302a52006-07-31 12:49:34 +02001186 { } /* end */
1187};
1188
Takashi Iwai1697055e2007-12-18 18:05:52 +01001189static struct snd_kcontrol_new stac_dmux_mixer = {
1190 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1191 .name = "Digital Input Source",
1192 /* count set later */
1193 .info = stac92xx_dmux_enum_info,
1194 .get = stac92xx_dmux_enum_get,
1195 .put = stac92xx_dmux_enum_put,
1196};
1197
Matthew Ranostayd9737752008-09-07 12:03:41 +02001198static struct snd_kcontrol_new stac_smux_mixer = {
1199 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001200 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001201 /* count set later */
1202 .info = stac92xx_smux_enum_info,
1203 .get = stac92xx_smux_enum_get,
1204 .put = stac92xx_smux_enum_put,
1205};
1206
Takashi Iwai2134ea42008-01-10 16:53:55 +01001207static const char *slave_vols[] = {
1208 "Front Playback Volume",
1209 "Surround Playback Volume",
1210 "Center Playback Volume",
1211 "LFE Playback Volume",
1212 "Side Playback Volume",
1213 "Headphone Playback Volume",
1214 "Headphone Playback Volume",
1215 "Speaker Playback Volume",
1216 "External Speaker Playback Volume",
1217 "Speaker2 Playback Volume",
1218 NULL
1219};
1220
1221static const char *slave_sws[] = {
1222 "Front Playback Switch",
1223 "Surround Playback Switch",
1224 "Center Playback Switch",
1225 "LFE Playback Switch",
1226 "Side Playback Switch",
1227 "Headphone Playback Switch",
1228 "Headphone Playback Switch",
1229 "Speaker Playback Switch",
1230 "External Speaker Playback Switch",
1231 "Speaker2 Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001232 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001233 NULL
1234};
1235
Takashi Iwai603c4012008-07-30 15:01:44 +02001236static void stac92xx_free_kctls(struct hda_codec *codec);
Takashi Iwaie4973e12008-11-18 09:32:42 +01001237static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
Takashi Iwai603c4012008-07-30 15:01:44 +02001238
Matt2f2f4252005-04-13 14:45:30 +02001239static int stac92xx_build_controls(struct hda_codec *codec)
1240{
1241 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaie4973e12008-11-18 09:32:42 +01001242 struct auto_pin_cfg *cfg = &spec->autocfg;
1243 hda_nid_t nid;
Matt2f2f4252005-04-13 14:45:30 +02001244 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001245 int i;
Matt2f2f4252005-04-13 14:45:30 +02001246
1247 err = snd_hda_add_new_ctls(codec, spec->mixer);
1248 if (err < 0)
1249 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001250
1251 for (i = 0; i < spec->num_mixers; i++) {
1252 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1253 if (err < 0)
1254 return err;
1255 }
Takashi Iwai1697055e2007-12-18 18:05:52 +01001256 if (spec->num_dmuxes > 0) {
1257 stac_dmux_mixer.count = spec->num_dmuxes;
Takashi Iwaid13bd412008-07-30 15:01:45 +02001258 err = snd_hda_ctl_add(codec,
Takashi Iwai1697055e2007-12-18 18:05:52 +01001259 snd_ctl_new1(&stac_dmux_mixer, codec));
1260 if (err < 0)
1261 return err;
1262 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001263 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001264 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1265 struct hda_input_mux *smux = &spec->private_smux;
1266 /* check for mute support on SPDIF out */
1267 if (wcaps & AC_WCAP_OUT_AMP) {
1268 smux->items[smux->num_items].label = "Off";
1269 smux->items[smux->num_items].index = 0;
1270 smux->num_items++;
1271 spec->spdif_mute = 1;
1272 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001273 stac_smux_mixer.count = spec->num_smuxes;
Takashi Iwai4f2d23e2008-12-19 10:14:13 +01001274 err = snd_hda_ctl_add(codec,
Matthew Ranostayd9737752008-09-07 12:03:41 +02001275 snd_ctl_new1(&stac_smux_mixer, codec));
1276 if (err < 0)
1277 return err;
1278 }
Mattc7d4b2f2005-06-27 14:59:41 +02001279
Mattdabbed62005-06-14 10:19:34 +02001280 if (spec->multiout.dig_out_nid) {
1281 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1282 if (err < 0)
1283 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001284 err = snd_hda_create_spdif_share_sw(codec,
1285 &spec->multiout);
1286 if (err < 0)
1287 return err;
1288 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001289 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001290 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001291 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1292 if (err < 0)
1293 return err;
1294 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001295
1296 /* if we have no master control, let's create it */
1297 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001298 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001299 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001300 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai7c7767e2009-01-20 15:28:38 +01001301 /* correct volume offset */
1302 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
Takashi Iwai2134ea42008-01-10 16:53:55 +01001303 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001304 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001305 if (err < 0)
1306 return err;
1307 }
1308 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1309 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1310 NULL, slave_sws);
1311 if (err < 0)
1312 return err;
1313 }
1314
Takashi Iwai603c4012008-07-30 15:01:44 +02001315 stac92xx_free_kctls(codec); /* no longer needed */
Takashi Iwaie4973e12008-11-18 09:32:42 +01001316
1317 /* create jack input elements */
1318 if (spec->hp_detect) {
1319 for (i = 0; i < cfg->hp_outs; i++) {
1320 int type = SND_JACK_HEADPHONE;
1321 nid = cfg->hp_pins[i];
1322 /* jack detection */
1323 if (cfg->hp_outs == i)
1324 type |= SND_JACK_LINEOUT;
1325 err = stac92xx_add_jack(codec, nid, type);
1326 if (err < 0)
1327 return err;
1328 }
1329 }
1330 for (i = 0; i < cfg->line_outs; i++) {
1331 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1332 SND_JACK_LINEOUT);
1333 if (err < 0)
1334 return err;
1335 }
1336 for (i = 0; i < AUTO_PIN_LAST; i++) {
1337 nid = cfg->input_pins[i];
1338 if (nid) {
1339 err = stac92xx_add_jack(codec, nid,
1340 SND_JACK_MICROPHONE);
1341 if (err < 0)
1342 return err;
1343 }
1344 }
1345
Mattdabbed62005-06-14 10:19:34 +02001346 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001347}
1348
Matt Porter403d1942005-11-29 15:00:51 +01001349static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001350 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001351 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1352};
1353
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001354static unsigned int gateway9200_m4_pin_configs[8] = {
1355 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1356 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1357};
1358static unsigned int gateway9200_m4_2_pin_configs[8] = {
1359 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1360 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1361};
1362
1363/*
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001364 STAC 9200 pin configs for
1365 102801A8
1366 102801DE
1367 102801E8
1368*/
1369static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001370 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1371 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001372};
1373
1374/*
1375 STAC 9200 pin configs for
1376 102801C0
1377 102801C1
1378*/
1379static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001380 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1381 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001382};
1383
1384/*
1385 STAC 9200 pin configs for
1386 102801C4 (Dell Dimension E310)
1387 102801C5
1388 102801C7
1389 102801D9
1390 102801DA
1391 102801E3
1392*/
1393static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001394 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1395 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001396};
1397
1398
1399/*
1400 STAC 9200-32 pin configs for
1401 102801B5 (Dell Inspiron 630m)
1402 102801D8 (Dell Inspiron 640m)
1403*/
1404static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001405 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1406 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001407};
1408
1409/*
1410 STAC 9200-32 pin configs for
1411 102801C2 (Dell Latitude D620)
1412 102801C8
1413 102801CC (Dell Latitude D820)
1414 102801D4
1415 102801D6
1416*/
1417static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001418 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1419 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001420};
1421
1422/*
1423 STAC 9200-32 pin configs for
1424 102801CE (Dell XPS M1710)
1425 102801CF (Dell Precision M90)
1426*/
1427static unsigned int dell9200_m23_pin_configs[8] = {
1428 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1429 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1430};
1431
1432/*
1433 STAC 9200-32 pin configs for
1434 102801C9
1435 102801CA
1436 102801CB (Dell Latitude 120L)
1437 102801D3
1438*/
1439static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001440 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1441 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001442};
1443
1444/*
1445 STAC 9200-32 pin configs for
1446 102801BD (Dell Inspiron E1505n)
1447 102801EE
1448 102801EF
1449*/
1450static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001451 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1452 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001453};
1454
1455/*
1456 STAC 9200-32 pin configs for
1457 102801F5 (Dell Inspiron 1501)
1458 102801F6
1459*/
1460static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001461 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1462 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001463};
1464
1465/*
1466 STAC 9200-32
1467 102801CD (Dell Inspiron E1705/9400)
1468*/
1469static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001470 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1471 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001472};
1473
Tobin Davisbf277782008-02-03 20:31:47 +01001474static unsigned int oqo9200_pin_configs[8] = {
1475 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1476 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1477};
1478
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001479
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001480static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1481 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001482 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001483 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1484 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1485 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1486 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1487 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1488 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1489 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1490 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1491 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1492 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001493 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1494 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001495 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001496};
1497
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001498static const char *stac9200_models[STAC_9200_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001499 [STAC_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001500 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001501 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001502 [STAC_9200_DELL_D21] = "dell-d21",
1503 [STAC_9200_DELL_D22] = "dell-d22",
1504 [STAC_9200_DELL_D23] = "dell-d23",
1505 [STAC_9200_DELL_M21] = "dell-m21",
1506 [STAC_9200_DELL_M22] = "dell-m22",
1507 [STAC_9200_DELL_M23] = "dell-m23",
1508 [STAC_9200_DELL_M24] = "dell-m24",
1509 [STAC_9200_DELL_M25] = "dell-m25",
1510 [STAC_9200_DELL_M26] = "dell-m26",
1511 [STAC_9200_DELL_M27] = "dell-m27",
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001512 [STAC_9200_M4] = "gateway-m4",
1513 [STAC_9200_M4_2] = "gateway-m4-2",
Takashi Iwai117f2572008-03-18 09:53:23 +01001514 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001515};
1516
1517static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1518 /* SigmaTel reference board */
1519 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1520 "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001521 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1522 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001523 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001524 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1525 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001526 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001527 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1528 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1529 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1530 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1531 "unknown Dell", STAC_9200_DELL_D22),
1532 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1533 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001534 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001535 "Dell Latitude D620", STAC_9200_DELL_M22),
1536 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1537 "unknown Dell", STAC_9200_DELL_D23),
1538 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1539 "unknown Dell", STAC_9200_DELL_D23),
1540 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1541 "unknown Dell", STAC_9200_DELL_M22),
1542 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1543 "unknown Dell", STAC_9200_DELL_M24),
1544 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1545 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001546 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001547 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001548 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001549 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001550 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001551 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001552 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001553 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001554 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001555 "Dell Precision M90", STAC_9200_DELL_M23),
1556 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1557 "unknown Dell", STAC_9200_DELL_M22),
1558 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1559 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001560 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001561 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001562 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001563 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1564 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1565 "unknown Dell", STAC_9200_DELL_D23),
1566 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1567 "unknown Dell", STAC_9200_DELL_D23),
1568 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1569 "unknown Dell", STAC_9200_DELL_D21),
1570 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1571 "unknown Dell", STAC_9200_DELL_D23),
1572 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1573 "unknown Dell", STAC_9200_DELL_D21),
1574 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1575 "unknown Dell", STAC_9200_DELL_M25),
1576 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1577 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001578 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001579 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1580 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1581 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001582 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001583 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001584 /* Gateway machines needs EAPD to be set on resume */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001585 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1586 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1587 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
Tobin Davisbf277782008-02-03 20:31:47 +01001588 /* OQO Mobile */
1589 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001590 {} /* terminator */
1591};
1592
Tobin Davis8e21c342007-01-08 11:04:17 +01001593static unsigned int ref925x_pin_configs[8] = {
1594 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001595 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001596};
1597
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001598static unsigned int stac925xM1_pin_configs[8] = {
1599 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1600 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001601};
1602
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001603static unsigned int stac925xM1_2_pin_configs[8] = {
1604 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1605 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1606};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001607
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001608static unsigned int stac925xM2_pin_configs[8] = {
1609 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1610 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis2c11f952007-05-17 09:36:34 +02001611};
1612
Tobin Davis8e21c342007-01-08 11:04:17 +01001613static unsigned int stac925xM2_2_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001614 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1615 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1616};
1617
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001618static unsigned int stac925xM3_pin_configs[8] = {
1619 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1620 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1621};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001622
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001623static unsigned int stac925xM5_pin_configs[8] = {
1624 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1625 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1626};
1627
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001628static unsigned int stac925xM6_pin_configs[8] = {
1629 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1630 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
Tobin Davis8e21c342007-01-08 11:04:17 +01001631};
1632
1633static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1634 [STAC_REF] = ref925x_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001635 [STAC_M1] = stac925xM1_pin_configs,
1636 [STAC_M1_2] = stac925xM1_2_pin_configs,
1637 [STAC_M2] = stac925xM2_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001638 [STAC_M2_2] = stac925xM2_2_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001639 [STAC_M3] = stac925xM3_pin_configs,
1640 [STAC_M5] = stac925xM5_pin_configs,
1641 [STAC_M6] = stac925xM6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001642};
1643
1644static const char *stac925x_models[STAC_925x_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001645 [STAC_925x_AUTO] = "auto",
Tobin Davis8e21c342007-01-08 11:04:17 +01001646 [STAC_REF] = "ref",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001647 [STAC_M1] = "m1",
1648 [STAC_M1_2] = "m1-2",
1649 [STAC_M2] = "m2",
Tobin Davis8e21c342007-01-08 11:04:17 +01001650 [STAC_M2_2] = "m2-2",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001651 [STAC_M3] = "m3",
1652 [STAC_M5] = "m5",
1653 [STAC_M6] = "m6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001654};
1655
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001656static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001657 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1658 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1659 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1660 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001661 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001662 /* Not sure about the brand name for those */
1663 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1664 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1665 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1666 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001667 {} /* terminator */
Tobin Davis8e21c342007-01-08 11:04:17 +01001668};
1669
1670static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1671 /* SigmaTel reference board */
1672 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001673 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001674 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001675
1676 /* Default table for unknown ID */
1677 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1678
Tobin Davis8e21c342007-01-08 11:04:17 +01001679 {} /* terminator */
1680};
1681
Matthew Ranostaya7662642008-02-21 07:51:14 +01001682static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001683 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1684 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1685 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001686 0x01452050,
1687};
1688
1689static unsigned int dell_m6_pin_configs[13] = {
1690 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001691 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001692 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1693 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001694};
1695
1696static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001697 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001698 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1699 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1700 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001701 [STAC_DELL_EQ] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001702};
1703
1704static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001705 [STAC_92HD73XX_AUTO] = "auto",
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01001706 [STAC_92HD73XX_NO_JD] = "no-jd",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001707 [STAC_92HD73XX_REF] = "ref",
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001708 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1709 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1710 [STAC_DELL_M6_BOTH] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001711 [STAC_DELL_EQ] = "dell-eq",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001712};
1713
1714static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1715 /* SigmaTel reference board */
1716 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001717 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001718 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1719 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001720 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001721 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001722 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001723 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001724 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001725 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001726 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001727 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001728 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001729 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001730 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001731 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001732 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001733 "unknown Dell", STAC_DELL_M6_DMIC),
1734 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1735 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01001736 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001737 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Joerg Schirottkefa620e92008-12-19 08:13:49 +01001738 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1739 "Dell Studio 17", STAC_DELL_M6_DMIC),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001740 {} /* terminator */
1741};
1742
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001743static unsigned int ref92hd83xxx_pin_configs[10] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001744 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1745 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001746 0x01451160, 0x98560170,
1747};
1748
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001749static unsigned int dell_s14_pin_configs[10] = {
1750 0x02214030, 0x02211010, 0x02a19020, 0x01014050,
1751 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160,
1752 0x40f000f0, 0x40f000f0,
1753};
1754
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001755static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1756 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001757 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001758 [STAC_DELL_S14] = dell_s14_pin_configs,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001759};
1760
1761static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001762 [STAC_92HD83XXX_AUTO] = "auto",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001763 [STAC_92HD83XXX_REF] = "ref",
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001764 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001765 [STAC_DELL_S14] = "dell-s14",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001766};
1767
1768static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1769 /* SigmaTel reference board */
1770 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Takashi Iwaif9d088b2009-01-13 11:54:49 +01001771 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001772 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1773 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001774 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1775 "unknown Dell", STAC_DELL_S14),
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -02001776 {} /* terminator */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001777};
1778
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001779static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001780 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001781 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001782 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1783 0x00000000
Matthew Ranostaye035b842007-11-06 11:53:55 +01001784};
1785
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001786static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001787 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001788 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001789 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1790 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001791};
1792
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001793static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001794 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1795 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001796 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1797 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001798};
1799
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001800static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001801 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1802 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001803 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1804 0x00000000
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001805};
1806
Matthew Ranostaye035b842007-11-06 11:53:55 +01001807static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1808 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001809 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1810 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001811 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001812 [STAC_HP_M4] = NULL,
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001813 [STAC_HP_DV5] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001814};
1815
1816static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001817 [STAC_92HD71BXX_AUTO] = "auto",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001818 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001819 [STAC_DELL_M4_1] = "dell-m4-1",
1820 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001821 [STAC_DELL_M4_3] = "dell-m4-3",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001822 [STAC_HP_M4] = "hp-m4",
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001823 [STAC_HP_DV5] = "hp-dv5",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001824};
1825
1826static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1827 /* SigmaTel reference board */
1828 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1829 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001830 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1831 "DFI LanParty", STAC_92HD71BXX_REF),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001832 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
1833 "HP dv4-7", STAC_HP_DV5),
1834 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1835 "HP dv4-7", STAC_HP_DV5),
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001836 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001837 "HP mini 1000", STAC_HP_M4),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001838 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1839 "unknown Dell", STAC_DELL_M4_1),
1840 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1841 "unknown Dell", STAC_DELL_M4_1),
1842 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1843 "unknown Dell", STAC_DELL_M4_1),
1844 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1845 "unknown Dell", STAC_DELL_M4_1),
1846 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1847 "unknown Dell", STAC_DELL_M4_1),
1848 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1849 "unknown Dell", STAC_DELL_M4_1),
1850 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1851 "unknown Dell", STAC_DELL_M4_1),
1852 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1853 "unknown Dell", STAC_DELL_M4_2),
1854 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1855 "unknown Dell", STAC_DELL_M4_2),
1856 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1857 "unknown Dell", STAC_DELL_M4_2),
1858 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1859 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001860 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1861 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001862 {} /* terminator */
1863};
1864
Matt Porter403d1942005-11-29 15:00:51 +01001865static unsigned int ref922x_pin_configs[10] = {
1866 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1867 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001868 0x40000100, 0x40000100,
1869};
1870
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001871/*
1872 STAC 922X pin configs for
1873 102801A7
1874 102801AB
1875 102801A9
1876 102801D1
1877 102801D2
1878*/
1879static unsigned int dell_922x_d81_pin_configs[10] = {
1880 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1881 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1882 0x01813122, 0x400001f2,
1883};
1884
1885/*
1886 STAC 922X pin configs for
1887 102801AC
1888 102801D0
1889*/
1890static unsigned int dell_922x_d82_pin_configs[10] = {
1891 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1892 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1893 0x01813122, 0x400001f1,
1894};
1895
1896/*
1897 STAC 922X pin configs for
1898 102801BF
1899*/
1900static unsigned int dell_922x_m81_pin_configs[10] = {
1901 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1902 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1903 0x40C003f1, 0x405003f0,
1904};
1905
1906/*
1907 STAC 9221 A1 pin configs for
1908 102801D7 (Dell XPS M1210)
1909*/
1910static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001911 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1912 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001913 0x508003f3, 0x405003f4,
1914};
1915
Matt Porter403d1942005-11-29 15:00:51 +01001916static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001917 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001918 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1919 0x02a19120, 0x40000100,
1920};
1921
1922static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001923 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1924 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001925 0x02a19320, 0x40000100,
1926};
1927
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001928static unsigned int intel_mac_v1_pin_configs[10] = {
1929 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1930 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001931 0x400000fc, 0x400000fb,
1932};
1933
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001934static unsigned int intel_mac_v2_pin_configs[10] = {
1935 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1936 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001937 0x400000fc, 0x400000fb,
1938};
1939
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001940static unsigned int intel_mac_v3_pin_configs[10] = {
1941 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1942 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1943 0x400000fc, 0x400000fb,
1944};
1945
1946static unsigned int intel_mac_v4_pin_configs[10] = {
1947 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1948 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1949 0x400000fc, 0x400000fb,
1950};
1951
1952static unsigned int intel_mac_v5_pin_configs[10] = {
1953 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1954 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1955 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001956};
1957
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001958static unsigned int ecs202_pin_configs[10] = {
1959 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1960 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1961 0x9037012e, 0x40e000f2,
1962};
Takashi Iwai76c08822007-06-19 12:17:42 +02001963
Takashi Iwai19039bd2006-06-28 15:52:16 +02001964static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001965 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001966 [STAC_D945GTP3] = d945gtp3_pin_configs,
1967 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001968 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1969 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1970 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1971 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1972 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001973 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001974 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001975 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1976 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1977 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1978 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1979 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1980 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001981 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001982 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1983 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1984 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1985 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001986};
1987
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001988static const char *stac922x_models[STAC_922X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001989 [STAC_922X_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001990 [STAC_D945_REF] = "ref",
1991 [STAC_D945GTP5] = "5stack",
1992 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001993 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1994 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1995 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1996 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1997 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001998 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001999 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002000 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01002001 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01002002 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
2003 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02002004 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02002005 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002006 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002007 [STAC_922X_DELL_D81] = "dell-d81",
2008 [STAC_922X_DELL_D82] = "dell-d82",
2009 [STAC_922X_DELL_M81] = "dell-m81",
2010 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002011};
2012
2013static struct snd_pci_quirk stac922x_cfg_tbl[] = {
2014 /* SigmaTel reference board */
2015 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2016 "DFI LanParty", STAC_D945_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002017 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2018 "DFI LanParty", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002019 /* Intel 945G based systems */
2020 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2021 "Intel D945G", STAC_D945GTP3),
2022 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2023 "Intel D945G", STAC_D945GTP3),
2024 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2025 "Intel D945G", STAC_D945GTP3),
2026 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2027 "Intel D945G", STAC_D945GTP3),
2028 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2029 "Intel D945G", STAC_D945GTP3),
2030 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2031 "Intel D945G", STAC_D945GTP3),
2032 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2033 "Intel D945G", STAC_D945GTP3),
2034 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2035 "Intel D945G", STAC_D945GTP3),
2036 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2037 "Intel D945G", STAC_D945GTP3),
2038 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2039 "Intel D945G", STAC_D945GTP3),
2040 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2041 "Intel D945G", STAC_D945GTP3),
2042 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2043 "Intel D945G", STAC_D945GTP3),
2044 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2045 "Intel D945G", STAC_D945GTP3),
2046 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2047 "Intel D945G", STAC_D945GTP3),
2048 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2049 "Intel D945G", STAC_D945GTP3),
2050 /* Intel D945G 5-stack systems */
2051 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2052 "Intel D945G", STAC_D945GTP5),
2053 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2054 "Intel D945G", STAC_D945GTP5),
2055 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2056 "Intel D945G", STAC_D945GTP5),
2057 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2058 "Intel D945G", STAC_D945GTP5),
2059 /* Intel 945P based systems */
2060 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2061 "Intel D945P", STAC_D945GTP3),
2062 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2063 "Intel D945P", STAC_D945GTP3),
2064 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2065 "Intel D945P", STAC_D945GTP3),
2066 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2067 "Intel D945P", STAC_D945GTP3),
2068 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2069 "Intel D945P", STAC_D945GTP3),
2070 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2071 "Intel D945P", STAC_D945GTP5),
Takashi Iwai8056d472009-01-23 09:09:43 +01002072 /* other intel */
2073 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2074 "Intel D945", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002075 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08002076 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002077 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08002078 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002079 /* Dell systems */
2080 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2081 "unknown Dell", STAC_922X_DELL_D81),
2082 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2083 "unknown Dell", STAC_922X_DELL_D81),
2084 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2085 "unknown Dell", STAC_922X_DELL_D81),
2086 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2087 "unknown Dell", STAC_922X_DELL_D82),
2088 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2089 "unknown Dell", STAC_922X_DELL_M81),
2090 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2091 "unknown Dell", STAC_922X_DELL_D82),
2092 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2093 "unknown Dell", STAC_922X_DELL_D81),
2094 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2095 "unknown Dell", STAC_922X_DELL_D81),
2096 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2097 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002098 /* ECS/PC Chips boards */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002099 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
Herton Ronaldo Krzesinski8663ae52009-02-08 19:50:34 -02002100 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01002101 {} /* terminator */
2102};
2103
Matt Porter3cc08dc2006-01-23 15:27:49 +01002104static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002105 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2106 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2107 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2108 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002109};
2110
Tobin Davis93ed1502006-09-01 21:03:12 +02002111static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002112 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2113 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2114 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2115 0x40000100, 0x40000100
2116};
2117
Tobin Davis93ed1502006-09-01 21:03:12 +02002118static unsigned int d965_5st_pin_configs[14] = {
2119 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2120 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2121 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2122 0x40000100, 0x40000100
2123};
2124
Tobin Davis4ff076e2007-08-07 11:48:12 +02002125static unsigned int dell_3st_pin_configs[14] = {
2126 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2127 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002128 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002129 0x40c003fc, 0x40000100
2130};
2131
Tobin Davis93ed1502006-09-01 21:03:12 +02002132static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002133 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002134 [STAC_D965_REF] = ref927x_pin_configs,
2135 [STAC_D965_3ST] = d965_3st_pin_configs,
2136 [STAC_D965_5ST] = d965_5st_pin_configs,
2137 [STAC_DELL_3ST] = dell_3st_pin_configs,
2138 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002139};
2140
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002141static const char *stac927x_models[STAC_927X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002142 [STAC_927X_AUTO] = "auto",
Takashi Iwaie28d8322008-12-17 13:48:29 +01002143 [STAC_D965_REF_NO_JD] = "ref-no-jd",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002144 [STAC_D965_REF] = "ref",
2145 [STAC_D965_3ST] = "3stack",
2146 [STAC_D965_5ST] = "5stack",
2147 [STAC_DELL_3ST] = "dell-3stack",
2148 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002149};
2150
2151static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2152 /* SigmaTel reference board */
2153 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2154 "DFI LanParty", STAC_D965_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002155 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2156 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002157 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002158 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2159 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002160 /* 965 based 3 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002161 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2162 "Intel D965", STAC_D965_3ST),
2163 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2164 "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002165 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002166 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002167 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002168 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2169 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002170 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002171 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2172 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002173 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02002174 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002175 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2176 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2177 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2178 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002179 /* 965 based 5 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002180 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2181 "Intel D965", STAC_D965_5ST),
2182 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2183 "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002184 {} /* terminator */
2185};
2186
Matt Porterf3302a52006-07-31 12:49:34 +02002187static unsigned int ref9205_pin_configs[12] = {
2188 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002189 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002190 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002191};
2192
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002193/*
2194 STAC 9205 pin configs for
2195 102801F1
2196 102801F2
2197 102801FC
2198 102801FD
2199 10280204
2200 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002201 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002202*/
2203static unsigned int dell_9205_m42_pin_configs[12] = {
2204 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2205 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2206 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2207};
2208
2209/*
2210 STAC 9205 pin configs for
2211 102801F9
2212 102801FA
2213 102801FE
2214 102801FF (Dell Precision M4300)
2215 10280206
2216 10280200
2217 10280201
2218*/
2219static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002220 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2221 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2222 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2223};
2224
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002225static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002226 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2227 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2228 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2229};
2230
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002231static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002232 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002233 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2234 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2235 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Takashi Iwaid9a42682009-01-22 17:40:18 +01002236 [STAC_9205_EAPD] = NULL,
Matt Porterf3302a52006-07-31 12:49:34 +02002237};
2238
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002239static const char *stac9205_models[STAC_9205_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002240 [STAC_9205_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002241 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002242 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002243 [STAC_9205_DELL_M43] = "dell-m43",
2244 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaid9a42682009-01-22 17:40:18 +01002245 [STAC_9205_EAPD] = "eapd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002246};
2247
2248static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2249 /* SigmaTel reference board */
2250 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2251 "DFI LanParty", STAC_9205_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002252 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2253 "DFI LanParty", STAC_9205_REF),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002254 /* Dell */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002255 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2256 "unknown Dell", STAC_9205_DELL_M42),
2257 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2258 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002259 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002260 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002261 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2262 "Dell Precision", STAC_9205_DELL_M43),
2263 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2264 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002265 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2266 "unknown Dell", STAC_9205_DELL_M42),
2267 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2268 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002269 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2270 "Dell Precision", STAC_9205_DELL_M43),
2271 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002272 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002273 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2274 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002275 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2276 "Dell Precision", STAC_9205_DELL_M43),
2277 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2278 "Dell Precision", STAC_9205_DELL_M43),
2279 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2280 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002281 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2282 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002283 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2284 "Dell Vostro 1500", STAC_9205_DELL_M42),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002285 /* Gateway */
2286 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
Matt Porterf3302a52006-07-31 12:49:34 +02002287 {} /* terminator */
2288};
2289
Takashi Iwai330ee992009-02-20 14:33:36 +01002290static void stac92xx_set_config_regs(struct hda_codec *codec,
2291 unsigned int *pincfgs)
Matt2f2f4252005-04-13 14:45:30 +02002292{
2293 int i;
2294 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002295
Takashi Iwai330ee992009-02-20 14:33:36 +01002296 if (!pincfgs)
2297 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002298
Matthew Ranostay87d48362007-07-17 11:52:24 +02002299 for (i = 0; i < spec->num_pins; i++)
Takashi Iwai330ee992009-02-20 14:33:36 +01002300 if (spec->pin_nids[i] && pincfgs[i])
2301 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2302 pincfgs[i]);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002303}
2304
Matt2f2f4252005-04-13 14:45:30 +02002305/*
2306 * Analog playback callbacks
2307 */
2308static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2309 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002310 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002311{
2312 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002313 if (spec->stream_delay)
2314 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002315 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2316 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002317}
2318
2319static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2320 struct hda_codec *codec,
2321 unsigned int stream_tag,
2322 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002323 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002324{
2325 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002326 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002327}
2328
2329static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2330 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002331 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002332{
2333 struct sigmatel_spec *spec = codec->spec;
2334 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2335}
2336
2337/*
Mattdabbed62005-06-14 10:19:34 +02002338 * Digital playback callbacks
2339 */
2340static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2341 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002342 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002343{
2344 struct sigmatel_spec *spec = codec->spec;
2345 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2346}
2347
2348static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2349 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002350 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002351{
2352 struct sigmatel_spec *spec = codec->spec;
2353 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2354}
2355
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002356static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2357 struct hda_codec *codec,
2358 unsigned int stream_tag,
2359 unsigned int format,
2360 struct snd_pcm_substream *substream)
2361{
2362 struct sigmatel_spec *spec = codec->spec;
2363 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2364 stream_tag, format, substream);
2365}
2366
Takashi Iwai9411e212009-02-13 11:32:28 +01002367static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2368 struct hda_codec *codec,
2369 struct snd_pcm_substream *substream)
2370{
2371 struct sigmatel_spec *spec = codec->spec;
2372 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2373}
2374
Mattdabbed62005-06-14 10:19:34 +02002375
2376/*
Matt2f2f4252005-04-13 14:45:30 +02002377 * Analog capture callbacks
2378 */
2379static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2380 struct hda_codec *codec,
2381 unsigned int stream_tag,
2382 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002383 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002384{
2385 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002386 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002387
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002388 if (spec->powerdown_adcs) {
2389 msleep(40);
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002390 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002391 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2392 }
2393 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002394 return 0;
2395}
2396
2397static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2398 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002399 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002400{
2401 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002402 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002403
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002404 snd_hda_codec_cleanup_stream(codec, nid);
2405 if (spec->powerdown_adcs)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002406 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002407 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002408 return 0;
2409}
2410
Mattdabbed62005-06-14 10:19:34 +02002411static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2412 .substreams = 1,
2413 .channels_min = 2,
2414 .channels_max = 2,
2415 /* NID is set in stac92xx_build_pcms */
2416 .ops = {
2417 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002418 .close = stac92xx_dig_playback_pcm_close,
Takashi Iwai9411e212009-02-13 11:32:28 +01002419 .prepare = stac92xx_dig_playback_pcm_prepare,
2420 .cleanup = stac92xx_dig_playback_pcm_cleanup
Mattdabbed62005-06-14 10:19:34 +02002421 },
2422};
2423
2424static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2425 .substreams = 1,
2426 .channels_min = 2,
2427 .channels_max = 2,
2428 /* NID is set in stac92xx_build_pcms */
2429};
2430
Matt2f2f4252005-04-13 14:45:30 +02002431static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2432 .substreams = 1,
2433 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002434 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002435 .nid = 0x02, /* NID to query formats and rates */
2436 .ops = {
2437 .open = stac92xx_playback_pcm_open,
2438 .prepare = stac92xx_playback_pcm_prepare,
2439 .cleanup = stac92xx_playback_pcm_cleanup
2440 },
2441};
2442
Matt Porter3cc08dc2006-01-23 15:27:49 +01002443static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2444 .substreams = 1,
2445 .channels_min = 2,
2446 .channels_max = 2,
2447 .nid = 0x06, /* NID to query formats and rates */
2448 .ops = {
2449 .open = stac92xx_playback_pcm_open,
2450 .prepare = stac92xx_playback_pcm_prepare,
2451 .cleanup = stac92xx_playback_pcm_cleanup
2452 },
2453};
2454
Matt2f2f4252005-04-13 14:45:30 +02002455static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002456 .channels_min = 2,
2457 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002458 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002459 .ops = {
2460 .prepare = stac92xx_capture_pcm_prepare,
2461 .cleanup = stac92xx_capture_pcm_cleanup
2462 },
2463};
2464
2465static int stac92xx_build_pcms(struct hda_codec *codec)
2466{
2467 struct sigmatel_spec *spec = codec->spec;
2468 struct hda_pcm *info = spec->pcm_rec;
2469
2470 codec->num_pcms = 1;
2471 codec->pcm_info = info;
2472
Mattc7d4b2f2005-06-27 14:59:41 +02002473 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002474 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Takashi Iwai00a602d2009-01-23 11:55:42 +01002475 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2476 spec->multiout.dac_nids[0];
Matt2f2f4252005-04-13 14:45:30 +02002477 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002478 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002479 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002480
2481 if (spec->alt_switch) {
2482 codec->num_pcms++;
2483 info++;
2484 info->name = "STAC92xx Analog Alt";
2485 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2486 }
Matt2f2f4252005-04-13 14:45:30 +02002487
Mattdabbed62005-06-14 10:19:34 +02002488 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2489 codec->num_pcms++;
2490 info++;
2491 info->name = "STAC92xx Digital";
Takashi Iwai0852d7a2009-02-11 11:35:15 +01002492 info->pcm_type = spec->autocfg.dig_out_type[0];
Mattdabbed62005-06-14 10:19:34 +02002493 if (spec->multiout.dig_out_nid) {
2494 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2495 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2496 }
2497 if (spec->dig_in_nid) {
2498 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2499 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2500 }
2501 }
2502
Matt2f2f4252005-04-13 14:45:30 +02002503 return 0;
2504}
2505
Takashi Iwaic960a032006-03-23 17:06:28 +01002506static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2507{
2508 unsigned int pincap = snd_hda_param_read(codec, nid,
2509 AC_PAR_PIN_CAP);
2510 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2511 if (pincap & AC_PINCAP_VREF_100)
2512 return AC_PINCTL_VREF_100;
2513 if (pincap & AC_PINCAP_VREF_80)
2514 return AC_PINCTL_VREF_80;
2515 if (pincap & AC_PINCAP_VREF_50)
2516 return AC_PINCTL_VREF_50;
2517 if (pincap & AC_PINCAP_VREF_GRD)
2518 return AC_PINCTL_VREF_GRD;
2519 return 0;
2520}
2521
Matt Porter403d1942005-11-29 15:00:51 +01002522static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2523
2524{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002525 snd_hda_codec_write_cache(codec, nid, 0,
2526 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002527}
2528
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002529#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2530
2531static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2532 struct snd_ctl_elem_value *ucontrol)
2533{
2534 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2535 struct sigmatel_spec *spec = codec->spec;
2536
Takashi Iwaid7a89432008-11-12 09:48:04 +01002537 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002538 return 0;
2539}
2540
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002541static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
2542 unsigned char type);
2543
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002544static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2545 struct snd_ctl_elem_value *ucontrol)
2546{
2547 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2548 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002549 int nid = kcontrol->private_value;
2550
2551 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002552
2553 /* check to be sure that the ports are upto date with
2554 * switch changes
2555 */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002556 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002557
2558 return 1;
2559}
2560
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002561#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002562
2563static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2564{
2565 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2566 struct sigmatel_spec *spec = codec->spec;
2567 int io_idx = kcontrol-> private_value & 0xff;
2568
2569 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2570 return 0;
2571}
2572
2573static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2574{
2575 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2576 struct sigmatel_spec *spec = codec->spec;
2577 hda_nid_t nid = kcontrol->private_value >> 8;
2578 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002579 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002580
2581 spec->io_switch[io_idx] = val;
2582
2583 if (val)
2584 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002585 else {
2586 unsigned int pinctl = AC_PINCTL_IN_EN;
2587 if (io_idx) /* set VREF for mic */
2588 pinctl |= stac92xx_get_vref(codec, nid);
2589 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2590 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002591
2592 /* check the auto-mute again: we need to mute/unmute the speaker
2593 * appropriately according to the pin direction
2594 */
2595 if (spec->hp_detect)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002596 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
Jiang Zhe40c1d302007-11-12 13:05:16 +01002597
Matt Porter403d1942005-11-29 15:00:51 +01002598 return 1;
2599}
2600
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002601#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2602
2603static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2604 struct snd_ctl_elem_value *ucontrol)
2605{
2606 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2607 struct sigmatel_spec *spec = codec->spec;
2608
2609 ucontrol->value.integer.value[0] = spec->clfe_swap;
2610 return 0;
2611}
2612
2613static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2614 struct snd_ctl_elem_value *ucontrol)
2615{
2616 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2617 struct sigmatel_spec *spec = codec->spec;
2618 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002619 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002620
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002621 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002622 return 0;
2623
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002624 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002625
2626 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2627 spec->clfe_swap ? 0x4 : 0x0);
2628
2629 return 1;
2630}
2631
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002632#define STAC_CODEC_HP_SWITCH(xname) \
2633 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2634 .name = xname, \
2635 .index = 0, \
2636 .info = stac92xx_hp_switch_info, \
2637 .get = stac92xx_hp_switch_get, \
2638 .put = stac92xx_hp_switch_put, \
2639 }
2640
Matt Porter403d1942005-11-29 15:00:51 +01002641#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2642 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2643 .name = xname, \
2644 .index = 0, \
2645 .info = stac92xx_io_switch_info, \
2646 .get = stac92xx_io_switch_get, \
2647 .put = stac92xx_io_switch_put, \
2648 .private_value = xpval, \
2649 }
2650
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002651#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2652 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2653 .name = xname, \
2654 .index = 0, \
2655 .info = stac92xx_clfe_switch_info, \
2656 .get = stac92xx_clfe_switch_get, \
2657 .put = stac92xx_clfe_switch_put, \
2658 .private_value = xpval, \
2659 }
Matt Porter403d1942005-11-29 15:00:51 +01002660
Mattc7d4b2f2005-06-27 14:59:41 +02002661enum {
2662 STAC_CTL_WIDGET_VOL,
2663 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002664 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002665 STAC_CTL_WIDGET_AMP_MUX,
2666 STAC_CTL_WIDGET_AMP_VOL,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002667 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002668 STAC_CTL_WIDGET_IO_SWITCH,
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002669 STAC_CTL_WIDGET_CLFE_SWITCH
Mattc7d4b2f2005-06-27 14:59:41 +02002670};
2671
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002672static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002673 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2674 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002675 STAC_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002676 STAC_AMP_MUX,
2677 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002678 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002679 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002680 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002681};
2682
2683/* add dynamic controls */
Takashi Iwaie3c75962009-01-23 11:57:22 +01002684static struct snd_kcontrol_new *
2685stac_control_new(struct sigmatel_spec *spec,
2686 struct snd_kcontrol_new *ktemp,
2687 const char *name)
Mattc7d4b2f2005-06-27 14:59:41 +02002688{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002689 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002690
Takashi Iwai603c4012008-07-30 15:01:44 +02002691 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2692 knew = snd_array_new(&spec->kctls);
2693 if (!knew)
Takashi Iwaie3c75962009-01-23 11:57:22 +01002694 return NULL;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002695 *knew = *ktemp;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002696 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002697 if (!knew->name) {
2698 /* roolback */
2699 memset(knew, 0, sizeof(*knew));
2700 spec->kctls.alloced--;
2701 return NULL;
2702 }
2703 return knew;
2704}
2705
2706static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2707 struct snd_kcontrol_new *ktemp,
2708 int idx, const char *name,
2709 unsigned long val)
2710{
2711 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
2712 if (!knew)
Mattc7d4b2f2005-06-27 14:59:41 +02002713 return -ENOMEM;
Takashi Iwaie3c75962009-01-23 11:57:22 +01002714 knew->index = idx;
Mattc7d4b2f2005-06-27 14:59:41 +02002715 knew->private_value = val;
Mattc7d4b2f2005-06-27 14:59:41 +02002716 return 0;
2717}
2718
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002719static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2720 int type, int idx, const char *name,
2721 unsigned long val)
2722{
2723 return stac92xx_add_control_temp(spec,
2724 &stac92xx_control_templates[type],
2725 idx, name, val);
2726}
2727
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002728
2729/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002730static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2731 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002732{
2733 return stac92xx_add_control_idx(spec, type, 0, name, val);
2734}
2735
Takashi Iwaie3c75962009-01-23 11:57:22 +01002736static struct snd_kcontrol_new stac_input_src_temp = {
2737 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2738 .name = "Input Source",
2739 .info = stac92xx_mux_enum_info,
2740 .get = stac92xx_mux_enum_get,
2741 .put = stac92xx_mux_enum_put,
2742};
2743
2744static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2745{
2746 struct snd_kcontrol_new *knew;
2747 struct hda_input_mux *imux = &spec->private_imux;
2748
2749 if (!spec->num_adcs || imux->num_items <= 1)
2750 return 0; /* no need for input source control */
2751 knew = stac_control_new(spec, &stac_input_src_temp,
2752 stac_input_src_temp.name);
2753 if (!knew)
2754 return -ENOMEM;
2755 knew->count = spec->num_adcs;
2756 return 0;
2757}
2758
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002759/* check whether the line-input can be used as line-out */
2760static hda_nid_t check_line_out_switch(struct hda_codec *codec)
Matt Porter403d1942005-11-29 15:00:51 +01002761{
2762 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002763 struct auto_pin_cfg *cfg = &spec->autocfg;
2764 hda_nid_t nid;
2765 unsigned int pincap;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002766
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002767 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2768 return 0;
2769 nid = cfg->input_pins[AUTO_PIN_LINE];
2770 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
2771 if (pincap & AC_PINCAP_OUT)
2772 return nid;
Matt Porter403d1942005-11-29 15:00:51 +01002773 return 0;
2774}
2775
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002776/* check whether the mic-input can be used as line-out */
2777static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2778{
2779 struct sigmatel_spec *spec = codec->spec;
2780 struct auto_pin_cfg *cfg = &spec->autocfg;
2781 unsigned int def_conf, pincap;
2782 unsigned int mic_pin;
2783
2784 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2785 return 0;
2786 mic_pin = AUTO_PIN_MIC;
2787 for (;;) {
2788 hda_nid_t nid = cfg->input_pins[mic_pin];
Takashi Iwai330ee992009-02-20 14:33:36 +01002789 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002790 /* some laptops have an internal analog microphone
2791 * which can't be used as a output */
2792 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2793 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
2794 if (pincap & AC_PINCAP_OUT)
2795 return nid;
2796 }
2797 if (mic_pin == AUTO_PIN_MIC)
2798 mic_pin = AUTO_PIN_FRONT_MIC;
2799 else
2800 break;
2801 }
2802 return 0;
2803}
Steve Longerbeam7b043892007-05-03 20:50:03 +02002804
2805static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2806{
2807 int i;
2808
2809 for (i = 0; i < spec->multiout.num_dacs; i++) {
2810 if (spec->multiout.dac_nids[i] == nid)
2811 return 1;
2812 }
2813
2814 return 0;
2815}
2816
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002817static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2818{
2819 int i;
2820 if (is_in_dac_nids(spec, nid))
2821 return 1;
2822 for (i = 0; i < spec->autocfg.hp_outs; i++)
2823 if (spec->hp_dacs[i] == nid)
2824 return 1;
2825 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2826 if (spec->speaker_dacs[i] == nid)
2827 return 1;
2828 return 0;
2829}
2830
2831static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2832{
2833 struct sigmatel_spec *spec = codec->spec;
2834 int j, conn_len;
2835 hda_nid_t conn[HDA_MAX_CONNECTIONS];
2836 unsigned int wcaps, wtype;
2837
2838 conn_len = snd_hda_get_connections(codec, nid, conn,
2839 HDA_MAX_CONNECTIONS);
2840 for (j = 0; j < conn_len; j++) {
2841 wcaps = snd_hda_param_read(codec, conn[j],
2842 AC_PAR_AUDIO_WIDGET_CAP);
2843 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2844 /* we check only analog outputs */
2845 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2846 continue;
2847 /* if this route has a free DAC, assign it */
2848 if (!check_all_dac_nids(spec, conn[j])) {
2849 if (conn_len > 1) {
2850 /* select this DAC in the pin's input mux */
2851 snd_hda_codec_write_cache(codec, nid, 0,
2852 AC_VERB_SET_CONNECT_SEL, j);
2853 }
2854 return conn[j];
2855 }
2856 }
2857 return 0;
2858}
2859
2860static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2861static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2862
Matt Porter3cc08dc2006-01-23 15:27:49 +01002863/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02002864 * Fill in the dac_nids table from the parsed pin configuration
2865 * This function only works when every pin in line_out_pins[]
2866 * contains atleast one DAC in its connection list. Some 92xx
2867 * codecs are not connected directly to a DAC, such as the 9200
2868 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002869 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002870static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02002871{
2872 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002873 struct auto_pin_cfg *cfg = &spec->autocfg;
2874 int i;
2875 hda_nid_t nid, dac;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002876
Mattc7d4b2f2005-06-27 14:59:41 +02002877 for (i = 0; i < cfg->line_outs; i++) {
2878 nid = cfg->line_out_pins[i];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002879 dac = get_unassigned_dac(codec, nid);
2880 if (!dac) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002881 if (spec->multiout.num_dacs > 0) {
2882 /* we have already working output pins,
2883 * so let's drop the broken ones again
2884 */
2885 cfg->line_outs = spec->multiout.num_dacs;
2886 break;
2887 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002888 /* error out, no available DAC found */
2889 snd_printk(KERN_ERR
2890 "%s: No available DAC for pin 0x%x\n",
2891 __func__, nid);
2892 return -ENODEV;
2893 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002894 add_spec_dacs(spec, dac);
2895 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002896
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002897 /* add line-in as output */
2898 nid = check_line_out_switch(codec);
2899 if (nid) {
2900 dac = get_unassigned_dac(codec, nid);
2901 if (dac) {
2902 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
2903 nid, cfg->line_outs);
2904 cfg->line_out_pins[cfg->line_outs] = nid;
2905 cfg->line_outs++;
2906 spec->line_switch = nid;
2907 add_spec_dacs(spec, dac);
2908 }
2909 }
2910 /* add mic as output */
2911 nid = check_mic_out_switch(codec);
2912 if (nid) {
2913 dac = get_unassigned_dac(codec, nid);
2914 if (dac) {
2915 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
2916 nid, cfg->line_outs);
2917 cfg->line_out_pins[cfg->line_outs] = nid;
2918 cfg->line_outs++;
2919 spec->mic_switch = nid;
2920 add_spec_dacs(spec, dac);
Steve Longerbeam7b043892007-05-03 20:50:03 +02002921 }
Mattc7d4b2f2005-06-27 14:59:41 +02002922 }
2923
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002924 for (i = 0; i < cfg->hp_outs; i++) {
2925 nid = cfg->hp_pins[i];
2926 dac = get_unassigned_dac(codec, nid);
2927 if (dac) {
2928 if (!spec->multiout.hp_nid)
2929 spec->multiout.hp_nid = dac;
2930 else
2931 add_spec_extra_dacs(spec, dac);
2932 }
2933 spec->hp_dacs[i] = dac;
2934 }
2935
2936 for (i = 0; i < cfg->speaker_outs; i++) {
2937 nid = cfg->speaker_pins[i];
2938 dac = get_unassigned_dac(codec, nid);
2939 if (dac)
2940 add_spec_extra_dacs(spec, dac);
2941 spec->speaker_dacs[i] = dac;
2942 }
2943
2944 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
Steve Longerbeam7b043892007-05-03 20:50:03 +02002945 spec->multiout.num_dacs,
2946 spec->multiout.dac_nids[0],
2947 spec->multiout.dac_nids[1],
2948 spec->multiout.dac_nids[2],
2949 spec->multiout.dac_nids[3],
2950 spec->multiout.dac_nids[4]);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002951
Mattc7d4b2f2005-06-27 14:59:41 +02002952 return 0;
2953}
2954
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002955/* create volume control/switch for the given prefx type */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01002956static int create_controls(struct hda_codec *codec, const char *pfx,
2957 hda_nid_t nid, int chs)
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002958{
Takashi Iwai7c7767e2009-01-20 15:28:38 +01002959 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002960 char name[32];
2961 int err;
2962
Takashi Iwai7c7767e2009-01-20 15:28:38 +01002963 if (!spec->check_volume_offset) {
2964 unsigned int caps, step, nums, db_scale;
2965 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
2966 step = (caps & AC_AMPCAP_STEP_SIZE) >>
2967 AC_AMPCAP_STEP_SIZE_SHIFT;
2968 step = (step + 1) * 25; /* in .01dB unit */
2969 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
2970 AC_AMPCAP_NUM_STEPS_SHIFT;
2971 db_scale = nums * step;
2972 /* if dB scale is over -64dB, and finer enough,
2973 * let's reduce it to half
2974 */
2975 if (db_scale > 6400 && nums >= 0x1f)
2976 spec->volume_offset = nums / 2;
2977 spec->check_volume_offset = 1;
2978 }
2979
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002980 sprintf(name, "%s Playback Volume", pfx);
2981 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
Takashi Iwai7c7767e2009-01-20 15:28:38 +01002982 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
2983 spec->volume_offset));
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002984 if (err < 0)
2985 return err;
2986 sprintf(name, "%s Playback Switch", pfx);
2987 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2988 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2989 if (err < 0)
2990 return err;
2991 return 0;
2992}
2993
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002994static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2995{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002996 if (spec->multiout.num_dacs > 4) {
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002997 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2998 return 1;
2999 } else {
3000 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
3001 spec->multiout.num_dacs++;
3002 }
3003 return 0;
3004}
3005
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003006static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003007{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003008 int i;
3009 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3010 if (!spec->multiout.extra_out_nid[i]) {
3011 spec->multiout.extra_out_nid[i] = nid;
3012 return 0;
3013 }
3014 }
3015 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3016 return 1;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003017}
3018
Takashi Iwai76624532008-12-19 10:09:47 +01003019static int is_unique_dac(struct sigmatel_spec *spec, hda_nid_t nid)
3020{
3021 int i;
3022
3023 if (spec->autocfg.line_outs != 1)
3024 return 0;
3025 if (spec->multiout.hp_nid == nid)
3026 return 0;
3027 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++)
3028 if (spec->multiout.extra_out_nid[i] == nid)
3029 return 0;
3030 return 1;
3031}
3032
Mattc7d4b2f2005-06-27 14:59:41 +02003033/* add playback controls from the parsed DAC table */
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003034static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
Takashi Iwai19039bd2006-06-28 15:52:16 +02003035 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003036{
Takashi Iwai76624532008-12-19 10:09:47 +01003037 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003038 static const char *chname[4] = {
3039 "Front", "Surround", NULL /*CLFE*/, "Side"
3040 };
Matthew Ranostayd21995e2008-10-13 13:22:45 -04003041 hda_nid_t nid = 0;
Takashi Iwai91589232008-12-19 15:59:40 +01003042 int i, err;
3043 unsigned int wid_caps;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003044
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003045 for (i = 0; i < cfg->line_outs && spec->multiout.dac_nids[i]; i++) {
Mattc7d4b2f2005-06-27 14:59:41 +02003046 nid = spec->multiout.dac_nids[i];
Mattc7d4b2f2005-06-27 14:59:41 +02003047 if (i == 2) {
3048 /* Center/LFE */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003049 err = create_controls(codec, "Center", nid, 1);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003050 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003051 return err;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003052 err = create_controls(codec, "LFE", nid, 2);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003053 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003054 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003055
3056 wid_caps = get_wcaps(codec, nid);
3057
3058 if (wid_caps & AC_WCAP_LR_SWAP) {
3059 err = stac92xx_add_control(spec,
3060 STAC_CTL_WIDGET_CLFE_SWITCH,
3061 "Swap Center/LFE Playback Switch", nid);
3062
3063 if (err < 0)
3064 return err;
3065 }
3066
Mattc7d4b2f2005-06-27 14:59:41 +02003067 } else {
Takashi Iwai76624532008-12-19 10:09:47 +01003068 const char *name = chname[i];
3069 /* if it's a single DAC, assign a better name */
3070 if (!i && is_unique_dac(spec, nid)) {
3071 switch (cfg->line_out_type) {
3072 case AUTO_PIN_HP_OUT:
3073 name = "Headphone";
3074 break;
3075 case AUTO_PIN_SPEAKER_OUT:
3076 name = "Speaker";
3077 break;
3078 }
3079 }
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003080 err = create_controls(codec, name, nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003081 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003082 return err;
3083 }
3084 }
3085
Takashi Iwaia9cb5c92008-11-24 07:51:11 +01003086 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003087 err = stac92xx_add_control(spec,
3088 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01003089 "Headphone as Line Out Switch",
3090 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003091 if (err < 0)
3092 return err;
3093 }
3094
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003095 if (spec->line_switch) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003096 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
3097 "Line In as Output Switch",
3098 spec->line_switch << 8);
3099 if (err < 0)
3100 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003101 }
Matt Porter403d1942005-11-29 15:00:51 +01003102
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003103 if (spec->mic_switch) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003104 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
3105 "Mic as Output Switch",
3106 (spec->mic_switch << 8) | 1);
3107 if (err < 0)
3108 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003109 }
Matt Porter403d1942005-11-29 15:00:51 +01003110
Mattc7d4b2f2005-06-27 14:59:41 +02003111 return 0;
3112}
3113
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003114/* add playback controls for Speaker and HP outputs */
3115static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3116 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003117{
3118 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003119 hda_nid_t nid;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003120 int i, err, nums;
Mattc7d4b2f2005-06-27 14:59:41 +02003121
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003122 nums = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003123 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003124 static const char *pfxs[] = {
3125 "Headphone", "Headphone2", "Headphone3",
3126 };
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003127 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
3128 if (wid_caps & AC_WCAP_UNSOL_CAP)
3129 spec->hp_detect = 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003130 if (nums >= ARRAY_SIZE(pfxs))
Mattc7d4b2f2005-06-27 14:59:41 +02003131 continue;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003132 nid = spec->hp_dacs[i];
3133 if (!nid)
3134 continue;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003135 err = create_controls(codec, pfxs[nums++], nid, 3);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003136 if (err < 0)
3137 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003138 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003139 nums = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003140 for (i = 0; i < cfg->speaker_outs; i++) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003141 static const char *pfxs[] = {
3142 "Speaker", "External Speaker", "Speaker2",
3143 };
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003144 if (nums >= ARRAY_SIZE(pfxs))
3145 continue;
3146 nid = spec->speaker_dacs[i];
3147 if (!nid)
3148 continue;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003149 err = create_controls(codec, pfxs[nums++], nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003150 if (err < 0)
3151 return err;
3152 }
Mattc7d4b2f2005-06-27 14:59:41 +02003153 return 0;
3154}
3155
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003156/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003157static const char *stac92xx_mono_labels[4] = {
3158 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003159};
3160
3161/* create mono mux for mono out on capable codecs */
3162static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3163{
3164 struct sigmatel_spec *spec = codec->spec;
3165 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3166 int i, num_cons;
3167 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3168
3169 num_cons = snd_hda_get_connections(codec,
3170 spec->mono_nid,
3171 con_lst,
3172 HDA_MAX_NUM_INPUTS);
3173 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3174 return -EINVAL;
3175
3176 for (i = 0; i < num_cons; i++) {
3177 mono_mux->items[mono_mux->num_items].label =
3178 stac92xx_mono_labels[i];
3179 mono_mux->items[mono_mux->num_items].index = i;
3180 mono_mux->num_items++;
3181 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003182
3183 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3184 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003185}
3186
Matthew Ranostay89385032008-09-11 09:49:39 -04003187/* labels for amp mux outputs */
3188static const char *stac92xx_amp_labels[3] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04003189 "Front Microphone", "Microphone", "Line In",
Matthew Ranostay89385032008-09-11 09:49:39 -04003190};
3191
3192/* create amp out controls mux on capable codecs */
3193static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3194{
3195 struct sigmatel_spec *spec = codec->spec;
3196 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3197 int i, err;
3198
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003199 for (i = 0; i < spec->num_amps; i++) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003200 amp_mux->items[amp_mux->num_items].label =
3201 stac92xx_amp_labels[i];
3202 amp_mux->items[amp_mux->num_items].index = i;
3203 amp_mux->num_items++;
3204 }
3205
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003206 if (spec->num_amps > 1) {
3207 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3208 "Amp Selector Capture Switch", 0);
3209 if (err < 0)
3210 return err;
3211 }
Matthew Ranostay89385032008-09-11 09:49:39 -04003212 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3213 "Amp Capture Volume",
3214 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3215}
3216
3217
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003218/* create PC beep volume controls */
3219static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3220 hda_nid_t nid)
3221{
3222 struct sigmatel_spec *spec = codec->spec;
3223 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3224 int err;
3225
3226 /* check for mute support for the the amp */
3227 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3228 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3229 "PC Beep Playback Switch",
3230 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3231 if (err < 0)
3232 return err;
3233 }
3234
3235 /* check to see if there is volume support for the amp */
3236 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3237 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3238 "PC Beep Playback Volume",
3239 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3240 if (err < 0)
3241 return err;
3242 }
3243 return 0;
3244}
3245
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003246#ifdef CONFIG_SND_HDA_INPUT_BEEP
3247#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3248
3249static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3250 struct snd_ctl_elem_value *ucontrol)
3251{
3252 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3253 ucontrol->value.integer.value[0] = codec->beep->enabled;
3254 return 0;
3255}
3256
3257static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3258 struct snd_ctl_elem_value *ucontrol)
3259{
3260 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3261 int enabled = !!ucontrol->value.integer.value[0];
3262 if (codec->beep->enabled != enabled) {
3263 codec->beep->enabled = enabled;
3264 return 1;
3265 }
3266 return 0;
3267}
3268
3269static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3270 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3271 .info = stac92xx_dig_beep_switch_info,
3272 .get = stac92xx_dig_beep_switch_get,
3273 .put = stac92xx_dig_beep_switch_put,
3274};
3275
3276static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3277{
3278 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3279 0, "PC Beep Playback Switch", 0);
3280}
3281#endif
3282
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003283static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3284{
3285 struct sigmatel_spec *spec = codec->spec;
3286 int wcaps, nid, i, err = 0;
3287
3288 for (i = 0; i < spec->num_muxes; i++) {
3289 nid = spec->mux_nids[i];
3290 wcaps = get_wcaps(codec, nid);
3291
3292 if (wcaps & AC_WCAP_OUT_AMP) {
3293 err = stac92xx_add_control_idx(spec,
3294 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3295 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3296 if (err < 0)
3297 return err;
3298 }
3299 }
3300 return 0;
3301};
3302
Matthew Ranostayd9737752008-09-07 12:03:41 +02003303static const char *stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003304 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003305};
3306
3307static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3308{
3309 struct sigmatel_spec *spec = codec->spec;
3310 struct hda_input_mux *spdif_mux = &spec->private_smux;
Matthew Ranostay65973632008-09-16 10:39:37 -04003311 const char **labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003312 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003313 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003314
3315 num_cons = snd_hda_get_connections(codec,
3316 spec->smux_nids[0],
3317 con_lst,
3318 HDA_MAX_NUM_INPUTS);
Matthew Ranostay65973632008-09-16 10:39:37 -04003319 if (!num_cons)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003320 return -EINVAL;
3321
Matthew Ranostay65973632008-09-16 10:39:37 -04003322 if (!labels)
3323 labels = stac92xx_spdif_labels;
3324
Matthew Ranostayd9737752008-09-07 12:03:41 +02003325 for (i = 0; i < num_cons; i++) {
Matthew Ranostay65973632008-09-16 10:39:37 -04003326 spdif_mux->items[spdif_mux->num_items].label = labels[i];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003327 spdif_mux->items[spdif_mux->num_items].index = i;
3328 spdif_mux->num_items++;
3329 }
3330
3331 return 0;
3332}
3333
Matt Porter8b657272006-10-26 17:12:59 +02003334/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003335static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003336 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3337 "Digital Mic 3", "Digital Mic 4"
3338};
3339
3340/* create playback/capture controls for input pins on dmic capable codecs */
3341static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3342 const struct auto_pin_cfg *cfg)
3343{
3344 struct sigmatel_spec *spec = codec->spec;
3345 struct hda_input_mux *dimux = &spec->private_dimux;
3346 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003347 int err, i, j;
3348 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02003349
3350 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3351 dimux->items[dimux->num_items].index = 0;
3352 dimux->num_items++;
3353
3354 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003355 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003356 int index;
3357 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003358 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02003359 unsigned int def_conf;
3360
Takashi Iwai330ee992009-02-20 14:33:36 +01003361 def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
Matt Porter8b657272006-10-26 17:12:59 +02003362 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3363 continue;
3364
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003365 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02003366 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003367 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02003368 con_lst,
3369 HDA_MAX_NUM_INPUTS);
3370 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003371 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02003372 index = j;
3373 goto found;
3374 }
3375 continue;
3376found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003377 wcaps = get_wcaps(codec, nid) &
3378 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003379
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003380 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003381 sprintf(name, "%s Capture Volume",
3382 stac92xx_dmic_labels[dimux->num_items]);
3383
3384 err = stac92xx_add_control(spec,
3385 STAC_CTL_WIDGET_VOL,
3386 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003387 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3388 (wcaps & AC_WCAP_OUT_AMP) ?
3389 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003390 if (err < 0)
3391 return err;
3392 }
3393
Matt Porter8b657272006-10-26 17:12:59 +02003394 dimux->items[dimux->num_items].label =
3395 stac92xx_dmic_labels[dimux->num_items];
3396 dimux->items[dimux->num_items].index = index;
3397 dimux->num_items++;
3398 }
3399
3400 return 0;
3401}
3402
Mattc7d4b2f2005-06-27 14:59:41 +02003403/* create playback/capture controls for input pins */
3404static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3405{
3406 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003407 struct hda_input_mux *imux = &spec->private_imux;
3408 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3409 int i, j, k;
3410
3411 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003412 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02003413
Takashi Iwai314634b2006-09-21 11:56:18 +02003414 if (!cfg->input_pins[i])
3415 continue;
3416 index = -1;
3417 for (j = 0; j < spec->num_muxes; j++) {
3418 int num_cons;
3419 num_cons = snd_hda_get_connections(codec,
3420 spec->mux_nids[j],
3421 con_lst,
3422 HDA_MAX_NUM_INPUTS);
3423 for (k = 0; k < num_cons; k++)
3424 if (con_lst[k] == cfg->input_pins[i]) {
3425 index = k;
3426 goto found;
3427 }
Mattc7d4b2f2005-06-27 14:59:41 +02003428 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003429 continue;
3430 found:
3431 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3432 imux->items[imux->num_items].index = index;
3433 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003434 }
3435
Steve Longerbeam7b043892007-05-03 20:50:03 +02003436 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003437 /*
3438 * Set the current input for the muxes.
3439 * The STAC9221 has two input muxes with identical source
3440 * NID lists. Hopefully this won't get confused.
3441 */
3442 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003443 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3444 AC_VERB_SET_CONNECT_SEL,
3445 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003446 }
3447 }
3448
Mattc7d4b2f2005-06-27 14:59:41 +02003449 return 0;
3450}
3451
Mattc7d4b2f2005-06-27 14:59:41 +02003452static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3453{
3454 struct sigmatel_spec *spec = codec->spec;
3455 int i;
3456
3457 for (i = 0; i < spec->autocfg.line_outs; i++) {
3458 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3459 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3460 }
3461}
3462
3463static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3464{
3465 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003466 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003467
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003468 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3469 hda_nid_t pin;
3470 pin = spec->autocfg.hp_pins[i];
3471 if (pin) /* connect to front */
3472 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3473 }
3474 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3475 hda_nid_t pin;
3476 pin = spec->autocfg.speaker_pins[i];
3477 if (pin) /* connect to front */
3478 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3479 }
Mattc7d4b2f2005-06-27 14:59:41 +02003480}
3481
Matt Porter3cc08dc2006-01-23 15:27:49 +01003482static 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 +02003483{
3484 struct sigmatel_spec *spec = codec->spec;
3485 int err;
3486
Matt Porter8b657272006-10-26 17:12:59 +02003487 if ((err = snd_hda_parse_pin_def_config(codec,
3488 &spec->autocfg,
3489 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003490 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003491 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003492 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003493
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003494 /* If we have no real line-out pin and multiple hp-outs, HPs should
3495 * be set up as multi-channel outputs.
3496 */
3497 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3498 spec->autocfg.hp_outs > 1) {
3499 /* Copy hp_outs to line_outs, backup line_outs in
3500 * speaker_outs so that the following routines can handle
3501 * HP pins as primary outputs.
3502 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003503 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003504 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3505 sizeof(spec->autocfg.line_out_pins));
3506 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3507 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3508 sizeof(spec->autocfg.hp_pins));
3509 spec->autocfg.line_outs = spec->autocfg.hp_outs;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003510 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3511 spec->autocfg.hp_outs = 0;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003512 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003513 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003514 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3515 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003516 u32 caps = query_amp_caps(codec,
3517 spec->autocfg.mono_out_pin, dir);
3518 hda_nid_t conn_list[1];
3519
3520 /* get the mixer node and then the mono mux if it exists */
3521 if (snd_hda_get_connections(codec,
3522 spec->autocfg.mono_out_pin, conn_list, 1) &&
3523 snd_hda_get_connections(codec, conn_list[0],
3524 conn_list, 1)) {
3525
3526 int wcaps = get_wcaps(codec, conn_list[0]);
3527 int wid_type = (wcaps & AC_WCAP_TYPE)
3528 >> AC_WCAP_TYPE_SHIFT;
3529 /* LR swap check, some stac925x have a mux that
3530 * changes the DACs output path instead of the
3531 * mono-mux path.
3532 */
3533 if (wid_type == AC_WID_AUD_SEL &&
3534 !(wcaps & AC_WCAP_LR_SWAP))
3535 spec->mono_nid = conn_list[0];
3536 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003537 if (dir) {
3538 hda_nid_t nid = spec->autocfg.mono_out_pin;
3539
3540 /* most mono outs have a least a mute/unmute switch */
3541 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3542 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3543 "Mono Playback Switch",
3544 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003545 if (err < 0)
3546 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003547 /* check for volume support for the amp */
3548 if ((caps & AC_AMPCAP_NUM_STEPS)
3549 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3550 err = stac92xx_add_control(spec,
3551 STAC_CTL_WIDGET_VOL,
3552 "Mono Playback Volume",
3553 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3554 if (err < 0)
3555 return err;
3556 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003557 }
3558
3559 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3560 AC_PINCTL_OUT_EN);
3561 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003562
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003563 if (!spec->multiout.num_dacs) {
3564 err = stac92xx_auto_fill_dac_nids(codec);
3565 if (err < 0)
Takashi Iwai19039bd2006-06-28 15:52:16 +02003566 return err;
Takashi Iwaic9280d62009-01-15 17:31:00 +01003567 err = stac92xx_auto_create_multi_out_ctls(codec,
3568 &spec->autocfg);
3569 if (err < 0)
3570 return err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003571 }
Mattc7d4b2f2005-06-27 14:59:41 +02003572
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003573 /* setup analog beep controls */
3574 if (spec->anabeep_nid > 0) {
3575 err = stac92xx_auto_create_beep_ctls(codec,
3576 spec->anabeep_nid);
3577 if (err < 0)
3578 return err;
3579 }
3580
3581 /* setup digital beep controls and input device */
3582#ifdef CONFIG_SND_HDA_INPUT_BEEP
3583 if (spec->digbeep_nid > 0) {
3584 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003585 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003586
3587 err = stac92xx_auto_create_beep_ctls(codec, nid);
3588 if (err < 0)
3589 return err;
3590 err = snd_hda_attach_beep_device(codec, nid);
3591 if (err < 0)
3592 return err;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003593 /* if no beep switch is available, make its own one */
3594 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3595 if (codec->beep &&
3596 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3597 err = stac92xx_beep_switch_ctl(codec);
3598 if (err < 0)
3599 return err;
3600 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003601 }
3602#endif
3603
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003604 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3605
3606 if (err < 0)
3607 return err;
3608
3609 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3610
3611 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003612 return err;
3613
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003614 if (spec->mono_nid > 0) {
3615 err = stac92xx_auto_create_mono_output_ctls(codec);
3616 if (err < 0)
3617 return err;
3618 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003619 if (spec->num_amps > 0) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003620 err = stac92xx_auto_create_amp_output_ctls(codec);
3621 if (err < 0)
3622 return err;
3623 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003624 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003625 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3626 &spec->autocfg)) < 0)
3627 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003628 if (spec->num_muxes > 0) {
3629 err = stac92xx_auto_create_mux_input_ctls(codec);
3630 if (err < 0)
3631 return err;
3632 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003633 if (spec->num_smuxes > 0) {
3634 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3635 if (err < 0)
3636 return err;
3637 }
Matt Porter8b657272006-10-26 17:12:59 +02003638
Takashi Iwaie3c75962009-01-23 11:57:22 +01003639 err = stac92xx_add_input_source(spec);
3640 if (err < 0)
3641 return err;
3642
Mattc7d4b2f2005-06-27 14:59:41 +02003643 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003644 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003645 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003646
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003647 if (spec->autocfg.dig_outs)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003648 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003649 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003650 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003651
Takashi Iwai603c4012008-07-30 15:01:44 +02003652 if (spec->kctls.list)
3653 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003654
3655 spec->input_mux = &spec->private_imux;
Matthew Ranostayf8ccbf62008-12-20 17:36:28 -05003656 if (!spec->dinput_mux)
3657 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003658 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003659 spec->mono_mux = &spec->private_mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -04003660 spec->amp_mux = &spec->private_amp_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003661 return 1;
3662}
3663
Takashi Iwai82bc9552006-03-21 11:24:42 +01003664/* add playback controls for HP output */
3665static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3666 struct auto_pin_cfg *cfg)
3667{
3668 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003669 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003670 unsigned int wid_caps;
3671
3672 if (! pin)
3673 return 0;
3674
3675 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003676 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003677 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003678
3679 return 0;
3680}
3681
Richard Fish160ea0d2006-09-06 13:58:25 +02003682/* add playback controls for LFE output */
3683static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3684 struct auto_pin_cfg *cfg)
3685{
3686 struct sigmatel_spec *spec = codec->spec;
3687 int err;
3688 hda_nid_t lfe_pin = 0x0;
3689 int i;
3690
3691 /*
3692 * search speaker outs and line outs for a mono speaker pin
3693 * with an amp. If one is found, add LFE controls
3694 * for it.
3695 */
3696 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3697 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003698 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003699 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3700 if (wcaps == AC_WCAP_OUT_AMP)
3701 /* found a mono speaker with an amp, must be lfe */
3702 lfe_pin = pin;
3703 }
3704
3705 /* if speaker_outs is 0, then speakers may be in line_outs */
3706 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3707 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3708 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003709 unsigned int defcfg;
Takashi Iwai330ee992009-02-20 14:33:36 +01003710 defcfg = snd_hda_codec_get_pincfg(codec, pin);
Harvey Harrison8b551782008-02-29 11:56:48 +01003711 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003712 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003713 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3714 if (wcaps == AC_WCAP_OUT_AMP)
3715 /* found a mono speaker with an amp,
3716 must be lfe */
3717 lfe_pin = pin;
3718 }
3719 }
3720 }
3721
3722 if (lfe_pin) {
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003723 err = create_controls(codec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003724 if (err < 0)
3725 return err;
3726 }
3727
3728 return 0;
3729}
3730
Mattc7d4b2f2005-06-27 14:59:41 +02003731static int stac9200_parse_auto_config(struct hda_codec *codec)
3732{
3733 struct sigmatel_spec *spec = codec->spec;
3734 int err;
3735
Kailang Yangdf694da2005-12-05 19:42:22 +01003736 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003737 return err;
3738
3739 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3740 return err;
3741
Takashi Iwai82bc9552006-03-21 11:24:42 +01003742 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3743 return err;
3744
Richard Fish160ea0d2006-09-06 13:58:25 +02003745 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3746 return err;
3747
Takashi Iwai355a0ec2008-11-11 16:46:19 +01003748 if (spec->num_muxes > 0) {
3749 err = stac92xx_auto_create_mux_input_ctls(codec);
3750 if (err < 0)
3751 return err;
3752 }
3753
Takashi Iwaie3c75962009-01-23 11:57:22 +01003754 err = stac92xx_add_input_source(spec);
3755 if (err < 0)
3756 return err;
3757
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003758 if (spec->autocfg.dig_outs)
Mattc7d4b2f2005-06-27 14:59:41 +02003759 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003760 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003761 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003762
Takashi Iwai603c4012008-07-30 15:01:44 +02003763 if (spec->kctls.list)
3764 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003765
3766 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003767 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003768
3769 return 1;
3770}
3771
Sam Revitch62fe78e2006-05-10 15:09:17 +02003772/*
3773 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3774 * funky external mute control using GPIO pins.
3775 */
3776
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003777static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003778 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003779{
3780 unsigned int gpiostate, gpiomask, gpiodir;
3781
3782 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3783 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003784 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003785
3786 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3787 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003788 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003789
3790 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3791 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003792 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003793
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003794 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003795 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3796
3797 snd_hda_codec_write(codec, codec->afg, 0,
3798 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003799 snd_hda_codec_read(codec, codec->afg, 0,
3800 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003801
3802 msleep(1);
3803
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003804 snd_hda_codec_read(codec, codec->afg, 0,
3805 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003806}
3807
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003808static int stac92xx_add_jack(struct hda_codec *codec,
3809 hda_nid_t nid, int type)
3810{
Takashi Iwaie4973e12008-11-18 09:32:42 +01003811#ifdef CONFIG_SND_JACK
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003812 struct sigmatel_spec *spec = codec->spec;
3813 struct sigmatel_jack *jack;
Takashi Iwai330ee992009-02-20 14:33:36 +01003814 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003815 int connectivity = get_defcfg_connect(def_conf);
3816 char name[32];
3817
3818 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
3819 return 0;
3820
3821 snd_array_init(&spec->jacks, sizeof(*jack), 32);
3822 jack = snd_array_new(&spec->jacks);
3823 if (!jack)
3824 return -ENOMEM;
3825 jack->nid = nid;
3826 jack->type = type;
3827
3828 sprintf(name, "%s at %s %s Jack",
3829 snd_hda_get_jack_type(def_conf),
3830 snd_hda_get_jack_connectivity(def_conf),
3831 snd_hda_get_jack_location(def_conf));
3832
3833 return snd_jack_new(codec->bus->card, name, type, &jack->jack);
Takashi Iwaie4973e12008-11-18 09:32:42 +01003834#else
3835 return 0;
3836#endif
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003837}
3838
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003839static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
3840 unsigned char type, int data)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003841{
3842 struct sigmatel_event *event;
3843
3844 snd_array_init(&spec->events, sizeof(*event), 32);
3845 event = snd_array_new(&spec->events);
3846 if (!event)
3847 return -ENOMEM;
3848 event->nid = nid;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003849 event->type = type;
3850 event->tag = spec->events.used;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003851 event->data = data;
3852
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003853 return event->tag;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003854}
3855
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003856static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
3857 hda_nid_t nid, unsigned char type)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003858{
3859 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003860 struct sigmatel_event *event = spec->events.list;
3861 int i;
3862
3863 for (i = 0; i < spec->events.used; i++, event++) {
3864 if (event->nid == nid && event->type == type)
3865 return event;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003866 }
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003867 return NULL;
3868}
3869
3870static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
3871 unsigned char tag)
3872{
3873 struct sigmatel_spec *spec = codec->spec;
3874 struct sigmatel_event *event = spec->events.list;
3875 int i;
3876
3877 for (i = 0; i < spec->events.used; i++, event++) {
3878 if (event->tag == tag)
3879 return event;
3880 }
3881 return NULL;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003882}
3883
Takashi Iwai314634b2006-09-21 11:56:18 +02003884static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003885 unsigned int type)
Takashi Iwai314634b2006-09-21 11:56:18 +02003886{
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003887 struct sigmatel_event *event;
3888 int tag;
3889
3890 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
3891 return;
3892 event = stac_get_event(codec, nid, type);
3893 if (event)
3894 tag = event->tag;
3895 else
3896 tag = stac_add_event(codec->spec, nid, type, 0);
3897 if (tag < 0)
3898 return;
3899 snd_hda_codec_write_cache(codec, nid, 0,
3900 AC_VERB_SET_UNSOLICITED_ENABLE,
3901 AC_USRSP_EN | tag);
Takashi Iwai314634b2006-09-21 11:56:18 +02003902}
3903
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003904static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3905{
3906 int i;
3907 for (i = 0; i < cfg->hp_outs; i++)
3908 if (cfg->hp_pins[i] == nid)
3909 return 1; /* nid is a HP-Out */
3910
3911 return 0; /* nid is not a HP-Out */
3912};
3913
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003914static void stac92xx_power_down(struct hda_codec *codec)
3915{
3916 struct sigmatel_spec *spec = codec->spec;
3917
3918 /* power down inactive DACs */
3919 hda_nid_t *dac;
3920 for (dac = spec->dac_list; *dac; dac++)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003921 if (!check_all_dac_nids(spec, *dac))
Takashi Iwai8c2f7672008-12-01 11:54:35 +01003922 snd_hda_codec_write(codec, *dac, 0,
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003923 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3924}
3925
Takashi Iwaif73d3582008-11-25 08:21:51 +01003926static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
3927 int enable);
3928
Mattc7d4b2f2005-06-27 14:59:41 +02003929static int stac92xx_init(struct hda_codec *codec)
3930{
3931 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003932 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01003933 unsigned int gpio;
Takashi Iwaie4973e12008-11-18 09:32:42 +01003934 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003935
Mattc7d4b2f2005-06-27 14:59:41 +02003936 snd_hda_sequence_write(codec, spec->init);
3937
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003938 /* power down adcs initially */
3939 if (spec->powerdown_adcs)
3940 for (i = 0; i < spec->num_adcs; i++)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01003941 snd_hda_codec_write(codec,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003942 spec->adc_nids[i], 0,
3943 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01003944
3945 /* set up GPIO */
3946 gpio = spec->gpio_data;
3947 /* turn on EAPD statically when spec->eapd_switch isn't set.
3948 * otherwise, unsol event will turn it on/off dynamically
3949 */
3950 if (!spec->eapd_switch)
3951 gpio |= spec->eapd_mask;
3952 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
3953
Takashi Iwai82bc9552006-03-21 11:24:42 +01003954 /* set up pins */
3955 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02003956 /* Enable unsolicited responses on the HP widget */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003957 for (i = 0; i < cfg->hp_outs; i++) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003958 hda_nid_t nid = cfg->hp_pins[i];
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003959 enable_pin_detect(codec, nid, STAC_HP_EVENT);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003960 }
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01003961 /* force to enable the first line-out; the others are set up
3962 * in unsol_event
3963 */
3964 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003965 AC_PINCTL_OUT_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003966 /* fake event to set up pins */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003967 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
3968 STAC_HP_EVENT);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003969 } else {
3970 stac92xx_auto_init_multi_out(codec);
3971 stac92xx_auto_init_hp_out(codec);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01003972 for (i = 0; i < cfg->hp_outs; i++)
3973 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003974 }
3975 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01003976 hda_nid_t nid = cfg->input_pins[i];
3977 if (nid) {
Takashi Iwai12dde4c2008-12-05 13:09:27 +01003978 unsigned int pinctl, conf;
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01003979 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
3980 /* for mic pins, force to initialize */
3981 pinctl = stac92xx_get_vref(codec, nid);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01003982 pinctl |= AC_PINCTL_IN_EN;
3983 stac92xx_auto_set_pinctl(codec, nid, pinctl);
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01003984 } else {
3985 pinctl = snd_hda_codec_read(codec, nid, 0,
3986 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3987 /* if PINCTL already set then skip */
Takashi Iwai12dde4c2008-12-05 13:09:27 +01003988 if (!(pinctl & AC_PINCTL_IN_EN)) {
3989 pinctl |= AC_PINCTL_IN_EN;
3990 stac92xx_auto_set_pinctl(codec, nid,
3991 pinctl);
3992 }
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01003993 }
Takashi Iwai330ee992009-02-20 14:33:36 +01003994 conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01003995 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
3996 enable_pin_detect(codec, nid,
3997 STAC_INSERT_EVENT);
3998 stac_issue_unsol_event(codec, nid,
3999 STAC_INSERT_EVENT);
4000 }
Takashi Iwaic960a032006-03-23 17:06:28 +01004001 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01004002 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004003 for (i = 0; i < spec->num_dmics; i++)
4004 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4005 AC_PINCTL_IN_EN);
Takashi Iwai0852d7a2009-02-11 11:35:15 +01004006 if (cfg->dig_out_pins[0])
4007 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
Takashi Iwai82bc9552006-03-21 11:24:42 +01004008 AC_PINCTL_OUT_EN);
4009 if (cfg->dig_in_pin)
4010 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4011 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004012 for (i = 0; i < spec->num_pwrs; i++) {
4013 hda_nid_t nid = spec->pwr_nids[i];
4014 int pinctl, def_conf;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004015
Takashi Iwaieb632122008-12-19 16:39:48 +01004016 /* power on when no jack detection is available */
4017 if (!spec->hp_detect) {
4018 stac_toggle_power_map(codec, nid, 1);
4019 continue;
4020 }
4021
4022 if (is_nid_hp_pin(cfg, nid))
Takashi Iwaif73d3582008-11-25 08:21:51 +01004023 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004024
Takashi Iwaif73d3582008-11-25 08:21:51 +01004025 pinctl = snd_hda_codec_read(codec, nid, 0,
4026 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4027 /* outputs are only ports capable of power management
4028 * any attempts on powering down a input port cause the
4029 * referenced VREF to act quirky.
4030 */
Takashi Iwaieb632122008-12-19 16:39:48 +01004031 if (pinctl & AC_PINCTL_IN_EN) {
4032 stac_toggle_power_map(codec, nid, 1);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004033 continue;
Takashi Iwaieb632122008-12-19 16:39:48 +01004034 }
Takashi Iwai330ee992009-02-20 14:33:36 +01004035 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004036 def_conf = get_defcfg_connect(def_conf);
4037 /* skip any ports that don't have jacks since presence
4038 * detection is useless */
4039 if (def_conf != AC_JACK_PORT_COMPLEX) {
4040 if (def_conf != AC_JACK_PORT_NONE)
4041 stac_toggle_power_map(codec, nid, 1);
4042 continue;
4043 }
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004044 if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) {
4045 enable_pin_detect(codec, nid, STAC_PWR_EVENT);
4046 stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT);
4047 }
Takashi Iwaif73d3582008-11-25 08:21:51 +01004048 }
4049 if (spec->dac_list)
4050 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02004051 return 0;
4052}
4053
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004054static void stac92xx_free_jacks(struct hda_codec *codec)
4055{
Takashi Iwaie4973e12008-11-18 09:32:42 +01004056#ifdef CONFIG_SND_JACK
Takashi Iwaib94d35392008-11-21 09:08:06 +01004057 /* free jack instances manually when clearing/reconfiguring */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004058 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaib94d35392008-11-21 09:08:06 +01004059 if (!codec->bus->shutdown && spec->jacks.list) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004060 struct sigmatel_jack *jacks = spec->jacks.list;
4061 int i;
4062 for (i = 0; i < spec->jacks.used; i++)
4063 snd_device_free(codec->bus->card, &jacks[i].jack);
4064 }
4065 snd_array_free(&spec->jacks);
Takashi Iwaie4973e12008-11-18 09:32:42 +01004066#endif
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004067}
4068
Takashi Iwai603c4012008-07-30 15:01:44 +02004069static void stac92xx_free_kctls(struct hda_codec *codec)
4070{
4071 struct sigmatel_spec *spec = codec->spec;
4072
4073 if (spec->kctls.list) {
4074 struct snd_kcontrol_new *kctl = spec->kctls.list;
4075 int i;
4076 for (i = 0; i < spec->kctls.used; i++)
4077 kfree(kctl[i].name);
4078 }
4079 snd_array_free(&spec->kctls);
4080}
4081
Matt2f2f4252005-04-13 14:45:30 +02004082static void stac92xx_free(struct hda_codec *codec)
4083{
Mattc7d4b2f2005-06-27 14:59:41 +02004084 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004085
4086 if (! spec)
4087 return;
4088
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004089 stac92xx_free_jacks(codec);
4090 snd_array_free(&spec->events);
Richard Fish11b44bb2006-08-23 18:31:34 +02004091
Mattc7d4b2f2005-06-27 14:59:41 +02004092 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004093 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02004094}
4095
Matt4e550962005-07-04 17:51:39 +02004096static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4097 unsigned int flag)
4098{
Takashi Iwai8ce84192009-01-22 16:59:20 +01004099 unsigned int old_ctl, pin_ctl;
4100
4101 pin_ctl = snd_hda_codec_read(codec, nid,
Matt4e550962005-07-04 17:51:39 +02004102 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02004103
Takashi Iwaif9acba42007-05-29 18:01:06 +02004104 if (pin_ctl & AC_PINCTL_IN_EN) {
4105 /*
4106 * we need to check the current set-up direction of
4107 * shared input pins since they can be switched via
4108 * "xxx as Output" mixer switch
4109 */
4110 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004111 if (nid == spec->line_switch || nid == spec->mic_switch)
Takashi Iwaif9acba42007-05-29 18:01:06 +02004112 return;
4113 }
4114
Takashi Iwai8ce84192009-01-22 16:59:20 +01004115 old_ctl = pin_ctl;
Steve Longerbeam7b043892007-05-03 20:50:03 +02004116 /* if setting pin direction bits, clear the current
4117 direction bits first */
4118 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4119 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4120
Takashi Iwai8ce84192009-01-22 16:59:20 +01004121 pin_ctl |= flag;
4122 if (old_ctl != pin_ctl)
4123 snd_hda_codec_write_cache(codec, nid, 0,
4124 AC_VERB_SET_PIN_WIDGET_CONTROL,
4125 pin_ctl);
Matt4e550962005-07-04 17:51:39 +02004126}
4127
4128static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4129 unsigned int flag)
4130{
4131 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4132 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai8ce84192009-01-22 16:59:20 +01004133 if (pin_ctl & flag)
4134 snd_hda_codec_write_cache(codec, nid, 0,
4135 AC_VERB_SET_PIN_WIDGET_CONTROL,
4136 pin_ctl & ~flag);
Matt4e550962005-07-04 17:51:39 +02004137}
4138
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004139static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02004140{
4141 if (!nid)
4142 return 0;
4143 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004144 & (1 << 31))
4145 return 1;
Takashi Iwai314634b2006-09-21 11:56:18 +02004146 return 0;
4147}
4148
Takashi Iwaid7a89432008-11-12 09:48:04 +01004149/* return non-zero if the hp-pin of the given array index isn't
4150 * a jack-detection target
4151 */
4152static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4153{
4154 struct auto_pin_cfg *cfg = &spec->autocfg;
4155
4156 /* ignore sensing of shared line and mic jacks */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004157 if (cfg->hp_pins[i] == spec->line_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004158 return 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004159 if (cfg->hp_pins[i] == spec->mic_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004160 return 1;
4161 /* ignore if the pin is set as line-out */
4162 if (cfg->hp_pins[i] == spec->hp_switch)
4163 return 1;
4164 return 0;
4165}
4166
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004167static void stac92xx_hp_detect(struct hda_codec *codec)
Matt4e550962005-07-04 17:51:39 +02004168{
4169 struct sigmatel_spec *spec = codec->spec;
4170 struct auto_pin_cfg *cfg = &spec->autocfg;
4171 int i, presence;
4172
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004173 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004174 if (spec->gpio_mute)
4175 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4176 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4177
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004178 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004179 if (presence)
4180 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01004181 if (no_hp_sensing(spec, i))
4182 continue;
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004183 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4184 if (presence) {
4185 unsigned int pinctl;
4186 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4187 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4188 if (pinctl & AC_PINCTL_IN_EN)
4189 presence = 0; /* mic- or line-input */
4190 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004191 }
Matt4e550962005-07-04 17:51:39 +02004192
4193 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004194 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004195 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004196 stac92xx_reset_pinctl(codec, spec->hp_switch,
4197 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004198 for (i = 0; i < cfg->line_outs; i++)
4199 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4200 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004201 for (i = 0; i < cfg->speaker_outs; i++)
4202 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4203 AC_PINCTL_OUT_EN);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004204 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004205 stac_gpio_set(codec, spec->gpio_mask,
4206 spec->gpio_dir, spec->gpio_data &
4207 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02004208 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004209 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004210 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004211 stac92xx_set_pinctl(codec, spec->hp_switch,
4212 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004213 for (i = 0; i < cfg->line_outs; i++)
4214 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4215 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004216 for (i = 0; i < cfg->speaker_outs; i++)
4217 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4218 AC_PINCTL_OUT_EN);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004219 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004220 stac_gpio_set(codec, spec->gpio_mask,
4221 spec->gpio_dir, spec->gpio_data |
4222 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02004223 }
Takashi Iwaid7a89432008-11-12 09:48:04 +01004224 /* toggle hp outs */
4225 for (i = 0; i < cfg->hp_outs; i++) {
4226 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4227 if (no_hp_sensing(spec, i))
4228 continue;
4229 if (presence)
4230 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004231#if 0 /* FIXME */
4232/* Resetting the pinctl like below may lead to (a sort of) regressions
4233 * on some devices since they use the HP pin actually for line/speaker
4234 * outs although the default pin config shows a different pin (that is
4235 * wrong and useless).
4236 *
4237 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4238 * But, disabling the code below just works around it, and I'm too tired of
4239 * bug reports with such devices...
4240 */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004241 else
4242 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004243#endif /* FIXME */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004244 }
Matt4e550962005-07-04 17:51:39 +02004245}
4246
Takashi Iwaif73d3582008-11-25 08:21:51 +01004247static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4248 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004249{
4250 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004251 unsigned int idx, val;
4252
4253 for (idx = 0; idx < spec->num_pwrs; idx++) {
4254 if (spec->pwr_nids[idx] == nid)
4255 break;
4256 }
4257 if (idx >= spec->num_pwrs)
4258 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004259
4260 /* several codecs have two power down bits */
4261 if (spec->pwr_mapping)
4262 idx = spec->pwr_mapping[idx];
4263 else
4264 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004265
Takashi Iwaif73d3582008-11-25 08:21:51 +01004266 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4267 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004268 val &= ~idx;
4269 else
4270 val |= idx;
4271
4272 /* power down unused output ports */
4273 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004274}
4275
Takashi Iwaif73d3582008-11-25 08:21:51 +01004276static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4277{
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004278 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
Takashi Iwaif73d3582008-11-25 08:21:51 +01004279}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004280
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004281static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4282{
4283 struct sigmatel_spec *spec = codec->spec;
4284 struct sigmatel_jack *jacks = spec->jacks.list;
4285
4286 if (jacks) {
4287 int i;
4288 for (i = 0; i < spec->jacks.used; i++) {
4289 if (jacks->nid == nid) {
4290 unsigned int pin_ctl =
4291 snd_hda_codec_read(codec, nid,
4292 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4293 0x00);
4294 int type = jacks->type;
4295 if (type == (SND_JACK_LINEOUT
4296 | SND_JACK_HEADPHONE))
4297 type = (pin_ctl & AC_PINCTL_HP_EN)
4298 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4299 snd_jack_report(jacks->jack,
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004300 get_pin_presence(codec, nid)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004301 ? type : 0);
4302 }
4303 jacks++;
4304 }
4305 }
4306}
Matt2f2f4252005-04-13 14:45:30 +02004307
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004308static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
4309 unsigned char type)
4310{
4311 struct sigmatel_event *event = stac_get_event(codec, nid, type);
4312 if (!event)
4313 return;
4314 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4315}
4316
Takashi Iwai314634b2006-09-21 11:56:18 +02004317static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4318{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004319 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004320 struct sigmatel_event *event;
4321 int tag, data;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004322
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004323 tag = (res >> 26) & 0x7f;
4324 event = stac_get_event_from_tag(codec, tag);
4325 if (!event)
4326 return;
4327
4328 switch (event->type) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004329 case STAC_HP_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004330 stac92xx_hp_detect(codec);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004331 /* fallthru */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004332 case STAC_INSERT_EVENT:
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004333 case STAC_PWR_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004334 if (spec->num_pwrs > 0)
4335 stac92xx_pin_sense(codec, event->nid);
4336 stac92xx_report_jack(codec, event->nid);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004337 break;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004338 case STAC_VREF_EVENT:
4339 data = snd_hda_codec_read(codec, codec->afg, 0,
4340 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004341 /* toggle VREF state based on GPIOx status */
4342 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004343 !!(data & (1 << event->data)));
Matthew Ranostay72474be2008-10-09 09:32:17 -04004344 break;
Takashi Iwai314634b2006-09-21 11:56:18 +02004345 }
4346}
4347
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004348#ifdef CONFIG_PROC_FS
4349static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4350 struct hda_codec *codec, hda_nid_t nid)
4351{
4352 if (nid == codec->afg)
4353 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4354 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4355}
4356
4357static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4358 struct hda_codec *codec,
4359 unsigned int verb)
4360{
4361 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4362 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4363}
4364
4365/* stac92hd71bxx, stac92hd73xx */
4366static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4367 struct hda_codec *codec, hda_nid_t nid)
4368{
4369 stac92hd_proc_hook(buffer, codec, nid);
4370 if (nid == codec->afg)
4371 analog_loop_proc_hook(buffer, codec, 0xfa0);
4372}
4373
4374static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4375 struct hda_codec *codec, hda_nid_t nid)
4376{
4377 if (nid == codec->afg)
4378 analog_loop_proc_hook(buffer, codec, 0xfe0);
4379}
4380
4381static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4382 struct hda_codec *codec, hda_nid_t nid)
4383{
4384 if (nid == codec->afg)
4385 analog_loop_proc_hook(buffer, codec, 0xfeb);
4386}
4387#else
4388#define stac92hd_proc_hook NULL
4389#define stac92hd7x_proc_hook NULL
4390#define stac9205_proc_hook NULL
4391#define stac927x_proc_hook NULL
4392#endif
4393
Takashi Iwaicb53c622007-08-10 17:21:45 +02004394#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004395static int stac92xx_resume(struct hda_codec *codec)
4396{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004397 struct sigmatel_spec *spec = codec->spec;
4398
Takashi Iwai2c885872008-11-18 09:36:55 +01004399 stac92xx_init(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004400 snd_hda_codec_resume_amp(codec);
4401 snd_hda_codec_resume_cache(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01004402 /* fake event to set up pins again to override cached values */
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004403 if (spec->hp_detect)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004404 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4405 STAC_HP_EVENT);
Mattff6fdc32005-06-27 15:06:52 +02004406 return 0;
4407}
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004408
4409static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4410{
4411 struct sigmatel_spec *spec = codec->spec;
4412 if (spec->eapd_mask)
4413 stac_gpio_set(codec, spec->gpio_mask,
4414 spec->gpio_dir, spec->gpio_data &
4415 ~spec->eapd_mask);
4416 return 0;
4417}
Mattff6fdc32005-06-27 15:06:52 +02004418#endif
4419
Matt2f2f4252005-04-13 14:45:30 +02004420static struct hda_codec_ops stac92xx_patch_ops = {
4421 .build_controls = stac92xx_build_controls,
4422 .build_pcms = stac92xx_build_pcms,
4423 .init = stac92xx_init,
4424 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02004425 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004426#ifdef SND_HDA_NEEDS_RESUME
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004427 .suspend = stac92xx_suspend,
Mattff6fdc32005-06-27 15:06:52 +02004428 .resume = stac92xx_resume,
4429#endif
Matt2f2f4252005-04-13 14:45:30 +02004430};
4431
4432static int patch_stac9200(struct hda_codec *codec)
4433{
4434 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004435 int err;
Matt2f2f4252005-04-13 14:45:30 +02004436
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004437 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004438 if (spec == NULL)
4439 return -ENOMEM;
4440
4441 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004442 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004443 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004444 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4445 stac9200_models,
4446 stac9200_cfg_tbl);
Takashi Iwai330ee992009-02-20 14:33:36 +01004447 if (spec->board_config < 0)
Richard Fish11b44bb2006-08-23 18:31:34 +02004448 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01004449 else
4450 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004451 stac9200_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02004452
4453 spec->multiout.max_channels = 2;
4454 spec->multiout.num_dacs = 1;
4455 spec->multiout.dac_nids = stac9200_dac_nids;
4456 spec->adc_nids = stac9200_adc_nids;
4457 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02004458 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02004459 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004460 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004461 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004462
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02004463 if (spec->board_config == STAC_9200_M4 ||
4464 spec->board_config == STAC_9200_M4_2 ||
Tobin Davisbf277782008-02-03 20:31:47 +01004465 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02004466 spec->init = stac9200_eapd_init;
4467 else
4468 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004469 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004470
Takashi Iwai117f2572008-03-18 09:53:23 +01004471 if (spec->board_config == STAC_9200_PANASONIC) {
4472 spec->gpio_mask = spec->gpio_dir = 0x09;
4473 spec->gpio_data = 0x00;
4474 }
4475
Mattc7d4b2f2005-06-27 14:59:41 +02004476 err = stac9200_parse_auto_config(codec);
4477 if (err < 0) {
4478 stac92xx_free(codec);
4479 return err;
4480 }
Matt2f2f4252005-04-13 14:45:30 +02004481
Takashi Iwai2acc9dc2009-01-09 16:57:14 +01004482 /* CF-74 has no headphone detection, and the driver should *NOT*
4483 * do detection and HP/speaker toggle because the hardware does it.
4484 */
4485 if (spec->board_config == STAC_9200_PANASONIC)
4486 spec->hp_detect = 0;
4487
Matt2f2f4252005-04-13 14:45:30 +02004488 codec->patch_ops = stac92xx_patch_ops;
4489
4490 return 0;
4491}
4492
Tobin Davis8e21c342007-01-08 11:04:17 +01004493static int patch_stac925x(struct hda_codec *codec)
4494{
4495 struct sigmatel_spec *spec;
4496 int err;
4497
4498 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4499 if (spec == NULL)
4500 return -ENOMEM;
4501
4502 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004503 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01004504 spec->pin_nids = stac925x_pin_nids;
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02004505
4506 /* Check first for codec ID */
4507 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
4508 STAC_925x_MODELS,
4509 stac925x_models,
4510 stac925x_codec_id_cfg_tbl);
4511
4512 /* Now checks for PCI ID, if codec ID is not found */
4513 if (spec->board_config < 0)
4514 spec->board_config = snd_hda_check_board_config(codec,
4515 STAC_925x_MODELS,
Tobin Davis8e21c342007-01-08 11:04:17 +01004516 stac925x_models,
4517 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004518 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01004519 if (spec->board_config < 0)
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02004520 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
Tobin Davis2c11f952007-05-17 09:36:34 +02004521 "using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01004522 else
4523 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004524 stac925x_brd_tbl[spec->board_config]);
Tobin Davis8e21c342007-01-08 11:04:17 +01004525
4526 spec->multiout.max_channels = 2;
4527 spec->multiout.num_dacs = 1;
4528 spec->multiout.dac_nids = stac925x_dac_nids;
4529 spec->adc_nids = stac925x_adc_nids;
4530 spec->mux_nids = stac925x_mux_nids;
4531 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004532 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004533 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02004534 switch (codec->vendor_id) {
4535 case 0x83847632: /* STAC9202 */
4536 case 0x83847633: /* STAC9202D */
4537 case 0x83847636: /* STAC9251 */
4538 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02004539 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02004540 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004541 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4542 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02004543 break;
4544 default:
4545 spec->num_dmics = 0;
4546 break;
4547 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004548
4549 spec->init = stac925x_core_init;
4550 spec->mixer = stac925x_mixer;
4551
4552 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004553 if (!err) {
4554 if (spec->board_config < 0) {
4555 printk(KERN_WARNING "hda_codec: No auto-config is "
4556 "available, default to model=ref\n");
4557 spec->board_config = STAC_925x_REF;
4558 goto again;
4559 }
4560 err = -EINVAL;
4561 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004562 if (err < 0) {
4563 stac92xx_free(codec);
4564 return err;
4565 }
4566
4567 codec->patch_ops = stac92xx_patch_ops;
4568
4569 return 0;
4570}
4571
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004572static struct hda_input_mux stac92hd73xx_dmux = {
4573 .num_items = 4,
4574 .items = {
4575 { "Analog Inputs", 0x0b },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004576 { "Digital Mic 1", 0x09 },
4577 { "Digital Mic 2", 0x0a },
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004578 { "CD", 0x08 },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004579 }
4580};
4581
4582static int patch_stac92hd73xx(struct hda_codec *codec)
4583{
4584 struct sigmatel_spec *spec;
4585 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4586 int err = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004587 int num_dacs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004588
4589 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4590 if (spec == NULL)
4591 return -ENOMEM;
4592
4593 codec->spec = spec;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02004594 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004595 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4596 spec->pin_nids = stac92hd73xx_pin_nids;
4597 spec->board_config = snd_hda_check_board_config(codec,
4598 STAC_92HD73XX_MODELS,
4599 stac92hd73xx_models,
4600 stac92hd73xx_cfg_tbl);
4601again:
Takashi Iwai330ee992009-02-20 14:33:36 +01004602 if (spec->board_config < 0)
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004603 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4604 " STAC92HD73XX, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01004605 else
4606 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004607 stac92hd73xx_brd_tbl[spec->board_config]);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004608
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004609 num_dacs = snd_hda_get_connections(codec, 0x0a,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004610 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4611
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004612 if (num_dacs < 3 || num_dacs > 5) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004613 printk(KERN_WARNING "hda_codec: Could not determine "
4614 "number of channels defaulting to DAC count\n");
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004615 num_dacs = STAC92HD73_DAC_COUNT;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004616 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004617 switch (num_dacs) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004618 case 0x3: /* 6 Channel */
4619 spec->mixer = stac92hd73xx_6ch_mixer;
4620 spec->init = stac92hd73xx_6ch_core_init;
4621 break;
4622 case 0x4: /* 8 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004623 spec->mixer = stac92hd73xx_8ch_mixer;
4624 spec->init = stac92hd73xx_8ch_core_init;
4625 break;
4626 case 0x5: /* 10 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004627 spec->mixer = stac92hd73xx_10ch_mixer;
4628 spec->init = stac92hd73xx_10ch_core_init;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004629 }
4630 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004631
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004632 spec->aloopback_mask = 0x01;
4633 spec->aloopback_shift = 8;
4634
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004635 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004636 spec->mux_nids = stac92hd73xx_mux_nids;
4637 spec->adc_nids = stac92hd73xx_adc_nids;
4638 spec->dmic_nids = stac92hd73xx_dmic_nids;
4639 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004640 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostay89385032008-09-11 09:49:39 -04004641 spec->amp_nids = stac92hd73xx_amp_nids;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004642 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004643
4644 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4645 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01004646 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004647 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4648 sizeof(stac92hd73xx_dmux));
4649
Matthew Ranostaya7662642008-02-21 07:51:14 +01004650 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004651 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004652 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004653 /* fallthru */
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004654 case STAC_DELL_M6_AMIC:
4655 case STAC_DELL_M6_DMIC:
4656 case STAC_DELL_M6_BOTH:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004657 spec->num_smuxes = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004658 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4659 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004660 spec->eapd_switch = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004661 spec->num_amps = 1;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004662
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004663 if (spec->board_config != STAC_DELL_EQ)
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004664 spec->init = dell_m6_core_init;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004665 switch (spec->board_config) {
4666 case STAC_DELL_M6_AMIC: /* Analog Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01004667 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
Matthew Ranostaya7662642008-02-21 07:51:14 +01004668 spec->num_dmics = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004669 spec->private_dimux.num_items = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004670 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004671 case STAC_DELL_M6_DMIC: /* Digital Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01004672 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01004673 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004674 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004675 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004676 case STAC_DELL_M6_BOTH: /* Both */
Takashi Iwai330ee992009-02-20 14:33:36 +01004677 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
4678 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01004679 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004680 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004681 break;
4682 }
4683 break;
4684 default:
4685 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004686 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004687 spec->eapd_switch = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004688 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004689 if (spec->board_config > STAC_92HD73XX_REF) {
4690 /* GPIO0 High = Enable EAPD */
4691 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4692 spec->gpio_data = 0x01;
4693 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004694 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004695
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004696 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4697 spec->pwr_nids = stac92hd73xx_pwr_nids;
4698
Matthew Ranostayd9737752008-09-07 12:03:41 +02004699 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004700
4701 if (!err) {
4702 if (spec->board_config < 0) {
4703 printk(KERN_WARNING "hda_codec: No auto-config is "
4704 "available, default to model=ref\n");
4705 spec->board_config = STAC_92HD73XX_REF;
4706 goto again;
4707 }
4708 err = -EINVAL;
4709 }
4710
4711 if (err < 0) {
4712 stac92xx_free(codec);
4713 return err;
4714 }
4715
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01004716 if (spec->board_config == STAC_92HD73XX_NO_JD)
4717 spec->hp_detect = 0;
4718
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004719 codec->patch_ops = stac92xx_patch_ops;
4720
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004721 codec->proc_widget_hook = stac92hd7x_proc_hook;
4722
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004723 return 0;
4724}
4725
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004726static struct hda_input_mux stac92hd83xxx_dmux = {
4727 .num_items = 3,
4728 .items = {
4729 { "Analog Inputs", 0x03 },
4730 { "Digital Mic 1", 0x04 },
4731 { "Digital Mic 2", 0x05 },
4732 }
4733};
4734
4735static int patch_stac92hd83xxx(struct hda_codec *codec)
4736{
4737 struct sigmatel_spec *spec;
Matthew Ranostay65557f32009-01-20 16:50:25 -05004738 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004739 int err;
Matthew Ranostay65557f32009-01-20 16:50:25 -05004740 int num_dacs;
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05004741 hda_nid_t nid;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004742
4743 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4744 if (spec == NULL)
4745 return -ENOMEM;
4746
4747 codec->spec = spec;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004748 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004749 spec->mono_nid = 0x19;
4750 spec->digbeep_nid = 0x21;
4751 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4752 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4753 spec->adc_nids = stac92hd83xxx_adc_nids;
4754 spec->pwr_nids = stac92hd83xxx_pwr_nids;
Matthew Ranostayc15c5062009-01-13 13:30:07 -05004755 spec->amp_nids = stac92hd83xxx_amp_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004756 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4757 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004758 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004759
4760 spec->init = stac92hd83xxx_core_init;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004761 spec->mixer = stac92hd83xxx_mixer;
4762 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4763 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4764 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
Matthew Ranostayc15c5062009-01-13 13:30:07 -05004765 spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004766 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4767 spec->dinput_mux = &stac92hd83xxx_dmux;
4768 spec->pin_nids = stac92hd83xxx_pin_nids;
4769 spec->board_config = snd_hda_check_board_config(codec,
4770 STAC_92HD83XXX_MODELS,
4771 stac92hd83xxx_models,
4772 stac92hd83xxx_cfg_tbl);
4773again:
Takashi Iwai330ee992009-02-20 14:33:36 +01004774 if (spec->board_config < 0)
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004775 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4776 " STAC92HD83XXX, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01004777 else
4778 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004779 stac92hd83xxx_brd_tbl[spec->board_config]);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004780
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05004781 switch (codec->vendor_id) {
4782 case 0x111d7604:
4783 case 0x111d7605:
4784 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
4785 break;
4786 spec->num_pwrs = 0;
4787 break;
4788 }
4789
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004790 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4791 if (!err) {
4792 if (spec->board_config < 0) {
4793 printk(KERN_WARNING "hda_codec: No auto-config is "
4794 "available, default to model=ref\n");
4795 spec->board_config = STAC_92HD83XXX_REF;
4796 goto again;
4797 }
4798 err = -EINVAL;
4799 }
4800
4801 if (err < 0) {
4802 stac92xx_free(codec);
4803 return err;
4804 }
4805
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05004806 switch (spec->board_config) {
4807 case STAC_DELL_S14:
4808 nid = 0xf;
4809 break;
4810 default:
4811 nid = 0xe;
4812 break;
4813 }
4814
4815 num_dacs = snd_hda_get_connections(codec, nid,
4816 conn, STAC92HD83_DAC_COUNT + 1) - 1;
4817
4818 /* set port X to select the last DAC
4819 */
4820 snd_hda_codec_write_cache(codec, nid, 0,
4821 AC_VERB_SET_CONNECT_SEL, num_dacs);
4822
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004823 codec->patch_ops = stac92xx_patch_ops;
4824
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004825 codec->proc_widget_hook = stac92hd_proc_hook;
4826
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004827 return 0;
4828}
4829
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004830static struct hda_input_mux stac92hd71bxx_dmux_nomixer = {
4831 .num_items = 3,
4832 .items = {
4833 { "Analog Inputs", 0x00 },
4834 { "Digital Mic 1", 0x02 },
4835 { "Digital Mic 2", 0x03 },
4836 }
4837};
4838
4839static struct hda_input_mux stac92hd71bxx_dmux_amixer = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004840 .num_items = 4,
4841 .items = {
4842 { "Analog Inputs", 0x00 },
4843 { "Mixer", 0x01 },
4844 { "Digital Mic 1", 0x02 },
4845 { "Digital Mic 2", 0x03 },
4846 }
4847};
4848
Takashi Iwai330ee992009-02-20 14:33:36 +01004849/* get the pin connection (fixed, none, etc) */
4850static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
4851{
4852 struct sigmatel_spec *spec = codec->spec;
4853 unsigned int cfg;
4854
4855 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
4856 return get_defcfg_connect(cfg);
4857}
4858
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004859static int stac92hd71bxx_connected_ports(struct hda_codec *codec,
4860 hda_nid_t *nids, int num_nids)
4861{
4862 struct sigmatel_spec *spec = codec->spec;
4863 int idx, num;
4864 unsigned int def_conf;
4865
4866 for (num = 0; num < num_nids; num++) {
4867 for (idx = 0; idx < spec->num_pins; idx++)
4868 if (spec->pin_nids[idx] == nids[num])
4869 break;
4870 if (idx >= spec->num_pins)
4871 break;
Takashi Iwai330ee992009-02-20 14:33:36 +01004872 def_conf = stac_get_defcfg_connect(codec, idx);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004873 if (def_conf == AC_JACK_PORT_NONE)
4874 break;
4875 }
4876 return num;
4877}
4878
4879static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
4880 hda_nid_t dig0pin)
4881{
4882 struct sigmatel_spec *spec = codec->spec;
4883 int idx;
4884
4885 for (idx = 0; idx < spec->num_pins; idx++)
4886 if (spec->pin_nids[idx] == dig0pin)
4887 break;
4888 if ((idx + 2) >= spec->num_pins)
4889 return 0;
4890
4891 /* dig1pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01004892 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004893 return 2;
4894
4895 /* dig0pin + dig2pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01004896 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004897 return 2;
Takashi Iwai330ee992009-02-20 14:33:36 +01004898 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004899 return 1;
4900 else
4901 return 0;
4902}
4903
Matthew Ranostaye035b842007-11-06 11:53:55 +01004904static int patch_stac92hd71bxx(struct hda_codec *codec)
4905{
4906 struct sigmatel_spec *spec;
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05004907 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004908 int err = 0;
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004909 unsigned int ndmic_nids = 0;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004910
4911 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4912 if (spec == NULL)
4913 return -ENOMEM;
4914
4915 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004916 codec->patch_ops = stac92xx_patch_ops;
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05004917 spec->num_pins = STAC92HD71BXX_NUM_PINS;
4918 switch (codec->vendor_id) {
4919 case 0x111d76b6:
4920 case 0x111d76b7:
4921 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
4922 break;
4923 case 0x111d7603:
4924 case 0x111d7608:
4925 /* On 92HD75Bx 0x27 isn't a pin nid */
4926 spec->num_pins--;
4927 /* fallthrough */
4928 default:
4929 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
4930 }
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004931 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004932 spec->board_config = snd_hda_check_board_config(codec,
4933 STAC_92HD71BXX_MODELS,
4934 stac92hd71bxx_models,
4935 stac92hd71bxx_cfg_tbl);
4936again:
Takashi Iwai330ee992009-02-20 14:33:36 +01004937 if (spec->board_config < 0)
Matthew Ranostaye035b842007-11-06 11:53:55 +01004938 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4939 " STAC92HD71BXX, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01004940 else
4941 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004942 stac92hd71bxx_brd_tbl[spec->board_config]);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004943
Takashi Iwai41c3b642008-11-18 10:45:15 +01004944 if (spec->board_config > STAC_92HD71BXX_REF) {
4945 /* GPIO0 = EAPD */
4946 spec->gpio_mask = 0x01;
4947 spec->gpio_dir = 0x01;
4948 spec->gpio_data = 0x01;
4949 }
4950
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004951 spec->dmic_nids = stac92hd71bxx_dmic_nids;
4952 spec->dmux_nids = stac92hd71bxx_dmux_nids;
4953
Matthew Ranostay541eee82007-12-14 12:08:04 +01004954 switch (codec->vendor_id) {
4955 case 0x111d76b6: /* 4 Port without Analog Mixer */
4956 case 0x111d76b7:
Herton Ronaldo Krzesinski23c7b522009-02-08 19:51:28 -02004957 unmute_init++;
4958 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01004959 case 0x111d76b4: /* 6 Port without Analog Mixer */
4960 case 0x111d76b5:
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004961 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_nomixer,
4962 sizeof(stac92hd71bxx_dmux_nomixer));
Matthew Ranostay541eee82007-12-14 12:08:04 +01004963 spec->mixer = stac92hd71bxx_mixer;
4964 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004965 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004966 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
4967 stac92hd71bxx_dmic_nids,
4968 STAC92HD71BXX_NUM_DMICS);
4969 if (spec->num_dmics) {
4970 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4971 spec->dinput_mux = &spec->private_dimux;
4972 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
4973 }
Matthew Ranostay541eee82007-12-14 12:08:04 +01004974 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004975 case 0x111d7608: /* 5 Port with Analog Mixer */
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004976 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
4977 sizeof(stac92hd71bxx_dmux_amixer));
4978 spec->private_dimux.num_items--;
Takashi Iwai8e5f2622008-11-15 19:28:54 +01004979 switch (spec->board_config) {
4980 case STAC_HP_M4:
Matthew Ranostay72474be2008-10-09 09:32:17 -04004981 /* Enable VREF power saving on GPIO1 detect */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004982 err = stac_add_event(spec, codec->afg,
4983 STAC_VREF_EVENT, 0x02);
4984 if (err < 0)
4985 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01004986 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay72474be2008-10-09 09:32:17 -04004987 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
4988 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004989 AC_VERB_SET_UNSOLICITED_ENABLE,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004990 AC_USRSP_EN | err);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004991 spec->gpio_mask |= 0x02;
4992 break;
4993 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004994 if ((codec->revision_id & 0xf) == 0 ||
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004995 (codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004996 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004997
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004998 /* no output amps */
4999 spec->num_pwrs = 0;
5000 spec->mixer = stac92hd71bxx_analog_mixer;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005001 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005002
5003 /* disable VSW */
5004 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005005 unmute_init++;
Takashi Iwai330ee992009-02-20 14:33:36 +01005006 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5007 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005008 stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0;
5009 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5010 stac92hd71bxx_dmic_nids,
5011 STAC92HD71BXX_NUM_DMICS - 1);
5012 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5013 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 2;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005014 break;
5015 case 0x111d7603: /* 6 Port with Analog Mixer */
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005016 if ((codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005017 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005018
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005019 /* no output amps */
5020 spec->num_pwrs = 0;
5021 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005022 default:
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005023 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
5024 sizeof(stac92hd71bxx_dmux_amixer));
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005025 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005026 spec->mixer = stac92hd71bxx_analog_mixer;
5027 spec->init = stac92hd71bxx_analog_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005028 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005029 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5030 stac92hd71bxx_dmic_nids,
5031 STAC92HD71BXX_NUM_DMICS);
5032 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5033 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005034 }
5035
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005036 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5037 snd_hda_sequence_write_cache(codec, unmute_init);
5038
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005039 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005040 spec->aloopback_shift = 0;
5041
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005042 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005043 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005044 spec->mux_nids = stac92hd71bxx_mux_nids;
5045 spec->adc_nids = stac92hd71bxx_adc_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005046 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005047 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005048
5049 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5050 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005051 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005052
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005053 switch (spec->board_config) {
5054 case STAC_HP_M4:
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005055 /* enable internal microphone */
Takashi Iwai330ee992009-02-20 14:33:36 +01005056 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
Matthew Ranostayb9aea712008-10-09 08:37:28 -04005057 stac92xx_auto_set_pinctl(codec, 0x0e,
5058 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05005059 /* fallthru */
5060 case STAC_DELL_M4_2:
5061 spec->num_dmics = 0;
5062 spec->num_smuxes = 0;
5063 spec->num_dmuxes = 0;
5064 break;
5065 case STAC_DELL_M4_1:
5066 case STAC_DELL_M4_3:
5067 spec->num_dmics = 1;
5068 spec->num_smuxes = 0;
5069 spec->num_dmuxes = 0;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005070 break;
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005071 case STAC_HP_DV5:
Takashi Iwai330ee992009-02-20 14:33:36 +01005072 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005073 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
5074 break;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005075 };
5076
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005077 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005078 if (spec->dinput_mux)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005079 spec->private_dimux.num_items += spec->num_dmics - ndmic_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005080
Herton Ronaldo Krzesinski29d4ab42009-02-04 11:37:27 -05005081 err = stac92xx_parse_auto_config(codec, 0x21, 0);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005082 if (!err) {
5083 if (spec->board_config < 0) {
5084 printk(KERN_WARNING "hda_codec: No auto-config is "
5085 "available, default to model=ref\n");
5086 spec->board_config = STAC_92HD71BXX_REF;
5087 goto again;
5088 }
5089 err = -EINVAL;
5090 }
5091
5092 if (err < 0) {
5093 stac92xx_free(codec);
5094 return err;
5095 }
5096
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005097 codec->proc_widget_hook = stac92hd7x_proc_hook;
5098
Matthew Ranostaye035b842007-11-06 11:53:55 +01005099 return 0;
5100};
5101
Matt2f2f4252005-04-13 14:45:30 +02005102static int patch_stac922x(struct hda_codec *codec)
5103{
5104 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005105 int err;
Matt2f2f4252005-04-13 14:45:30 +02005106
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005107 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02005108 if (spec == NULL)
5109 return -ENOMEM;
5110
5111 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005112 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005113 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005114 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5115 stac922x_models,
5116 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08005117 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005118 spec->gpio_mask = spec->gpio_dir = 0x03;
5119 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005120 /* Intel Macs have all same PCI SSID, so we need to check
5121 * codec SSID to distinguish the exact models
5122 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005123 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005124 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005125
5126 case 0x106b0800:
5127 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02005128 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005129 case 0x106b0600:
5130 case 0x106b0700:
5131 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005132 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005133 case 0x106b0e00:
5134 case 0x106b0f00:
5135 case 0x106b1600:
5136 case 0x106b1700:
5137 case 0x106b0200:
5138 case 0x106b1e00:
5139 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005140 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005141 case 0x106b1a00:
5142 case 0x00000100:
5143 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02005144 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005145 case 0x106b0a00:
5146 case 0x106b2200:
5147 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02005148 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08005149 default:
5150 spec->board_config = STAC_INTEL_MAC_V3;
5151 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005152 }
5153 }
5154
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005155 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005156 if (spec->board_config < 0)
Richard Fish11b44bb2006-08-23 18:31:34 +02005157 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
5158 "using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01005159 else
5160 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005161 stac922x_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02005162
Matt2f2f4252005-04-13 14:45:30 +02005163 spec->adc_nids = stac922x_adc_nids;
5164 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005165 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005166 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005167 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005168 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02005169
5170 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02005171 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02005172
5173 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02005174
Matt Porter3cc08dc2006-01-23 15:27:49 +01005175 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005176 if (!err) {
5177 if (spec->board_config < 0) {
5178 printk(KERN_WARNING "hda_codec: No auto-config is "
5179 "available, default to model=ref\n");
5180 spec->board_config = STAC_D945_REF;
5181 goto again;
5182 }
5183 err = -EINVAL;
5184 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005185 if (err < 0) {
5186 stac92xx_free(codec);
5187 return err;
5188 }
5189
5190 codec->patch_ops = stac92xx_patch_ops;
5191
Takashi Iwai807a46362007-05-29 19:01:37 +02005192 /* Fix Mux capture level; max to 2 */
5193 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
5194 (0 << AC_AMPCAP_OFFSET_SHIFT) |
5195 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5196 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5197 (0 << AC_AMPCAP_MUTE_SHIFT));
5198
Matt Porter3cc08dc2006-01-23 15:27:49 +01005199 return 0;
5200}
5201
5202static int patch_stac927x(struct hda_codec *codec)
5203{
5204 struct sigmatel_spec *spec;
5205 int err;
5206
5207 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5208 if (spec == NULL)
5209 return -ENOMEM;
5210
5211 codec->spec = spec;
Matthew Ranostay45c1d852009-02-04 17:49:41 -05005212 codec->slave_dig_outs = stac927x_slave_dig_outs;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005213 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005214 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005215 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5216 stac927x_models,
5217 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005218 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005219 if (spec->board_config < 0)
Herton Ronaldo Krzesinskic98041f2009-02-11 20:33:15 -02005220 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
5221 "STAC927x, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01005222 else
5223 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005224 stac927x_brd_tbl[spec->board_config]);
Matt Porter3cc08dc2006-01-23 15:27:49 +01005225
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005226 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005227 spec->adc_nids = stac927x_adc_nids;
5228 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
5229 spec->mux_nids = stac927x_mux_nids;
5230 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005231 spec->smux_nids = stac927x_smux_nids;
5232 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04005233 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005234 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005235 spec->multiout.dac_nids = spec->dac_nids;
5236
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005237 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02005238 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005239 case STAC_D965_5ST:
5240 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005241 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005242 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005243 spec->num_dmics = 0;
5244
Tobin Davis93ed1502006-09-01 21:03:12 +02005245 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005246 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005247 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005248 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02005249 switch (codec->subsystem_id) {
5250 case 0x10280209:
5251 case 0x1028022e:
5252 /* correct the device field to SPDIF out */
Takashi Iwai330ee992009-02-20 14:33:36 +01005253 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
Matthew Ranostay780c8be2008-04-14 13:32:27 +02005254 break;
5255 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01005256 /* configure the analog microphone on some laptops */
Takashi Iwai330ee992009-02-20 14:33:36 +01005257 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01005258 /* correct the front output jack as a hp out */
Takashi Iwai330ee992009-02-20 14:33:36 +01005259 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01005260 /* correct the front input jack as a mic */
Takashi Iwai330ee992009-02-20 14:33:36 +01005261 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01005262 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005263 case STAC_DELL_3ST:
5264 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005265 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005266 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005267 spec->dmic_nids = stac927x_dmic_nids;
5268 spec->num_dmics = STAC927X_NUM_DMICS;
5269
Tobin Davis93ed1502006-09-01 21:03:12 +02005270 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005271 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005272 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005273 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005274 break;
5275 default:
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005276 if (spec->board_config > STAC_D965_REF) {
5277 /* GPIO0 High = Enable EAPD */
5278 spec->eapd_mask = spec->gpio_mask = 0x01;
5279 spec->gpio_dir = spec->gpio_data = 0x01;
5280 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005281 spec->num_dmics = 0;
5282
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005283 spec->init = stac927x_core_init;
5284 spec->mixer = stac927x_mixer;
5285 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005286
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005287 spec->num_pwrs = 0;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005288 spec->aloopback_mask = 0x40;
5289 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005290 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005291
Matt Porter3cc08dc2006-01-23 15:27:49 +01005292 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005293 if (!err) {
5294 if (spec->board_config < 0) {
5295 printk(KERN_WARNING "hda_codec: No auto-config is "
5296 "available, default to model=ref\n");
5297 spec->board_config = STAC_D965_REF;
5298 goto again;
5299 }
5300 err = -EINVAL;
5301 }
Mattc7d4b2f2005-06-27 14:59:41 +02005302 if (err < 0) {
5303 stac92xx_free(codec);
5304 return err;
5305 }
Matt2f2f4252005-04-13 14:45:30 +02005306
5307 codec->patch_ops = stac92xx_patch_ops;
5308
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005309 codec->proc_widget_hook = stac927x_proc_hook;
5310
Takashi Iwai52987652008-01-16 16:09:47 +01005311 /*
5312 * !!FIXME!!
5313 * The STAC927x seem to require fairly long delays for certain
5314 * command sequences. With too short delays (even if the answer
5315 * is set to RIRB properly), it results in the silence output
5316 * on some hardwares like Dell.
5317 *
5318 * The below flag enables the longer delay (see get_response
5319 * in hda_intel.c).
5320 */
5321 codec->bus->needs_damn_long_delay = 1;
5322
Takashi Iwaie28d8322008-12-17 13:48:29 +01005323 /* no jack detecion for ref-no-jd model */
5324 if (spec->board_config == STAC_D965_REF_NO_JD)
5325 spec->hp_detect = 0;
5326
Matt2f2f4252005-04-13 14:45:30 +02005327 return 0;
5328}
5329
Matt Porterf3302a52006-07-31 12:49:34 +02005330static int patch_stac9205(struct hda_codec *codec)
5331{
5332 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02005333 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02005334
5335 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5336 if (spec == NULL)
5337 return -ENOMEM;
5338
5339 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005340 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005341 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005342 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
5343 stac9205_models,
5344 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005345 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005346 if (spec->board_config < 0)
Richard Fish11b44bb2006-08-23 18:31:34 +02005347 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01005348 else
5349 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005350 stac9205_brd_tbl[spec->board_config]);
Matt Porterf3302a52006-07-31 12:49:34 +02005351
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005352 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02005353 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005354 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02005355 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005356 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005357 spec->smux_nids = stac9205_smux_nids;
5358 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005359 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02005360 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005361 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005362 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005363 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02005364
5365 spec->init = stac9205_core_init;
5366 spec->mixer = stac9205_mixer;
5367
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005368 spec->aloopback_mask = 0x40;
5369 spec->aloopback_shift = 0;
Takashi Iwaid9a42682009-01-22 17:40:18 +01005370 /* Turn on/off EAPD per HP plugging */
5371 if (spec->board_config != STAC_9205_EAPD)
5372 spec->eapd_switch = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02005373 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02005374
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005375 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005376 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02005377 /* Enable SPDIF in/out */
Takashi Iwai330ee992009-02-20 14:33:36 +01005378 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
5379 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01005380
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005381 /* Enable unsol response for GPIO4/Dock HP connection */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005382 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
5383 if (err < 0)
5384 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005385 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005386 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
5387 snd_hda_codec_write_cache(codec, codec->afg, 0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005388 AC_VERB_SET_UNSOLICITED_ENABLE,
5389 AC_USRSP_EN | err);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005390
5391 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005392 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005393 spec->gpio_mask = 0x1b;
5394 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01005395 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005396 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02005397 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005398 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005399 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005400 case STAC_9205_REF:
5401 /* SPDIF-In enabled */
5402 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005403 default:
5404 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005405 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005406 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005407 break;
5408 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02005409
Matt Porterf3302a52006-07-31 12:49:34 +02005410 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005411 if (!err) {
5412 if (spec->board_config < 0) {
5413 printk(KERN_WARNING "hda_codec: No auto-config is "
5414 "available, default to model=ref\n");
5415 spec->board_config = STAC_9205_REF;
5416 goto again;
5417 }
5418 err = -EINVAL;
5419 }
Matt Porterf3302a52006-07-31 12:49:34 +02005420 if (err < 0) {
5421 stac92xx_free(codec);
5422 return err;
5423 }
5424
5425 codec->patch_ops = stac92xx_patch_ops;
5426
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005427 codec->proc_widget_hook = stac9205_proc_hook;
5428
Matt Porterf3302a52006-07-31 12:49:34 +02005429 return 0;
5430}
5431
Matt2f2f4252005-04-13 14:45:30 +02005432/*
Guillaume Munch6d859062006-08-22 17:15:47 +02005433 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01005434 */
5435
Takashi Iwai1e137f92009-01-21 07:41:22 +01005436static struct hda_verb stac9872_core_init[] = {
Takashi Iwai1624cb92007-07-05 13:10:51 +02005437 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005438 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5439 {}
5440};
5441
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005442static struct snd_kcontrol_new stac9872_mixer[] = {
5443 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5444 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005445 { } /* end */
5446};
5447
5448static hda_nid_t stac9872_pin_nids[] = {
5449 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
5450 0x11, 0x13, 0x14,
5451};
5452
5453static hda_nid_t stac9872_adc_nids[] = {
5454 0x8 /*,0x6*/
5455};
5456
5457static hda_nid_t stac9872_mux_nids[] = {
5458 0x15
5459};
5460
Guillaume Munch6d859062006-08-22 17:15:47 +02005461static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01005462{
5463 struct sigmatel_spec *spec;
Takashi Iwai1e137f92009-01-21 07:41:22 +01005464 int err;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005465
Takashi Iwaidb064e52006-03-16 16:04:58 +01005466 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5467 if (spec == NULL)
5468 return -ENOMEM;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005469 codec->spec = spec;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005470
Takashi Iwai1e137f92009-01-21 07:41:22 +01005471#if 0 /* no model right now */
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005472 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5473 stac9872_models,
5474 stac9872_cfg_tbl);
Takashi Iwai1e137f92009-01-21 07:41:22 +01005475#endif
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005476
Takashi Iwai1e137f92009-01-21 07:41:22 +01005477 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
5478 spec->pin_nids = stac9872_pin_nids;
5479 spec->multiout.dac_nids = spec->dac_nids;
5480 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
5481 spec->adc_nids = stac9872_adc_nids;
5482 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
5483 spec->mux_nids = stac9872_mux_nids;
5484 spec->mixer = stac9872_mixer;
5485 spec->init = stac9872_core_init;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005486
Takashi Iwai1e137f92009-01-21 07:41:22 +01005487 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
5488 if (err < 0) {
5489 stac92xx_free(codec);
5490 return -EINVAL;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005491 }
Takashi Iwai1e137f92009-01-21 07:41:22 +01005492 spec->input_mux = &spec->private_imux;
5493 codec->patch_ops = stac92xx_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005494 return 0;
5495}
5496
5497
5498/*
Matt2f2f4252005-04-13 14:45:30 +02005499 * patch entries
5500 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +01005501static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
Matt2f2f4252005-04-13 14:45:30 +02005502 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5503 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5504 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5505 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5506 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5507 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5508 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02005509 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5510 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5511 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5512 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5513 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5514 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01005515 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5516 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5517 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5518 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5519 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5520 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5521 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5522 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5523 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5524 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01005525 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5526 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5527 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5528 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5529 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5530 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02005531 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5532 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02005533 /* The following does not take into account .id=0x83847661 when subsys =
5534 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5535 * currently not fully supported.
5536 */
5537 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5538 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5539 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02005540 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5541 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5542 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5543 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5544 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5545 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5546 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5547 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005548 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005549 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5550 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005551 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01005552 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5553 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005554 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01005555 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5556 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5557 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5558 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5559 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5560 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5561 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5562 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02005563 {} /* terminator */
5564};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01005565
5566MODULE_ALIAS("snd-hda-codec-id:8384*");
5567MODULE_ALIAS("snd-hda-codec-id:111d*");
5568
5569MODULE_LICENSE("GPL");
5570MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
5571
5572static struct hda_codec_preset_list sigmatel_list = {
5573 .preset = snd_hda_preset_sigmatel,
5574 .owner = THIS_MODULE,
5575};
5576
5577static int __init patch_sigmatel_init(void)
5578{
5579 return snd_hda_add_codec_preset(&sigmatel_list);
5580}
5581
5582static void __exit patch_sigmatel_exit(void)
5583{
5584 snd_hda_delete_codec_preset(&sigmatel_list);
5585}
5586
5587module_init(patch_sigmatel_init)
5588module_exit(patch_sigmatel_exit)