blob: 7381325b98ff7c6d8f00521bc7a012a78d44cd95 [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 */
Takashi Iwaid78d7a92009-03-02 14:26:25 +0100193 struct snd_kcontrol_new *aloopback_ctl;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100194 unsigned char aloopback_mask;
195 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200196
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100197 /* power management */
198 unsigned int num_pwrs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200199 unsigned int *pwr_mapping;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100200 hda_nid_t *pwr_nids;
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100201 hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100202
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400203 /* jack detection */
204 struct snd_array jacks;
205
206 /* events */
207 struct snd_array events;
208
Matt2f2f4252005-04-13 14:45:30 +0200209 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100210 struct hda_input_mux *mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400211 struct hda_input_mux *amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100212 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200213 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100214 hda_nid_t dac_nids[5];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100215 hda_nid_t hp_dacs[5];
216 hda_nid_t speaker_dacs[5];
Matt2f2f4252005-04-13 14:45:30 +0200217
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100218 int volume_offset;
219
Matt2f2f4252005-04-13 14:45:30 +0200220 /* capture */
221 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200222 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200223 hda_nid_t *mux_nids;
224 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200225 hda_nid_t *dmic_nids;
226 unsigned int num_dmics;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100227 hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100228 unsigned int num_dmuxes;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200229 hda_nid_t *smux_nids;
230 unsigned int num_smuxes;
Matthew Ranostay65973632008-09-16 10:39:37 -0400231 const char **spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200232
Mattdabbed62005-06-14 10:19:34 +0200233 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100234 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200235 hda_nid_t anabeep_nid;
236 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200237
Matt2f2f4252005-04-13 14:45:30 +0200238 /* pin widgets */
239 hda_nid_t *pin_nids;
240 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200241
242 /* codec specific stuff */
243 struct hda_verb *init;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100244 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200245
246 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200247 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100248 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200249 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100250 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200251 struct hda_input_mux *sinput_mux;
252 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400253 unsigned int cur_amux;
254 hda_nid_t *amp_nids;
255 unsigned int num_amps;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200256 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200257
Matt Porter403d1942005-11-29 15:00:51 +0100258 /* i/o switches */
259 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200260 unsigned int clfe_swap;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100261 hda_nid_t line_switch; /* shared line-in for input and output */
262 hda_nid_t mic_switch; /* shared mic-in for input and output */
263 hda_nid_t hp_switch; /* NID of HP as line-out */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200264 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200265
Mattc7d4b2f2005-06-27 14:59:41 +0200266 struct hda_pcm pcm_rec[2]; /* PCM information */
267
268 /* dynamic controls and input_mux */
269 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200270 struct snd_array kctls;
Matt Porter8b657272006-10-26 17:12:59 +0200271 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200272 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200273 struct hda_input_mux private_smux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400274 struct hda_input_mux private_amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100275 struct hda_input_mux private_mono_mux;
Matt2f2f4252005-04-13 14:45:30 +0200276};
277
278static hda_nid_t stac9200_adc_nids[1] = {
279 0x03,
280};
281
282static hda_nid_t stac9200_mux_nids[1] = {
283 0x0c,
284};
285
286static hda_nid_t stac9200_dac_nids[1] = {
287 0x02,
288};
289
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100290static hda_nid_t stac92hd73xx_pwr_nids[8] = {
291 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
292 0x0f, 0x10, 0x11
293};
294
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400295static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
296 0x26, 0,
297};
298
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100299static hda_nid_t stac92hd73xx_adc_nids[2] = {
300 0x1a, 0x1b
301};
302
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400303#define DELL_M6_AMP 2
304static hda_nid_t stac92hd73xx_amp_nids[3] = {
305 0x0b, 0x0c, 0x0e
Matthew Ranostay89385032008-09-11 09:49:39 -0400306};
307
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100308#define STAC92HD73XX_NUM_DMICS 2
309static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
310 0x13, 0x14, 0
311};
312
313#define STAC92HD73_DAC_COUNT 5
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100314
315static hda_nid_t stac92hd73xx_mux_nids[4] = {
316 0x28, 0x29, 0x2a, 0x2b,
317};
318
319static hda_nid_t stac92hd73xx_dmux_nids[2] = {
320 0x20, 0x21,
321};
322
Matthew Ranostayd9737752008-09-07 12:03:41 +0200323static hda_nid_t stac92hd73xx_smux_nids[2] = {
324 0x22, 0x23,
325};
326
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200327#define STAC92HD83XXX_NUM_DMICS 2
328static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
329 0x11, 0x12, 0
330};
331
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200332#define STAC92HD83_DAC_COUNT 3
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200333
334static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
335 0x17, 0x18,
336};
337
338static hda_nid_t stac92hd83xxx_adc_nids[2] = {
339 0x15, 0x16,
340};
341
342static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
343 0xa, 0xb, 0xd, 0xe,
344};
345
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400346static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
347 0x1e, 0,
348};
349
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200350static unsigned int stac92hd83xxx_pwr_mapping[4] = {
Matthew Ranostay87e88a72009-01-22 20:38:42 -0500351 0x03, 0x0c, 0x20, 0x40,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200352};
353
Takashi Iwai9248f262009-01-14 09:40:25 +0100354static hda_nid_t stac92hd83xxx_amp_nids[1] = {
Matthew Ranostayc15c5062009-01-13 13:30:07 -0500355 0xc,
356};
357
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100358static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
359 0x0a, 0x0d, 0x0f
360};
361
Matthew Ranostaye035b842007-11-06 11:53:55 +0100362static hda_nid_t stac92hd71bxx_adc_nids[2] = {
363 0x12, 0x13,
364};
365
366static hda_nid_t stac92hd71bxx_mux_nids[2] = {
367 0x1a, 0x1b
368};
369
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400370static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
371 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100372};
373
Matthew Ranostayd9737752008-09-07 12:03:41 +0200374static hda_nid_t stac92hd71bxx_smux_nids[2] = {
375 0x24, 0x25,
376};
377
Matthew Ranostaye035b842007-11-06 11:53:55 +0100378#define STAC92HD71BXX_NUM_DMICS 2
379static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
380 0x18, 0x19, 0
381};
382
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400383static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
384 0x22, 0
385};
386
Tobin Davis8e21c342007-01-08 11:04:17 +0100387static hda_nid_t stac925x_adc_nids[1] = {
388 0x03,
389};
390
391static hda_nid_t stac925x_mux_nids[1] = {
392 0x0f,
393};
394
395static hda_nid_t stac925x_dac_nids[1] = {
396 0x02,
397};
398
Takashi Iwaif6e98522007-10-16 14:27:04 +0200399#define STAC925X_NUM_DMICS 1
400static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
401 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200402};
403
Takashi Iwai1697055e2007-12-18 18:05:52 +0100404static hda_nid_t stac925x_dmux_nids[1] = {
405 0x14,
406};
407
Matt2f2f4252005-04-13 14:45:30 +0200408static hda_nid_t stac922x_adc_nids[2] = {
409 0x06, 0x07,
410};
411
412static hda_nid_t stac922x_mux_nids[2] = {
413 0x12, 0x13,
414};
415
Matthew Ranostay45c1d852009-02-04 17:49:41 -0500416static hda_nid_t stac927x_slave_dig_outs[2] = {
417 0x1f, 0,
418};
419
Matt Porter3cc08dc2006-01-23 15:27:49 +0100420static hda_nid_t stac927x_adc_nids[3] = {
421 0x07, 0x08, 0x09
422};
423
424static hda_nid_t stac927x_mux_nids[3] = {
425 0x15, 0x16, 0x17
426};
427
Matthew Ranostayd9737752008-09-07 12:03:41 +0200428static hda_nid_t stac927x_smux_nids[1] = {
429 0x21,
430};
431
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100432static hda_nid_t stac927x_dac_nids[6] = {
433 0x02, 0x03, 0x04, 0x05, 0x06, 0
434};
435
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100436static hda_nid_t stac927x_dmux_nids[1] = {
437 0x1b,
438};
439
Matthew Ranostay7f168592007-10-18 17:38:17 +0200440#define STAC927X_NUM_DMICS 2
441static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
442 0x13, 0x14, 0
443};
444
Matthew Ranostay65973632008-09-16 10:39:37 -0400445static const char *stac927x_spdif_labels[5] = {
446 "Digital Playback", "ADAT", "Analog Mux 1",
447 "Analog Mux 2", "Analog Mux 3"
448};
449
Matt Porterf3302a52006-07-31 12:49:34 +0200450static hda_nid_t stac9205_adc_nids[2] = {
451 0x12, 0x13
452};
453
454static hda_nid_t stac9205_mux_nids[2] = {
455 0x19, 0x1a
456};
457
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100458static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100459 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100460};
461
Matthew Ranostayd9737752008-09-07 12:03:41 +0200462static hda_nid_t stac9205_smux_nids[1] = {
463 0x21,
464};
465
Takashi Iwaif6e98522007-10-16 14:27:04 +0200466#define STAC9205_NUM_DMICS 2
467static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
468 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200469};
470
Mattc7d4b2f2005-06-27 14:59:41 +0200471static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200472 0x08, 0x09, 0x0d, 0x0e,
473 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200474};
475
Tobin Davis8e21c342007-01-08 11:04:17 +0100476static hda_nid_t stac925x_pin_nids[8] = {
477 0x07, 0x08, 0x0a, 0x0b,
478 0x0c, 0x0d, 0x10, 0x11,
479};
480
Matt2f2f4252005-04-13 14:45:30 +0200481static hda_nid_t stac922x_pin_nids[10] = {
482 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
483 0x0f, 0x10, 0x11, 0x15, 0x1b,
484};
485
Matthew Ranostaya7662642008-02-21 07:51:14 +0100486static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100487 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
488 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200489 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100490};
491
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -0500492static hda_nid_t stac92hd83xxx_pin_nids[10] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200493 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -0500494 0x0f, 0x10, 0x11, 0x1f, 0x20,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200495};
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500496
497#define STAC92HD71BXX_NUM_PINS 13
498static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
499 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
500 0x00, 0x14, 0x18, 0x19, 0x1e,
501 0x1f, 0x20, 0x27
502};
503static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100504 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
505 0x0f, 0x14, 0x18, 0x19, 0x1e,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500506 0x1f, 0x20, 0x27
Matthew Ranostaye035b842007-11-06 11:53:55 +0100507};
508
Matt Porter3cc08dc2006-01-23 15:27:49 +0100509static hda_nid_t stac927x_pin_nids[14] = {
510 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
511 0x0f, 0x10, 0x11, 0x12, 0x13,
512 0x14, 0x21, 0x22, 0x23,
513};
514
Matt Porterf3302a52006-07-31 12:49:34 +0200515static hda_nid_t stac9205_pin_nids[12] = {
516 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
517 0x0f, 0x14, 0x16, 0x17, 0x18,
518 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200519};
520
Matthew Ranostay89385032008-09-11 09:49:39 -0400521#define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
522
523static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
524 struct snd_ctl_elem_value *ucontrol)
525{
526 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
527 struct sigmatel_spec *spec = codec->spec;
528 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
529
530 kcontrol->private_value ^= get_amp_nid(kcontrol);
531 kcontrol->private_value |= nid;
532
533 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
534}
535
536static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
537 struct snd_ctl_elem_value *ucontrol)
538{
539 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
540 struct sigmatel_spec *spec = codec->spec;
541 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
542
543 kcontrol->private_value ^= get_amp_nid(kcontrol);
544 kcontrol->private_value |= nid;
545
546 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
547}
548
Matt Porter8b657272006-10-26 17:12:59 +0200549static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
550 struct snd_ctl_elem_info *uinfo)
551{
552 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
553 struct sigmatel_spec *spec = codec->spec;
554 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
555}
556
557static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
558 struct snd_ctl_elem_value *ucontrol)
559{
560 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
561 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100562 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200563
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100564 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200565 return 0;
566}
567
568static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
569 struct snd_ctl_elem_value *ucontrol)
570{
571 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
572 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100573 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200574
575 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100576 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200577}
578
Matthew Ranostayd9737752008-09-07 12:03:41 +0200579static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
580 struct snd_ctl_elem_info *uinfo)
581{
582 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
583 struct sigmatel_spec *spec = codec->spec;
584 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
585}
586
587static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
588 struct snd_ctl_elem_value *ucontrol)
589{
590 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
591 struct sigmatel_spec *spec = codec->spec;
592 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
593
594 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
595 return 0;
596}
597
598static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
599 struct snd_ctl_elem_value *ucontrol)
600{
601 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
602 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400603 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200604 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400605 int err, val;
606 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200607
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400608 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200609 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400610 if (err < 0)
611 return err;
612
613 if (spec->spdif_mute) {
614 if (smux_idx == 0)
615 nid = spec->multiout.dig_out_nid;
616 else
617 nid = codec->slave_dig_outs[smux_idx - 1];
618 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100619 val = HDA_AMP_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400620 else
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100621 val = 0;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400622 /* un/mute SPDIF out */
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100623 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
624 HDA_AMP_MUTE, val);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400625 }
626 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200627}
628
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100629static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200630{
631 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
632 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200633 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200634}
635
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100636static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200637{
638 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
639 struct sigmatel_spec *spec = codec->spec;
640 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
641
642 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
643 return 0;
644}
645
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100646static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200647{
648 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
649 struct sigmatel_spec *spec = codec->spec;
650 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
651
Mattc7d4b2f2005-06-27 14:59:41 +0200652 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200653 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
654}
655
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100656static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
657 struct snd_ctl_elem_info *uinfo)
658{
659 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
660 struct sigmatel_spec *spec = codec->spec;
661 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
662}
663
664static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
665 struct snd_ctl_elem_value *ucontrol)
666{
667 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
668 struct sigmatel_spec *spec = codec->spec;
669
670 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
671 return 0;
672}
673
674static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
675 struct snd_ctl_elem_value *ucontrol)
676{
677 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
678 struct sigmatel_spec *spec = codec->spec;
679
680 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
681 spec->mono_nid, &spec->cur_mmux);
682}
683
Matthew Ranostay89385032008-09-11 09:49:39 -0400684static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
685 struct snd_ctl_elem_info *uinfo)
686{
687 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
688 struct sigmatel_spec *spec = codec->spec;
689 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
690}
691
692static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
693 struct snd_ctl_elem_value *ucontrol)
694{
695 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
696 struct sigmatel_spec *spec = codec->spec;
697
698 ucontrol->value.enumerated.item[0] = spec->cur_amux;
699 return 0;
700}
701
702static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
703 struct snd_ctl_elem_value *ucontrol)
704{
705 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
706 struct sigmatel_spec *spec = codec->spec;
707 struct snd_kcontrol *ctl =
708 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
709 if (!ctl)
710 return -EINVAL;
711
712 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
713 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
714
715 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
716 0, &spec->cur_amux);
717}
718
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200719#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
720
721static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
722 struct snd_ctl_elem_value *ucontrol)
723{
724 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100725 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200726 struct sigmatel_spec *spec = codec->spec;
727
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100728 ucontrol->value.integer.value[0] = !!(spec->aloopback &
729 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200730 return 0;
731}
732
733static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
734 struct snd_ctl_elem_value *ucontrol)
735{
736 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
737 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100738 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200739 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100740 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200741
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100742 idx_val = spec->aloopback_mask << idx;
743 if (ucontrol->value.integer.value[0])
744 val = spec->aloopback | idx_val;
745 else
746 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100747 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200748 return 0;
749
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100750 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200751
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100752 /* Only return the bits defined by the shift value of the
753 * first two bytes of the mask
754 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200755 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100756 kcontrol->private_value & 0xFFFF, 0x0);
757 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200758
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100759 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200760 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100761 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200762 } else {
763 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100764 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200765 }
766
767 snd_hda_codec_write_cache(codec, codec->afg, 0,
768 kcontrol->private_value >> 16, dac_mode);
769
770 return 1;
771}
772
Mattc7d4b2f2005-06-27 14:59:41 +0200773static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200774 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200775 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200776 {}
777};
778
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200779static struct hda_verb stac9200_eapd_init[] = {
780 /* set dac0mux for dac converter */
781 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
782 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
783 {}
784};
785
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100786static struct hda_verb stac92hd73xx_6ch_core_init[] = {
787 /* set master volume and direct control */
788 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100789 /* setup adcs to point to mixer */
790 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
791 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100792 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
793 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
794 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
795 /* setup import muxs */
796 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
797 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
798 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
799 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
800 {}
801};
802
Matthew Ranostayd654a662008-03-14 08:46:51 +0100803static struct hda_verb dell_eq_core_init[] = {
804 /* set master volume to max value without distortion
805 * and direct control */
806 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100807 /* setup adcs to point to mixer */
808 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
809 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
810 /* setup import muxs */
811 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
812 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
813 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
814 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
815 {}
816};
817
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100818static struct hda_verb dell_m6_core_init[] = {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -0500819 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100820 /* setup adcs to point to mixer */
821 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
822 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
823 /* setup import muxs */
824 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
825 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
826 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
827 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
828 {}
829};
830
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100831static struct hda_verb stac92hd73xx_8ch_core_init[] = {
832 /* set master volume and direct control */
833 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100834 /* setup adcs to point to mixer */
835 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
836 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100837 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
838 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
839 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
840 /* setup import muxs */
841 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
842 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
843 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
844 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
845 {}
846};
847
848static struct hda_verb stac92hd73xx_10ch_core_init[] = {
849 /* set master volume and direct control */
850 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100851 /* dac3 is connected to import3 mux */
852 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100853 /* setup adcs to point to mixer */
854 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
855 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100856 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
857 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
858 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
859 /* setup import muxs */
860 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
861 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
862 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
863 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
864 {}
865};
866
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200867static struct hda_verb stac92hd83xxx_core_init[] = {
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -0500868 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1},
869 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1},
870 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200871
872 /* power state controls amps */
873 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200874 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200875};
876
Matthew Ranostaye035b842007-11-06 11:53:55 +0100877static struct hda_verb stac92hd71bxx_core_init[] = {
878 /* set master volume and direct control */
879 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200880 {}
Matthew Ranostay541eee82007-12-14 12:08:04 +0100881};
882
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500883#define HD_DISABLE_PORTF 1
Matthew Ranostay541eee82007-12-14 12:08:04 +0100884static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200885 /* start of config #1 */
886
887 /* connect port 0f to audio mixer */
888 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200889 /* start of config #2 */
890
Matthew Ranostay541eee82007-12-14 12:08:04 +0100891 /* set master volume and direct control */
892 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500893 {}
894};
895
896static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
897 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
898 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100899 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
900 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100901 {}
902};
903
Tobin Davis8e21c342007-01-08 11:04:17 +0100904static struct hda_verb stac925x_core_init[] = {
905 /* set dac0mux for dac converter */
906 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaic9280d62009-01-15 17:31:00 +0100907 /* mute the master volume */
908 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Tobin Davis8e21c342007-01-08 11:04:17 +0100909 {}
910};
911
Mattc7d4b2f2005-06-27 14:59:41 +0200912static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200913 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200914 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200915 {}
916};
917
Tobin Davis93ed1502006-09-01 21:03:12 +0200918static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200919 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200920 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200921 /* unmute node 0x1b */
922 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
923 /* select node 0x03 as DAC */
924 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
925 {}
926};
927
Matt Porter3cc08dc2006-01-23 15:27:49 +0100928static struct hda_verb stac927x_core_init[] = {
929 /* set master volume and direct control */
930 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200931 /* enable analog pc beep path */
932 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100933 {}
934};
935
Matt Porterf3302a52006-07-31 12:49:34 +0200936static struct hda_verb stac9205_core_init[] = {
937 /* set master volume and direct control */
938 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200939 /* enable analog pc beep path */
940 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200941 {}
942};
943
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100944#define STAC_MONO_MUX \
945 { \
946 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
947 .name = "Mono Mux", \
948 .count = 1, \
949 .info = stac92xx_mono_mux_enum_info, \
950 .get = stac92xx_mono_mux_enum_get, \
951 .put = stac92xx_mono_mux_enum_put, \
952 }
953
Matthew Ranostay89385032008-09-11 09:49:39 -0400954#define STAC_AMP_MUX \
955 { \
956 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
957 .name = "Amp Selector Capture Switch", \
958 .count = 1, \
959 .info = stac92xx_amp_mux_enum_info, \
960 .get = stac92xx_amp_mux_enum_get, \
961 .put = stac92xx_amp_mux_enum_put, \
962 }
963
964#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
965 { \
966 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
967 .name = xname, \
968 .index = 0, \
969 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
970 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
971 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
972 .info = stac92xx_amp_volume_info, \
973 .get = stac92xx_amp_volume_get, \
974 .put = stac92xx_amp_volume_put, \
975 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
976 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
977 }
978
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100979#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200980 { \
981 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
982 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100983 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200984 .info = stac92xx_aloopback_info, \
985 .get = stac92xx_aloopback_get, \
986 .put = stac92xx_aloopback_put, \
987 .private_value = verb_read | (verb_write << 16), \
988 }
989
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100990static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200991 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
992 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200993 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
994 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200995 { } /* end */
996};
997
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400998#define DELL_M6_MIXER 6
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100999static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04001000 /* start of config #1 */
1001 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1002 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1003
1004 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1005 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1006
1007 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1008 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1009
1010 /* start of config #2 */
1011 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1012 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1013
1014 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1015 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1016
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001017 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1018 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1019
1020 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1021 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1022
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001023 { } /* end */
1024};
1025
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001026static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
1027 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1028 {}
1029};
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001030
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001031static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
1032 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1033 {}
1034};
1035
1036static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
1037 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1038 {}
1039};
1040
1041static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001042 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1043 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1044
1045 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1046 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1047
1048 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1049 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1050
1051 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1052 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1053
1054 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1055 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1056
1057 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1058 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1059
1060 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1061 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1062 { } /* end */
1063};
1064
1065static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001066 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1067 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1068
1069 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1070 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1071
1072 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1073 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1074
1075 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1076 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1077
1078 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1079 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1080
1081 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1082 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1083
1084 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1085 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1086 { } /* end */
1087};
1088
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001089
1090static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1091 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1092 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1093
1094 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1095 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1096
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001097 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT),
1098 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001099
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001100 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT),
1101 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001102
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001103 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT),
1104 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001105
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001106 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT),
1107 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001108
1109 /*
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001110 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT),
1111 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001112 */
1113 { } /* end */
1114};
1115
Matthew Ranostay541eee82007-12-14 12:08:04 +01001116static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostay9b359472007-11-07 13:03:12 +01001117 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1118 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay9b359472007-11-07 13:03:12 +01001119
1120 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1121 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001122 /* analog pc-beep replaced with digital beep support */
1123 /*
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001124 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1125 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001126 */
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001127
Matthew Ranostay687cb982008-10-11 13:52:43 -04001128 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1129 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001130
Matthew Ranostay687cb982008-10-11 13:52:43 -04001131 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1132 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001133
1134 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1135 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1136
1137 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1138 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001139 { } /* end */
1140};
1141
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001142static struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
1143 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1144};
Matthew Ranostay541eee82007-12-14 12:08:04 +01001145
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001146static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +01001147 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1148 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001149
1150 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1151 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001152 { } /* end */
1153};
1154
Tobin Davis8e21c342007-01-08 11:04:17 +01001155static struct snd_kcontrol_new stac925x_mixer[] = {
Takashi Iwaic9280d62009-01-15 17:31:00 +01001156 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
1157 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001158 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +02001159 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001160 { } /* end */
1161};
1162
Takashi Iwaid1d985f2006-11-23 19:27:12 +01001163static struct snd_kcontrol_new stac9205_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001164 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1165 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001166
1167 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1168 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001169 { } /* end */
1170};
1171
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001172static struct snd_kcontrol_new stac9205_loopback[] = {
1173 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1174 {}
1175};
1176
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001177/* This needs to be generated dynamically based on sequence */
1178static struct snd_kcontrol_new stac922x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001179 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1180 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001181
1182 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1183 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001184 { } /* end */
1185};
1186
1187
1188static struct snd_kcontrol_new stac927x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001189 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1190 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001191
1192 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1193 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001194
1195 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1196 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
Matt Porterf3302a52006-07-31 12:49:34 +02001197 { } /* end */
1198};
1199
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001200static struct snd_kcontrol_new stac927x_loopback[] = {
1201 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1202 {}
1203};
1204
Takashi Iwai1697055e2007-12-18 18:05:52 +01001205static struct snd_kcontrol_new stac_dmux_mixer = {
1206 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1207 .name = "Digital Input Source",
1208 /* count set later */
1209 .info = stac92xx_dmux_enum_info,
1210 .get = stac92xx_dmux_enum_get,
1211 .put = stac92xx_dmux_enum_put,
1212};
1213
Matthew Ranostayd9737752008-09-07 12:03:41 +02001214static struct snd_kcontrol_new stac_smux_mixer = {
1215 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001216 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001217 /* count set later */
1218 .info = stac92xx_smux_enum_info,
1219 .get = stac92xx_smux_enum_get,
1220 .put = stac92xx_smux_enum_put,
1221};
1222
Takashi Iwai2134ea42008-01-10 16:53:55 +01001223static const char *slave_vols[] = {
1224 "Front Playback Volume",
1225 "Surround Playback Volume",
1226 "Center Playback Volume",
1227 "LFE Playback Volume",
1228 "Side Playback Volume",
1229 "Headphone Playback Volume",
1230 "Headphone Playback Volume",
1231 "Speaker Playback Volume",
1232 "External Speaker Playback Volume",
1233 "Speaker2 Playback Volume",
1234 NULL
1235};
1236
1237static const char *slave_sws[] = {
1238 "Front Playback Switch",
1239 "Surround Playback Switch",
1240 "Center Playback Switch",
1241 "LFE Playback Switch",
1242 "Side Playback Switch",
1243 "Headphone Playback Switch",
1244 "Headphone Playback Switch",
1245 "Speaker Playback Switch",
1246 "External Speaker Playback Switch",
1247 "Speaker2 Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001248 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001249 NULL
1250};
1251
Takashi Iwai603c4012008-07-30 15:01:44 +02001252static void stac92xx_free_kctls(struct hda_codec *codec);
Takashi Iwaie4973e12008-11-18 09:32:42 +01001253static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
Takashi Iwai603c4012008-07-30 15:01:44 +02001254
Matt2f2f4252005-04-13 14:45:30 +02001255static int stac92xx_build_controls(struct hda_codec *codec)
1256{
1257 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaie4973e12008-11-18 09:32:42 +01001258 struct auto_pin_cfg *cfg = &spec->autocfg;
1259 hda_nid_t nid;
Matt2f2f4252005-04-13 14:45:30 +02001260 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001261 int i;
Matt2f2f4252005-04-13 14:45:30 +02001262
1263 err = snd_hda_add_new_ctls(codec, spec->mixer);
1264 if (err < 0)
1265 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001266
1267 for (i = 0; i < spec->num_mixers; i++) {
1268 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1269 if (err < 0)
1270 return err;
1271 }
Takashi Iwai1697055e2007-12-18 18:05:52 +01001272 if (spec->num_dmuxes > 0) {
1273 stac_dmux_mixer.count = spec->num_dmuxes;
Takashi Iwaid13bd412008-07-30 15:01:45 +02001274 err = snd_hda_ctl_add(codec,
Takashi Iwai1697055e2007-12-18 18:05:52 +01001275 snd_ctl_new1(&stac_dmux_mixer, codec));
1276 if (err < 0)
1277 return err;
1278 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001279 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001280 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1281 struct hda_input_mux *smux = &spec->private_smux;
1282 /* check for mute support on SPDIF out */
1283 if (wcaps & AC_WCAP_OUT_AMP) {
1284 smux->items[smux->num_items].label = "Off";
1285 smux->items[smux->num_items].index = 0;
1286 smux->num_items++;
1287 spec->spdif_mute = 1;
1288 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001289 stac_smux_mixer.count = spec->num_smuxes;
Takashi Iwai4f2d23e2008-12-19 10:14:13 +01001290 err = snd_hda_ctl_add(codec,
Matthew Ranostayd9737752008-09-07 12:03:41 +02001291 snd_ctl_new1(&stac_smux_mixer, codec));
1292 if (err < 0)
1293 return err;
1294 }
Mattc7d4b2f2005-06-27 14:59:41 +02001295
Mattdabbed62005-06-14 10:19:34 +02001296 if (spec->multiout.dig_out_nid) {
1297 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1298 if (err < 0)
1299 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001300 err = snd_hda_create_spdif_share_sw(codec,
1301 &spec->multiout);
1302 if (err < 0)
1303 return err;
1304 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001305 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001306 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001307 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1308 if (err < 0)
1309 return err;
1310 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001311
1312 /* if we have no master control, let's create it */
1313 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001314 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001315 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001316 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai7c7767e2009-01-20 15:28:38 +01001317 /* correct volume offset */
1318 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
Takashi Iwai2134ea42008-01-10 16:53:55 +01001319 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001320 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001321 if (err < 0)
1322 return err;
1323 }
1324 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1325 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1326 NULL, slave_sws);
1327 if (err < 0)
1328 return err;
1329 }
1330
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001331 if (spec->aloopback_ctl &&
1332 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1333 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1334 if (err < 0)
1335 return err;
1336 }
1337
Takashi Iwai603c4012008-07-30 15:01:44 +02001338 stac92xx_free_kctls(codec); /* no longer needed */
Takashi Iwaie4973e12008-11-18 09:32:42 +01001339
1340 /* create jack input elements */
1341 if (spec->hp_detect) {
1342 for (i = 0; i < cfg->hp_outs; i++) {
1343 int type = SND_JACK_HEADPHONE;
1344 nid = cfg->hp_pins[i];
1345 /* jack detection */
1346 if (cfg->hp_outs == i)
1347 type |= SND_JACK_LINEOUT;
1348 err = stac92xx_add_jack(codec, nid, type);
1349 if (err < 0)
1350 return err;
1351 }
1352 }
1353 for (i = 0; i < cfg->line_outs; i++) {
1354 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1355 SND_JACK_LINEOUT);
1356 if (err < 0)
1357 return err;
1358 }
1359 for (i = 0; i < AUTO_PIN_LAST; i++) {
1360 nid = cfg->input_pins[i];
1361 if (nid) {
1362 err = stac92xx_add_jack(codec, nid,
1363 SND_JACK_MICROPHONE);
1364 if (err < 0)
1365 return err;
1366 }
1367 }
1368
Mattdabbed62005-06-14 10:19:34 +02001369 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001370}
1371
Matt Porter403d1942005-11-29 15:00:51 +01001372static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001373 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001374 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1375};
1376
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001377static unsigned int gateway9200_m4_pin_configs[8] = {
1378 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1379 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1380};
1381static unsigned int gateway9200_m4_2_pin_configs[8] = {
1382 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1383 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1384};
1385
1386/*
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001387 STAC 9200 pin configs for
1388 102801A8
1389 102801DE
1390 102801E8
1391*/
1392static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001393 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1394 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001395};
1396
1397/*
1398 STAC 9200 pin configs for
1399 102801C0
1400 102801C1
1401*/
1402static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001403 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1404 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001405};
1406
1407/*
1408 STAC 9200 pin configs for
1409 102801C4 (Dell Dimension E310)
1410 102801C5
1411 102801C7
1412 102801D9
1413 102801DA
1414 102801E3
1415*/
1416static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001417 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1418 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001419};
1420
1421
1422/*
1423 STAC 9200-32 pin configs for
1424 102801B5 (Dell Inspiron 630m)
1425 102801D8 (Dell Inspiron 640m)
1426*/
1427static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001428 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1429 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001430};
1431
1432/*
1433 STAC 9200-32 pin configs for
1434 102801C2 (Dell Latitude D620)
1435 102801C8
1436 102801CC (Dell Latitude D820)
1437 102801D4
1438 102801D6
1439*/
1440static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001441 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1442 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001443};
1444
1445/*
1446 STAC 9200-32 pin configs for
1447 102801CE (Dell XPS M1710)
1448 102801CF (Dell Precision M90)
1449*/
1450static unsigned int dell9200_m23_pin_configs[8] = {
1451 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1452 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1453};
1454
1455/*
1456 STAC 9200-32 pin configs for
1457 102801C9
1458 102801CA
1459 102801CB (Dell Latitude 120L)
1460 102801D3
1461*/
1462static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001463 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1464 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001465};
1466
1467/*
1468 STAC 9200-32 pin configs for
1469 102801BD (Dell Inspiron E1505n)
1470 102801EE
1471 102801EF
1472*/
1473static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001474 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1475 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001476};
1477
1478/*
1479 STAC 9200-32 pin configs for
1480 102801F5 (Dell Inspiron 1501)
1481 102801F6
1482*/
1483static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001484 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1485 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001486};
1487
1488/*
1489 STAC 9200-32
1490 102801CD (Dell Inspiron E1705/9400)
1491*/
1492static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001493 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1494 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001495};
1496
Tobin Davisbf277782008-02-03 20:31:47 +01001497static unsigned int oqo9200_pin_configs[8] = {
1498 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1499 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1500};
1501
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001502
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001503static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1504 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001505 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001506 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1507 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1508 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1509 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1510 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1511 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1512 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1513 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1514 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1515 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001516 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1517 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001518 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001519};
1520
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001521static const char *stac9200_models[STAC_9200_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001522 [STAC_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001523 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001524 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001525 [STAC_9200_DELL_D21] = "dell-d21",
1526 [STAC_9200_DELL_D22] = "dell-d22",
1527 [STAC_9200_DELL_D23] = "dell-d23",
1528 [STAC_9200_DELL_M21] = "dell-m21",
1529 [STAC_9200_DELL_M22] = "dell-m22",
1530 [STAC_9200_DELL_M23] = "dell-m23",
1531 [STAC_9200_DELL_M24] = "dell-m24",
1532 [STAC_9200_DELL_M25] = "dell-m25",
1533 [STAC_9200_DELL_M26] = "dell-m26",
1534 [STAC_9200_DELL_M27] = "dell-m27",
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001535 [STAC_9200_M4] = "gateway-m4",
1536 [STAC_9200_M4_2] = "gateway-m4-2",
Takashi Iwai117f2572008-03-18 09:53:23 +01001537 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001538};
1539
1540static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1541 /* SigmaTel reference board */
1542 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1543 "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001544 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1545 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001546 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001547 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1548 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001549 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001550 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1551 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1552 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1553 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1554 "unknown Dell", STAC_9200_DELL_D22),
1555 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1556 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001557 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001558 "Dell Latitude D620", STAC_9200_DELL_M22),
1559 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1560 "unknown Dell", STAC_9200_DELL_D23),
1561 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1562 "unknown Dell", STAC_9200_DELL_D23),
1563 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1564 "unknown Dell", STAC_9200_DELL_M22),
1565 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1566 "unknown Dell", STAC_9200_DELL_M24),
1567 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1568 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001569 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001570 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001571 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001572 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001573 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001574 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001575 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001576 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001577 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001578 "Dell Precision M90", STAC_9200_DELL_M23),
1579 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1580 "unknown Dell", STAC_9200_DELL_M22),
1581 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1582 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001583 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001584 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001585 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001586 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1587 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1588 "unknown Dell", STAC_9200_DELL_D23),
1589 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1590 "unknown Dell", STAC_9200_DELL_D23),
1591 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1592 "unknown Dell", STAC_9200_DELL_D21),
1593 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1594 "unknown Dell", STAC_9200_DELL_D23),
1595 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1596 "unknown Dell", STAC_9200_DELL_D21),
1597 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1598 "unknown Dell", STAC_9200_DELL_M25),
1599 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1600 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001601 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001602 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1603 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1604 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001605 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001606 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001607 /* Gateway machines needs EAPD to be set on resume */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001608 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1609 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1610 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
Tobin Davisbf277782008-02-03 20:31:47 +01001611 /* OQO Mobile */
1612 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001613 {} /* terminator */
1614};
1615
Tobin Davis8e21c342007-01-08 11:04:17 +01001616static unsigned int ref925x_pin_configs[8] = {
1617 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001618 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001619};
1620
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001621static unsigned int stac925xM1_pin_configs[8] = {
1622 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1623 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001624};
1625
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001626static unsigned int stac925xM1_2_pin_configs[8] = {
1627 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1628 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1629};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001630
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001631static unsigned int stac925xM2_pin_configs[8] = {
1632 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1633 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis2c11f952007-05-17 09:36:34 +02001634};
1635
Tobin Davis8e21c342007-01-08 11:04:17 +01001636static unsigned int stac925xM2_2_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001637 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1638 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1639};
1640
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001641static unsigned int stac925xM3_pin_configs[8] = {
1642 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1643 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1644};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001645
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001646static unsigned int stac925xM5_pin_configs[8] = {
1647 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1648 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1649};
1650
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001651static unsigned int stac925xM6_pin_configs[8] = {
1652 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1653 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
Tobin Davis8e21c342007-01-08 11:04:17 +01001654};
1655
1656static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1657 [STAC_REF] = ref925x_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001658 [STAC_M1] = stac925xM1_pin_configs,
1659 [STAC_M1_2] = stac925xM1_2_pin_configs,
1660 [STAC_M2] = stac925xM2_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001661 [STAC_M2_2] = stac925xM2_2_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001662 [STAC_M3] = stac925xM3_pin_configs,
1663 [STAC_M5] = stac925xM5_pin_configs,
1664 [STAC_M6] = stac925xM6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001665};
1666
1667static const char *stac925x_models[STAC_925x_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001668 [STAC_925x_AUTO] = "auto",
Tobin Davis8e21c342007-01-08 11:04:17 +01001669 [STAC_REF] = "ref",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001670 [STAC_M1] = "m1",
1671 [STAC_M1_2] = "m1-2",
1672 [STAC_M2] = "m2",
Tobin Davis8e21c342007-01-08 11:04:17 +01001673 [STAC_M2_2] = "m2-2",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001674 [STAC_M3] = "m3",
1675 [STAC_M5] = "m5",
1676 [STAC_M6] = "m6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001677};
1678
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001679static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001680 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1681 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1682 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1683 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001684 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001685 /* Not sure about the brand name for those */
1686 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1687 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1688 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1689 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001690 {} /* terminator */
Tobin Davis8e21c342007-01-08 11:04:17 +01001691};
1692
1693static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1694 /* SigmaTel reference board */
1695 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001696 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001697 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001698
1699 /* Default table for unknown ID */
1700 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1701
Tobin Davis8e21c342007-01-08 11:04:17 +01001702 {} /* terminator */
1703};
1704
Matthew Ranostaya7662642008-02-21 07:51:14 +01001705static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001706 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1707 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1708 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001709 0x01452050,
1710};
1711
1712static unsigned int dell_m6_pin_configs[13] = {
1713 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001714 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001715 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1716 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001717};
1718
1719static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001720 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001721 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1722 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1723 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001724 [STAC_DELL_EQ] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001725};
1726
1727static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001728 [STAC_92HD73XX_AUTO] = "auto",
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01001729 [STAC_92HD73XX_NO_JD] = "no-jd",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001730 [STAC_92HD73XX_REF] = "ref",
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001731 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1732 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1733 [STAC_DELL_M6_BOTH] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001734 [STAC_DELL_EQ] = "dell-eq",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001735};
1736
1737static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1738 /* SigmaTel reference board */
1739 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001740 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001741 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1742 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001743 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001744 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001745 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001746 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001747 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001748 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001749 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001750 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001751 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001752 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001753 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001754 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001755 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001756 "unknown Dell", STAC_DELL_M6_DMIC),
1757 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1758 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01001759 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001760 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Joerg Schirottkefa620e92008-12-19 08:13:49 +01001761 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1762 "Dell Studio 17", STAC_DELL_M6_DMIC),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001763 {} /* terminator */
1764};
1765
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001766static unsigned int ref92hd83xxx_pin_configs[10] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001767 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1768 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001769 0x01451160, 0x98560170,
1770};
1771
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001772static unsigned int dell_s14_pin_configs[10] = {
1773 0x02214030, 0x02211010, 0x02a19020, 0x01014050,
1774 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160,
1775 0x40f000f0, 0x40f000f0,
1776};
1777
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001778static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1779 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001780 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001781 [STAC_DELL_S14] = dell_s14_pin_configs,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001782};
1783
1784static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001785 [STAC_92HD83XXX_AUTO] = "auto",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001786 [STAC_92HD83XXX_REF] = "ref",
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001787 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001788 [STAC_DELL_S14] = "dell-s14",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001789};
1790
1791static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1792 /* SigmaTel reference board */
1793 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Takashi Iwaif9d088b2009-01-13 11:54:49 +01001794 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001795 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1796 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001797 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1798 "unknown Dell", STAC_DELL_S14),
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -02001799 {} /* terminator */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001800};
1801
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001802static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001803 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001804 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001805 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1806 0x00000000
Matthew Ranostaye035b842007-11-06 11:53:55 +01001807};
1808
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001809static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001810 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001811 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001812 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1813 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001814};
1815
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001816static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001817 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1818 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001819 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1820 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001821};
1822
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001823static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001824 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1825 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001826 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1827 0x00000000
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001828};
1829
Matthew Ranostaye035b842007-11-06 11:53:55 +01001830static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1831 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001832 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1833 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001834 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001835 [STAC_HP_M4] = NULL,
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001836 [STAC_HP_DV5] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001837};
1838
1839static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001840 [STAC_92HD71BXX_AUTO] = "auto",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001841 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001842 [STAC_DELL_M4_1] = "dell-m4-1",
1843 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001844 [STAC_DELL_M4_3] = "dell-m4-3",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001845 [STAC_HP_M4] = "hp-m4",
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001846 [STAC_HP_DV5] = "hp-dv5",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001847};
1848
1849static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1850 /* SigmaTel reference board */
1851 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1852 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001853 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1854 "DFI LanParty", STAC_92HD71BXX_REF),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001855 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
1856 "HP dv4-7", STAC_HP_DV5),
1857 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1858 "HP dv4-7", STAC_HP_DV5),
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001859 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001860 "HP mini 1000", STAC_HP_M4),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001861 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1862 "unknown Dell", STAC_DELL_M4_1),
1863 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1864 "unknown Dell", STAC_DELL_M4_1),
1865 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1866 "unknown Dell", STAC_DELL_M4_1),
1867 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1868 "unknown Dell", STAC_DELL_M4_1),
1869 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1870 "unknown Dell", STAC_DELL_M4_1),
1871 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1872 "unknown Dell", STAC_DELL_M4_1),
1873 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1874 "unknown Dell", STAC_DELL_M4_1),
1875 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1876 "unknown Dell", STAC_DELL_M4_2),
1877 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1878 "unknown Dell", STAC_DELL_M4_2),
1879 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1880 "unknown Dell", STAC_DELL_M4_2),
1881 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1882 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001883 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1884 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001885 {} /* terminator */
1886};
1887
Matt Porter403d1942005-11-29 15:00:51 +01001888static unsigned int ref922x_pin_configs[10] = {
1889 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1890 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001891 0x40000100, 0x40000100,
1892};
1893
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001894/*
1895 STAC 922X pin configs for
1896 102801A7
1897 102801AB
1898 102801A9
1899 102801D1
1900 102801D2
1901*/
1902static unsigned int dell_922x_d81_pin_configs[10] = {
1903 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1904 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1905 0x01813122, 0x400001f2,
1906};
1907
1908/*
1909 STAC 922X pin configs for
1910 102801AC
1911 102801D0
1912*/
1913static unsigned int dell_922x_d82_pin_configs[10] = {
1914 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1915 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1916 0x01813122, 0x400001f1,
1917};
1918
1919/*
1920 STAC 922X pin configs for
1921 102801BF
1922*/
1923static unsigned int dell_922x_m81_pin_configs[10] = {
1924 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1925 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1926 0x40C003f1, 0x405003f0,
1927};
1928
1929/*
1930 STAC 9221 A1 pin configs for
1931 102801D7 (Dell XPS M1210)
1932*/
1933static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001934 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1935 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001936 0x508003f3, 0x405003f4,
1937};
1938
Matt Porter403d1942005-11-29 15:00:51 +01001939static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001940 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001941 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1942 0x02a19120, 0x40000100,
1943};
1944
1945static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001946 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1947 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001948 0x02a19320, 0x40000100,
1949};
1950
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001951static unsigned int intel_mac_v1_pin_configs[10] = {
1952 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1953 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001954 0x400000fc, 0x400000fb,
1955};
1956
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001957static unsigned int intel_mac_v2_pin_configs[10] = {
1958 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1959 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001960 0x400000fc, 0x400000fb,
1961};
1962
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001963static unsigned int intel_mac_v3_pin_configs[10] = {
1964 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1965 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1966 0x400000fc, 0x400000fb,
1967};
1968
1969static unsigned int intel_mac_v4_pin_configs[10] = {
1970 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1971 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1972 0x400000fc, 0x400000fb,
1973};
1974
1975static unsigned int intel_mac_v5_pin_configs[10] = {
1976 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1977 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1978 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001979};
1980
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001981static unsigned int ecs202_pin_configs[10] = {
1982 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1983 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1984 0x9037012e, 0x40e000f2,
1985};
Takashi Iwai76c08822007-06-19 12:17:42 +02001986
Takashi Iwai19039bd2006-06-28 15:52:16 +02001987static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001988 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001989 [STAC_D945GTP3] = d945gtp3_pin_configs,
1990 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001991 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1992 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1993 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1994 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1995 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001996 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001997 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001998 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1999 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
2000 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
2001 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
2002 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
2003 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002004 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002005 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
2006 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
2007 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
2008 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01002009};
2010
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002011static const char *stac922x_models[STAC_922X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002012 [STAC_922X_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002013 [STAC_D945_REF] = "ref",
2014 [STAC_D945GTP5] = "5stack",
2015 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002016 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
2017 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
2018 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
2019 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
2020 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08002021 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002022 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002023 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01002024 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01002025 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
2026 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02002027 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02002028 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002029 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002030 [STAC_922X_DELL_D81] = "dell-d81",
2031 [STAC_922X_DELL_D82] = "dell-d82",
2032 [STAC_922X_DELL_M81] = "dell-m81",
2033 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002034};
2035
2036static struct snd_pci_quirk stac922x_cfg_tbl[] = {
2037 /* SigmaTel reference board */
2038 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2039 "DFI LanParty", STAC_D945_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002040 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2041 "DFI LanParty", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002042 /* Intel 945G based systems */
2043 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2044 "Intel D945G", STAC_D945GTP3),
2045 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2046 "Intel D945G", STAC_D945GTP3),
2047 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2048 "Intel D945G", STAC_D945GTP3),
2049 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2050 "Intel D945G", STAC_D945GTP3),
2051 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2052 "Intel D945G", STAC_D945GTP3),
2053 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2054 "Intel D945G", STAC_D945GTP3),
2055 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2056 "Intel D945G", STAC_D945GTP3),
2057 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2058 "Intel D945G", STAC_D945GTP3),
2059 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2060 "Intel D945G", STAC_D945GTP3),
2061 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2062 "Intel D945G", STAC_D945GTP3),
2063 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2064 "Intel D945G", STAC_D945GTP3),
2065 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2066 "Intel D945G", STAC_D945GTP3),
2067 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2068 "Intel D945G", STAC_D945GTP3),
2069 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2070 "Intel D945G", STAC_D945GTP3),
2071 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2072 "Intel D945G", STAC_D945GTP3),
2073 /* Intel D945G 5-stack systems */
2074 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2075 "Intel D945G", STAC_D945GTP5),
2076 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2077 "Intel D945G", STAC_D945GTP5),
2078 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2079 "Intel D945G", STAC_D945GTP5),
2080 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2081 "Intel D945G", STAC_D945GTP5),
2082 /* Intel 945P based systems */
2083 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2084 "Intel D945P", STAC_D945GTP3),
2085 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2086 "Intel D945P", STAC_D945GTP3),
2087 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2088 "Intel D945P", STAC_D945GTP3),
2089 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2090 "Intel D945P", STAC_D945GTP3),
2091 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2092 "Intel D945P", STAC_D945GTP3),
2093 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2094 "Intel D945P", STAC_D945GTP5),
Takashi Iwai8056d472009-01-23 09:09:43 +01002095 /* other intel */
2096 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2097 "Intel D945", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002098 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08002099 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002100 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08002101 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002102 /* Dell systems */
2103 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2104 "unknown Dell", STAC_922X_DELL_D81),
2105 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2106 "unknown Dell", STAC_922X_DELL_D81),
2107 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2108 "unknown Dell", STAC_922X_DELL_D81),
2109 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2110 "unknown Dell", STAC_922X_DELL_D82),
2111 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2112 "unknown Dell", STAC_922X_DELL_M81),
2113 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2114 "unknown Dell", STAC_922X_DELL_D82),
2115 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2116 "unknown Dell", STAC_922X_DELL_D81),
2117 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2118 "unknown Dell", STAC_922X_DELL_D81),
2119 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2120 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002121 /* ECS/PC Chips boards */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002122 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
Herton Ronaldo Krzesinski8663ae52009-02-08 19:50:34 -02002123 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01002124 {} /* terminator */
2125};
2126
Matt Porter3cc08dc2006-01-23 15:27:49 +01002127static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002128 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2129 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2130 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2131 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002132};
2133
Tobin Davis93ed1502006-09-01 21:03:12 +02002134static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002135 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2136 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2137 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2138 0x40000100, 0x40000100
2139};
2140
Tobin Davis93ed1502006-09-01 21:03:12 +02002141static unsigned int d965_5st_pin_configs[14] = {
2142 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2143 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2144 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2145 0x40000100, 0x40000100
2146};
2147
Tobin Davis4ff076e2007-08-07 11:48:12 +02002148static unsigned int dell_3st_pin_configs[14] = {
2149 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2150 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002151 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002152 0x40c003fc, 0x40000100
2153};
2154
Tobin Davis93ed1502006-09-01 21:03:12 +02002155static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002156 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002157 [STAC_D965_REF] = ref927x_pin_configs,
2158 [STAC_D965_3ST] = d965_3st_pin_configs,
2159 [STAC_D965_5ST] = d965_5st_pin_configs,
2160 [STAC_DELL_3ST] = dell_3st_pin_configs,
2161 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002162};
2163
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002164static const char *stac927x_models[STAC_927X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002165 [STAC_927X_AUTO] = "auto",
Takashi Iwaie28d8322008-12-17 13:48:29 +01002166 [STAC_D965_REF_NO_JD] = "ref-no-jd",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002167 [STAC_D965_REF] = "ref",
2168 [STAC_D965_3ST] = "3stack",
2169 [STAC_D965_5ST] = "5stack",
2170 [STAC_DELL_3ST] = "dell-3stack",
2171 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002172};
2173
2174static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2175 /* SigmaTel reference board */
2176 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2177 "DFI LanParty", STAC_D965_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002178 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2179 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002180 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002181 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2182 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002183 /* 965 based 3 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002184 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2185 "Intel D965", STAC_D965_3ST),
2186 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2187 "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002188 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002189 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002190 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002191 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2192 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002193 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002194 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2195 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002196 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02002197 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002198 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2199 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2200 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2201 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002202 /* 965 based 5 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002203 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2204 "Intel D965", STAC_D965_5ST),
2205 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2206 "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002207 {} /* terminator */
2208};
2209
Matt Porterf3302a52006-07-31 12:49:34 +02002210static unsigned int ref9205_pin_configs[12] = {
2211 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002212 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002213 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002214};
2215
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002216/*
2217 STAC 9205 pin configs for
2218 102801F1
2219 102801F2
2220 102801FC
2221 102801FD
2222 10280204
2223 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002224 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002225*/
2226static unsigned int dell_9205_m42_pin_configs[12] = {
2227 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2228 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2229 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2230};
2231
2232/*
2233 STAC 9205 pin configs for
2234 102801F9
2235 102801FA
2236 102801FE
2237 102801FF (Dell Precision M4300)
2238 10280206
2239 10280200
2240 10280201
2241*/
2242static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002243 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2244 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2245 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2246};
2247
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002248static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002249 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2250 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2251 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2252};
2253
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002254static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002255 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002256 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2257 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2258 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Takashi Iwaid9a42682009-01-22 17:40:18 +01002259 [STAC_9205_EAPD] = NULL,
Matt Porterf3302a52006-07-31 12:49:34 +02002260};
2261
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002262static const char *stac9205_models[STAC_9205_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002263 [STAC_9205_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002264 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002265 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002266 [STAC_9205_DELL_M43] = "dell-m43",
2267 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaid9a42682009-01-22 17:40:18 +01002268 [STAC_9205_EAPD] = "eapd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002269};
2270
2271static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2272 /* SigmaTel reference board */
2273 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2274 "DFI LanParty", STAC_9205_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002275 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2276 "DFI LanParty", STAC_9205_REF),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002277 /* Dell */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002278 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2279 "unknown Dell", STAC_9205_DELL_M42),
2280 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2281 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002282 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002283 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002284 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2285 "Dell Precision", STAC_9205_DELL_M43),
2286 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2287 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002288 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2289 "unknown Dell", STAC_9205_DELL_M42),
2290 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2291 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002292 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2293 "Dell Precision", STAC_9205_DELL_M43),
2294 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002295 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002296 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2297 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002298 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2299 "Dell Precision", STAC_9205_DELL_M43),
2300 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2301 "Dell Precision", STAC_9205_DELL_M43),
2302 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2303 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002304 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2305 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002306 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2307 "Dell Vostro 1500", STAC_9205_DELL_M42),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002308 /* Gateway */
2309 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
Matt Porterf3302a52006-07-31 12:49:34 +02002310 {} /* terminator */
2311};
2312
Takashi Iwai330ee992009-02-20 14:33:36 +01002313static void stac92xx_set_config_regs(struct hda_codec *codec,
2314 unsigned int *pincfgs)
Matt2f2f4252005-04-13 14:45:30 +02002315{
2316 int i;
2317 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002318
Takashi Iwai330ee992009-02-20 14:33:36 +01002319 if (!pincfgs)
2320 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002321
Matthew Ranostay87d48362007-07-17 11:52:24 +02002322 for (i = 0; i < spec->num_pins; i++)
Takashi Iwai330ee992009-02-20 14:33:36 +01002323 if (spec->pin_nids[i] && pincfgs[i])
2324 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2325 pincfgs[i]);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002326}
2327
Matt2f2f4252005-04-13 14:45:30 +02002328/*
2329 * Analog playback callbacks
2330 */
2331static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2332 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002333 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002334{
2335 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002336 if (spec->stream_delay)
2337 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002338 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2339 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002340}
2341
2342static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2343 struct hda_codec *codec,
2344 unsigned int stream_tag,
2345 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002346 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002347{
2348 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002349 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002350}
2351
2352static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2353 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002354 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002355{
2356 struct sigmatel_spec *spec = codec->spec;
2357 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2358}
2359
2360/*
Mattdabbed62005-06-14 10:19:34 +02002361 * Digital playback callbacks
2362 */
2363static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2364 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002365 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002366{
2367 struct sigmatel_spec *spec = codec->spec;
2368 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2369}
2370
2371static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2372 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002373 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002374{
2375 struct sigmatel_spec *spec = codec->spec;
2376 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2377}
2378
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002379static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2380 struct hda_codec *codec,
2381 unsigned int stream_tag,
2382 unsigned int format,
2383 struct snd_pcm_substream *substream)
2384{
2385 struct sigmatel_spec *spec = codec->spec;
2386 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2387 stream_tag, format, substream);
2388}
2389
Takashi Iwai9411e212009-02-13 11:32:28 +01002390static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2391 struct hda_codec *codec,
2392 struct snd_pcm_substream *substream)
2393{
2394 struct sigmatel_spec *spec = codec->spec;
2395 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2396}
2397
Mattdabbed62005-06-14 10:19:34 +02002398
2399/*
Matt2f2f4252005-04-13 14:45:30 +02002400 * Analog capture callbacks
2401 */
2402static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2403 struct hda_codec *codec,
2404 unsigned int stream_tag,
2405 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002406 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002407{
2408 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002409 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002410
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002411 if (spec->powerdown_adcs) {
2412 msleep(40);
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002413 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002414 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2415 }
2416 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002417 return 0;
2418}
2419
2420static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2421 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002422 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002423{
2424 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002425 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002426
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002427 snd_hda_codec_cleanup_stream(codec, nid);
2428 if (spec->powerdown_adcs)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002429 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002430 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002431 return 0;
2432}
2433
Mattdabbed62005-06-14 10:19:34 +02002434static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2435 .substreams = 1,
2436 .channels_min = 2,
2437 .channels_max = 2,
2438 /* NID is set in stac92xx_build_pcms */
2439 .ops = {
2440 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002441 .close = stac92xx_dig_playback_pcm_close,
Takashi Iwai9411e212009-02-13 11:32:28 +01002442 .prepare = stac92xx_dig_playback_pcm_prepare,
2443 .cleanup = stac92xx_dig_playback_pcm_cleanup
Mattdabbed62005-06-14 10:19:34 +02002444 },
2445};
2446
2447static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2448 .substreams = 1,
2449 .channels_min = 2,
2450 .channels_max = 2,
2451 /* NID is set in stac92xx_build_pcms */
2452};
2453
Matt2f2f4252005-04-13 14:45:30 +02002454static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2455 .substreams = 1,
2456 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002457 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002458 .nid = 0x02, /* NID to query formats and rates */
2459 .ops = {
2460 .open = stac92xx_playback_pcm_open,
2461 .prepare = stac92xx_playback_pcm_prepare,
2462 .cleanup = stac92xx_playback_pcm_cleanup
2463 },
2464};
2465
Matt Porter3cc08dc2006-01-23 15:27:49 +01002466static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2467 .substreams = 1,
2468 .channels_min = 2,
2469 .channels_max = 2,
2470 .nid = 0x06, /* NID to query formats and rates */
2471 .ops = {
2472 .open = stac92xx_playback_pcm_open,
2473 .prepare = stac92xx_playback_pcm_prepare,
2474 .cleanup = stac92xx_playback_pcm_cleanup
2475 },
2476};
2477
Matt2f2f4252005-04-13 14:45:30 +02002478static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002479 .channels_min = 2,
2480 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002481 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002482 .ops = {
2483 .prepare = stac92xx_capture_pcm_prepare,
2484 .cleanup = stac92xx_capture_pcm_cleanup
2485 },
2486};
2487
2488static int stac92xx_build_pcms(struct hda_codec *codec)
2489{
2490 struct sigmatel_spec *spec = codec->spec;
2491 struct hda_pcm *info = spec->pcm_rec;
2492
2493 codec->num_pcms = 1;
2494 codec->pcm_info = info;
2495
Mattc7d4b2f2005-06-27 14:59:41 +02002496 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002497 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Takashi Iwai00a602d2009-01-23 11:55:42 +01002498 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2499 spec->multiout.dac_nids[0];
Matt2f2f4252005-04-13 14:45:30 +02002500 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002501 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002502 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002503
2504 if (spec->alt_switch) {
2505 codec->num_pcms++;
2506 info++;
2507 info->name = "STAC92xx Analog Alt";
2508 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2509 }
Matt2f2f4252005-04-13 14:45:30 +02002510
Mattdabbed62005-06-14 10:19:34 +02002511 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2512 codec->num_pcms++;
2513 info++;
2514 info->name = "STAC92xx Digital";
Takashi Iwai0852d7a2009-02-11 11:35:15 +01002515 info->pcm_type = spec->autocfg.dig_out_type[0];
Mattdabbed62005-06-14 10:19:34 +02002516 if (spec->multiout.dig_out_nid) {
2517 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2518 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2519 }
2520 if (spec->dig_in_nid) {
2521 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2522 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2523 }
2524 }
2525
Matt2f2f4252005-04-13 14:45:30 +02002526 return 0;
2527}
2528
Takashi Iwaic960a032006-03-23 17:06:28 +01002529static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2530{
2531 unsigned int pincap = snd_hda_param_read(codec, nid,
2532 AC_PAR_PIN_CAP);
2533 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2534 if (pincap & AC_PINCAP_VREF_100)
2535 return AC_PINCTL_VREF_100;
2536 if (pincap & AC_PINCAP_VREF_80)
2537 return AC_PINCTL_VREF_80;
2538 if (pincap & AC_PINCAP_VREF_50)
2539 return AC_PINCTL_VREF_50;
2540 if (pincap & AC_PINCAP_VREF_GRD)
2541 return AC_PINCTL_VREF_GRD;
2542 return 0;
2543}
2544
Matt Porter403d1942005-11-29 15:00:51 +01002545static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2546
2547{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002548 snd_hda_codec_write_cache(codec, nid, 0,
2549 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002550}
2551
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002552#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2553
2554static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2555 struct snd_ctl_elem_value *ucontrol)
2556{
2557 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2558 struct sigmatel_spec *spec = codec->spec;
2559
Takashi Iwaid7a89432008-11-12 09:48:04 +01002560 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002561 return 0;
2562}
2563
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002564static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
2565 unsigned char type);
2566
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002567static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2568 struct snd_ctl_elem_value *ucontrol)
2569{
2570 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2571 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002572 int nid = kcontrol->private_value;
2573
2574 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002575
2576 /* check to be sure that the ports are upto date with
2577 * switch changes
2578 */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002579 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002580
2581 return 1;
2582}
2583
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002584#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002585
2586static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2587{
2588 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2589 struct sigmatel_spec *spec = codec->spec;
2590 int io_idx = kcontrol-> private_value & 0xff;
2591
2592 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2593 return 0;
2594}
2595
2596static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2597{
2598 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2599 struct sigmatel_spec *spec = codec->spec;
2600 hda_nid_t nid = kcontrol->private_value >> 8;
2601 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002602 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002603
2604 spec->io_switch[io_idx] = val;
2605
2606 if (val)
2607 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002608 else {
2609 unsigned int pinctl = AC_PINCTL_IN_EN;
2610 if (io_idx) /* set VREF for mic */
2611 pinctl |= stac92xx_get_vref(codec, nid);
2612 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2613 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002614
2615 /* check the auto-mute again: we need to mute/unmute the speaker
2616 * appropriately according to the pin direction
2617 */
2618 if (spec->hp_detect)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002619 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
Jiang Zhe40c1d302007-11-12 13:05:16 +01002620
Matt Porter403d1942005-11-29 15:00:51 +01002621 return 1;
2622}
2623
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002624#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2625
2626static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2627 struct snd_ctl_elem_value *ucontrol)
2628{
2629 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2630 struct sigmatel_spec *spec = codec->spec;
2631
2632 ucontrol->value.integer.value[0] = spec->clfe_swap;
2633 return 0;
2634}
2635
2636static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2637 struct snd_ctl_elem_value *ucontrol)
2638{
2639 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2640 struct sigmatel_spec *spec = codec->spec;
2641 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002642 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002643
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002644 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002645 return 0;
2646
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002647 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002648
2649 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2650 spec->clfe_swap ? 0x4 : 0x0);
2651
2652 return 1;
2653}
2654
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002655#define STAC_CODEC_HP_SWITCH(xname) \
2656 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2657 .name = xname, \
2658 .index = 0, \
2659 .info = stac92xx_hp_switch_info, \
2660 .get = stac92xx_hp_switch_get, \
2661 .put = stac92xx_hp_switch_put, \
2662 }
2663
Matt Porter403d1942005-11-29 15:00:51 +01002664#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2665 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2666 .name = xname, \
2667 .index = 0, \
2668 .info = stac92xx_io_switch_info, \
2669 .get = stac92xx_io_switch_get, \
2670 .put = stac92xx_io_switch_put, \
2671 .private_value = xpval, \
2672 }
2673
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002674#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2675 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2676 .name = xname, \
2677 .index = 0, \
2678 .info = stac92xx_clfe_switch_info, \
2679 .get = stac92xx_clfe_switch_get, \
2680 .put = stac92xx_clfe_switch_put, \
2681 .private_value = xpval, \
2682 }
Matt Porter403d1942005-11-29 15:00:51 +01002683
Mattc7d4b2f2005-06-27 14:59:41 +02002684enum {
2685 STAC_CTL_WIDGET_VOL,
2686 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002687 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002688 STAC_CTL_WIDGET_AMP_MUX,
2689 STAC_CTL_WIDGET_AMP_VOL,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002690 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002691 STAC_CTL_WIDGET_IO_SWITCH,
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002692 STAC_CTL_WIDGET_CLFE_SWITCH
Mattc7d4b2f2005-06-27 14:59:41 +02002693};
2694
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002695static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002696 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2697 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002698 STAC_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002699 STAC_AMP_MUX,
2700 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002701 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002702 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002703 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002704};
2705
2706/* add dynamic controls */
Takashi Iwaie3c75962009-01-23 11:57:22 +01002707static struct snd_kcontrol_new *
2708stac_control_new(struct sigmatel_spec *spec,
2709 struct snd_kcontrol_new *ktemp,
2710 const char *name)
Mattc7d4b2f2005-06-27 14:59:41 +02002711{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002712 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002713
Takashi Iwai603c4012008-07-30 15:01:44 +02002714 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2715 knew = snd_array_new(&spec->kctls);
2716 if (!knew)
Takashi Iwaie3c75962009-01-23 11:57:22 +01002717 return NULL;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002718 *knew = *ktemp;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002719 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002720 if (!knew->name) {
2721 /* roolback */
2722 memset(knew, 0, sizeof(*knew));
2723 spec->kctls.alloced--;
2724 return NULL;
2725 }
2726 return knew;
2727}
2728
2729static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2730 struct snd_kcontrol_new *ktemp,
2731 int idx, const char *name,
2732 unsigned long val)
2733{
2734 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
2735 if (!knew)
Mattc7d4b2f2005-06-27 14:59:41 +02002736 return -ENOMEM;
Takashi Iwaie3c75962009-01-23 11:57:22 +01002737 knew->index = idx;
Mattc7d4b2f2005-06-27 14:59:41 +02002738 knew->private_value = val;
Mattc7d4b2f2005-06-27 14:59:41 +02002739 return 0;
2740}
2741
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002742static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2743 int type, int idx, const char *name,
2744 unsigned long val)
2745{
2746 return stac92xx_add_control_temp(spec,
2747 &stac92xx_control_templates[type],
2748 idx, name, val);
2749}
2750
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002751
2752/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002753static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2754 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002755{
2756 return stac92xx_add_control_idx(spec, type, 0, name, val);
2757}
2758
Takashi Iwaie3c75962009-01-23 11:57:22 +01002759static struct snd_kcontrol_new stac_input_src_temp = {
2760 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2761 .name = "Input Source",
2762 .info = stac92xx_mux_enum_info,
2763 .get = stac92xx_mux_enum_get,
2764 .put = stac92xx_mux_enum_put,
2765};
2766
2767static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2768{
2769 struct snd_kcontrol_new *knew;
2770 struct hda_input_mux *imux = &spec->private_imux;
2771
2772 if (!spec->num_adcs || imux->num_items <= 1)
2773 return 0; /* no need for input source control */
2774 knew = stac_control_new(spec, &stac_input_src_temp,
2775 stac_input_src_temp.name);
2776 if (!knew)
2777 return -ENOMEM;
2778 knew->count = spec->num_adcs;
2779 return 0;
2780}
2781
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002782/* check whether the line-input can be used as line-out */
2783static hda_nid_t check_line_out_switch(struct hda_codec *codec)
Matt Porter403d1942005-11-29 15:00:51 +01002784{
2785 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002786 struct auto_pin_cfg *cfg = &spec->autocfg;
2787 hda_nid_t nid;
2788 unsigned int pincap;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002789
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002790 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2791 return 0;
2792 nid = cfg->input_pins[AUTO_PIN_LINE];
2793 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
2794 if (pincap & AC_PINCAP_OUT)
2795 return nid;
Matt Porter403d1942005-11-29 15:00:51 +01002796 return 0;
2797}
2798
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002799/* check whether the mic-input can be used as line-out */
2800static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2801{
2802 struct sigmatel_spec *spec = codec->spec;
2803 struct auto_pin_cfg *cfg = &spec->autocfg;
2804 unsigned int def_conf, pincap;
2805 unsigned int mic_pin;
2806
2807 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2808 return 0;
2809 mic_pin = AUTO_PIN_MIC;
2810 for (;;) {
2811 hda_nid_t nid = cfg->input_pins[mic_pin];
Takashi Iwai330ee992009-02-20 14:33:36 +01002812 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002813 /* some laptops have an internal analog microphone
2814 * which can't be used as a output */
2815 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2816 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
2817 if (pincap & AC_PINCAP_OUT)
2818 return nid;
2819 }
2820 if (mic_pin == AUTO_PIN_MIC)
2821 mic_pin = AUTO_PIN_FRONT_MIC;
2822 else
2823 break;
2824 }
2825 return 0;
2826}
Steve Longerbeam7b043892007-05-03 20:50:03 +02002827
2828static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2829{
2830 int i;
2831
2832 for (i = 0; i < spec->multiout.num_dacs; i++) {
2833 if (spec->multiout.dac_nids[i] == nid)
2834 return 1;
2835 }
2836
2837 return 0;
2838}
2839
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002840static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2841{
2842 int i;
2843 if (is_in_dac_nids(spec, nid))
2844 return 1;
2845 for (i = 0; i < spec->autocfg.hp_outs; i++)
2846 if (spec->hp_dacs[i] == nid)
2847 return 1;
2848 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2849 if (spec->speaker_dacs[i] == nid)
2850 return 1;
2851 return 0;
2852}
2853
2854static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2855{
2856 struct sigmatel_spec *spec = codec->spec;
2857 int j, conn_len;
2858 hda_nid_t conn[HDA_MAX_CONNECTIONS];
2859 unsigned int wcaps, wtype;
2860
2861 conn_len = snd_hda_get_connections(codec, nid, conn,
2862 HDA_MAX_CONNECTIONS);
2863 for (j = 0; j < conn_len; j++) {
2864 wcaps = snd_hda_param_read(codec, conn[j],
2865 AC_PAR_AUDIO_WIDGET_CAP);
2866 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2867 /* we check only analog outputs */
2868 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2869 continue;
2870 /* if this route has a free DAC, assign it */
2871 if (!check_all_dac_nids(spec, conn[j])) {
2872 if (conn_len > 1) {
2873 /* select this DAC in the pin's input mux */
2874 snd_hda_codec_write_cache(codec, nid, 0,
2875 AC_VERB_SET_CONNECT_SEL, j);
2876 }
2877 return conn[j];
2878 }
2879 }
2880 return 0;
2881}
2882
2883static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2884static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2885
Matt Porter3cc08dc2006-01-23 15:27:49 +01002886/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02002887 * Fill in the dac_nids table from the parsed pin configuration
2888 * This function only works when every pin in line_out_pins[]
2889 * contains atleast one DAC in its connection list. Some 92xx
2890 * codecs are not connected directly to a DAC, such as the 9200
2891 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002892 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002893static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02002894{
2895 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002896 struct auto_pin_cfg *cfg = &spec->autocfg;
2897 int i;
2898 hda_nid_t nid, dac;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002899
Mattc7d4b2f2005-06-27 14:59:41 +02002900 for (i = 0; i < cfg->line_outs; i++) {
2901 nid = cfg->line_out_pins[i];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002902 dac = get_unassigned_dac(codec, nid);
2903 if (!dac) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002904 if (spec->multiout.num_dacs > 0) {
2905 /* we have already working output pins,
2906 * so let's drop the broken ones again
2907 */
2908 cfg->line_outs = spec->multiout.num_dacs;
2909 break;
2910 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002911 /* error out, no available DAC found */
2912 snd_printk(KERN_ERR
2913 "%s: No available DAC for pin 0x%x\n",
2914 __func__, nid);
2915 return -ENODEV;
2916 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002917 add_spec_dacs(spec, dac);
2918 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002919
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002920 /* add line-in as output */
2921 nid = check_line_out_switch(codec);
2922 if (nid) {
2923 dac = get_unassigned_dac(codec, nid);
2924 if (dac) {
2925 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
2926 nid, cfg->line_outs);
2927 cfg->line_out_pins[cfg->line_outs] = nid;
2928 cfg->line_outs++;
2929 spec->line_switch = nid;
2930 add_spec_dacs(spec, dac);
2931 }
2932 }
2933 /* add mic as output */
2934 nid = check_mic_out_switch(codec);
2935 if (nid) {
2936 dac = get_unassigned_dac(codec, nid);
2937 if (dac) {
2938 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
2939 nid, cfg->line_outs);
2940 cfg->line_out_pins[cfg->line_outs] = nid;
2941 cfg->line_outs++;
2942 spec->mic_switch = nid;
2943 add_spec_dacs(spec, dac);
Steve Longerbeam7b043892007-05-03 20:50:03 +02002944 }
Mattc7d4b2f2005-06-27 14:59:41 +02002945 }
2946
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002947 for (i = 0; i < cfg->hp_outs; i++) {
2948 nid = cfg->hp_pins[i];
2949 dac = get_unassigned_dac(codec, nid);
2950 if (dac) {
2951 if (!spec->multiout.hp_nid)
2952 spec->multiout.hp_nid = dac;
2953 else
2954 add_spec_extra_dacs(spec, dac);
2955 }
2956 spec->hp_dacs[i] = dac;
2957 }
2958
2959 for (i = 0; i < cfg->speaker_outs; i++) {
2960 nid = cfg->speaker_pins[i];
2961 dac = get_unassigned_dac(codec, nid);
2962 if (dac)
2963 add_spec_extra_dacs(spec, dac);
2964 spec->speaker_dacs[i] = dac;
2965 }
2966
2967 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
Steve Longerbeam7b043892007-05-03 20:50:03 +02002968 spec->multiout.num_dacs,
2969 spec->multiout.dac_nids[0],
2970 spec->multiout.dac_nids[1],
2971 spec->multiout.dac_nids[2],
2972 spec->multiout.dac_nids[3],
2973 spec->multiout.dac_nids[4]);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002974
Mattc7d4b2f2005-06-27 14:59:41 +02002975 return 0;
2976}
2977
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002978/* create volume control/switch for the given prefx type */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01002979static int create_controls(struct hda_codec *codec, const char *pfx,
2980 hda_nid_t nid, int chs)
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002981{
Takashi Iwai7c7767e2009-01-20 15:28:38 +01002982 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002983 char name[32];
2984 int err;
2985
Takashi Iwai7c7767e2009-01-20 15:28:38 +01002986 if (!spec->check_volume_offset) {
2987 unsigned int caps, step, nums, db_scale;
2988 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
2989 step = (caps & AC_AMPCAP_STEP_SIZE) >>
2990 AC_AMPCAP_STEP_SIZE_SHIFT;
2991 step = (step + 1) * 25; /* in .01dB unit */
2992 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
2993 AC_AMPCAP_NUM_STEPS_SHIFT;
2994 db_scale = nums * step;
2995 /* if dB scale is over -64dB, and finer enough,
2996 * let's reduce it to half
2997 */
2998 if (db_scale > 6400 && nums >= 0x1f)
2999 spec->volume_offset = nums / 2;
3000 spec->check_volume_offset = 1;
3001 }
3002
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003003 sprintf(name, "%s Playback Volume", pfx);
3004 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003005 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3006 spec->volume_offset));
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003007 if (err < 0)
3008 return err;
3009 sprintf(name, "%s Playback Switch", pfx);
3010 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
3011 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3012 if (err < 0)
3013 return err;
3014 return 0;
3015}
3016
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003017static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3018{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003019 if (spec->multiout.num_dacs > 4) {
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003020 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3021 return 1;
3022 } else {
3023 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
3024 spec->multiout.num_dacs++;
3025 }
3026 return 0;
3027}
3028
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003029static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003030{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003031 int i;
3032 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3033 if (!spec->multiout.extra_out_nid[i]) {
3034 spec->multiout.extra_out_nid[i] = nid;
3035 return 0;
3036 }
3037 }
3038 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3039 return 1;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003040}
3041
Takashi Iwai76624532008-12-19 10:09:47 +01003042static int is_unique_dac(struct sigmatel_spec *spec, hda_nid_t nid)
3043{
3044 int i;
3045
3046 if (spec->autocfg.line_outs != 1)
3047 return 0;
3048 if (spec->multiout.hp_nid == nid)
3049 return 0;
3050 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++)
3051 if (spec->multiout.extra_out_nid[i] == nid)
3052 return 0;
3053 return 1;
3054}
3055
Mattc7d4b2f2005-06-27 14:59:41 +02003056/* add playback controls from the parsed DAC table */
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003057static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
Takashi Iwai19039bd2006-06-28 15:52:16 +02003058 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003059{
Takashi Iwai76624532008-12-19 10:09:47 +01003060 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003061 static const char *chname[4] = {
3062 "Front", "Surround", NULL /*CLFE*/, "Side"
3063 };
Matthew Ranostayd21995e2008-10-13 13:22:45 -04003064 hda_nid_t nid = 0;
Takashi Iwai91589232008-12-19 15:59:40 +01003065 int i, err;
3066 unsigned int wid_caps;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003067
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003068 for (i = 0; i < cfg->line_outs && spec->multiout.dac_nids[i]; i++) {
Mattc7d4b2f2005-06-27 14:59:41 +02003069 nid = spec->multiout.dac_nids[i];
Mattc7d4b2f2005-06-27 14:59:41 +02003070 if (i == 2) {
3071 /* Center/LFE */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003072 err = create_controls(codec, "Center", nid, 1);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003073 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003074 return err;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003075 err = create_controls(codec, "LFE", nid, 2);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003076 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003077 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003078
3079 wid_caps = get_wcaps(codec, nid);
3080
3081 if (wid_caps & AC_WCAP_LR_SWAP) {
3082 err = stac92xx_add_control(spec,
3083 STAC_CTL_WIDGET_CLFE_SWITCH,
3084 "Swap Center/LFE Playback Switch", nid);
3085
3086 if (err < 0)
3087 return err;
3088 }
3089
Mattc7d4b2f2005-06-27 14:59:41 +02003090 } else {
Takashi Iwai76624532008-12-19 10:09:47 +01003091 const char *name = chname[i];
3092 /* if it's a single DAC, assign a better name */
3093 if (!i && is_unique_dac(spec, nid)) {
3094 switch (cfg->line_out_type) {
3095 case AUTO_PIN_HP_OUT:
3096 name = "Headphone";
3097 break;
3098 case AUTO_PIN_SPEAKER_OUT:
3099 name = "Speaker";
3100 break;
3101 }
3102 }
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003103 err = create_controls(codec, name, nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003104 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003105 return err;
3106 }
3107 }
3108
Takashi Iwaia9cb5c92008-11-24 07:51:11 +01003109 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003110 err = stac92xx_add_control(spec,
3111 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01003112 "Headphone as Line Out Switch",
3113 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003114 if (err < 0)
3115 return err;
3116 }
3117
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003118 if (spec->line_switch) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003119 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
3120 "Line In as Output Switch",
3121 spec->line_switch << 8);
3122 if (err < 0)
3123 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003124 }
Matt Porter403d1942005-11-29 15:00:51 +01003125
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003126 if (spec->mic_switch) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003127 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
3128 "Mic as Output Switch",
3129 (spec->mic_switch << 8) | 1);
3130 if (err < 0)
3131 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003132 }
Matt Porter403d1942005-11-29 15:00:51 +01003133
Mattc7d4b2f2005-06-27 14:59:41 +02003134 return 0;
3135}
3136
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003137/* add playback controls for Speaker and HP outputs */
3138static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3139 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003140{
3141 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003142 hda_nid_t nid;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003143 int i, err, nums;
Mattc7d4b2f2005-06-27 14:59:41 +02003144
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003145 nums = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003146 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003147 static const char *pfxs[] = {
3148 "Headphone", "Headphone2", "Headphone3",
3149 };
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003150 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
3151 if (wid_caps & AC_WCAP_UNSOL_CAP)
3152 spec->hp_detect = 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003153 if (nums >= ARRAY_SIZE(pfxs))
Mattc7d4b2f2005-06-27 14:59:41 +02003154 continue;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003155 nid = spec->hp_dacs[i];
3156 if (!nid)
3157 continue;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003158 err = create_controls(codec, pfxs[nums++], nid, 3);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003159 if (err < 0)
3160 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003161 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003162 nums = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003163 for (i = 0; i < cfg->speaker_outs; i++) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003164 static const char *pfxs[] = {
3165 "Speaker", "External Speaker", "Speaker2",
3166 };
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003167 if (nums >= ARRAY_SIZE(pfxs))
3168 continue;
3169 nid = spec->speaker_dacs[i];
3170 if (!nid)
3171 continue;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003172 err = create_controls(codec, pfxs[nums++], nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003173 if (err < 0)
3174 return err;
3175 }
Mattc7d4b2f2005-06-27 14:59:41 +02003176 return 0;
3177}
3178
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003179/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003180static const char *stac92xx_mono_labels[4] = {
3181 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003182};
3183
3184/* create mono mux for mono out on capable codecs */
3185static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3186{
3187 struct sigmatel_spec *spec = codec->spec;
3188 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3189 int i, num_cons;
3190 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3191
3192 num_cons = snd_hda_get_connections(codec,
3193 spec->mono_nid,
3194 con_lst,
3195 HDA_MAX_NUM_INPUTS);
3196 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3197 return -EINVAL;
3198
3199 for (i = 0; i < num_cons; i++) {
3200 mono_mux->items[mono_mux->num_items].label =
3201 stac92xx_mono_labels[i];
3202 mono_mux->items[mono_mux->num_items].index = i;
3203 mono_mux->num_items++;
3204 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003205
3206 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3207 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003208}
3209
Matthew Ranostay89385032008-09-11 09:49:39 -04003210/* labels for amp mux outputs */
3211static const char *stac92xx_amp_labels[3] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04003212 "Front Microphone", "Microphone", "Line In",
Matthew Ranostay89385032008-09-11 09:49:39 -04003213};
3214
3215/* create amp out controls mux on capable codecs */
3216static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3217{
3218 struct sigmatel_spec *spec = codec->spec;
3219 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3220 int i, err;
3221
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003222 for (i = 0; i < spec->num_amps; i++) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003223 amp_mux->items[amp_mux->num_items].label =
3224 stac92xx_amp_labels[i];
3225 amp_mux->items[amp_mux->num_items].index = i;
3226 amp_mux->num_items++;
3227 }
3228
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003229 if (spec->num_amps > 1) {
3230 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3231 "Amp Selector Capture Switch", 0);
3232 if (err < 0)
3233 return err;
3234 }
Matthew Ranostay89385032008-09-11 09:49:39 -04003235 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3236 "Amp Capture Volume",
3237 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3238}
3239
3240
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003241/* create PC beep volume controls */
3242static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3243 hda_nid_t nid)
3244{
3245 struct sigmatel_spec *spec = codec->spec;
3246 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3247 int err;
3248
3249 /* check for mute support for the the amp */
3250 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3251 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3252 "PC Beep Playback Switch",
3253 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3254 if (err < 0)
3255 return err;
3256 }
3257
3258 /* check to see if there is volume support for the amp */
3259 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3260 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3261 "PC Beep Playback Volume",
3262 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3263 if (err < 0)
3264 return err;
3265 }
3266 return 0;
3267}
3268
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003269#ifdef CONFIG_SND_HDA_INPUT_BEEP
3270#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3271
3272static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3273 struct snd_ctl_elem_value *ucontrol)
3274{
3275 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3276 ucontrol->value.integer.value[0] = codec->beep->enabled;
3277 return 0;
3278}
3279
3280static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3281 struct snd_ctl_elem_value *ucontrol)
3282{
3283 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3284 int enabled = !!ucontrol->value.integer.value[0];
3285 if (codec->beep->enabled != enabled) {
3286 codec->beep->enabled = enabled;
3287 return 1;
3288 }
3289 return 0;
3290}
3291
3292static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3293 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3294 .info = stac92xx_dig_beep_switch_info,
3295 .get = stac92xx_dig_beep_switch_get,
3296 .put = stac92xx_dig_beep_switch_put,
3297};
3298
3299static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3300{
3301 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3302 0, "PC Beep Playback Switch", 0);
3303}
3304#endif
3305
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003306static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3307{
3308 struct sigmatel_spec *spec = codec->spec;
3309 int wcaps, nid, i, err = 0;
3310
3311 for (i = 0; i < spec->num_muxes; i++) {
3312 nid = spec->mux_nids[i];
3313 wcaps = get_wcaps(codec, nid);
3314
3315 if (wcaps & AC_WCAP_OUT_AMP) {
3316 err = stac92xx_add_control_idx(spec,
3317 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3318 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3319 if (err < 0)
3320 return err;
3321 }
3322 }
3323 return 0;
3324};
3325
Matthew Ranostayd9737752008-09-07 12:03:41 +02003326static const char *stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003327 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003328};
3329
3330static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3331{
3332 struct sigmatel_spec *spec = codec->spec;
3333 struct hda_input_mux *spdif_mux = &spec->private_smux;
Matthew Ranostay65973632008-09-16 10:39:37 -04003334 const char **labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003335 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003336 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003337
3338 num_cons = snd_hda_get_connections(codec,
3339 spec->smux_nids[0],
3340 con_lst,
3341 HDA_MAX_NUM_INPUTS);
Matthew Ranostay65973632008-09-16 10:39:37 -04003342 if (!num_cons)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003343 return -EINVAL;
3344
Matthew Ranostay65973632008-09-16 10:39:37 -04003345 if (!labels)
3346 labels = stac92xx_spdif_labels;
3347
Matthew Ranostayd9737752008-09-07 12:03:41 +02003348 for (i = 0; i < num_cons; i++) {
Matthew Ranostay65973632008-09-16 10:39:37 -04003349 spdif_mux->items[spdif_mux->num_items].label = labels[i];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003350 spdif_mux->items[spdif_mux->num_items].index = i;
3351 spdif_mux->num_items++;
3352 }
3353
3354 return 0;
3355}
3356
Matt Porter8b657272006-10-26 17:12:59 +02003357/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003358static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003359 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3360 "Digital Mic 3", "Digital Mic 4"
3361};
3362
3363/* create playback/capture controls for input pins on dmic capable codecs */
3364static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3365 const struct auto_pin_cfg *cfg)
3366{
3367 struct sigmatel_spec *spec = codec->spec;
3368 struct hda_input_mux *dimux = &spec->private_dimux;
3369 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003370 int err, i, j;
3371 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02003372
3373 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3374 dimux->items[dimux->num_items].index = 0;
3375 dimux->num_items++;
3376
3377 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003378 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003379 int index;
3380 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003381 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02003382 unsigned int def_conf;
3383
Takashi Iwai330ee992009-02-20 14:33:36 +01003384 def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
Matt Porter8b657272006-10-26 17:12:59 +02003385 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3386 continue;
3387
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003388 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02003389 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003390 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02003391 con_lst,
3392 HDA_MAX_NUM_INPUTS);
3393 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003394 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02003395 index = j;
3396 goto found;
3397 }
3398 continue;
3399found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003400 wcaps = get_wcaps(codec, nid) &
3401 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003402
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003403 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003404 sprintf(name, "%s Capture Volume",
3405 stac92xx_dmic_labels[dimux->num_items]);
3406
3407 err = stac92xx_add_control(spec,
3408 STAC_CTL_WIDGET_VOL,
3409 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003410 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3411 (wcaps & AC_WCAP_OUT_AMP) ?
3412 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003413 if (err < 0)
3414 return err;
3415 }
3416
Matt Porter8b657272006-10-26 17:12:59 +02003417 dimux->items[dimux->num_items].label =
3418 stac92xx_dmic_labels[dimux->num_items];
3419 dimux->items[dimux->num_items].index = index;
3420 dimux->num_items++;
3421 }
3422
3423 return 0;
3424}
3425
Mattc7d4b2f2005-06-27 14:59:41 +02003426/* create playback/capture controls for input pins */
3427static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3428{
3429 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003430 struct hda_input_mux *imux = &spec->private_imux;
3431 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3432 int i, j, k;
3433
3434 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003435 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02003436
Takashi Iwai314634b2006-09-21 11:56:18 +02003437 if (!cfg->input_pins[i])
3438 continue;
3439 index = -1;
3440 for (j = 0; j < spec->num_muxes; j++) {
3441 int num_cons;
3442 num_cons = snd_hda_get_connections(codec,
3443 spec->mux_nids[j],
3444 con_lst,
3445 HDA_MAX_NUM_INPUTS);
3446 for (k = 0; k < num_cons; k++)
3447 if (con_lst[k] == cfg->input_pins[i]) {
3448 index = k;
3449 goto found;
3450 }
Mattc7d4b2f2005-06-27 14:59:41 +02003451 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003452 continue;
3453 found:
3454 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3455 imux->items[imux->num_items].index = index;
3456 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003457 }
3458
Steve Longerbeam7b043892007-05-03 20:50:03 +02003459 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003460 /*
3461 * Set the current input for the muxes.
3462 * The STAC9221 has two input muxes with identical source
3463 * NID lists. Hopefully this won't get confused.
3464 */
3465 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003466 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3467 AC_VERB_SET_CONNECT_SEL,
3468 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003469 }
3470 }
3471
Mattc7d4b2f2005-06-27 14:59:41 +02003472 return 0;
3473}
3474
Mattc7d4b2f2005-06-27 14:59:41 +02003475static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3476{
3477 struct sigmatel_spec *spec = codec->spec;
3478 int i;
3479
3480 for (i = 0; i < spec->autocfg.line_outs; i++) {
3481 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3482 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3483 }
3484}
3485
3486static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3487{
3488 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003489 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003490
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003491 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3492 hda_nid_t pin;
3493 pin = spec->autocfg.hp_pins[i];
3494 if (pin) /* connect to front */
3495 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3496 }
3497 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3498 hda_nid_t pin;
3499 pin = spec->autocfg.speaker_pins[i];
3500 if (pin) /* connect to front */
3501 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3502 }
Mattc7d4b2f2005-06-27 14:59:41 +02003503}
3504
Matt Porter3cc08dc2006-01-23 15:27:49 +01003505static 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 +02003506{
3507 struct sigmatel_spec *spec = codec->spec;
3508 int err;
3509
Matt Porter8b657272006-10-26 17:12:59 +02003510 if ((err = snd_hda_parse_pin_def_config(codec,
3511 &spec->autocfg,
3512 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003513 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003514 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003515 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003516
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003517 /* If we have no real line-out pin and multiple hp-outs, HPs should
3518 * be set up as multi-channel outputs.
3519 */
3520 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3521 spec->autocfg.hp_outs > 1) {
3522 /* Copy hp_outs to line_outs, backup line_outs in
3523 * speaker_outs so that the following routines can handle
3524 * HP pins as primary outputs.
3525 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003526 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003527 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3528 sizeof(spec->autocfg.line_out_pins));
3529 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3530 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3531 sizeof(spec->autocfg.hp_pins));
3532 spec->autocfg.line_outs = spec->autocfg.hp_outs;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003533 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3534 spec->autocfg.hp_outs = 0;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003535 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003536 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003537 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3538 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003539 u32 caps = query_amp_caps(codec,
3540 spec->autocfg.mono_out_pin, dir);
3541 hda_nid_t conn_list[1];
3542
3543 /* get the mixer node and then the mono mux if it exists */
3544 if (snd_hda_get_connections(codec,
3545 spec->autocfg.mono_out_pin, conn_list, 1) &&
3546 snd_hda_get_connections(codec, conn_list[0],
3547 conn_list, 1)) {
3548
3549 int wcaps = get_wcaps(codec, conn_list[0]);
3550 int wid_type = (wcaps & AC_WCAP_TYPE)
3551 >> AC_WCAP_TYPE_SHIFT;
3552 /* LR swap check, some stac925x have a mux that
3553 * changes the DACs output path instead of the
3554 * mono-mux path.
3555 */
3556 if (wid_type == AC_WID_AUD_SEL &&
3557 !(wcaps & AC_WCAP_LR_SWAP))
3558 spec->mono_nid = conn_list[0];
3559 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003560 if (dir) {
3561 hda_nid_t nid = spec->autocfg.mono_out_pin;
3562
3563 /* most mono outs have a least a mute/unmute switch */
3564 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3565 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3566 "Mono Playback Switch",
3567 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003568 if (err < 0)
3569 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003570 /* check for volume support for the amp */
3571 if ((caps & AC_AMPCAP_NUM_STEPS)
3572 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3573 err = stac92xx_add_control(spec,
3574 STAC_CTL_WIDGET_VOL,
3575 "Mono Playback Volume",
3576 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3577 if (err < 0)
3578 return err;
3579 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003580 }
3581
3582 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3583 AC_PINCTL_OUT_EN);
3584 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003585
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003586 if (!spec->multiout.num_dacs) {
3587 err = stac92xx_auto_fill_dac_nids(codec);
3588 if (err < 0)
Takashi Iwai19039bd2006-06-28 15:52:16 +02003589 return err;
Takashi Iwaic9280d62009-01-15 17:31:00 +01003590 err = stac92xx_auto_create_multi_out_ctls(codec,
3591 &spec->autocfg);
3592 if (err < 0)
3593 return err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003594 }
Mattc7d4b2f2005-06-27 14:59:41 +02003595
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003596 /* setup analog beep controls */
3597 if (spec->anabeep_nid > 0) {
3598 err = stac92xx_auto_create_beep_ctls(codec,
3599 spec->anabeep_nid);
3600 if (err < 0)
3601 return err;
3602 }
3603
3604 /* setup digital beep controls and input device */
3605#ifdef CONFIG_SND_HDA_INPUT_BEEP
3606 if (spec->digbeep_nid > 0) {
3607 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003608 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003609
3610 err = stac92xx_auto_create_beep_ctls(codec, nid);
3611 if (err < 0)
3612 return err;
3613 err = snd_hda_attach_beep_device(codec, nid);
3614 if (err < 0)
3615 return err;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003616 /* if no beep switch is available, make its own one */
3617 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3618 if (codec->beep &&
3619 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3620 err = stac92xx_beep_switch_ctl(codec);
3621 if (err < 0)
3622 return err;
3623 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003624 }
3625#endif
3626
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003627 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3628
3629 if (err < 0)
3630 return err;
3631
3632 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3633
3634 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003635 return err;
3636
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003637 if (spec->mono_nid > 0) {
3638 err = stac92xx_auto_create_mono_output_ctls(codec);
3639 if (err < 0)
3640 return err;
3641 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003642 if (spec->num_amps > 0) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003643 err = stac92xx_auto_create_amp_output_ctls(codec);
3644 if (err < 0)
3645 return err;
3646 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003647 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003648 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3649 &spec->autocfg)) < 0)
3650 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003651 if (spec->num_muxes > 0) {
3652 err = stac92xx_auto_create_mux_input_ctls(codec);
3653 if (err < 0)
3654 return err;
3655 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003656 if (spec->num_smuxes > 0) {
3657 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3658 if (err < 0)
3659 return err;
3660 }
Matt Porter8b657272006-10-26 17:12:59 +02003661
Takashi Iwaie3c75962009-01-23 11:57:22 +01003662 err = stac92xx_add_input_source(spec);
3663 if (err < 0)
3664 return err;
3665
Mattc7d4b2f2005-06-27 14:59:41 +02003666 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003667 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003668 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003669
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003670 if (spec->autocfg.dig_outs)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003671 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003672 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003673 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003674
Takashi Iwai603c4012008-07-30 15:01:44 +02003675 if (spec->kctls.list)
3676 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003677
3678 spec->input_mux = &spec->private_imux;
Matthew Ranostayf8ccbf62008-12-20 17:36:28 -05003679 if (!spec->dinput_mux)
3680 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003681 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003682 spec->mono_mux = &spec->private_mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -04003683 spec->amp_mux = &spec->private_amp_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003684 return 1;
3685}
3686
Takashi Iwai82bc9552006-03-21 11:24:42 +01003687/* add playback controls for HP output */
3688static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3689 struct auto_pin_cfg *cfg)
3690{
3691 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003692 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003693 unsigned int wid_caps;
3694
3695 if (! pin)
3696 return 0;
3697
3698 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003699 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003700 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003701
3702 return 0;
3703}
3704
Richard Fish160ea0d2006-09-06 13:58:25 +02003705/* add playback controls for LFE output */
3706static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3707 struct auto_pin_cfg *cfg)
3708{
3709 struct sigmatel_spec *spec = codec->spec;
3710 int err;
3711 hda_nid_t lfe_pin = 0x0;
3712 int i;
3713
3714 /*
3715 * search speaker outs and line outs for a mono speaker pin
3716 * with an amp. If one is found, add LFE controls
3717 * for it.
3718 */
3719 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3720 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003721 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003722 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3723 if (wcaps == AC_WCAP_OUT_AMP)
3724 /* found a mono speaker with an amp, must be lfe */
3725 lfe_pin = pin;
3726 }
3727
3728 /* if speaker_outs is 0, then speakers may be in line_outs */
3729 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3730 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3731 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003732 unsigned int defcfg;
Takashi Iwai330ee992009-02-20 14:33:36 +01003733 defcfg = snd_hda_codec_get_pincfg(codec, pin);
Harvey Harrison8b551782008-02-29 11:56:48 +01003734 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003735 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003736 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3737 if (wcaps == AC_WCAP_OUT_AMP)
3738 /* found a mono speaker with an amp,
3739 must be lfe */
3740 lfe_pin = pin;
3741 }
3742 }
3743 }
3744
3745 if (lfe_pin) {
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003746 err = create_controls(codec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003747 if (err < 0)
3748 return err;
3749 }
3750
3751 return 0;
3752}
3753
Mattc7d4b2f2005-06-27 14:59:41 +02003754static int stac9200_parse_auto_config(struct hda_codec *codec)
3755{
3756 struct sigmatel_spec *spec = codec->spec;
3757 int err;
3758
Kailang Yangdf694da2005-12-05 19:42:22 +01003759 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003760 return err;
3761
3762 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3763 return err;
3764
Takashi Iwai82bc9552006-03-21 11:24:42 +01003765 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3766 return err;
3767
Richard Fish160ea0d2006-09-06 13:58:25 +02003768 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3769 return err;
3770
Takashi Iwai355a0ec2008-11-11 16:46:19 +01003771 if (spec->num_muxes > 0) {
3772 err = stac92xx_auto_create_mux_input_ctls(codec);
3773 if (err < 0)
3774 return err;
3775 }
3776
Takashi Iwaie3c75962009-01-23 11:57:22 +01003777 err = stac92xx_add_input_source(spec);
3778 if (err < 0)
3779 return err;
3780
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003781 if (spec->autocfg.dig_outs)
Mattc7d4b2f2005-06-27 14:59:41 +02003782 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003783 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003784 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003785
Takashi Iwai603c4012008-07-30 15:01:44 +02003786 if (spec->kctls.list)
3787 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003788
3789 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003790 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003791
3792 return 1;
3793}
3794
Sam Revitch62fe78e2006-05-10 15:09:17 +02003795/*
3796 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3797 * funky external mute control using GPIO pins.
3798 */
3799
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003800static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003801 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003802{
3803 unsigned int gpiostate, gpiomask, gpiodir;
3804
3805 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3806 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003807 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003808
3809 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3810 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003811 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003812
3813 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3814 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003815 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003816
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003817 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003818 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3819
3820 snd_hda_codec_write(codec, codec->afg, 0,
3821 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003822 snd_hda_codec_read(codec, codec->afg, 0,
3823 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003824
3825 msleep(1);
3826
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003827 snd_hda_codec_read(codec, codec->afg, 0,
3828 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003829}
3830
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003831static int stac92xx_add_jack(struct hda_codec *codec,
3832 hda_nid_t nid, int type)
3833{
Takashi Iwaie4973e12008-11-18 09:32:42 +01003834#ifdef CONFIG_SND_JACK
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003835 struct sigmatel_spec *spec = codec->spec;
3836 struct sigmatel_jack *jack;
Takashi Iwai330ee992009-02-20 14:33:36 +01003837 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003838 int connectivity = get_defcfg_connect(def_conf);
3839 char name[32];
3840
3841 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
3842 return 0;
3843
3844 snd_array_init(&spec->jacks, sizeof(*jack), 32);
3845 jack = snd_array_new(&spec->jacks);
3846 if (!jack)
3847 return -ENOMEM;
3848 jack->nid = nid;
3849 jack->type = type;
3850
3851 sprintf(name, "%s at %s %s Jack",
3852 snd_hda_get_jack_type(def_conf),
3853 snd_hda_get_jack_connectivity(def_conf),
3854 snd_hda_get_jack_location(def_conf));
3855
3856 return snd_jack_new(codec->bus->card, name, type, &jack->jack);
Takashi Iwaie4973e12008-11-18 09:32:42 +01003857#else
3858 return 0;
3859#endif
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003860}
3861
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003862static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
3863 unsigned char type, int data)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003864{
3865 struct sigmatel_event *event;
3866
3867 snd_array_init(&spec->events, sizeof(*event), 32);
3868 event = snd_array_new(&spec->events);
3869 if (!event)
3870 return -ENOMEM;
3871 event->nid = nid;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003872 event->type = type;
3873 event->tag = spec->events.used;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003874 event->data = data;
3875
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003876 return event->tag;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003877}
3878
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003879static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
3880 hda_nid_t nid, unsigned char type)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003881{
3882 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003883 struct sigmatel_event *event = spec->events.list;
3884 int i;
3885
3886 for (i = 0; i < spec->events.used; i++, event++) {
3887 if (event->nid == nid && event->type == type)
3888 return event;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003889 }
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003890 return NULL;
3891}
3892
3893static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
3894 unsigned char tag)
3895{
3896 struct sigmatel_spec *spec = codec->spec;
3897 struct sigmatel_event *event = spec->events.list;
3898 int i;
3899
3900 for (i = 0; i < spec->events.used; i++, event++) {
3901 if (event->tag == tag)
3902 return event;
3903 }
3904 return NULL;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003905}
3906
Takashi Iwai314634b2006-09-21 11:56:18 +02003907static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003908 unsigned int type)
Takashi Iwai314634b2006-09-21 11:56:18 +02003909{
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003910 struct sigmatel_event *event;
3911 int tag;
3912
3913 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
3914 return;
3915 event = stac_get_event(codec, nid, type);
3916 if (event)
3917 tag = event->tag;
3918 else
3919 tag = stac_add_event(codec->spec, nid, type, 0);
3920 if (tag < 0)
3921 return;
3922 snd_hda_codec_write_cache(codec, nid, 0,
3923 AC_VERB_SET_UNSOLICITED_ENABLE,
3924 AC_USRSP_EN | tag);
Takashi Iwai314634b2006-09-21 11:56:18 +02003925}
3926
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003927static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3928{
3929 int i;
3930 for (i = 0; i < cfg->hp_outs; i++)
3931 if (cfg->hp_pins[i] == nid)
3932 return 1; /* nid is a HP-Out */
3933
3934 return 0; /* nid is not a HP-Out */
3935};
3936
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003937static void stac92xx_power_down(struct hda_codec *codec)
3938{
3939 struct sigmatel_spec *spec = codec->spec;
3940
3941 /* power down inactive DACs */
3942 hda_nid_t *dac;
3943 for (dac = spec->dac_list; *dac; dac++)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003944 if (!check_all_dac_nids(spec, *dac))
Takashi Iwai8c2f7672008-12-01 11:54:35 +01003945 snd_hda_codec_write(codec, *dac, 0,
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003946 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3947}
3948
Takashi Iwaif73d3582008-11-25 08:21:51 +01003949static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
3950 int enable);
3951
Mattc7d4b2f2005-06-27 14:59:41 +02003952static int stac92xx_init(struct hda_codec *codec)
3953{
3954 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003955 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01003956 unsigned int gpio;
Takashi Iwaie4973e12008-11-18 09:32:42 +01003957 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003958
Mattc7d4b2f2005-06-27 14:59:41 +02003959 snd_hda_sequence_write(codec, spec->init);
3960
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003961 /* power down adcs initially */
3962 if (spec->powerdown_adcs)
3963 for (i = 0; i < spec->num_adcs; i++)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01003964 snd_hda_codec_write(codec,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003965 spec->adc_nids[i], 0,
3966 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01003967
3968 /* set up GPIO */
3969 gpio = spec->gpio_data;
3970 /* turn on EAPD statically when spec->eapd_switch isn't set.
3971 * otherwise, unsol event will turn it on/off dynamically
3972 */
3973 if (!spec->eapd_switch)
3974 gpio |= spec->eapd_mask;
3975 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
3976
Takashi Iwai82bc9552006-03-21 11:24:42 +01003977 /* set up pins */
3978 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02003979 /* Enable unsolicited responses on the HP widget */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003980 for (i = 0; i < cfg->hp_outs; i++) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003981 hda_nid_t nid = cfg->hp_pins[i];
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003982 enable_pin_detect(codec, nid, STAC_HP_EVENT);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003983 }
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01003984 /* force to enable the first line-out; the others are set up
3985 * in unsol_event
3986 */
3987 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003988 AC_PINCTL_OUT_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003989 /* fake event to set up pins */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003990 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
3991 STAC_HP_EVENT);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003992 } else {
3993 stac92xx_auto_init_multi_out(codec);
3994 stac92xx_auto_init_hp_out(codec);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01003995 for (i = 0; i < cfg->hp_outs; i++)
3996 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003997 }
3998 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01003999 hda_nid_t nid = cfg->input_pins[i];
4000 if (nid) {
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004001 unsigned int pinctl, conf;
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004002 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
4003 /* for mic pins, force to initialize */
4004 pinctl = stac92xx_get_vref(codec, nid);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004005 pinctl |= AC_PINCTL_IN_EN;
4006 stac92xx_auto_set_pinctl(codec, nid, pinctl);
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004007 } else {
4008 pinctl = snd_hda_codec_read(codec, nid, 0,
4009 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4010 /* if PINCTL already set then skip */
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004011 if (!(pinctl & AC_PINCTL_IN_EN)) {
4012 pinctl |= AC_PINCTL_IN_EN;
4013 stac92xx_auto_set_pinctl(codec, nid,
4014 pinctl);
4015 }
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004016 }
Takashi Iwai330ee992009-02-20 14:33:36 +01004017 conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004018 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4019 enable_pin_detect(codec, nid,
4020 STAC_INSERT_EVENT);
4021 stac_issue_unsol_event(codec, nid,
4022 STAC_INSERT_EVENT);
4023 }
Takashi Iwaic960a032006-03-23 17:06:28 +01004024 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01004025 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004026 for (i = 0; i < spec->num_dmics; i++)
4027 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4028 AC_PINCTL_IN_EN);
Takashi Iwai0852d7a2009-02-11 11:35:15 +01004029 if (cfg->dig_out_pins[0])
4030 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
Takashi Iwai82bc9552006-03-21 11:24:42 +01004031 AC_PINCTL_OUT_EN);
4032 if (cfg->dig_in_pin)
4033 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4034 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004035 for (i = 0; i < spec->num_pwrs; i++) {
4036 hda_nid_t nid = spec->pwr_nids[i];
4037 int pinctl, def_conf;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004038
Takashi Iwaieb632122008-12-19 16:39:48 +01004039 /* power on when no jack detection is available */
4040 if (!spec->hp_detect) {
4041 stac_toggle_power_map(codec, nid, 1);
4042 continue;
4043 }
4044
4045 if (is_nid_hp_pin(cfg, nid))
Takashi Iwaif73d3582008-11-25 08:21:51 +01004046 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004047
Takashi Iwaif73d3582008-11-25 08:21:51 +01004048 pinctl = snd_hda_codec_read(codec, nid, 0,
4049 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4050 /* outputs are only ports capable of power management
4051 * any attempts on powering down a input port cause the
4052 * referenced VREF to act quirky.
4053 */
Takashi Iwaieb632122008-12-19 16:39:48 +01004054 if (pinctl & AC_PINCTL_IN_EN) {
4055 stac_toggle_power_map(codec, nid, 1);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004056 continue;
Takashi Iwaieb632122008-12-19 16:39:48 +01004057 }
Takashi Iwai330ee992009-02-20 14:33:36 +01004058 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004059 def_conf = get_defcfg_connect(def_conf);
4060 /* skip any ports that don't have jacks since presence
4061 * detection is useless */
4062 if (def_conf != AC_JACK_PORT_COMPLEX) {
4063 if (def_conf != AC_JACK_PORT_NONE)
4064 stac_toggle_power_map(codec, nid, 1);
4065 continue;
4066 }
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004067 if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) {
4068 enable_pin_detect(codec, nid, STAC_PWR_EVENT);
4069 stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT);
4070 }
Takashi Iwaif73d3582008-11-25 08:21:51 +01004071 }
4072 if (spec->dac_list)
4073 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02004074 return 0;
4075}
4076
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004077static void stac92xx_free_jacks(struct hda_codec *codec)
4078{
Takashi Iwaie4973e12008-11-18 09:32:42 +01004079#ifdef CONFIG_SND_JACK
Takashi Iwaib94d3532008-11-21 09:08:06 +01004080 /* free jack instances manually when clearing/reconfiguring */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004081 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaib94d3532008-11-21 09:08:06 +01004082 if (!codec->bus->shutdown && spec->jacks.list) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004083 struct sigmatel_jack *jacks = spec->jacks.list;
4084 int i;
4085 for (i = 0; i < spec->jacks.used; i++)
4086 snd_device_free(codec->bus->card, &jacks[i].jack);
4087 }
4088 snd_array_free(&spec->jacks);
Takashi Iwaie4973e12008-11-18 09:32:42 +01004089#endif
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004090}
4091
Takashi Iwai603c4012008-07-30 15:01:44 +02004092static void stac92xx_free_kctls(struct hda_codec *codec)
4093{
4094 struct sigmatel_spec *spec = codec->spec;
4095
4096 if (spec->kctls.list) {
4097 struct snd_kcontrol_new *kctl = spec->kctls.list;
4098 int i;
4099 for (i = 0; i < spec->kctls.used; i++)
4100 kfree(kctl[i].name);
4101 }
4102 snd_array_free(&spec->kctls);
4103}
4104
Matt2f2f4252005-04-13 14:45:30 +02004105static void stac92xx_free(struct hda_codec *codec)
4106{
Mattc7d4b2f2005-06-27 14:59:41 +02004107 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004108
4109 if (! spec)
4110 return;
4111
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004112 stac92xx_free_jacks(codec);
4113 snd_array_free(&spec->events);
Richard Fish11b44bb2006-08-23 18:31:34 +02004114
Mattc7d4b2f2005-06-27 14:59:41 +02004115 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004116 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02004117}
4118
Matt4e550962005-07-04 17:51:39 +02004119static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4120 unsigned int flag)
4121{
Takashi Iwai8ce841982009-01-22 16:59:20 +01004122 unsigned int old_ctl, pin_ctl;
4123
4124 pin_ctl = snd_hda_codec_read(codec, nid,
Matt4e550962005-07-04 17:51:39 +02004125 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02004126
Takashi Iwaif9acba42007-05-29 18:01:06 +02004127 if (pin_ctl & AC_PINCTL_IN_EN) {
4128 /*
4129 * we need to check the current set-up direction of
4130 * shared input pins since they can be switched via
4131 * "xxx as Output" mixer switch
4132 */
4133 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004134 if (nid == spec->line_switch || nid == spec->mic_switch)
Takashi Iwaif9acba42007-05-29 18:01:06 +02004135 return;
4136 }
4137
Takashi Iwai8ce841982009-01-22 16:59:20 +01004138 old_ctl = pin_ctl;
Steve Longerbeam7b043892007-05-03 20:50:03 +02004139 /* if setting pin direction bits, clear the current
4140 direction bits first */
4141 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4142 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4143
Takashi Iwai8ce841982009-01-22 16:59:20 +01004144 pin_ctl |= flag;
4145 if (old_ctl != pin_ctl)
4146 snd_hda_codec_write_cache(codec, nid, 0,
4147 AC_VERB_SET_PIN_WIDGET_CONTROL,
4148 pin_ctl);
Matt4e550962005-07-04 17:51:39 +02004149}
4150
4151static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4152 unsigned int flag)
4153{
4154 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4155 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai8ce841982009-01-22 16:59:20 +01004156 if (pin_ctl & flag)
4157 snd_hda_codec_write_cache(codec, nid, 0,
4158 AC_VERB_SET_PIN_WIDGET_CONTROL,
4159 pin_ctl & ~flag);
Matt4e550962005-07-04 17:51:39 +02004160}
4161
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004162static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02004163{
4164 if (!nid)
4165 return 0;
4166 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004167 & (1 << 31))
4168 return 1;
Takashi Iwai314634b2006-09-21 11:56:18 +02004169 return 0;
4170}
4171
Takashi Iwaid7a89432008-11-12 09:48:04 +01004172/* return non-zero if the hp-pin of the given array index isn't
4173 * a jack-detection target
4174 */
4175static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4176{
4177 struct auto_pin_cfg *cfg = &spec->autocfg;
4178
4179 /* ignore sensing of shared line and mic jacks */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004180 if (cfg->hp_pins[i] == spec->line_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004181 return 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004182 if (cfg->hp_pins[i] == spec->mic_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004183 return 1;
4184 /* ignore if the pin is set as line-out */
4185 if (cfg->hp_pins[i] == spec->hp_switch)
4186 return 1;
4187 return 0;
4188}
4189
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004190static void stac92xx_hp_detect(struct hda_codec *codec)
Matt4e550962005-07-04 17:51:39 +02004191{
4192 struct sigmatel_spec *spec = codec->spec;
4193 struct auto_pin_cfg *cfg = &spec->autocfg;
4194 int i, presence;
4195
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004196 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004197 if (spec->gpio_mute)
4198 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4199 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4200
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004201 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004202 if (presence)
4203 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01004204 if (no_hp_sensing(spec, i))
4205 continue;
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004206 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4207 if (presence) {
4208 unsigned int pinctl;
4209 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4210 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4211 if (pinctl & AC_PINCTL_IN_EN)
4212 presence = 0; /* mic- or line-input */
4213 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004214 }
Matt4e550962005-07-04 17:51:39 +02004215
4216 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004217 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004218 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004219 stac92xx_reset_pinctl(codec, spec->hp_switch,
4220 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004221 for (i = 0; i < cfg->line_outs; i++)
4222 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4223 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004224 for (i = 0; i < cfg->speaker_outs; i++)
4225 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4226 AC_PINCTL_OUT_EN);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004227 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004228 stac_gpio_set(codec, spec->gpio_mask,
4229 spec->gpio_dir, spec->gpio_data &
4230 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02004231 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004232 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004233 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004234 stac92xx_set_pinctl(codec, spec->hp_switch,
4235 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004236 for (i = 0; i < cfg->line_outs; i++)
4237 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4238 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004239 for (i = 0; i < cfg->speaker_outs; i++)
4240 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4241 AC_PINCTL_OUT_EN);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004242 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004243 stac_gpio_set(codec, spec->gpio_mask,
4244 spec->gpio_dir, spec->gpio_data |
4245 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02004246 }
Takashi Iwaid7a89432008-11-12 09:48:04 +01004247 /* toggle hp outs */
4248 for (i = 0; i < cfg->hp_outs; i++) {
4249 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4250 if (no_hp_sensing(spec, i))
4251 continue;
4252 if (presence)
4253 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004254#if 0 /* FIXME */
4255/* Resetting the pinctl like below may lead to (a sort of) regressions
4256 * on some devices since they use the HP pin actually for line/speaker
4257 * outs although the default pin config shows a different pin (that is
4258 * wrong and useless).
4259 *
4260 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4261 * But, disabling the code below just works around it, and I'm too tired of
4262 * bug reports with such devices...
4263 */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004264 else
4265 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004266#endif /* FIXME */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004267 }
Matt4e550962005-07-04 17:51:39 +02004268}
4269
Takashi Iwaif73d3582008-11-25 08:21:51 +01004270static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4271 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004272{
4273 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004274 unsigned int idx, val;
4275
4276 for (idx = 0; idx < spec->num_pwrs; idx++) {
4277 if (spec->pwr_nids[idx] == nid)
4278 break;
4279 }
4280 if (idx >= spec->num_pwrs)
4281 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004282
4283 /* several codecs have two power down bits */
4284 if (spec->pwr_mapping)
4285 idx = spec->pwr_mapping[idx];
4286 else
4287 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004288
Takashi Iwaif73d3582008-11-25 08:21:51 +01004289 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4290 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004291 val &= ~idx;
4292 else
4293 val |= idx;
4294
4295 /* power down unused output ports */
4296 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004297}
4298
Takashi Iwaif73d3582008-11-25 08:21:51 +01004299static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4300{
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004301 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
Takashi Iwaif73d3582008-11-25 08:21:51 +01004302}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004303
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004304static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4305{
4306 struct sigmatel_spec *spec = codec->spec;
4307 struct sigmatel_jack *jacks = spec->jacks.list;
4308
4309 if (jacks) {
4310 int i;
4311 for (i = 0; i < spec->jacks.used; i++) {
4312 if (jacks->nid == nid) {
4313 unsigned int pin_ctl =
4314 snd_hda_codec_read(codec, nid,
4315 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4316 0x00);
4317 int type = jacks->type;
4318 if (type == (SND_JACK_LINEOUT
4319 | SND_JACK_HEADPHONE))
4320 type = (pin_ctl & AC_PINCTL_HP_EN)
4321 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4322 snd_jack_report(jacks->jack,
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004323 get_pin_presence(codec, nid)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004324 ? type : 0);
4325 }
4326 jacks++;
4327 }
4328 }
4329}
Matt2f2f4252005-04-13 14:45:30 +02004330
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004331static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
4332 unsigned char type)
4333{
4334 struct sigmatel_event *event = stac_get_event(codec, nid, type);
4335 if (!event)
4336 return;
4337 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4338}
4339
Takashi Iwai314634b2006-09-21 11:56:18 +02004340static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4341{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004342 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004343 struct sigmatel_event *event;
4344 int tag, data;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004345
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004346 tag = (res >> 26) & 0x7f;
4347 event = stac_get_event_from_tag(codec, tag);
4348 if (!event)
4349 return;
4350
4351 switch (event->type) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004352 case STAC_HP_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004353 stac92xx_hp_detect(codec);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004354 /* fallthru */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004355 case STAC_INSERT_EVENT:
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004356 case STAC_PWR_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004357 if (spec->num_pwrs > 0)
4358 stac92xx_pin_sense(codec, event->nid);
4359 stac92xx_report_jack(codec, event->nid);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004360 break;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004361 case STAC_VREF_EVENT:
4362 data = snd_hda_codec_read(codec, codec->afg, 0,
4363 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004364 /* toggle VREF state based on GPIOx status */
4365 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004366 !!(data & (1 << event->data)));
Matthew Ranostay72474be2008-10-09 09:32:17 -04004367 break;
Takashi Iwai314634b2006-09-21 11:56:18 +02004368 }
4369}
4370
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004371#ifdef CONFIG_PROC_FS
4372static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4373 struct hda_codec *codec, hda_nid_t nid)
4374{
4375 if (nid == codec->afg)
4376 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4377 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4378}
4379
4380static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4381 struct hda_codec *codec,
4382 unsigned int verb)
4383{
4384 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4385 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4386}
4387
4388/* stac92hd71bxx, stac92hd73xx */
4389static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4390 struct hda_codec *codec, hda_nid_t nid)
4391{
4392 stac92hd_proc_hook(buffer, codec, nid);
4393 if (nid == codec->afg)
4394 analog_loop_proc_hook(buffer, codec, 0xfa0);
4395}
4396
4397static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4398 struct hda_codec *codec, hda_nid_t nid)
4399{
4400 if (nid == codec->afg)
4401 analog_loop_proc_hook(buffer, codec, 0xfe0);
4402}
4403
4404static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4405 struct hda_codec *codec, hda_nid_t nid)
4406{
4407 if (nid == codec->afg)
4408 analog_loop_proc_hook(buffer, codec, 0xfeb);
4409}
4410#else
4411#define stac92hd_proc_hook NULL
4412#define stac92hd7x_proc_hook NULL
4413#define stac9205_proc_hook NULL
4414#define stac927x_proc_hook NULL
4415#endif
4416
Takashi Iwaicb53c622007-08-10 17:21:45 +02004417#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004418static int stac92xx_resume(struct hda_codec *codec)
4419{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004420 struct sigmatel_spec *spec = codec->spec;
4421
Takashi Iwai2c885872008-11-18 09:36:55 +01004422 stac92xx_init(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004423 snd_hda_codec_resume_amp(codec);
4424 snd_hda_codec_resume_cache(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01004425 /* fake event to set up pins again to override cached values */
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004426 if (spec->hp_detect)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004427 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4428 STAC_HP_EVENT);
Mattff6fdc32005-06-27 15:06:52 +02004429 return 0;
4430}
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004431
4432static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4433{
4434 struct sigmatel_spec *spec = codec->spec;
4435 if (spec->eapd_mask)
4436 stac_gpio_set(codec, spec->gpio_mask,
4437 spec->gpio_dir, spec->gpio_data &
4438 ~spec->eapd_mask);
4439 return 0;
4440}
Mattff6fdc32005-06-27 15:06:52 +02004441#endif
4442
Matt2f2f4252005-04-13 14:45:30 +02004443static struct hda_codec_ops stac92xx_patch_ops = {
4444 .build_controls = stac92xx_build_controls,
4445 .build_pcms = stac92xx_build_pcms,
4446 .init = stac92xx_init,
4447 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02004448 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004449#ifdef SND_HDA_NEEDS_RESUME
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004450 .suspend = stac92xx_suspend,
Mattff6fdc32005-06-27 15:06:52 +02004451 .resume = stac92xx_resume,
4452#endif
Matt2f2f4252005-04-13 14:45:30 +02004453};
4454
4455static int patch_stac9200(struct hda_codec *codec)
4456{
4457 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004458 int err;
Matt2f2f4252005-04-13 14:45:30 +02004459
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004460 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004461 if (spec == NULL)
4462 return -ENOMEM;
4463
4464 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004465 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004466 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004467 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4468 stac9200_models,
4469 stac9200_cfg_tbl);
Takashi Iwai330ee992009-02-20 14:33:36 +01004470 if (spec->board_config < 0)
Richard Fish11b44bb2006-08-23 18:31:34 +02004471 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01004472 else
4473 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004474 stac9200_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02004475
4476 spec->multiout.max_channels = 2;
4477 spec->multiout.num_dacs = 1;
4478 spec->multiout.dac_nids = stac9200_dac_nids;
4479 spec->adc_nids = stac9200_adc_nids;
4480 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02004481 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02004482 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004483 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004484 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004485
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02004486 if (spec->board_config == STAC_9200_M4 ||
4487 spec->board_config == STAC_9200_M4_2 ||
Tobin Davisbf277782008-02-03 20:31:47 +01004488 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02004489 spec->init = stac9200_eapd_init;
4490 else
4491 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004492 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004493
Takashi Iwai117f2572008-03-18 09:53:23 +01004494 if (spec->board_config == STAC_9200_PANASONIC) {
4495 spec->gpio_mask = spec->gpio_dir = 0x09;
4496 spec->gpio_data = 0x00;
4497 }
4498
Mattc7d4b2f2005-06-27 14:59:41 +02004499 err = stac9200_parse_auto_config(codec);
4500 if (err < 0) {
4501 stac92xx_free(codec);
4502 return err;
4503 }
Matt2f2f4252005-04-13 14:45:30 +02004504
Takashi Iwai2acc9dc2009-01-09 16:57:14 +01004505 /* CF-74 has no headphone detection, and the driver should *NOT*
4506 * do detection and HP/speaker toggle because the hardware does it.
4507 */
4508 if (spec->board_config == STAC_9200_PANASONIC)
4509 spec->hp_detect = 0;
4510
Matt2f2f4252005-04-13 14:45:30 +02004511 codec->patch_ops = stac92xx_patch_ops;
4512
4513 return 0;
4514}
4515
Tobin Davis8e21c342007-01-08 11:04:17 +01004516static int patch_stac925x(struct hda_codec *codec)
4517{
4518 struct sigmatel_spec *spec;
4519 int err;
4520
4521 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4522 if (spec == NULL)
4523 return -ENOMEM;
4524
4525 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004526 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01004527 spec->pin_nids = stac925x_pin_nids;
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02004528
4529 /* Check first for codec ID */
4530 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
4531 STAC_925x_MODELS,
4532 stac925x_models,
4533 stac925x_codec_id_cfg_tbl);
4534
4535 /* Now checks for PCI ID, if codec ID is not found */
4536 if (spec->board_config < 0)
4537 spec->board_config = snd_hda_check_board_config(codec,
4538 STAC_925x_MODELS,
Tobin Davis8e21c342007-01-08 11:04:17 +01004539 stac925x_models,
4540 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004541 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01004542 if (spec->board_config < 0)
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02004543 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
Tobin Davis2c11f952007-05-17 09:36:34 +02004544 "using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01004545 else
4546 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004547 stac925x_brd_tbl[spec->board_config]);
Tobin Davis8e21c342007-01-08 11:04:17 +01004548
4549 spec->multiout.max_channels = 2;
4550 spec->multiout.num_dacs = 1;
4551 spec->multiout.dac_nids = stac925x_dac_nids;
4552 spec->adc_nids = stac925x_adc_nids;
4553 spec->mux_nids = stac925x_mux_nids;
4554 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004555 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004556 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02004557 switch (codec->vendor_id) {
4558 case 0x83847632: /* STAC9202 */
4559 case 0x83847633: /* STAC9202D */
4560 case 0x83847636: /* STAC9251 */
4561 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02004562 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02004563 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004564 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4565 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02004566 break;
4567 default:
4568 spec->num_dmics = 0;
4569 break;
4570 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004571
4572 spec->init = stac925x_core_init;
4573 spec->mixer = stac925x_mixer;
4574
4575 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004576 if (!err) {
4577 if (spec->board_config < 0) {
4578 printk(KERN_WARNING "hda_codec: No auto-config is "
4579 "available, default to model=ref\n");
4580 spec->board_config = STAC_925x_REF;
4581 goto again;
4582 }
4583 err = -EINVAL;
4584 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004585 if (err < 0) {
4586 stac92xx_free(codec);
4587 return err;
4588 }
4589
4590 codec->patch_ops = stac92xx_patch_ops;
4591
4592 return 0;
4593}
4594
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004595static struct hda_input_mux stac92hd73xx_dmux = {
4596 .num_items = 4,
4597 .items = {
4598 { "Analog Inputs", 0x0b },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004599 { "Digital Mic 1", 0x09 },
4600 { "Digital Mic 2", 0x0a },
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004601 { "CD", 0x08 },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004602 }
4603};
4604
4605static int patch_stac92hd73xx(struct hda_codec *codec)
4606{
4607 struct sigmatel_spec *spec;
4608 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4609 int err = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004610 int num_dacs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004611
4612 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4613 if (spec == NULL)
4614 return -ENOMEM;
4615
4616 codec->spec = spec;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02004617 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004618 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4619 spec->pin_nids = stac92hd73xx_pin_nids;
4620 spec->board_config = snd_hda_check_board_config(codec,
4621 STAC_92HD73XX_MODELS,
4622 stac92hd73xx_models,
4623 stac92hd73xx_cfg_tbl);
4624again:
Takashi Iwai330ee992009-02-20 14:33:36 +01004625 if (spec->board_config < 0)
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004626 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4627 " STAC92HD73XX, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01004628 else
4629 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004630 stac92hd73xx_brd_tbl[spec->board_config]);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004631
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004632 num_dacs = snd_hda_get_connections(codec, 0x0a,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004633 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4634
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004635 if (num_dacs < 3 || num_dacs > 5) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004636 printk(KERN_WARNING "hda_codec: Could not determine "
4637 "number of channels defaulting to DAC count\n");
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004638 num_dacs = STAC92HD73_DAC_COUNT;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004639 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004640 switch (num_dacs) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004641 case 0x3: /* 6 Channel */
4642 spec->mixer = stac92hd73xx_6ch_mixer;
4643 spec->init = stac92hd73xx_6ch_core_init;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01004644 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004645 break;
4646 case 0x4: /* 8 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004647 spec->mixer = stac92hd73xx_8ch_mixer;
4648 spec->init = stac92hd73xx_8ch_core_init;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01004649 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004650 break;
4651 case 0x5: /* 10 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004652 spec->mixer = stac92hd73xx_10ch_mixer;
4653 spec->init = stac92hd73xx_10ch_core_init;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01004654 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
4655 break;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004656 }
4657 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004658
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004659 spec->aloopback_mask = 0x01;
4660 spec->aloopback_shift = 8;
4661
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004662 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004663 spec->mux_nids = stac92hd73xx_mux_nids;
4664 spec->adc_nids = stac92hd73xx_adc_nids;
4665 spec->dmic_nids = stac92hd73xx_dmic_nids;
4666 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004667 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostay89385032008-09-11 09:49:39 -04004668 spec->amp_nids = stac92hd73xx_amp_nids;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004669 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004670
4671 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4672 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01004673 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004674 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4675 sizeof(stac92hd73xx_dmux));
4676
Matthew Ranostaya7662642008-02-21 07:51:14 +01004677 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004678 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004679 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004680 /* fallthru */
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004681 case STAC_DELL_M6_AMIC:
4682 case STAC_DELL_M6_DMIC:
4683 case STAC_DELL_M6_BOTH:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004684 spec->num_smuxes = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004685 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4686 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004687 spec->eapd_switch = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004688 spec->num_amps = 1;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004689
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004690 if (spec->board_config != STAC_DELL_EQ)
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004691 spec->init = dell_m6_core_init;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004692 switch (spec->board_config) {
4693 case STAC_DELL_M6_AMIC: /* Analog Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01004694 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
Matthew Ranostaya7662642008-02-21 07:51:14 +01004695 spec->num_dmics = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004696 spec->private_dimux.num_items = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004697 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004698 case STAC_DELL_M6_DMIC: /* Digital Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01004699 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01004700 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004701 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004702 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004703 case STAC_DELL_M6_BOTH: /* Both */
Takashi Iwai330ee992009-02-20 14:33:36 +01004704 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
4705 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01004706 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004707 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004708 break;
4709 }
4710 break;
4711 default:
4712 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004713 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004714 spec->eapd_switch = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004715 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004716 if (spec->board_config > STAC_92HD73XX_REF) {
4717 /* GPIO0 High = Enable EAPD */
4718 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4719 spec->gpio_data = 0x01;
4720 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004721 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004722
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004723 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4724 spec->pwr_nids = stac92hd73xx_pwr_nids;
4725
Matthew Ranostayd9737752008-09-07 12:03:41 +02004726 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004727
4728 if (!err) {
4729 if (spec->board_config < 0) {
4730 printk(KERN_WARNING "hda_codec: No auto-config is "
4731 "available, default to model=ref\n");
4732 spec->board_config = STAC_92HD73XX_REF;
4733 goto again;
4734 }
4735 err = -EINVAL;
4736 }
4737
4738 if (err < 0) {
4739 stac92xx_free(codec);
4740 return err;
4741 }
4742
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01004743 if (spec->board_config == STAC_92HD73XX_NO_JD)
4744 spec->hp_detect = 0;
4745
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004746 codec->patch_ops = stac92xx_patch_ops;
4747
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004748 codec->proc_widget_hook = stac92hd7x_proc_hook;
4749
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004750 return 0;
4751}
4752
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004753static struct hda_input_mux stac92hd83xxx_dmux = {
4754 .num_items = 3,
4755 .items = {
4756 { "Analog Inputs", 0x03 },
4757 { "Digital Mic 1", 0x04 },
4758 { "Digital Mic 2", 0x05 },
4759 }
4760};
4761
4762static int patch_stac92hd83xxx(struct hda_codec *codec)
4763{
4764 struct sigmatel_spec *spec;
Matthew Ranostay65557f32009-01-20 16:50:25 -05004765 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004766 int err;
Matthew Ranostay65557f32009-01-20 16:50:25 -05004767 int num_dacs;
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05004768 hda_nid_t nid;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004769
4770 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4771 if (spec == NULL)
4772 return -ENOMEM;
4773
4774 codec->spec = spec;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004775 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004776 spec->mono_nid = 0x19;
4777 spec->digbeep_nid = 0x21;
4778 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4779 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4780 spec->adc_nids = stac92hd83xxx_adc_nids;
4781 spec->pwr_nids = stac92hd83xxx_pwr_nids;
Matthew Ranostayc15c5062009-01-13 13:30:07 -05004782 spec->amp_nids = stac92hd83xxx_amp_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004783 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4784 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004785 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004786
4787 spec->init = stac92hd83xxx_core_init;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004788 spec->mixer = stac92hd83xxx_mixer;
4789 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4790 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4791 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
Matthew Ranostayc15c5062009-01-13 13:30:07 -05004792 spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004793 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4794 spec->dinput_mux = &stac92hd83xxx_dmux;
4795 spec->pin_nids = stac92hd83xxx_pin_nids;
4796 spec->board_config = snd_hda_check_board_config(codec,
4797 STAC_92HD83XXX_MODELS,
4798 stac92hd83xxx_models,
4799 stac92hd83xxx_cfg_tbl);
4800again:
Takashi Iwai330ee992009-02-20 14:33:36 +01004801 if (spec->board_config < 0)
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004802 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4803 " STAC92HD83XXX, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01004804 else
4805 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004806 stac92hd83xxx_brd_tbl[spec->board_config]);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004807
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05004808 switch (codec->vendor_id) {
4809 case 0x111d7604:
4810 case 0x111d7605:
4811 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
4812 break;
4813 spec->num_pwrs = 0;
4814 break;
4815 }
4816
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004817 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4818 if (!err) {
4819 if (spec->board_config < 0) {
4820 printk(KERN_WARNING "hda_codec: No auto-config is "
4821 "available, default to model=ref\n");
4822 spec->board_config = STAC_92HD83XXX_REF;
4823 goto again;
4824 }
4825 err = -EINVAL;
4826 }
4827
4828 if (err < 0) {
4829 stac92xx_free(codec);
4830 return err;
4831 }
4832
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05004833 switch (spec->board_config) {
4834 case STAC_DELL_S14:
4835 nid = 0xf;
4836 break;
4837 default:
4838 nid = 0xe;
4839 break;
4840 }
4841
4842 num_dacs = snd_hda_get_connections(codec, nid,
4843 conn, STAC92HD83_DAC_COUNT + 1) - 1;
4844
4845 /* set port X to select the last DAC
4846 */
4847 snd_hda_codec_write_cache(codec, nid, 0,
4848 AC_VERB_SET_CONNECT_SEL, num_dacs);
4849
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004850 codec->patch_ops = stac92xx_patch_ops;
4851
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004852 codec->proc_widget_hook = stac92hd_proc_hook;
4853
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004854 return 0;
4855}
4856
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004857static struct hda_input_mux stac92hd71bxx_dmux_nomixer = {
4858 .num_items = 3,
4859 .items = {
4860 { "Analog Inputs", 0x00 },
4861 { "Digital Mic 1", 0x02 },
4862 { "Digital Mic 2", 0x03 },
4863 }
4864};
4865
4866static struct hda_input_mux stac92hd71bxx_dmux_amixer = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004867 .num_items = 4,
4868 .items = {
4869 { "Analog Inputs", 0x00 },
4870 { "Mixer", 0x01 },
4871 { "Digital Mic 1", 0x02 },
4872 { "Digital Mic 2", 0x03 },
4873 }
4874};
4875
Takashi Iwai330ee992009-02-20 14:33:36 +01004876/* get the pin connection (fixed, none, etc) */
4877static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
4878{
4879 struct sigmatel_spec *spec = codec->spec;
4880 unsigned int cfg;
4881
4882 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
4883 return get_defcfg_connect(cfg);
4884}
4885
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004886static int stac92hd71bxx_connected_ports(struct hda_codec *codec,
4887 hda_nid_t *nids, int num_nids)
4888{
4889 struct sigmatel_spec *spec = codec->spec;
4890 int idx, num;
4891 unsigned int def_conf;
4892
4893 for (num = 0; num < num_nids; num++) {
4894 for (idx = 0; idx < spec->num_pins; idx++)
4895 if (spec->pin_nids[idx] == nids[num])
4896 break;
4897 if (idx >= spec->num_pins)
4898 break;
Takashi Iwai330ee992009-02-20 14:33:36 +01004899 def_conf = stac_get_defcfg_connect(codec, idx);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004900 if (def_conf == AC_JACK_PORT_NONE)
4901 break;
4902 }
4903 return num;
4904}
4905
4906static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
4907 hda_nid_t dig0pin)
4908{
4909 struct sigmatel_spec *spec = codec->spec;
4910 int idx;
4911
4912 for (idx = 0; idx < spec->num_pins; idx++)
4913 if (spec->pin_nids[idx] == dig0pin)
4914 break;
4915 if ((idx + 2) >= spec->num_pins)
4916 return 0;
4917
4918 /* dig1pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01004919 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004920 return 2;
4921
4922 /* dig0pin + dig2pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01004923 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004924 return 2;
Takashi Iwai330ee992009-02-20 14:33:36 +01004925 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004926 return 1;
4927 else
4928 return 0;
4929}
4930
Matthew Ranostaye035b842007-11-06 11:53:55 +01004931static int patch_stac92hd71bxx(struct hda_codec *codec)
4932{
4933 struct sigmatel_spec *spec;
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05004934 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004935 int err = 0;
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004936 unsigned int ndmic_nids = 0;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004937
4938 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4939 if (spec == NULL)
4940 return -ENOMEM;
4941
4942 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004943 codec->patch_ops = stac92xx_patch_ops;
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05004944 spec->num_pins = STAC92HD71BXX_NUM_PINS;
4945 switch (codec->vendor_id) {
4946 case 0x111d76b6:
4947 case 0x111d76b7:
4948 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
4949 break;
4950 case 0x111d7603:
4951 case 0x111d7608:
4952 /* On 92HD75Bx 0x27 isn't a pin nid */
4953 spec->num_pins--;
4954 /* fallthrough */
4955 default:
4956 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
4957 }
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004958 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004959 spec->board_config = snd_hda_check_board_config(codec,
4960 STAC_92HD71BXX_MODELS,
4961 stac92hd71bxx_models,
4962 stac92hd71bxx_cfg_tbl);
4963again:
Takashi Iwai330ee992009-02-20 14:33:36 +01004964 if (spec->board_config < 0)
Matthew Ranostaye035b842007-11-06 11:53:55 +01004965 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4966 " STAC92HD71BXX, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01004967 else
4968 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004969 stac92hd71bxx_brd_tbl[spec->board_config]);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004970
Takashi Iwai41c3b642008-11-18 10:45:15 +01004971 if (spec->board_config > STAC_92HD71BXX_REF) {
4972 /* GPIO0 = EAPD */
4973 spec->gpio_mask = 0x01;
4974 spec->gpio_dir = 0x01;
4975 spec->gpio_data = 0x01;
4976 }
4977
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004978 spec->dmic_nids = stac92hd71bxx_dmic_nids;
4979 spec->dmux_nids = stac92hd71bxx_dmux_nids;
4980
Matthew Ranostay541eee82007-12-14 12:08:04 +01004981 switch (codec->vendor_id) {
4982 case 0x111d76b6: /* 4 Port without Analog Mixer */
4983 case 0x111d76b7:
Herton Ronaldo Krzesinski23c7b522009-02-08 19:51:28 -02004984 unmute_init++;
4985 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01004986 case 0x111d76b4: /* 6 Port without Analog Mixer */
4987 case 0x111d76b5:
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004988 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_nomixer,
4989 sizeof(stac92hd71bxx_dmux_nomixer));
Matthew Ranostay541eee82007-12-14 12:08:04 +01004990 spec->mixer = stac92hd71bxx_mixer;
4991 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004992 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004993 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
4994 stac92hd71bxx_dmic_nids,
4995 STAC92HD71BXX_NUM_DMICS);
4996 if (spec->num_dmics) {
4997 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4998 spec->dinput_mux = &spec->private_dimux;
4999 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
5000 }
Matthew Ranostay541eee82007-12-14 12:08:04 +01005001 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005002 case 0x111d7608: /* 5 Port with Analog Mixer */
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005003 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
5004 sizeof(stac92hd71bxx_dmux_amixer));
5005 spec->private_dimux.num_items--;
Takashi Iwai8e5f2622008-11-15 19:28:54 +01005006 switch (spec->board_config) {
5007 case STAC_HP_M4:
Matthew Ranostay72474be2008-10-09 09:32:17 -04005008 /* Enable VREF power saving on GPIO1 detect */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005009 err = stac_add_event(spec, codec->afg,
5010 STAC_VREF_EVENT, 0x02);
5011 if (err < 0)
5012 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005013 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay72474be2008-10-09 09:32:17 -04005014 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
5015 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005016 AC_VERB_SET_UNSOLICITED_ENABLE,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005017 AC_USRSP_EN | err);
Matthew Ranostay72474be2008-10-09 09:32:17 -04005018 spec->gpio_mask |= 0x02;
5019 break;
5020 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005021 if ((codec->revision_id & 0xf) == 0 ||
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005022 (codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005023 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005024
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005025 /* no output amps */
5026 spec->num_pwrs = 0;
5027 spec->mixer = stac92hd71bxx_analog_mixer;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005028 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005029
5030 /* disable VSW */
5031 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005032 unmute_init++;
Takashi Iwai330ee992009-02-20 14:33:36 +01005033 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5034 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005035 stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0;
5036 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5037 stac92hd71bxx_dmic_nids,
5038 STAC92HD71BXX_NUM_DMICS - 1);
5039 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5040 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 2;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005041 break;
5042 case 0x111d7603: /* 6 Port with Analog Mixer */
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005043 if ((codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005044 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005045
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005046 /* no output amps */
5047 spec->num_pwrs = 0;
5048 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005049 default:
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005050 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
5051 sizeof(stac92hd71bxx_dmux_amixer));
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005052 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005053 spec->mixer = stac92hd71bxx_analog_mixer;
5054 spec->init = stac92hd71bxx_analog_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005055 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005056 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5057 stac92hd71bxx_dmic_nids,
5058 STAC92HD71BXX_NUM_DMICS);
5059 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5060 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005061 }
5062
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005063 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5064 snd_hda_sequence_write_cache(codec, unmute_init);
5065
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005066 spec->aloopback_ctl = stac92hd71bxx_loopback;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005067 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005068 spec->aloopback_shift = 0;
5069
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005070 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005071 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005072 spec->mux_nids = stac92hd71bxx_mux_nids;
5073 spec->adc_nids = stac92hd71bxx_adc_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005074 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005075 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005076
5077 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5078 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005079 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005080
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005081 switch (spec->board_config) {
5082 case STAC_HP_M4:
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005083 /* enable internal microphone */
Takashi Iwai330ee992009-02-20 14:33:36 +01005084 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
Matthew Ranostayb9aea712008-10-09 08:37:28 -04005085 stac92xx_auto_set_pinctl(codec, 0x0e,
5086 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05005087 /* fallthru */
5088 case STAC_DELL_M4_2:
5089 spec->num_dmics = 0;
5090 spec->num_smuxes = 0;
5091 spec->num_dmuxes = 0;
5092 break;
5093 case STAC_DELL_M4_1:
5094 case STAC_DELL_M4_3:
5095 spec->num_dmics = 1;
5096 spec->num_smuxes = 0;
Takashi Iwaiea18aa42009-02-27 17:36:33 +01005097 spec->num_dmuxes = 1;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005098 break;
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005099 case STAC_HP_DV5:
Takashi Iwai330ee992009-02-20 14:33:36 +01005100 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005101 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
5102 break;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005103 };
5104
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005105 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005106 if (spec->dinput_mux)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005107 spec->private_dimux.num_items += spec->num_dmics - ndmic_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005108
Herton Ronaldo Krzesinski29d4ab42009-02-04 11:37:27 -05005109 err = stac92xx_parse_auto_config(codec, 0x21, 0);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005110 if (!err) {
5111 if (spec->board_config < 0) {
5112 printk(KERN_WARNING "hda_codec: No auto-config is "
5113 "available, default to model=ref\n");
5114 spec->board_config = STAC_92HD71BXX_REF;
5115 goto again;
5116 }
5117 err = -EINVAL;
5118 }
5119
5120 if (err < 0) {
5121 stac92xx_free(codec);
5122 return err;
5123 }
5124
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005125 codec->proc_widget_hook = stac92hd7x_proc_hook;
5126
Matthew Ranostaye035b842007-11-06 11:53:55 +01005127 return 0;
5128};
5129
Matt2f2f4252005-04-13 14:45:30 +02005130static int patch_stac922x(struct hda_codec *codec)
5131{
5132 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005133 int err;
Matt2f2f4252005-04-13 14:45:30 +02005134
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005135 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02005136 if (spec == NULL)
5137 return -ENOMEM;
5138
5139 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005140 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005141 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005142 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5143 stac922x_models,
5144 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08005145 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005146 spec->gpio_mask = spec->gpio_dir = 0x03;
5147 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005148 /* Intel Macs have all same PCI SSID, so we need to check
5149 * codec SSID to distinguish the exact models
5150 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005151 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005152 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005153
5154 case 0x106b0800:
5155 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02005156 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005157 case 0x106b0600:
5158 case 0x106b0700:
5159 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005160 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005161 case 0x106b0e00:
5162 case 0x106b0f00:
5163 case 0x106b1600:
5164 case 0x106b1700:
5165 case 0x106b0200:
5166 case 0x106b1e00:
5167 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005168 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005169 case 0x106b1a00:
5170 case 0x00000100:
5171 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02005172 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005173 case 0x106b0a00:
5174 case 0x106b2200:
5175 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02005176 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08005177 default:
5178 spec->board_config = STAC_INTEL_MAC_V3;
5179 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005180 }
5181 }
5182
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005183 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005184 if (spec->board_config < 0)
Richard Fish11b44bb2006-08-23 18:31:34 +02005185 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
5186 "using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01005187 else
5188 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005189 stac922x_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02005190
Matt2f2f4252005-04-13 14:45:30 +02005191 spec->adc_nids = stac922x_adc_nids;
5192 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005193 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005194 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005195 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005196 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02005197
5198 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02005199 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02005200
5201 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02005202
Matt Porter3cc08dc2006-01-23 15:27:49 +01005203 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005204 if (!err) {
5205 if (spec->board_config < 0) {
5206 printk(KERN_WARNING "hda_codec: No auto-config is "
5207 "available, default to model=ref\n");
5208 spec->board_config = STAC_D945_REF;
5209 goto again;
5210 }
5211 err = -EINVAL;
5212 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005213 if (err < 0) {
5214 stac92xx_free(codec);
5215 return err;
5216 }
5217
5218 codec->patch_ops = stac92xx_patch_ops;
5219
Takashi Iwai807a46362007-05-29 19:01:37 +02005220 /* Fix Mux capture level; max to 2 */
5221 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
5222 (0 << AC_AMPCAP_OFFSET_SHIFT) |
5223 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5224 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5225 (0 << AC_AMPCAP_MUTE_SHIFT));
5226
Matt Porter3cc08dc2006-01-23 15:27:49 +01005227 return 0;
5228}
5229
5230static int patch_stac927x(struct hda_codec *codec)
5231{
5232 struct sigmatel_spec *spec;
5233 int err;
5234
5235 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5236 if (spec == NULL)
5237 return -ENOMEM;
5238
5239 codec->spec = spec;
Matthew Ranostay45c1d852009-02-04 17:49:41 -05005240 codec->slave_dig_outs = stac927x_slave_dig_outs;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005241 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005242 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005243 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5244 stac927x_models,
5245 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005246 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005247 if (spec->board_config < 0)
Herton Ronaldo Krzesinskic98041f2009-02-11 20:33:15 -02005248 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
5249 "STAC927x, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01005250 else
5251 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005252 stac927x_brd_tbl[spec->board_config]);
Matt Porter3cc08dc2006-01-23 15:27:49 +01005253
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005254 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005255 spec->adc_nids = stac927x_adc_nids;
5256 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
5257 spec->mux_nids = stac927x_mux_nids;
5258 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005259 spec->smux_nids = stac927x_smux_nids;
5260 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04005261 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005262 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005263 spec->multiout.dac_nids = spec->dac_nids;
5264
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005265 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02005266 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005267 case STAC_D965_5ST:
5268 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005269 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005270 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005271 spec->num_dmics = 0;
5272
Tobin Davis93ed1502006-09-01 21:03:12 +02005273 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005274 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005275 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005276 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02005277 switch (codec->subsystem_id) {
5278 case 0x10280209:
5279 case 0x1028022e:
5280 /* correct the device field to SPDIF out */
Takashi Iwai330ee992009-02-20 14:33:36 +01005281 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
Matthew Ranostay780c8be2008-04-14 13:32:27 +02005282 break;
5283 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01005284 /* configure the analog microphone on some laptops */
Takashi Iwai330ee992009-02-20 14:33:36 +01005285 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01005286 /* correct the front output jack as a hp out */
Takashi Iwai330ee992009-02-20 14:33:36 +01005287 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01005288 /* correct the front input jack as a mic */
Takashi Iwai330ee992009-02-20 14:33:36 +01005289 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01005290 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005291 case STAC_DELL_3ST:
5292 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005293 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005294 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005295 spec->dmic_nids = stac927x_dmic_nids;
5296 spec->num_dmics = STAC927X_NUM_DMICS;
5297
Tobin Davis93ed1502006-09-01 21:03:12 +02005298 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005299 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005300 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005301 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005302 break;
5303 default:
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005304 if (spec->board_config > STAC_D965_REF) {
5305 /* GPIO0 High = Enable EAPD */
5306 spec->eapd_mask = spec->gpio_mask = 0x01;
5307 spec->gpio_dir = spec->gpio_data = 0x01;
5308 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005309 spec->num_dmics = 0;
5310
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005311 spec->init = stac927x_core_init;
5312 spec->mixer = stac927x_mixer;
5313 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005314
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005315 spec->num_pwrs = 0;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005316 spec->aloopback_ctl = stac927x_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005317 spec->aloopback_mask = 0x40;
5318 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005319 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005320
Matt Porter3cc08dc2006-01-23 15:27:49 +01005321 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005322 if (!err) {
5323 if (spec->board_config < 0) {
5324 printk(KERN_WARNING "hda_codec: No auto-config is "
5325 "available, default to model=ref\n");
5326 spec->board_config = STAC_D965_REF;
5327 goto again;
5328 }
5329 err = -EINVAL;
5330 }
Mattc7d4b2f2005-06-27 14:59:41 +02005331 if (err < 0) {
5332 stac92xx_free(codec);
5333 return err;
5334 }
Matt2f2f4252005-04-13 14:45:30 +02005335
5336 codec->patch_ops = stac92xx_patch_ops;
5337
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005338 codec->proc_widget_hook = stac927x_proc_hook;
5339
Takashi Iwai52987652008-01-16 16:09:47 +01005340 /*
5341 * !!FIXME!!
5342 * The STAC927x seem to require fairly long delays for certain
5343 * command sequences. With too short delays (even if the answer
5344 * is set to RIRB properly), it results in the silence output
5345 * on some hardwares like Dell.
5346 *
5347 * The below flag enables the longer delay (see get_response
5348 * in hda_intel.c).
5349 */
5350 codec->bus->needs_damn_long_delay = 1;
5351
Takashi Iwaie28d8322008-12-17 13:48:29 +01005352 /* no jack detecion for ref-no-jd model */
5353 if (spec->board_config == STAC_D965_REF_NO_JD)
5354 spec->hp_detect = 0;
5355
Matt2f2f4252005-04-13 14:45:30 +02005356 return 0;
5357}
5358
Matt Porterf3302a52006-07-31 12:49:34 +02005359static int patch_stac9205(struct hda_codec *codec)
5360{
5361 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02005362 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02005363
5364 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5365 if (spec == NULL)
5366 return -ENOMEM;
5367
5368 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005369 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005370 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005371 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
5372 stac9205_models,
5373 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005374 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005375 if (spec->board_config < 0)
Richard Fish11b44bb2006-08-23 18:31:34 +02005376 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01005377 else
5378 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005379 stac9205_brd_tbl[spec->board_config]);
Matt Porterf3302a52006-07-31 12:49:34 +02005380
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005381 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02005382 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005383 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02005384 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005385 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005386 spec->smux_nids = stac9205_smux_nids;
5387 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005388 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02005389 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005390 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005391 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005392 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02005393
5394 spec->init = stac9205_core_init;
5395 spec->mixer = stac9205_mixer;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005396 spec->aloopback_ctl = stac9205_loopback;
Matt Porterf3302a52006-07-31 12:49:34 +02005397
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005398 spec->aloopback_mask = 0x40;
5399 spec->aloopback_shift = 0;
Takashi Iwaid9a42682009-01-22 17:40:18 +01005400 /* Turn on/off EAPD per HP plugging */
5401 if (spec->board_config != STAC_9205_EAPD)
5402 spec->eapd_switch = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02005403 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02005404
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005405 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005406 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02005407 /* Enable SPDIF in/out */
Takashi Iwai330ee992009-02-20 14:33:36 +01005408 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
5409 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01005410
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005411 /* Enable unsol response for GPIO4/Dock HP connection */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005412 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
5413 if (err < 0)
5414 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005415 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005416 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
5417 snd_hda_codec_write_cache(codec, codec->afg, 0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005418 AC_VERB_SET_UNSOLICITED_ENABLE,
5419 AC_USRSP_EN | err);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005420
5421 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005422 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005423 spec->gpio_mask = 0x1b;
5424 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01005425 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005426 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02005427 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005428 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005429 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005430 case STAC_9205_REF:
5431 /* SPDIF-In enabled */
5432 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005433 default:
5434 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005435 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005436 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005437 break;
5438 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02005439
Matt Porterf3302a52006-07-31 12:49:34 +02005440 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005441 if (!err) {
5442 if (spec->board_config < 0) {
5443 printk(KERN_WARNING "hda_codec: No auto-config is "
5444 "available, default to model=ref\n");
5445 spec->board_config = STAC_9205_REF;
5446 goto again;
5447 }
5448 err = -EINVAL;
5449 }
Matt Porterf3302a52006-07-31 12:49:34 +02005450 if (err < 0) {
5451 stac92xx_free(codec);
5452 return err;
5453 }
5454
5455 codec->patch_ops = stac92xx_patch_ops;
5456
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005457 codec->proc_widget_hook = stac9205_proc_hook;
5458
Matt Porterf3302a52006-07-31 12:49:34 +02005459 return 0;
5460}
5461
Matt2f2f4252005-04-13 14:45:30 +02005462/*
Guillaume Munch6d859062006-08-22 17:15:47 +02005463 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01005464 */
5465
Takashi Iwai1e137f92009-01-21 07:41:22 +01005466static struct hda_verb stac9872_core_init[] = {
Takashi Iwai1624cb92007-07-05 13:10:51 +02005467 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005468 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5469 {}
5470};
5471
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005472static struct snd_kcontrol_new stac9872_mixer[] = {
5473 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5474 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005475 { } /* end */
5476};
5477
5478static hda_nid_t stac9872_pin_nids[] = {
5479 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
5480 0x11, 0x13, 0x14,
5481};
5482
5483static hda_nid_t stac9872_adc_nids[] = {
5484 0x8 /*,0x6*/
5485};
5486
5487static hda_nid_t stac9872_mux_nids[] = {
5488 0x15
5489};
5490
Guillaume Munch6d859062006-08-22 17:15:47 +02005491static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01005492{
5493 struct sigmatel_spec *spec;
Takashi Iwai1e137f92009-01-21 07:41:22 +01005494 int err;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005495
Takashi Iwaidb064e52006-03-16 16:04:58 +01005496 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5497 if (spec == NULL)
5498 return -ENOMEM;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005499 codec->spec = spec;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005500
Takashi Iwai1e137f92009-01-21 07:41:22 +01005501#if 0 /* no model right now */
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005502 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5503 stac9872_models,
5504 stac9872_cfg_tbl);
Takashi Iwai1e137f92009-01-21 07:41:22 +01005505#endif
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005506
Takashi Iwai1e137f92009-01-21 07:41:22 +01005507 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
5508 spec->pin_nids = stac9872_pin_nids;
5509 spec->multiout.dac_nids = spec->dac_nids;
5510 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
5511 spec->adc_nids = stac9872_adc_nids;
5512 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
5513 spec->mux_nids = stac9872_mux_nids;
5514 spec->mixer = stac9872_mixer;
5515 spec->init = stac9872_core_init;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005516
Takashi Iwai1e137f92009-01-21 07:41:22 +01005517 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
5518 if (err < 0) {
5519 stac92xx_free(codec);
5520 return -EINVAL;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005521 }
Takashi Iwai1e137f92009-01-21 07:41:22 +01005522 spec->input_mux = &spec->private_imux;
5523 codec->patch_ops = stac92xx_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005524 return 0;
5525}
5526
5527
5528/*
Matt2f2f4252005-04-13 14:45:30 +02005529 * patch entries
5530 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +01005531static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
Matt2f2f4252005-04-13 14:45:30 +02005532 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5533 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5534 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5535 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5536 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5537 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5538 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02005539 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5540 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5541 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5542 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5543 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5544 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01005545 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5546 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5547 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5548 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5549 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5550 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5551 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5552 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5553 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5554 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01005555 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5556 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5557 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5558 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5559 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5560 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02005561 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5562 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02005563 /* The following does not take into account .id=0x83847661 when subsys =
5564 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5565 * currently not fully supported.
5566 */
5567 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5568 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5569 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02005570 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5571 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5572 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5573 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5574 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5575 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5576 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5577 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005578 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005579 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5580 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005581 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01005582 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5583 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005584 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01005585 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5586 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5587 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5588 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5589 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5590 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5591 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5592 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02005593 {} /* terminator */
5594};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01005595
5596MODULE_ALIAS("snd-hda-codec-id:8384*");
5597MODULE_ALIAS("snd-hda-codec-id:111d*");
5598
5599MODULE_LICENSE("GPL");
5600MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
5601
5602static struct hda_codec_preset_list sigmatel_list = {
5603 .preset = snd_hda_preset_sigmatel,
5604 .owner = THIS_MODULE,
5605};
5606
5607static int __init patch_sigmatel_init(void)
5608{
5609 return snd_hda_add_codec_preset(&sigmatel_list);
5610}
5611
5612static void __exit patch_sigmatel_exit(void)
5613{
5614 snd_hda_delete_codec_preset(&sigmatel_list);
5615}
5616
5617module_init(patch_sigmatel_init)
5618module_exit(patch_sigmatel_exit)