blob: ee119259183c203b6828dd0ebbd18508f38a0474 [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",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001230 "Speaker Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001231 NULL
1232};
1233
1234static const char *slave_sws[] = {
1235 "Front Playback Switch",
1236 "Surround Playback Switch",
1237 "Center Playback Switch",
1238 "LFE Playback Switch",
1239 "Side Playback Switch",
1240 "Headphone Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001241 "Speaker Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001242 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001243 NULL
1244};
1245
Takashi Iwai603c4012008-07-30 15:01:44 +02001246static void stac92xx_free_kctls(struct hda_codec *codec);
Takashi Iwaie4973e12008-11-18 09:32:42 +01001247static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
Takashi Iwai603c4012008-07-30 15:01:44 +02001248
Matt2f2f4252005-04-13 14:45:30 +02001249static int stac92xx_build_controls(struct hda_codec *codec)
1250{
1251 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaie4973e12008-11-18 09:32:42 +01001252 struct auto_pin_cfg *cfg = &spec->autocfg;
1253 hda_nid_t nid;
Matt2f2f4252005-04-13 14:45:30 +02001254 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001255 int i;
Matt2f2f4252005-04-13 14:45:30 +02001256
1257 err = snd_hda_add_new_ctls(codec, spec->mixer);
1258 if (err < 0)
1259 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001260
1261 for (i = 0; i < spec->num_mixers; i++) {
1262 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1263 if (err < 0)
1264 return err;
1265 }
Takashi Iwai1697055e2007-12-18 18:05:52 +01001266 if (spec->num_dmuxes > 0) {
1267 stac_dmux_mixer.count = spec->num_dmuxes;
Takashi Iwaid13bd412008-07-30 15:01:45 +02001268 err = snd_hda_ctl_add(codec,
Takashi Iwai1697055e2007-12-18 18:05:52 +01001269 snd_ctl_new1(&stac_dmux_mixer, codec));
1270 if (err < 0)
1271 return err;
1272 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001273 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001274 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1275 struct hda_input_mux *smux = &spec->private_smux;
1276 /* check for mute support on SPDIF out */
1277 if (wcaps & AC_WCAP_OUT_AMP) {
1278 smux->items[smux->num_items].label = "Off";
1279 smux->items[smux->num_items].index = 0;
1280 smux->num_items++;
1281 spec->spdif_mute = 1;
1282 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001283 stac_smux_mixer.count = spec->num_smuxes;
Takashi Iwai4f2d23e2008-12-19 10:14:13 +01001284 err = snd_hda_ctl_add(codec,
Matthew Ranostayd9737752008-09-07 12:03:41 +02001285 snd_ctl_new1(&stac_smux_mixer, codec));
1286 if (err < 0)
1287 return err;
1288 }
Mattc7d4b2f2005-06-27 14:59:41 +02001289
Mattdabbed62005-06-14 10:19:34 +02001290 if (spec->multiout.dig_out_nid) {
1291 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1292 if (err < 0)
1293 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001294 err = snd_hda_create_spdif_share_sw(codec,
1295 &spec->multiout);
1296 if (err < 0)
1297 return err;
1298 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001299 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001300 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001301 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1302 if (err < 0)
1303 return err;
1304 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001305
1306 /* if we have no master control, let's create it */
1307 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001308 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001309 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001310 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai7c7767e2009-01-20 15:28:38 +01001311 /* correct volume offset */
1312 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
Takashi Iwai2134ea42008-01-10 16:53:55 +01001313 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001314 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001315 if (err < 0)
1316 return err;
1317 }
1318 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1319 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1320 NULL, slave_sws);
1321 if (err < 0)
1322 return err;
1323 }
1324
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001325 if (spec->aloopback_ctl &&
1326 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1327 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1328 if (err < 0)
1329 return err;
1330 }
1331
Takashi Iwai603c4012008-07-30 15:01:44 +02001332 stac92xx_free_kctls(codec); /* no longer needed */
Takashi Iwaie4973e12008-11-18 09:32:42 +01001333
1334 /* create jack input elements */
1335 if (spec->hp_detect) {
1336 for (i = 0; i < cfg->hp_outs; i++) {
1337 int type = SND_JACK_HEADPHONE;
1338 nid = cfg->hp_pins[i];
1339 /* jack detection */
1340 if (cfg->hp_outs == i)
1341 type |= SND_JACK_LINEOUT;
1342 err = stac92xx_add_jack(codec, nid, type);
1343 if (err < 0)
1344 return err;
1345 }
1346 }
1347 for (i = 0; i < cfg->line_outs; i++) {
1348 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1349 SND_JACK_LINEOUT);
1350 if (err < 0)
1351 return err;
1352 }
1353 for (i = 0; i < AUTO_PIN_LAST; i++) {
1354 nid = cfg->input_pins[i];
1355 if (nid) {
1356 err = stac92xx_add_jack(codec, nid,
1357 SND_JACK_MICROPHONE);
1358 if (err < 0)
1359 return err;
1360 }
1361 }
1362
Mattdabbed62005-06-14 10:19:34 +02001363 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001364}
1365
Matt Porter403d1942005-11-29 15:00:51 +01001366static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001367 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001368 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1369};
1370
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001371static unsigned int gateway9200_m4_pin_configs[8] = {
1372 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1373 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1374};
1375static unsigned int gateway9200_m4_2_pin_configs[8] = {
1376 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1377 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1378};
1379
1380/*
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001381 STAC 9200 pin configs for
1382 102801A8
1383 102801DE
1384 102801E8
1385*/
1386static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001387 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1388 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001389};
1390
1391/*
1392 STAC 9200 pin configs for
1393 102801C0
1394 102801C1
1395*/
1396static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001397 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1398 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001399};
1400
1401/*
1402 STAC 9200 pin configs for
1403 102801C4 (Dell Dimension E310)
1404 102801C5
1405 102801C7
1406 102801D9
1407 102801DA
1408 102801E3
1409*/
1410static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001411 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1412 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001413};
1414
1415
1416/*
1417 STAC 9200-32 pin configs for
1418 102801B5 (Dell Inspiron 630m)
1419 102801D8 (Dell Inspiron 640m)
1420*/
1421static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001422 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1423 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001424};
1425
1426/*
1427 STAC 9200-32 pin configs for
1428 102801C2 (Dell Latitude D620)
1429 102801C8
1430 102801CC (Dell Latitude D820)
1431 102801D4
1432 102801D6
1433*/
1434static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001435 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1436 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001437};
1438
1439/*
1440 STAC 9200-32 pin configs for
1441 102801CE (Dell XPS M1710)
1442 102801CF (Dell Precision M90)
1443*/
1444static unsigned int dell9200_m23_pin_configs[8] = {
1445 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1446 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1447};
1448
1449/*
1450 STAC 9200-32 pin configs for
1451 102801C9
1452 102801CA
1453 102801CB (Dell Latitude 120L)
1454 102801D3
1455*/
1456static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001457 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1458 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001459};
1460
1461/*
1462 STAC 9200-32 pin configs for
1463 102801BD (Dell Inspiron E1505n)
1464 102801EE
1465 102801EF
1466*/
1467static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001468 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1469 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001470};
1471
1472/*
1473 STAC 9200-32 pin configs for
1474 102801F5 (Dell Inspiron 1501)
1475 102801F6
1476*/
1477static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001478 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1479 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001480};
1481
1482/*
1483 STAC 9200-32
1484 102801CD (Dell Inspiron E1705/9400)
1485*/
1486static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001487 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1488 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001489};
1490
Tobin Davisbf277782008-02-03 20:31:47 +01001491static unsigned int oqo9200_pin_configs[8] = {
1492 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1493 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1494};
1495
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001496
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001497static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1498 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001499 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001500 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1501 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1502 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1503 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1504 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1505 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1506 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1507 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1508 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1509 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001510 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1511 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001512 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001513};
1514
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001515static const char *stac9200_models[STAC_9200_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001516 [STAC_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001517 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001518 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001519 [STAC_9200_DELL_D21] = "dell-d21",
1520 [STAC_9200_DELL_D22] = "dell-d22",
1521 [STAC_9200_DELL_D23] = "dell-d23",
1522 [STAC_9200_DELL_M21] = "dell-m21",
1523 [STAC_9200_DELL_M22] = "dell-m22",
1524 [STAC_9200_DELL_M23] = "dell-m23",
1525 [STAC_9200_DELL_M24] = "dell-m24",
1526 [STAC_9200_DELL_M25] = "dell-m25",
1527 [STAC_9200_DELL_M26] = "dell-m26",
1528 [STAC_9200_DELL_M27] = "dell-m27",
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001529 [STAC_9200_M4] = "gateway-m4",
1530 [STAC_9200_M4_2] = "gateway-m4-2",
Takashi Iwai117f2572008-03-18 09:53:23 +01001531 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001532};
1533
1534static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1535 /* SigmaTel reference board */
1536 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1537 "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001538 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1539 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001540 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001541 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1542 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001543 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001544 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1545 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1546 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1547 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1548 "unknown Dell", STAC_9200_DELL_D22),
1549 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1550 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001551 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001552 "Dell Latitude D620", STAC_9200_DELL_M22),
1553 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1554 "unknown Dell", STAC_9200_DELL_D23),
1555 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1556 "unknown Dell", STAC_9200_DELL_D23),
1557 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1558 "unknown Dell", STAC_9200_DELL_M22),
1559 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1560 "unknown Dell", STAC_9200_DELL_M24),
1561 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1562 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001563 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001564 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001565 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001566 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001567 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001568 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001569 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001570 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001571 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001572 "Dell Precision M90", STAC_9200_DELL_M23),
1573 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1574 "unknown Dell", STAC_9200_DELL_M22),
1575 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1576 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001577 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001578 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001579 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001580 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1581 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1582 "unknown Dell", STAC_9200_DELL_D23),
1583 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1584 "unknown Dell", STAC_9200_DELL_D23),
1585 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1586 "unknown Dell", STAC_9200_DELL_D21),
1587 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1588 "unknown Dell", STAC_9200_DELL_D23),
1589 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1590 "unknown Dell", STAC_9200_DELL_D21),
1591 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1592 "unknown Dell", STAC_9200_DELL_M25),
1593 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1594 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001595 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001596 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1597 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1598 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001599 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001600 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001601 /* Gateway machines needs EAPD to be set on resume */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001602 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1603 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1604 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
Tobin Davisbf277782008-02-03 20:31:47 +01001605 /* OQO Mobile */
1606 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001607 {} /* terminator */
1608};
1609
Tobin Davis8e21c342007-01-08 11:04:17 +01001610static unsigned int ref925x_pin_configs[8] = {
1611 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001612 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001613};
1614
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001615static unsigned int stac925xM1_pin_configs[8] = {
1616 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1617 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001618};
1619
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001620static unsigned int stac925xM1_2_pin_configs[8] = {
1621 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1622 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1623};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001624
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001625static unsigned int stac925xM2_pin_configs[8] = {
1626 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1627 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis2c11f952007-05-17 09:36:34 +02001628};
1629
Tobin Davis8e21c342007-01-08 11:04:17 +01001630static unsigned int stac925xM2_2_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001631 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1632 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1633};
1634
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001635static unsigned int stac925xM3_pin_configs[8] = {
1636 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1637 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1638};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001639
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001640static unsigned int stac925xM5_pin_configs[8] = {
1641 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1642 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1643};
1644
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001645static unsigned int stac925xM6_pin_configs[8] = {
1646 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1647 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
Tobin Davis8e21c342007-01-08 11:04:17 +01001648};
1649
1650static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1651 [STAC_REF] = ref925x_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001652 [STAC_M1] = stac925xM1_pin_configs,
1653 [STAC_M1_2] = stac925xM1_2_pin_configs,
1654 [STAC_M2] = stac925xM2_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001655 [STAC_M2_2] = stac925xM2_2_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001656 [STAC_M3] = stac925xM3_pin_configs,
1657 [STAC_M5] = stac925xM5_pin_configs,
1658 [STAC_M6] = stac925xM6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001659};
1660
1661static const char *stac925x_models[STAC_925x_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001662 [STAC_925x_AUTO] = "auto",
Tobin Davis8e21c342007-01-08 11:04:17 +01001663 [STAC_REF] = "ref",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001664 [STAC_M1] = "m1",
1665 [STAC_M1_2] = "m1-2",
1666 [STAC_M2] = "m2",
Tobin Davis8e21c342007-01-08 11:04:17 +01001667 [STAC_M2_2] = "m2-2",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001668 [STAC_M3] = "m3",
1669 [STAC_M5] = "m5",
1670 [STAC_M6] = "m6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001671};
1672
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001673static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001674 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1675 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1676 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1677 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001678 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001679 /* Not sure about the brand name for those */
1680 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1681 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1682 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1683 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001684 {} /* terminator */
Tobin Davis8e21c342007-01-08 11:04:17 +01001685};
1686
1687static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1688 /* SigmaTel reference board */
1689 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001690 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001691 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001692
1693 /* Default table for unknown ID */
1694 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1695
Tobin Davis8e21c342007-01-08 11:04:17 +01001696 {} /* terminator */
1697};
1698
Matthew Ranostaya7662642008-02-21 07:51:14 +01001699static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001700 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1701 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1702 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001703 0x01452050,
1704};
1705
1706static unsigned int dell_m6_pin_configs[13] = {
1707 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001708 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001709 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1710 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001711};
1712
1713static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001714 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001715 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1716 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1717 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001718 [STAC_DELL_EQ] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001719};
1720
1721static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001722 [STAC_92HD73XX_AUTO] = "auto",
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01001723 [STAC_92HD73XX_NO_JD] = "no-jd",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001724 [STAC_92HD73XX_REF] = "ref",
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001725 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1726 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1727 [STAC_DELL_M6_BOTH] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001728 [STAC_DELL_EQ] = "dell-eq",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001729};
1730
1731static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1732 /* SigmaTel reference board */
1733 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001734 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001735 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1736 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001737 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001738 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001739 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001740 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001741 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001742 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001743 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001744 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001745 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001746 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001747 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001748 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001749 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001750 "unknown Dell", STAC_DELL_M6_DMIC),
1751 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1752 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01001753 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001754 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Joerg Schirottkefa620e92008-12-19 08:13:49 +01001755 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1756 "Dell Studio 17", STAC_DELL_M6_DMIC),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001757 {} /* terminator */
1758};
1759
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001760static unsigned int ref92hd83xxx_pin_configs[10] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001761 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1762 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001763 0x01451160, 0x98560170,
1764};
1765
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001766static unsigned int dell_s14_pin_configs[10] = {
1767 0x02214030, 0x02211010, 0x02a19020, 0x01014050,
1768 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160,
1769 0x40f000f0, 0x40f000f0,
1770};
1771
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001772static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1773 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001774 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001775 [STAC_DELL_S14] = dell_s14_pin_configs,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001776};
1777
1778static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001779 [STAC_92HD83XXX_AUTO] = "auto",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001780 [STAC_92HD83XXX_REF] = "ref",
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001781 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001782 [STAC_DELL_S14] = "dell-s14",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001783};
1784
1785static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1786 /* SigmaTel reference board */
1787 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Takashi Iwaif9d088b2009-01-13 11:54:49 +01001788 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001789 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1790 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001791 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1792 "unknown Dell", STAC_DELL_S14),
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -02001793 {} /* terminator */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001794};
1795
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001796static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001797 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001798 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001799 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1800 0x00000000
Matthew Ranostaye035b842007-11-06 11:53:55 +01001801};
1802
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001803static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001804 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001805 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001806 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1807 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001808};
1809
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001810static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001811 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1812 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001813 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1814 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001815};
1816
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001817static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001818 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1819 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001820 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1821 0x00000000
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001822};
1823
Matthew Ranostaye035b842007-11-06 11:53:55 +01001824static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1825 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001826 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1827 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001828 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001829 [STAC_HP_M4] = NULL,
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001830 [STAC_HP_DV5] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001831};
1832
1833static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001834 [STAC_92HD71BXX_AUTO] = "auto",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001835 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001836 [STAC_DELL_M4_1] = "dell-m4-1",
1837 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001838 [STAC_DELL_M4_3] = "dell-m4-3",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001839 [STAC_HP_M4] = "hp-m4",
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001840 [STAC_HP_DV5] = "hp-dv5",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001841};
1842
1843static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1844 /* SigmaTel reference board */
1845 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1846 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001847 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1848 "DFI LanParty", STAC_92HD71BXX_REF),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001849 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
1850 "HP dv4-7", STAC_HP_DV5),
1851 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1852 "HP dv4-7", STAC_HP_DV5),
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001853 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001854 "HP mini 1000", STAC_HP_M4),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001855 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1856 "unknown Dell", STAC_DELL_M4_1),
1857 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1858 "unknown Dell", STAC_DELL_M4_1),
1859 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1860 "unknown Dell", STAC_DELL_M4_1),
1861 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1862 "unknown Dell", STAC_DELL_M4_1),
1863 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1864 "unknown Dell", STAC_DELL_M4_1),
1865 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1866 "unknown Dell", STAC_DELL_M4_1),
1867 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1868 "unknown Dell", STAC_DELL_M4_1),
1869 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1870 "unknown Dell", STAC_DELL_M4_2),
1871 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1872 "unknown Dell", STAC_DELL_M4_2),
1873 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1874 "unknown Dell", STAC_DELL_M4_2),
1875 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1876 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001877 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1878 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001879 {} /* terminator */
1880};
1881
Matt Porter403d1942005-11-29 15:00:51 +01001882static unsigned int ref922x_pin_configs[10] = {
1883 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1884 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001885 0x40000100, 0x40000100,
1886};
1887
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001888/*
1889 STAC 922X pin configs for
1890 102801A7
1891 102801AB
1892 102801A9
1893 102801D1
1894 102801D2
1895*/
1896static unsigned int dell_922x_d81_pin_configs[10] = {
1897 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1898 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1899 0x01813122, 0x400001f2,
1900};
1901
1902/*
1903 STAC 922X pin configs for
1904 102801AC
1905 102801D0
1906*/
1907static unsigned int dell_922x_d82_pin_configs[10] = {
1908 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1909 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1910 0x01813122, 0x400001f1,
1911};
1912
1913/*
1914 STAC 922X pin configs for
1915 102801BF
1916*/
1917static unsigned int dell_922x_m81_pin_configs[10] = {
1918 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1919 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1920 0x40C003f1, 0x405003f0,
1921};
1922
1923/*
1924 STAC 9221 A1 pin configs for
1925 102801D7 (Dell XPS M1210)
1926*/
1927static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001928 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1929 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001930 0x508003f3, 0x405003f4,
1931};
1932
Matt Porter403d1942005-11-29 15:00:51 +01001933static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001934 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001935 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1936 0x02a19120, 0x40000100,
1937};
1938
1939static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001940 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1941 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001942 0x02a19320, 0x40000100,
1943};
1944
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001945static unsigned int intel_mac_v1_pin_configs[10] = {
1946 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1947 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001948 0x400000fc, 0x400000fb,
1949};
1950
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001951static unsigned int intel_mac_v2_pin_configs[10] = {
1952 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1953 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001954 0x400000fc, 0x400000fb,
1955};
1956
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001957static unsigned int intel_mac_v3_pin_configs[10] = {
1958 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1959 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1960 0x400000fc, 0x400000fb,
1961};
1962
1963static unsigned int intel_mac_v4_pin_configs[10] = {
1964 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1965 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1966 0x400000fc, 0x400000fb,
1967};
1968
1969static unsigned int intel_mac_v5_pin_configs[10] = {
1970 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1971 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1972 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001973};
1974
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001975static unsigned int ecs202_pin_configs[10] = {
1976 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1977 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1978 0x9037012e, 0x40e000f2,
1979};
Takashi Iwai76c08822007-06-19 12:17:42 +02001980
Takashi Iwai19039bd2006-06-28 15:52:16 +02001981static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001982 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001983 [STAC_D945GTP3] = d945gtp3_pin_configs,
1984 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001985 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1986 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1987 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1988 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1989 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001990 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001991 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001992 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1993 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1994 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1995 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1996 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1997 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001998 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001999 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
2000 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
2001 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
2002 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01002003};
2004
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002005static const char *stac922x_models[STAC_922X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002006 [STAC_922X_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002007 [STAC_D945_REF] = "ref",
2008 [STAC_D945GTP5] = "5stack",
2009 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002010 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
2011 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
2012 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
2013 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
2014 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08002015 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002016 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002017 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01002018 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01002019 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
2020 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02002021 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02002022 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002023 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002024 [STAC_922X_DELL_D81] = "dell-d81",
2025 [STAC_922X_DELL_D82] = "dell-d82",
2026 [STAC_922X_DELL_M81] = "dell-m81",
2027 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002028};
2029
2030static struct snd_pci_quirk stac922x_cfg_tbl[] = {
2031 /* SigmaTel reference board */
2032 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2033 "DFI LanParty", STAC_D945_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002034 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2035 "DFI LanParty", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002036 /* Intel 945G based systems */
2037 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2038 "Intel D945G", STAC_D945GTP3),
2039 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2040 "Intel D945G", STAC_D945GTP3),
2041 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2042 "Intel D945G", STAC_D945GTP3),
2043 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2044 "Intel D945G", STAC_D945GTP3),
2045 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2046 "Intel D945G", STAC_D945GTP3),
2047 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2048 "Intel D945G", STAC_D945GTP3),
2049 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2050 "Intel D945G", STAC_D945GTP3),
2051 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2052 "Intel D945G", STAC_D945GTP3),
2053 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2054 "Intel D945G", STAC_D945GTP3),
2055 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2056 "Intel D945G", STAC_D945GTP3),
2057 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2058 "Intel D945G", STAC_D945GTP3),
2059 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2060 "Intel D945G", STAC_D945GTP3),
2061 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2062 "Intel D945G", STAC_D945GTP3),
2063 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2064 "Intel D945G", STAC_D945GTP3),
2065 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2066 "Intel D945G", STAC_D945GTP3),
2067 /* Intel D945G 5-stack systems */
2068 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2069 "Intel D945G", STAC_D945GTP5),
2070 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2071 "Intel D945G", STAC_D945GTP5),
2072 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2073 "Intel D945G", STAC_D945GTP5),
2074 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2075 "Intel D945G", STAC_D945GTP5),
2076 /* Intel 945P based systems */
2077 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2078 "Intel D945P", STAC_D945GTP3),
2079 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2080 "Intel D945P", STAC_D945GTP3),
2081 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2082 "Intel D945P", STAC_D945GTP3),
2083 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2084 "Intel D945P", STAC_D945GTP3),
2085 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2086 "Intel D945P", STAC_D945GTP3),
2087 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2088 "Intel D945P", STAC_D945GTP5),
Takashi Iwai8056d472009-01-23 09:09:43 +01002089 /* other intel */
2090 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2091 "Intel D945", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002092 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08002093 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002094 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08002095 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002096 /* Dell systems */
2097 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2098 "unknown Dell", STAC_922X_DELL_D81),
2099 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2100 "unknown Dell", STAC_922X_DELL_D81),
2101 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2102 "unknown Dell", STAC_922X_DELL_D81),
2103 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2104 "unknown Dell", STAC_922X_DELL_D82),
2105 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2106 "unknown Dell", STAC_922X_DELL_M81),
2107 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2108 "unknown Dell", STAC_922X_DELL_D82),
2109 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2110 "unknown Dell", STAC_922X_DELL_D81),
2111 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2112 "unknown Dell", STAC_922X_DELL_D81),
2113 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2114 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002115 /* ECS/PC Chips boards */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002116 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
Herton Ronaldo Krzesinski8663ae52009-02-08 19:50:34 -02002117 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01002118 {} /* terminator */
2119};
2120
Matt Porter3cc08dc2006-01-23 15:27:49 +01002121static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002122 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2123 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2124 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2125 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002126};
2127
Tobin Davis93ed1502006-09-01 21:03:12 +02002128static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002129 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2130 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2131 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2132 0x40000100, 0x40000100
2133};
2134
Tobin Davis93ed1502006-09-01 21:03:12 +02002135static unsigned int d965_5st_pin_configs[14] = {
2136 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2137 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2138 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2139 0x40000100, 0x40000100
2140};
2141
Tobin Davis4ff076e2007-08-07 11:48:12 +02002142static unsigned int dell_3st_pin_configs[14] = {
2143 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2144 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002145 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002146 0x40c003fc, 0x40000100
2147};
2148
Tobin Davis93ed1502006-09-01 21:03:12 +02002149static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002150 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002151 [STAC_D965_REF] = ref927x_pin_configs,
2152 [STAC_D965_3ST] = d965_3st_pin_configs,
2153 [STAC_D965_5ST] = d965_5st_pin_configs,
2154 [STAC_DELL_3ST] = dell_3st_pin_configs,
2155 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002156};
2157
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002158static const char *stac927x_models[STAC_927X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002159 [STAC_927X_AUTO] = "auto",
Takashi Iwaie28d8322008-12-17 13:48:29 +01002160 [STAC_D965_REF_NO_JD] = "ref-no-jd",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002161 [STAC_D965_REF] = "ref",
2162 [STAC_D965_3ST] = "3stack",
2163 [STAC_D965_5ST] = "5stack",
2164 [STAC_DELL_3ST] = "dell-3stack",
2165 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002166};
2167
2168static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2169 /* SigmaTel reference board */
2170 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2171 "DFI LanParty", STAC_D965_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002172 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2173 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002174 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002175 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2176 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002177 /* 965 based 3 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002178 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2179 "Intel D965", STAC_D965_3ST),
2180 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2181 "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002182 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002183 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002184 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002185 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2186 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002187 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002188 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2189 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002190 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02002191 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002192 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2193 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2194 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2195 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002196 /* 965 based 5 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002197 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2198 "Intel D965", STAC_D965_5ST),
2199 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2200 "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002201 {} /* terminator */
2202};
2203
Matt Porterf3302a52006-07-31 12:49:34 +02002204static unsigned int ref9205_pin_configs[12] = {
2205 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002206 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002207 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002208};
2209
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002210/*
2211 STAC 9205 pin configs for
2212 102801F1
2213 102801F2
2214 102801FC
2215 102801FD
2216 10280204
2217 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002218 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002219*/
2220static unsigned int dell_9205_m42_pin_configs[12] = {
2221 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2222 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2223 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2224};
2225
2226/*
2227 STAC 9205 pin configs for
2228 102801F9
2229 102801FA
2230 102801FE
2231 102801FF (Dell Precision M4300)
2232 10280206
2233 10280200
2234 10280201
2235*/
2236static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002237 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2238 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2239 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2240};
2241
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002242static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002243 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2244 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2245 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2246};
2247
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002248static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002249 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002250 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2251 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2252 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Takashi Iwaid9a42682009-01-22 17:40:18 +01002253 [STAC_9205_EAPD] = NULL,
Matt Porterf3302a52006-07-31 12:49:34 +02002254};
2255
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002256static const char *stac9205_models[STAC_9205_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002257 [STAC_9205_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002258 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002259 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002260 [STAC_9205_DELL_M43] = "dell-m43",
2261 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaid9a42682009-01-22 17:40:18 +01002262 [STAC_9205_EAPD] = "eapd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002263};
2264
2265static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2266 /* SigmaTel reference board */
2267 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2268 "DFI LanParty", STAC_9205_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002269 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2270 "DFI LanParty", STAC_9205_REF),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002271 /* Dell */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002272 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2273 "unknown Dell", STAC_9205_DELL_M42),
2274 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2275 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002276 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002277 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002278 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2279 "Dell Precision", STAC_9205_DELL_M43),
2280 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2281 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002282 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2283 "unknown Dell", STAC_9205_DELL_M42),
2284 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2285 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002286 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2287 "Dell Precision", STAC_9205_DELL_M43),
2288 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002289 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002290 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2291 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002292 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2293 "Dell Precision", STAC_9205_DELL_M43),
2294 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2295 "Dell Precision", STAC_9205_DELL_M43),
2296 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2297 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002298 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2299 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002300 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2301 "Dell Vostro 1500", STAC_9205_DELL_M42),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002302 /* Gateway */
2303 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
Matt Porterf3302a52006-07-31 12:49:34 +02002304 {} /* terminator */
2305};
2306
Takashi Iwai330ee992009-02-20 14:33:36 +01002307static void stac92xx_set_config_regs(struct hda_codec *codec,
2308 unsigned int *pincfgs)
Matt2f2f4252005-04-13 14:45:30 +02002309{
2310 int i;
2311 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002312
Takashi Iwai330ee992009-02-20 14:33:36 +01002313 if (!pincfgs)
2314 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002315
Matthew Ranostay87d48362007-07-17 11:52:24 +02002316 for (i = 0; i < spec->num_pins; i++)
Takashi Iwai330ee992009-02-20 14:33:36 +01002317 if (spec->pin_nids[i] && pincfgs[i])
2318 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2319 pincfgs[i]);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002320}
2321
Matt2f2f4252005-04-13 14:45:30 +02002322/*
2323 * Analog playback callbacks
2324 */
2325static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2326 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002327 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002328{
2329 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002330 if (spec->stream_delay)
2331 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002332 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2333 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002334}
2335
2336static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2337 struct hda_codec *codec,
2338 unsigned int stream_tag,
2339 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002340 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002341{
2342 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002343 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002344}
2345
2346static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2347 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002348 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002349{
2350 struct sigmatel_spec *spec = codec->spec;
2351 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2352}
2353
2354/*
Mattdabbed62005-06-14 10:19:34 +02002355 * Digital playback callbacks
2356 */
2357static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2358 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002359 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002360{
2361 struct sigmatel_spec *spec = codec->spec;
2362 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2363}
2364
2365static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2366 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002367 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002368{
2369 struct sigmatel_spec *spec = codec->spec;
2370 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2371}
2372
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002373static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2374 struct hda_codec *codec,
2375 unsigned int stream_tag,
2376 unsigned int format,
2377 struct snd_pcm_substream *substream)
2378{
2379 struct sigmatel_spec *spec = codec->spec;
2380 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2381 stream_tag, format, substream);
2382}
2383
Takashi Iwai9411e212009-02-13 11:32:28 +01002384static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2385 struct hda_codec *codec,
2386 struct snd_pcm_substream *substream)
2387{
2388 struct sigmatel_spec *spec = codec->spec;
2389 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2390}
2391
Mattdabbed62005-06-14 10:19:34 +02002392
2393/*
Matt2f2f4252005-04-13 14:45:30 +02002394 * Analog capture callbacks
2395 */
2396static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2397 struct hda_codec *codec,
2398 unsigned int stream_tag,
2399 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002400 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002401{
2402 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002403 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002404
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002405 if (spec->powerdown_adcs) {
2406 msleep(40);
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002407 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002408 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2409 }
2410 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002411 return 0;
2412}
2413
2414static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2415 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002416 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002417{
2418 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002419 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002420
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002421 snd_hda_codec_cleanup_stream(codec, nid);
2422 if (spec->powerdown_adcs)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002423 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002424 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002425 return 0;
2426}
2427
Mattdabbed62005-06-14 10:19:34 +02002428static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2429 .substreams = 1,
2430 .channels_min = 2,
2431 .channels_max = 2,
2432 /* NID is set in stac92xx_build_pcms */
2433 .ops = {
2434 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002435 .close = stac92xx_dig_playback_pcm_close,
Takashi Iwai9411e212009-02-13 11:32:28 +01002436 .prepare = stac92xx_dig_playback_pcm_prepare,
2437 .cleanup = stac92xx_dig_playback_pcm_cleanup
Mattdabbed62005-06-14 10:19:34 +02002438 },
2439};
2440
2441static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2442 .substreams = 1,
2443 .channels_min = 2,
2444 .channels_max = 2,
2445 /* NID is set in stac92xx_build_pcms */
2446};
2447
Matt2f2f4252005-04-13 14:45:30 +02002448static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2449 .substreams = 1,
2450 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002451 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002452 .nid = 0x02, /* NID to query formats and rates */
2453 .ops = {
2454 .open = stac92xx_playback_pcm_open,
2455 .prepare = stac92xx_playback_pcm_prepare,
2456 .cleanup = stac92xx_playback_pcm_cleanup
2457 },
2458};
2459
Matt Porter3cc08dc2006-01-23 15:27:49 +01002460static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2461 .substreams = 1,
2462 .channels_min = 2,
2463 .channels_max = 2,
2464 .nid = 0x06, /* NID to query formats and rates */
2465 .ops = {
2466 .open = stac92xx_playback_pcm_open,
2467 .prepare = stac92xx_playback_pcm_prepare,
2468 .cleanup = stac92xx_playback_pcm_cleanup
2469 },
2470};
2471
Matt2f2f4252005-04-13 14:45:30 +02002472static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002473 .channels_min = 2,
2474 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002475 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002476 .ops = {
2477 .prepare = stac92xx_capture_pcm_prepare,
2478 .cleanup = stac92xx_capture_pcm_cleanup
2479 },
2480};
2481
2482static int stac92xx_build_pcms(struct hda_codec *codec)
2483{
2484 struct sigmatel_spec *spec = codec->spec;
2485 struct hda_pcm *info = spec->pcm_rec;
2486
2487 codec->num_pcms = 1;
2488 codec->pcm_info = info;
2489
Mattc7d4b2f2005-06-27 14:59:41 +02002490 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002491 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Takashi Iwai00a602d2009-01-23 11:55:42 +01002492 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2493 spec->multiout.dac_nids[0];
Matt2f2f4252005-04-13 14:45:30 +02002494 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002495 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002496 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002497
2498 if (spec->alt_switch) {
2499 codec->num_pcms++;
2500 info++;
2501 info->name = "STAC92xx Analog Alt";
2502 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2503 }
Matt2f2f4252005-04-13 14:45:30 +02002504
Mattdabbed62005-06-14 10:19:34 +02002505 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2506 codec->num_pcms++;
2507 info++;
2508 info->name = "STAC92xx Digital";
Takashi Iwai0852d7a2009-02-11 11:35:15 +01002509 info->pcm_type = spec->autocfg.dig_out_type[0];
Mattdabbed62005-06-14 10:19:34 +02002510 if (spec->multiout.dig_out_nid) {
2511 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2512 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2513 }
2514 if (spec->dig_in_nid) {
2515 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2516 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2517 }
2518 }
2519
Matt2f2f4252005-04-13 14:45:30 +02002520 return 0;
2521}
2522
Takashi Iwaic960a032006-03-23 17:06:28 +01002523static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2524{
2525 unsigned int pincap = snd_hda_param_read(codec, nid,
2526 AC_PAR_PIN_CAP);
2527 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2528 if (pincap & AC_PINCAP_VREF_100)
2529 return AC_PINCTL_VREF_100;
2530 if (pincap & AC_PINCAP_VREF_80)
2531 return AC_PINCTL_VREF_80;
2532 if (pincap & AC_PINCAP_VREF_50)
2533 return AC_PINCTL_VREF_50;
2534 if (pincap & AC_PINCAP_VREF_GRD)
2535 return AC_PINCTL_VREF_GRD;
2536 return 0;
2537}
2538
Matt Porter403d1942005-11-29 15:00:51 +01002539static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2540
2541{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002542 snd_hda_codec_write_cache(codec, nid, 0,
2543 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002544}
2545
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002546#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2547
2548static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2549 struct snd_ctl_elem_value *ucontrol)
2550{
2551 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2552 struct sigmatel_spec *spec = codec->spec;
2553
Takashi Iwaid7a89432008-11-12 09:48:04 +01002554 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002555 return 0;
2556}
2557
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002558static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
2559 unsigned char type);
2560
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002561static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2562 struct snd_ctl_elem_value *ucontrol)
2563{
2564 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2565 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002566 int nid = kcontrol->private_value;
2567
2568 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002569
2570 /* check to be sure that the ports are upto date with
2571 * switch changes
2572 */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002573 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002574
2575 return 1;
2576}
2577
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002578#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002579
2580static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2581{
2582 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2583 struct sigmatel_spec *spec = codec->spec;
2584 int io_idx = kcontrol-> private_value & 0xff;
2585
2586 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2587 return 0;
2588}
2589
2590static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2591{
2592 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2593 struct sigmatel_spec *spec = codec->spec;
2594 hda_nid_t nid = kcontrol->private_value >> 8;
2595 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002596 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002597
2598 spec->io_switch[io_idx] = val;
2599
2600 if (val)
2601 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002602 else {
2603 unsigned int pinctl = AC_PINCTL_IN_EN;
2604 if (io_idx) /* set VREF for mic */
2605 pinctl |= stac92xx_get_vref(codec, nid);
2606 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2607 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002608
2609 /* check the auto-mute again: we need to mute/unmute the speaker
2610 * appropriately according to the pin direction
2611 */
2612 if (spec->hp_detect)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002613 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
Jiang Zhe40c1d302007-11-12 13:05:16 +01002614
Matt Porter403d1942005-11-29 15:00:51 +01002615 return 1;
2616}
2617
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002618#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2619
2620static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2621 struct snd_ctl_elem_value *ucontrol)
2622{
2623 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2624 struct sigmatel_spec *spec = codec->spec;
2625
2626 ucontrol->value.integer.value[0] = spec->clfe_swap;
2627 return 0;
2628}
2629
2630static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2631 struct snd_ctl_elem_value *ucontrol)
2632{
2633 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2634 struct sigmatel_spec *spec = codec->spec;
2635 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002636 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002637
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002638 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002639 return 0;
2640
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002641 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002642
2643 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2644 spec->clfe_swap ? 0x4 : 0x0);
2645
2646 return 1;
2647}
2648
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002649#define STAC_CODEC_HP_SWITCH(xname) \
2650 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2651 .name = xname, \
2652 .index = 0, \
2653 .info = stac92xx_hp_switch_info, \
2654 .get = stac92xx_hp_switch_get, \
2655 .put = stac92xx_hp_switch_put, \
2656 }
2657
Matt Porter403d1942005-11-29 15:00:51 +01002658#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2659 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2660 .name = xname, \
2661 .index = 0, \
2662 .info = stac92xx_io_switch_info, \
2663 .get = stac92xx_io_switch_get, \
2664 .put = stac92xx_io_switch_put, \
2665 .private_value = xpval, \
2666 }
2667
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002668#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2669 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2670 .name = xname, \
2671 .index = 0, \
2672 .info = stac92xx_clfe_switch_info, \
2673 .get = stac92xx_clfe_switch_get, \
2674 .put = stac92xx_clfe_switch_put, \
2675 .private_value = xpval, \
2676 }
Matt Porter403d1942005-11-29 15:00:51 +01002677
Mattc7d4b2f2005-06-27 14:59:41 +02002678enum {
2679 STAC_CTL_WIDGET_VOL,
2680 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002681 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002682 STAC_CTL_WIDGET_AMP_MUX,
2683 STAC_CTL_WIDGET_AMP_VOL,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002684 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002685 STAC_CTL_WIDGET_IO_SWITCH,
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002686 STAC_CTL_WIDGET_CLFE_SWITCH
Mattc7d4b2f2005-06-27 14:59:41 +02002687};
2688
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002689static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002690 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2691 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002692 STAC_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002693 STAC_AMP_MUX,
2694 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002695 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002696 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002697 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002698};
2699
2700/* add dynamic controls */
Takashi Iwaie3c75962009-01-23 11:57:22 +01002701static struct snd_kcontrol_new *
2702stac_control_new(struct sigmatel_spec *spec,
2703 struct snd_kcontrol_new *ktemp,
2704 const char *name)
Mattc7d4b2f2005-06-27 14:59:41 +02002705{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002706 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002707
Takashi Iwai603c4012008-07-30 15:01:44 +02002708 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2709 knew = snd_array_new(&spec->kctls);
2710 if (!knew)
Takashi Iwaie3c75962009-01-23 11:57:22 +01002711 return NULL;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002712 *knew = *ktemp;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002713 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002714 if (!knew->name) {
2715 /* roolback */
2716 memset(knew, 0, sizeof(*knew));
2717 spec->kctls.alloced--;
2718 return NULL;
2719 }
2720 return knew;
2721}
2722
2723static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2724 struct snd_kcontrol_new *ktemp,
2725 int idx, const char *name,
2726 unsigned long val)
2727{
2728 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
2729 if (!knew)
Mattc7d4b2f2005-06-27 14:59:41 +02002730 return -ENOMEM;
Takashi Iwaie3c75962009-01-23 11:57:22 +01002731 knew->index = idx;
Mattc7d4b2f2005-06-27 14:59:41 +02002732 knew->private_value = val;
Mattc7d4b2f2005-06-27 14:59:41 +02002733 return 0;
2734}
2735
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002736static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2737 int type, int idx, const char *name,
2738 unsigned long val)
2739{
2740 return stac92xx_add_control_temp(spec,
2741 &stac92xx_control_templates[type],
2742 idx, name, val);
2743}
2744
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002745
2746/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002747static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2748 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002749{
2750 return stac92xx_add_control_idx(spec, type, 0, name, val);
2751}
2752
Takashi Iwaie3c75962009-01-23 11:57:22 +01002753static struct snd_kcontrol_new stac_input_src_temp = {
2754 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2755 .name = "Input Source",
2756 .info = stac92xx_mux_enum_info,
2757 .get = stac92xx_mux_enum_get,
2758 .put = stac92xx_mux_enum_put,
2759};
2760
2761static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2762{
2763 struct snd_kcontrol_new *knew;
2764 struct hda_input_mux *imux = &spec->private_imux;
2765
2766 if (!spec->num_adcs || imux->num_items <= 1)
2767 return 0; /* no need for input source control */
2768 knew = stac_control_new(spec, &stac_input_src_temp,
2769 stac_input_src_temp.name);
2770 if (!knew)
2771 return -ENOMEM;
2772 knew->count = spec->num_adcs;
2773 return 0;
2774}
2775
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002776/* check whether the line-input can be used as line-out */
2777static hda_nid_t check_line_out_switch(struct hda_codec *codec)
Matt Porter403d1942005-11-29 15:00:51 +01002778{
2779 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002780 struct auto_pin_cfg *cfg = &spec->autocfg;
2781 hda_nid_t nid;
2782 unsigned int pincap;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002783
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002784 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2785 return 0;
2786 nid = cfg->input_pins[AUTO_PIN_LINE];
2787 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
2788 if (pincap & AC_PINCAP_OUT)
2789 return nid;
Matt Porter403d1942005-11-29 15:00:51 +01002790 return 0;
2791}
2792
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002793/* check whether the mic-input can be used as line-out */
2794static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2795{
2796 struct sigmatel_spec *spec = codec->spec;
2797 struct auto_pin_cfg *cfg = &spec->autocfg;
2798 unsigned int def_conf, pincap;
2799 unsigned int mic_pin;
2800
2801 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2802 return 0;
2803 mic_pin = AUTO_PIN_MIC;
2804 for (;;) {
2805 hda_nid_t nid = cfg->input_pins[mic_pin];
Takashi Iwai330ee992009-02-20 14:33:36 +01002806 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002807 /* some laptops have an internal analog microphone
2808 * which can't be used as a output */
2809 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2810 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
2811 if (pincap & AC_PINCAP_OUT)
2812 return nid;
2813 }
2814 if (mic_pin == AUTO_PIN_MIC)
2815 mic_pin = AUTO_PIN_FRONT_MIC;
2816 else
2817 break;
2818 }
2819 return 0;
2820}
Steve Longerbeam7b043892007-05-03 20:50:03 +02002821
2822static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2823{
2824 int i;
2825
2826 for (i = 0; i < spec->multiout.num_dacs; i++) {
2827 if (spec->multiout.dac_nids[i] == nid)
2828 return 1;
2829 }
2830
2831 return 0;
2832}
2833
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002834static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2835{
2836 int i;
2837 if (is_in_dac_nids(spec, nid))
2838 return 1;
2839 for (i = 0; i < spec->autocfg.hp_outs; i++)
2840 if (spec->hp_dacs[i] == nid)
2841 return 1;
2842 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2843 if (spec->speaker_dacs[i] == nid)
2844 return 1;
2845 return 0;
2846}
2847
2848static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2849{
2850 struct sigmatel_spec *spec = codec->spec;
2851 int j, conn_len;
2852 hda_nid_t conn[HDA_MAX_CONNECTIONS];
2853 unsigned int wcaps, wtype;
2854
2855 conn_len = snd_hda_get_connections(codec, nid, conn,
2856 HDA_MAX_CONNECTIONS);
2857 for (j = 0; j < conn_len; j++) {
2858 wcaps = snd_hda_param_read(codec, conn[j],
2859 AC_PAR_AUDIO_WIDGET_CAP);
2860 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2861 /* we check only analog outputs */
2862 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2863 continue;
2864 /* if this route has a free DAC, assign it */
2865 if (!check_all_dac_nids(spec, conn[j])) {
2866 if (conn_len > 1) {
2867 /* select this DAC in the pin's input mux */
2868 snd_hda_codec_write_cache(codec, nid, 0,
2869 AC_VERB_SET_CONNECT_SEL, j);
2870 }
2871 return conn[j];
2872 }
2873 }
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01002874 /* if all DACs are already assigned, connect to the primary DAC */
2875 if (conn_len > 1) {
2876 for (j = 0; j < conn_len; j++) {
2877 if (conn[j] == spec->multiout.dac_nids[0]) {
2878 snd_hda_codec_write_cache(codec, nid, 0,
2879 AC_VERB_SET_CONNECT_SEL, j);
2880 break;
2881 }
2882 }
2883 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002884 return 0;
2885}
2886
2887static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2888static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2889
Matt Porter3cc08dc2006-01-23 15:27:49 +01002890/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02002891 * Fill in the dac_nids table from the parsed pin configuration
2892 * This function only works when every pin in line_out_pins[]
2893 * contains atleast one DAC in its connection list. Some 92xx
2894 * codecs are not connected directly to a DAC, such as the 9200
2895 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002896 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002897static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02002898{
2899 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002900 struct auto_pin_cfg *cfg = &spec->autocfg;
2901 int i;
2902 hda_nid_t nid, dac;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002903
Mattc7d4b2f2005-06-27 14:59:41 +02002904 for (i = 0; i < cfg->line_outs; i++) {
2905 nid = cfg->line_out_pins[i];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002906 dac = get_unassigned_dac(codec, nid);
2907 if (!dac) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002908 if (spec->multiout.num_dacs > 0) {
2909 /* we have already working output pins,
2910 * so let's drop the broken ones again
2911 */
2912 cfg->line_outs = spec->multiout.num_dacs;
2913 break;
2914 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002915 /* error out, no available DAC found */
2916 snd_printk(KERN_ERR
2917 "%s: No available DAC for pin 0x%x\n",
2918 __func__, nid);
2919 return -ENODEV;
2920 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002921 add_spec_dacs(spec, dac);
2922 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002923
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002924 /* add line-in as output */
2925 nid = check_line_out_switch(codec);
2926 if (nid) {
2927 dac = get_unassigned_dac(codec, nid);
2928 if (dac) {
2929 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
2930 nid, cfg->line_outs);
2931 cfg->line_out_pins[cfg->line_outs] = nid;
2932 cfg->line_outs++;
2933 spec->line_switch = nid;
2934 add_spec_dacs(spec, dac);
2935 }
2936 }
2937 /* add mic as output */
2938 nid = check_mic_out_switch(codec);
2939 if (nid) {
2940 dac = get_unassigned_dac(codec, nid);
2941 if (dac) {
2942 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
2943 nid, cfg->line_outs);
2944 cfg->line_out_pins[cfg->line_outs] = nid;
2945 cfg->line_outs++;
2946 spec->mic_switch = nid;
2947 add_spec_dacs(spec, dac);
Steve Longerbeam7b043892007-05-03 20:50:03 +02002948 }
Mattc7d4b2f2005-06-27 14:59:41 +02002949 }
2950
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002951 for (i = 0; i < cfg->hp_outs; i++) {
2952 nid = cfg->hp_pins[i];
2953 dac = get_unassigned_dac(codec, nid);
2954 if (dac) {
2955 if (!spec->multiout.hp_nid)
2956 spec->multiout.hp_nid = dac;
2957 else
2958 add_spec_extra_dacs(spec, dac);
2959 }
2960 spec->hp_dacs[i] = dac;
2961 }
2962
2963 for (i = 0; i < cfg->speaker_outs; i++) {
2964 nid = cfg->speaker_pins[i];
2965 dac = get_unassigned_dac(codec, nid);
2966 if (dac)
2967 add_spec_extra_dacs(spec, dac);
2968 spec->speaker_dacs[i] = dac;
2969 }
2970
2971 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
Steve Longerbeam7b043892007-05-03 20:50:03 +02002972 spec->multiout.num_dacs,
2973 spec->multiout.dac_nids[0],
2974 spec->multiout.dac_nids[1],
2975 spec->multiout.dac_nids[2],
2976 spec->multiout.dac_nids[3],
2977 spec->multiout.dac_nids[4]);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002978
Mattc7d4b2f2005-06-27 14:59:41 +02002979 return 0;
2980}
2981
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002982/* create volume control/switch for the given prefx type */
Takashi Iwai668b9652009-03-06 10:13:24 +01002983static int create_controls_idx(struct hda_codec *codec, const char *pfx,
2984 int idx, hda_nid_t nid, int chs)
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002985{
Takashi Iwai7c7767e2009-01-20 15:28:38 +01002986 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002987 char name[32];
2988 int err;
2989
Takashi Iwai7c7767e2009-01-20 15:28:38 +01002990 if (!spec->check_volume_offset) {
2991 unsigned int caps, step, nums, db_scale;
2992 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
2993 step = (caps & AC_AMPCAP_STEP_SIZE) >>
2994 AC_AMPCAP_STEP_SIZE_SHIFT;
2995 step = (step + 1) * 25; /* in .01dB unit */
2996 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
2997 AC_AMPCAP_NUM_STEPS_SHIFT;
2998 db_scale = nums * step;
2999 /* if dB scale is over -64dB, and finer enough,
3000 * let's reduce it to half
3001 */
3002 if (db_scale > 6400 && nums >= 0x1f)
3003 spec->volume_offset = nums / 2;
3004 spec->check_volume_offset = 1;
3005 }
3006
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003007 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01003008 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003009 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3010 spec->volume_offset));
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003011 if (err < 0)
3012 return err;
3013 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01003014 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003015 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3016 if (err < 0)
3017 return err;
3018 return 0;
3019}
3020
Takashi Iwai668b9652009-03-06 10:13:24 +01003021#define create_controls(codec, pfx, nid, chs) \
3022 create_controls_idx(codec, pfx, 0, nid, chs)
3023
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003024static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3025{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003026 if (spec->multiout.num_dacs > 4) {
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003027 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3028 return 1;
3029 } else {
3030 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
3031 spec->multiout.num_dacs++;
3032 }
3033 return 0;
3034}
3035
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003036static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003037{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003038 int i;
3039 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3040 if (!spec->multiout.extra_out_nid[i]) {
3041 spec->multiout.extra_out_nid[i] = nid;
3042 return 0;
3043 }
3044 }
3045 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3046 return 1;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003047}
3048
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003049/* Create output controls
3050 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3051 */
3052static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3053 const hda_nid_t *pins,
3054 const hda_nid_t *dac_nids,
3055 int type)
Mattc7d4b2f2005-06-27 14:59:41 +02003056{
Takashi Iwai76624532008-12-19 10:09:47 +01003057 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003058 static const char *chname[4] = {
3059 "Front", "Surround", NULL /*CLFE*/, "Side"
3060 };
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003061 hda_nid_t nid;
Takashi Iwai91589232008-12-19 15:59:40 +01003062 int i, err;
3063 unsigned int wid_caps;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003064
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003065 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
3066 nid = dac_nids[i];
3067 if (!nid)
3068 continue;
3069 if (type != AUTO_PIN_HP_OUT && i == 2) {
Mattc7d4b2f2005-06-27 14:59:41 +02003070 /* Center/LFE */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003071 err = create_controls(codec, "Center", nid, 1);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003072 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003073 return err;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003074 err = create_controls(codec, "LFE", nid, 2);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003075 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003076 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003077
3078 wid_caps = get_wcaps(codec, nid);
3079
3080 if (wid_caps & AC_WCAP_LR_SWAP) {
3081 err = stac92xx_add_control(spec,
3082 STAC_CTL_WIDGET_CLFE_SWITCH,
3083 "Swap Center/LFE Playback Switch", nid);
3084
3085 if (err < 0)
3086 return err;
3087 }
3088
Mattc7d4b2f2005-06-27 14:59:41 +02003089 } else {
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003090 const char *name;
Takashi Iwai668b9652009-03-06 10:13:24 +01003091 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003092 switch (type) {
3093 case AUTO_PIN_HP_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01003094 name = "Headphone";
3095 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003096 break;
3097 case AUTO_PIN_SPEAKER_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01003098 name = "Speaker";
3099 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003100 break;
3101 default:
3102 name = chname[i];
Takashi Iwai668b9652009-03-06 10:13:24 +01003103 idx = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003104 break;
Takashi Iwai76624532008-12-19 10:09:47 +01003105 }
Takashi Iwai668b9652009-03-06 10:13:24 +01003106 err = create_controls_idx(codec, name, idx, nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003107 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003108 return err;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003109 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
3110 wid_caps = get_wcaps(codec, pins[i]);
3111 if (wid_caps & AC_WCAP_UNSOL_CAP)
3112 spec->hp_detect = 1;
3113 }
Mattc7d4b2f2005-06-27 14:59:41 +02003114 }
3115 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003116 return 0;
3117}
3118
3119/* add playback controls from the parsed DAC table */
3120static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3121 const struct auto_pin_cfg *cfg)
3122{
3123 struct sigmatel_spec *spec = codec->spec;
3124 int err;
3125
3126 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3127 spec->multiout.dac_nids,
3128 cfg->line_out_type);
3129 if (err < 0)
3130 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003131
Takashi Iwaia9cb5c92008-11-24 07:51:11 +01003132 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003133 err = stac92xx_add_control(spec,
3134 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01003135 "Headphone as Line Out Switch",
3136 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003137 if (err < 0)
3138 return err;
3139 }
3140
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003141 if (spec->line_switch) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003142 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
3143 "Line In as Output Switch",
3144 spec->line_switch << 8);
3145 if (err < 0)
3146 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003147 }
Matt Porter403d1942005-11-29 15:00:51 +01003148
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003149 if (spec->mic_switch) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003150 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
3151 "Mic as Output Switch",
3152 (spec->mic_switch << 8) | 1);
3153 if (err < 0)
3154 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003155 }
Matt Porter403d1942005-11-29 15:00:51 +01003156
Mattc7d4b2f2005-06-27 14:59:41 +02003157 return 0;
3158}
3159
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003160/* add playback controls for Speaker and HP outputs */
3161static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3162 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003163{
3164 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003165 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02003166
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003167 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3168 spec->hp_dacs, AUTO_PIN_HP_OUT);
3169 if (err < 0)
3170 return err;
3171
3172 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3173 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3174 if (err < 0)
3175 return err;
3176
Mattc7d4b2f2005-06-27 14:59:41 +02003177 return 0;
3178}
3179
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003180/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003181static const char *stac92xx_mono_labels[4] = {
3182 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003183};
3184
3185/* create mono mux for mono out on capable codecs */
3186static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3187{
3188 struct sigmatel_spec *spec = codec->spec;
3189 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3190 int i, num_cons;
3191 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3192
3193 num_cons = snd_hda_get_connections(codec,
3194 spec->mono_nid,
3195 con_lst,
3196 HDA_MAX_NUM_INPUTS);
3197 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3198 return -EINVAL;
3199
3200 for (i = 0; i < num_cons; i++) {
3201 mono_mux->items[mono_mux->num_items].label =
3202 stac92xx_mono_labels[i];
3203 mono_mux->items[mono_mux->num_items].index = i;
3204 mono_mux->num_items++;
3205 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003206
3207 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3208 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003209}
3210
Matthew Ranostay89385032008-09-11 09:49:39 -04003211/* labels for amp mux outputs */
3212static const char *stac92xx_amp_labels[3] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04003213 "Front Microphone", "Microphone", "Line In",
Matthew Ranostay89385032008-09-11 09:49:39 -04003214};
3215
3216/* create amp out controls mux on capable codecs */
3217static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3218{
3219 struct sigmatel_spec *spec = codec->spec;
3220 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3221 int i, err;
3222
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003223 for (i = 0; i < spec->num_amps; i++) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003224 amp_mux->items[amp_mux->num_items].label =
3225 stac92xx_amp_labels[i];
3226 amp_mux->items[amp_mux->num_items].index = i;
3227 amp_mux->num_items++;
3228 }
3229
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003230 if (spec->num_amps > 1) {
3231 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3232 "Amp Selector Capture Switch", 0);
3233 if (err < 0)
3234 return err;
3235 }
Matthew Ranostay89385032008-09-11 09:49:39 -04003236 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3237 "Amp Capture Volume",
3238 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3239}
3240
3241
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003242/* create PC beep volume controls */
3243static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3244 hda_nid_t nid)
3245{
3246 struct sigmatel_spec *spec = codec->spec;
3247 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3248 int err;
3249
3250 /* check for mute support for the the amp */
3251 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3252 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3253 "PC Beep Playback Switch",
3254 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3255 if (err < 0)
3256 return err;
3257 }
3258
3259 /* check to see if there is volume support for the amp */
3260 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3261 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3262 "PC Beep Playback Volume",
3263 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3264 if (err < 0)
3265 return err;
3266 }
3267 return 0;
3268}
3269
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003270#ifdef CONFIG_SND_HDA_INPUT_BEEP
3271#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3272
3273static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3274 struct snd_ctl_elem_value *ucontrol)
3275{
3276 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3277 ucontrol->value.integer.value[0] = codec->beep->enabled;
3278 return 0;
3279}
3280
3281static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3282 struct snd_ctl_elem_value *ucontrol)
3283{
3284 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3285 int enabled = !!ucontrol->value.integer.value[0];
3286 if (codec->beep->enabled != enabled) {
3287 codec->beep->enabled = enabled;
3288 return 1;
3289 }
3290 return 0;
3291}
3292
3293static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3294 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3295 .info = stac92xx_dig_beep_switch_info,
3296 .get = stac92xx_dig_beep_switch_get,
3297 .put = stac92xx_dig_beep_switch_put,
3298};
3299
3300static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3301{
3302 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3303 0, "PC Beep Playback Switch", 0);
3304}
3305#endif
3306
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003307static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3308{
3309 struct sigmatel_spec *spec = codec->spec;
3310 int wcaps, nid, i, err = 0;
3311
3312 for (i = 0; i < spec->num_muxes; i++) {
3313 nid = spec->mux_nids[i];
3314 wcaps = get_wcaps(codec, nid);
3315
3316 if (wcaps & AC_WCAP_OUT_AMP) {
3317 err = stac92xx_add_control_idx(spec,
3318 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3319 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3320 if (err < 0)
3321 return err;
3322 }
3323 }
3324 return 0;
3325};
3326
Matthew Ranostayd9737752008-09-07 12:03:41 +02003327static const char *stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003328 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003329};
3330
3331static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3332{
3333 struct sigmatel_spec *spec = codec->spec;
3334 struct hda_input_mux *spdif_mux = &spec->private_smux;
Matthew Ranostay65973632008-09-16 10:39:37 -04003335 const char **labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003336 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003337 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003338
3339 num_cons = snd_hda_get_connections(codec,
3340 spec->smux_nids[0],
3341 con_lst,
3342 HDA_MAX_NUM_INPUTS);
Matthew Ranostay65973632008-09-16 10:39:37 -04003343 if (!num_cons)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003344 return -EINVAL;
3345
Matthew Ranostay65973632008-09-16 10:39:37 -04003346 if (!labels)
3347 labels = stac92xx_spdif_labels;
3348
Matthew Ranostayd9737752008-09-07 12:03:41 +02003349 for (i = 0; i < num_cons; i++) {
Matthew Ranostay65973632008-09-16 10:39:37 -04003350 spdif_mux->items[spdif_mux->num_items].label = labels[i];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003351 spdif_mux->items[spdif_mux->num_items].index = i;
3352 spdif_mux->num_items++;
3353 }
3354
3355 return 0;
3356}
3357
Matt Porter8b657272006-10-26 17:12:59 +02003358/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003359static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003360 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3361 "Digital Mic 3", "Digital Mic 4"
3362};
3363
3364/* create playback/capture controls for input pins on dmic capable codecs */
3365static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3366 const struct auto_pin_cfg *cfg)
3367{
3368 struct sigmatel_spec *spec = codec->spec;
3369 struct hda_input_mux *dimux = &spec->private_dimux;
3370 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003371 int err, i, j;
3372 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02003373
3374 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3375 dimux->items[dimux->num_items].index = 0;
3376 dimux->num_items++;
3377
3378 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003379 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003380 int index;
3381 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003382 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02003383 unsigned int def_conf;
3384
Takashi Iwai330ee992009-02-20 14:33:36 +01003385 def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
Matt Porter8b657272006-10-26 17:12:59 +02003386 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3387 continue;
3388
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003389 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02003390 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003391 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02003392 con_lst,
3393 HDA_MAX_NUM_INPUTS);
3394 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003395 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02003396 index = j;
3397 goto found;
3398 }
3399 continue;
3400found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003401 wcaps = get_wcaps(codec, nid) &
3402 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003403
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003404 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003405 sprintf(name, "%s Capture Volume",
3406 stac92xx_dmic_labels[dimux->num_items]);
3407
3408 err = stac92xx_add_control(spec,
3409 STAC_CTL_WIDGET_VOL,
3410 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003411 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3412 (wcaps & AC_WCAP_OUT_AMP) ?
3413 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003414 if (err < 0)
3415 return err;
3416 }
3417
Matt Porter8b657272006-10-26 17:12:59 +02003418 dimux->items[dimux->num_items].label =
3419 stac92xx_dmic_labels[dimux->num_items];
3420 dimux->items[dimux->num_items].index = index;
3421 dimux->num_items++;
3422 }
3423
3424 return 0;
3425}
3426
Mattc7d4b2f2005-06-27 14:59:41 +02003427/* create playback/capture controls for input pins */
3428static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3429{
3430 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003431 struct hda_input_mux *imux = &spec->private_imux;
3432 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3433 int i, j, k;
3434
3435 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003436 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02003437
Takashi Iwai314634b2006-09-21 11:56:18 +02003438 if (!cfg->input_pins[i])
3439 continue;
3440 index = -1;
3441 for (j = 0; j < spec->num_muxes; j++) {
3442 int num_cons;
3443 num_cons = snd_hda_get_connections(codec,
3444 spec->mux_nids[j],
3445 con_lst,
3446 HDA_MAX_NUM_INPUTS);
3447 for (k = 0; k < num_cons; k++)
3448 if (con_lst[k] == cfg->input_pins[i]) {
3449 index = k;
3450 goto found;
3451 }
Mattc7d4b2f2005-06-27 14:59:41 +02003452 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003453 continue;
3454 found:
3455 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3456 imux->items[imux->num_items].index = index;
3457 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003458 }
3459
Steve Longerbeam7b043892007-05-03 20:50:03 +02003460 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003461 /*
3462 * Set the current input for the muxes.
3463 * The STAC9221 has two input muxes with identical source
3464 * NID lists. Hopefully this won't get confused.
3465 */
3466 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003467 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3468 AC_VERB_SET_CONNECT_SEL,
3469 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003470 }
3471 }
3472
Mattc7d4b2f2005-06-27 14:59:41 +02003473 return 0;
3474}
3475
Mattc7d4b2f2005-06-27 14:59:41 +02003476static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3477{
3478 struct sigmatel_spec *spec = codec->spec;
3479 int i;
3480
3481 for (i = 0; i < spec->autocfg.line_outs; i++) {
3482 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3483 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3484 }
3485}
3486
3487static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3488{
3489 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003490 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003491
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003492 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3493 hda_nid_t pin;
3494 pin = spec->autocfg.hp_pins[i];
3495 if (pin) /* connect to front */
3496 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3497 }
3498 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3499 hda_nid_t pin;
3500 pin = spec->autocfg.speaker_pins[i];
3501 if (pin) /* connect to front */
3502 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3503 }
Mattc7d4b2f2005-06-27 14:59:41 +02003504}
3505
Matt Porter3cc08dc2006-01-23 15:27:49 +01003506static 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 +02003507{
3508 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003509 int hp_swap = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003510 int err;
3511
Matt Porter8b657272006-10-26 17:12:59 +02003512 if ((err = snd_hda_parse_pin_def_config(codec,
3513 &spec->autocfg,
3514 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003515 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003516 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003517 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003518
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003519 /* If we have no real line-out pin and multiple hp-outs, HPs should
3520 * be set up as multi-channel outputs.
3521 */
3522 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3523 spec->autocfg.hp_outs > 1) {
3524 /* Copy hp_outs to line_outs, backup line_outs in
3525 * speaker_outs so that the following routines can handle
3526 * HP pins as primary outputs.
3527 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003528 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003529 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3530 sizeof(spec->autocfg.line_out_pins));
3531 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3532 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3533 sizeof(spec->autocfg.hp_pins));
3534 spec->autocfg.line_outs = spec->autocfg.hp_outs;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003535 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3536 spec->autocfg.hp_outs = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003537 hp_swap = 1;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003538 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003539 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003540 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3541 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003542 u32 caps = query_amp_caps(codec,
3543 spec->autocfg.mono_out_pin, dir);
3544 hda_nid_t conn_list[1];
3545
3546 /* get the mixer node and then the mono mux if it exists */
3547 if (snd_hda_get_connections(codec,
3548 spec->autocfg.mono_out_pin, conn_list, 1) &&
3549 snd_hda_get_connections(codec, conn_list[0],
3550 conn_list, 1)) {
3551
3552 int wcaps = get_wcaps(codec, conn_list[0]);
3553 int wid_type = (wcaps & AC_WCAP_TYPE)
3554 >> AC_WCAP_TYPE_SHIFT;
3555 /* LR swap check, some stac925x have a mux that
3556 * changes the DACs output path instead of the
3557 * mono-mux path.
3558 */
3559 if (wid_type == AC_WID_AUD_SEL &&
3560 !(wcaps & AC_WCAP_LR_SWAP))
3561 spec->mono_nid = conn_list[0];
3562 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003563 if (dir) {
3564 hda_nid_t nid = spec->autocfg.mono_out_pin;
3565
3566 /* most mono outs have a least a mute/unmute switch */
3567 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3568 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3569 "Mono Playback Switch",
3570 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003571 if (err < 0)
3572 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003573 /* check for volume support for the amp */
3574 if ((caps & AC_AMPCAP_NUM_STEPS)
3575 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3576 err = stac92xx_add_control(spec,
3577 STAC_CTL_WIDGET_VOL,
3578 "Mono Playback Volume",
3579 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3580 if (err < 0)
3581 return err;
3582 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003583 }
3584
3585 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3586 AC_PINCTL_OUT_EN);
3587 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003588
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003589 if (!spec->multiout.num_dacs) {
3590 err = stac92xx_auto_fill_dac_nids(codec);
3591 if (err < 0)
Takashi Iwai19039bd2006-06-28 15:52:16 +02003592 return err;
Takashi Iwaic9280d62009-01-15 17:31:00 +01003593 err = stac92xx_auto_create_multi_out_ctls(codec,
3594 &spec->autocfg);
3595 if (err < 0)
3596 return err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003597 }
Mattc7d4b2f2005-06-27 14:59:41 +02003598
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003599 /* setup analog beep controls */
3600 if (spec->anabeep_nid > 0) {
3601 err = stac92xx_auto_create_beep_ctls(codec,
3602 spec->anabeep_nid);
3603 if (err < 0)
3604 return err;
3605 }
3606
3607 /* setup digital beep controls and input device */
3608#ifdef CONFIG_SND_HDA_INPUT_BEEP
3609 if (spec->digbeep_nid > 0) {
3610 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003611 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003612
3613 err = stac92xx_auto_create_beep_ctls(codec, nid);
3614 if (err < 0)
3615 return err;
3616 err = snd_hda_attach_beep_device(codec, nid);
3617 if (err < 0)
3618 return err;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003619 /* if no beep switch is available, make its own one */
3620 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3621 if (codec->beep &&
3622 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3623 err = stac92xx_beep_switch_ctl(codec);
3624 if (err < 0)
3625 return err;
3626 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003627 }
3628#endif
3629
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003630 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003631 if (err < 0)
3632 return err;
3633
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003634 /* All output parsing done, now restore the swapped hp pins */
3635 if (hp_swap) {
3636 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3637 sizeof(spec->autocfg.hp_pins));
3638 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3639 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3640 spec->autocfg.line_outs = 0;
3641 }
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003642
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003643 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003644 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003645 return err;
3646
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003647 if (spec->mono_nid > 0) {
3648 err = stac92xx_auto_create_mono_output_ctls(codec);
3649 if (err < 0)
3650 return err;
3651 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003652 if (spec->num_amps > 0) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003653 err = stac92xx_auto_create_amp_output_ctls(codec);
3654 if (err < 0)
3655 return err;
3656 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003657 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003658 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3659 &spec->autocfg)) < 0)
3660 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003661 if (spec->num_muxes > 0) {
3662 err = stac92xx_auto_create_mux_input_ctls(codec);
3663 if (err < 0)
3664 return err;
3665 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003666 if (spec->num_smuxes > 0) {
3667 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3668 if (err < 0)
3669 return err;
3670 }
Matt Porter8b657272006-10-26 17:12:59 +02003671
Takashi Iwaie3c75962009-01-23 11:57:22 +01003672 err = stac92xx_add_input_source(spec);
3673 if (err < 0)
3674 return err;
3675
Mattc7d4b2f2005-06-27 14:59:41 +02003676 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003677 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003678 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003679
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003680 if (spec->autocfg.dig_outs)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003681 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003682 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003683 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003684
Takashi Iwai603c4012008-07-30 15:01:44 +02003685 if (spec->kctls.list)
3686 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003687
3688 spec->input_mux = &spec->private_imux;
Matthew Ranostayf8ccbf62008-12-20 17:36:28 -05003689 if (!spec->dinput_mux)
3690 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003691 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003692 spec->mono_mux = &spec->private_mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -04003693 spec->amp_mux = &spec->private_amp_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003694 return 1;
3695}
3696
Takashi Iwai82bc9552006-03-21 11:24:42 +01003697/* add playback controls for HP output */
3698static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3699 struct auto_pin_cfg *cfg)
3700{
3701 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003702 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003703 unsigned int wid_caps;
3704
3705 if (! pin)
3706 return 0;
3707
3708 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003709 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003710 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003711
3712 return 0;
3713}
3714
Richard Fish160ea0d2006-09-06 13:58:25 +02003715/* add playback controls for LFE output */
3716static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3717 struct auto_pin_cfg *cfg)
3718{
3719 struct sigmatel_spec *spec = codec->spec;
3720 int err;
3721 hda_nid_t lfe_pin = 0x0;
3722 int i;
3723
3724 /*
3725 * search speaker outs and line outs for a mono speaker pin
3726 * with an amp. If one is found, add LFE controls
3727 * for it.
3728 */
3729 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3730 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003731 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003732 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3733 if (wcaps == AC_WCAP_OUT_AMP)
3734 /* found a mono speaker with an amp, must be lfe */
3735 lfe_pin = pin;
3736 }
3737
3738 /* if speaker_outs is 0, then speakers may be in line_outs */
3739 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3740 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3741 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003742 unsigned int defcfg;
Takashi Iwai330ee992009-02-20 14:33:36 +01003743 defcfg = snd_hda_codec_get_pincfg(codec, pin);
Harvey Harrison8b551782008-02-29 11:56:48 +01003744 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003745 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003746 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3747 if (wcaps == AC_WCAP_OUT_AMP)
3748 /* found a mono speaker with an amp,
3749 must be lfe */
3750 lfe_pin = pin;
3751 }
3752 }
3753 }
3754
3755 if (lfe_pin) {
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003756 err = create_controls(codec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003757 if (err < 0)
3758 return err;
3759 }
3760
3761 return 0;
3762}
3763
Mattc7d4b2f2005-06-27 14:59:41 +02003764static int stac9200_parse_auto_config(struct hda_codec *codec)
3765{
3766 struct sigmatel_spec *spec = codec->spec;
3767 int err;
3768
Kailang Yangdf694da2005-12-05 19:42:22 +01003769 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003770 return err;
3771
3772 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3773 return err;
3774
Takashi Iwai82bc9552006-03-21 11:24:42 +01003775 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3776 return err;
3777
Richard Fish160ea0d2006-09-06 13:58:25 +02003778 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3779 return err;
3780
Takashi Iwai355a0ec2008-11-11 16:46:19 +01003781 if (spec->num_muxes > 0) {
3782 err = stac92xx_auto_create_mux_input_ctls(codec);
3783 if (err < 0)
3784 return err;
3785 }
3786
Takashi Iwaie3c75962009-01-23 11:57:22 +01003787 err = stac92xx_add_input_source(spec);
3788 if (err < 0)
3789 return err;
3790
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003791 if (spec->autocfg.dig_outs)
Mattc7d4b2f2005-06-27 14:59:41 +02003792 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003793 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003794 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003795
Takashi Iwai603c4012008-07-30 15:01:44 +02003796 if (spec->kctls.list)
3797 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003798
3799 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003800 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003801
3802 return 1;
3803}
3804
Sam Revitch62fe78e2006-05-10 15:09:17 +02003805/*
3806 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3807 * funky external mute control using GPIO pins.
3808 */
3809
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003810static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003811 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003812{
3813 unsigned int gpiostate, gpiomask, gpiodir;
3814
3815 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3816 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003817 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003818
3819 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3820 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003821 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003822
3823 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3824 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003825 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003826
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003827 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003828 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3829
3830 snd_hda_codec_write(codec, codec->afg, 0,
3831 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003832 snd_hda_codec_read(codec, codec->afg, 0,
3833 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003834
3835 msleep(1);
3836
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003837 snd_hda_codec_read(codec, codec->afg, 0,
3838 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003839}
3840
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003841static int stac92xx_add_jack(struct hda_codec *codec,
3842 hda_nid_t nid, int type)
3843{
Takashi Iwaie4973e12008-11-18 09:32:42 +01003844#ifdef CONFIG_SND_JACK
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003845 struct sigmatel_spec *spec = codec->spec;
3846 struct sigmatel_jack *jack;
Takashi Iwai330ee992009-02-20 14:33:36 +01003847 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003848 int connectivity = get_defcfg_connect(def_conf);
3849 char name[32];
3850
3851 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
3852 return 0;
3853
3854 snd_array_init(&spec->jacks, sizeof(*jack), 32);
3855 jack = snd_array_new(&spec->jacks);
3856 if (!jack)
3857 return -ENOMEM;
3858 jack->nid = nid;
3859 jack->type = type;
3860
3861 sprintf(name, "%s at %s %s Jack",
3862 snd_hda_get_jack_type(def_conf),
3863 snd_hda_get_jack_connectivity(def_conf),
3864 snd_hda_get_jack_location(def_conf));
3865
3866 return snd_jack_new(codec->bus->card, name, type, &jack->jack);
Takashi Iwaie4973e12008-11-18 09:32:42 +01003867#else
3868 return 0;
3869#endif
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003870}
3871
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003872static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
3873 unsigned char type, int data)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003874{
3875 struct sigmatel_event *event;
3876
3877 snd_array_init(&spec->events, sizeof(*event), 32);
3878 event = snd_array_new(&spec->events);
3879 if (!event)
3880 return -ENOMEM;
3881 event->nid = nid;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003882 event->type = type;
3883 event->tag = spec->events.used;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003884 event->data = data;
3885
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003886 return event->tag;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003887}
3888
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003889static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
3890 hda_nid_t nid, unsigned char type)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003891{
3892 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003893 struct sigmatel_event *event = spec->events.list;
3894 int i;
3895
3896 for (i = 0; i < spec->events.used; i++, event++) {
3897 if (event->nid == nid && event->type == type)
3898 return event;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003899 }
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003900 return NULL;
3901}
3902
3903static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
3904 unsigned char tag)
3905{
3906 struct sigmatel_spec *spec = codec->spec;
3907 struct sigmatel_event *event = spec->events.list;
3908 int i;
3909
3910 for (i = 0; i < spec->events.used; i++, event++) {
3911 if (event->tag == tag)
3912 return event;
3913 }
3914 return NULL;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003915}
3916
Takashi Iwai314634b2006-09-21 11:56:18 +02003917static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003918 unsigned int type)
Takashi Iwai314634b2006-09-21 11:56:18 +02003919{
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003920 struct sigmatel_event *event;
3921 int tag;
3922
3923 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
3924 return;
3925 event = stac_get_event(codec, nid, type);
3926 if (event)
3927 tag = event->tag;
3928 else
3929 tag = stac_add_event(codec->spec, nid, type, 0);
3930 if (tag < 0)
3931 return;
3932 snd_hda_codec_write_cache(codec, nid, 0,
3933 AC_VERB_SET_UNSOLICITED_ENABLE,
3934 AC_USRSP_EN | tag);
Takashi Iwai314634b2006-09-21 11:56:18 +02003935}
3936
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003937static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3938{
3939 int i;
3940 for (i = 0; i < cfg->hp_outs; i++)
3941 if (cfg->hp_pins[i] == nid)
3942 return 1; /* nid is a HP-Out */
3943
3944 return 0; /* nid is not a HP-Out */
3945};
3946
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003947static void stac92xx_power_down(struct hda_codec *codec)
3948{
3949 struct sigmatel_spec *spec = codec->spec;
3950
3951 /* power down inactive DACs */
3952 hda_nid_t *dac;
3953 for (dac = spec->dac_list; *dac; dac++)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003954 if (!check_all_dac_nids(spec, *dac))
Takashi Iwai8c2f7672008-12-01 11:54:35 +01003955 snd_hda_codec_write(codec, *dac, 0,
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003956 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3957}
3958
Takashi Iwaif73d3582008-11-25 08:21:51 +01003959static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
3960 int enable);
3961
Takashi Iwai6565e4f2009-03-02 14:38:35 +01003962/* override some hints from the hwdep entry */
3963static void stac_store_hints(struct hda_codec *codec)
3964{
3965 struct sigmatel_spec *spec = codec->spec;
3966 const char *p;
3967 int val;
3968
3969 val = snd_hda_get_bool_hint(codec, "hp_detect");
3970 if (val >= 0)
3971 spec->hp_detect = val;
3972 p = snd_hda_get_hint(codec, "gpio_mask");
3973 if (p) {
3974 spec->gpio_mask = simple_strtoul(p, NULL, 0);
3975 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
3976 spec->gpio_mask;
3977 }
3978 p = snd_hda_get_hint(codec, "gpio_dir");
3979 if (p)
3980 spec->gpio_dir = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
3981 p = snd_hda_get_hint(codec, "gpio_data");
3982 if (p)
3983 spec->gpio_data = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
3984 p = snd_hda_get_hint(codec, "eapd_mask");
3985 if (p)
3986 spec->eapd_mask = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
3987 val = snd_hda_get_bool_hint(codec, "eapd_switch");
3988 if (val >= 0)
3989 spec->eapd_switch = val;
3990}
3991
Mattc7d4b2f2005-06-27 14:59:41 +02003992static int stac92xx_init(struct hda_codec *codec)
3993{
3994 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003995 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01003996 unsigned int gpio;
Takashi Iwaie4973e12008-11-18 09:32:42 +01003997 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003998
Mattc7d4b2f2005-06-27 14:59:41 +02003999 snd_hda_sequence_write(codec, spec->init);
4000
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004001 /* power down adcs initially */
4002 if (spec->powerdown_adcs)
4003 for (i = 0; i < spec->num_adcs; i++)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004004 snd_hda_codec_write(codec,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004005 spec->adc_nids[i], 0,
4006 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004007
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004008 /* override some hints */
4009 stac_store_hints(codec);
4010
Takashi Iwaif73d3582008-11-25 08:21:51 +01004011 /* set up GPIO */
4012 gpio = spec->gpio_data;
4013 /* turn on EAPD statically when spec->eapd_switch isn't set.
4014 * otherwise, unsol event will turn it on/off dynamically
4015 */
4016 if (!spec->eapd_switch)
4017 gpio |= spec->eapd_mask;
4018 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4019
Takashi Iwai82bc9552006-03-21 11:24:42 +01004020 /* set up pins */
4021 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02004022 /* Enable unsolicited responses on the HP widget */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004023 for (i = 0; i < cfg->hp_outs; i++) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004024 hda_nid_t nid = cfg->hp_pins[i];
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004025 enable_pin_detect(codec, nid, STAC_HP_EVENT);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004026 }
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01004027 /* force to enable the first line-out; the others are set up
4028 * in unsol_event
4029 */
4030 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004031 AC_PINCTL_OUT_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004032 /* fake event to set up pins */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004033 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4034 STAC_HP_EVENT);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004035 } else {
4036 stac92xx_auto_init_multi_out(codec);
4037 stac92xx_auto_init_hp_out(codec);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004038 for (i = 0; i < cfg->hp_outs; i++)
4039 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004040 }
4041 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01004042 hda_nid_t nid = cfg->input_pins[i];
4043 if (nid) {
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004044 unsigned int pinctl, conf;
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004045 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
4046 /* for mic pins, force to initialize */
4047 pinctl = stac92xx_get_vref(codec, nid);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004048 pinctl |= AC_PINCTL_IN_EN;
4049 stac92xx_auto_set_pinctl(codec, nid, pinctl);
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004050 } else {
4051 pinctl = snd_hda_codec_read(codec, nid, 0,
4052 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4053 /* if PINCTL already set then skip */
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004054 if (!(pinctl & AC_PINCTL_IN_EN)) {
4055 pinctl |= AC_PINCTL_IN_EN;
4056 stac92xx_auto_set_pinctl(codec, nid,
4057 pinctl);
4058 }
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004059 }
Takashi Iwai330ee992009-02-20 14:33:36 +01004060 conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004061 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4062 enable_pin_detect(codec, nid,
4063 STAC_INSERT_EVENT);
4064 stac_issue_unsol_event(codec, nid,
4065 STAC_INSERT_EVENT);
4066 }
Takashi Iwaic960a032006-03-23 17:06:28 +01004067 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01004068 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004069 for (i = 0; i < spec->num_dmics; i++)
4070 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4071 AC_PINCTL_IN_EN);
Takashi Iwai0852d7a2009-02-11 11:35:15 +01004072 if (cfg->dig_out_pins[0])
4073 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
Takashi Iwai82bc9552006-03-21 11:24:42 +01004074 AC_PINCTL_OUT_EN);
4075 if (cfg->dig_in_pin)
4076 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4077 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004078 for (i = 0; i < spec->num_pwrs; i++) {
4079 hda_nid_t nid = spec->pwr_nids[i];
4080 int pinctl, def_conf;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004081
Takashi Iwaieb632122008-12-19 16:39:48 +01004082 /* power on when no jack detection is available */
4083 if (!spec->hp_detect) {
4084 stac_toggle_power_map(codec, nid, 1);
4085 continue;
4086 }
4087
4088 if (is_nid_hp_pin(cfg, nid))
Takashi Iwaif73d3582008-11-25 08:21:51 +01004089 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004090
Takashi Iwaif73d3582008-11-25 08:21:51 +01004091 pinctl = snd_hda_codec_read(codec, nid, 0,
4092 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4093 /* outputs are only ports capable of power management
4094 * any attempts on powering down a input port cause the
4095 * referenced VREF to act quirky.
4096 */
Takashi Iwaieb632122008-12-19 16:39:48 +01004097 if (pinctl & AC_PINCTL_IN_EN) {
4098 stac_toggle_power_map(codec, nid, 1);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004099 continue;
Takashi Iwaieb632122008-12-19 16:39:48 +01004100 }
Takashi Iwai330ee992009-02-20 14:33:36 +01004101 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004102 def_conf = get_defcfg_connect(def_conf);
4103 /* skip any ports that don't have jacks since presence
4104 * detection is useless */
4105 if (def_conf != AC_JACK_PORT_COMPLEX) {
4106 if (def_conf != AC_JACK_PORT_NONE)
4107 stac_toggle_power_map(codec, nid, 1);
4108 continue;
4109 }
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004110 if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) {
4111 enable_pin_detect(codec, nid, STAC_PWR_EVENT);
4112 stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT);
4113 }
Takashi Iwaif73d3582008-11-25 08:21:51 +01004114 }
4115 if (spec->dac_list)
4116 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02004117 return 0;
4118}
4119
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004120static void stac92xx_free_jacks(struct hda_codec *codec)
4121{
Takashi Iwaie4973e12008-11-18 09:32:42 +01004122#ifdef CONFIG_SND_JACK
Takashi Iwaib94d3532008-11-21 09:08:06 +01004123 /* free jack instances manually when clearing/reconfiguring */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004124 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaib94d3532008-11-21 09:08:06 +01004125 if (!codec->bus->shutdown && spec->jacks.list) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004126 struct sigmatel_jack *jacks = spec->jacks.list;
4127 int i;
4128 for (i = 0; i < spec->jacks.used; i++)
4129 snd_device_free(codec->bus->card, &jacks[i].jack);
4130 }
4131 snd_array_free(&spec->jacks);
Takashi Iwaie4973e12008-11-18 09:32:42 +01004132#endif
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004133}
4134
Takashi Iwai603c4012008-07-30 15:01:44 +02004135static void stac92xx_free_kctls(struct hda_codec *codec)
4136{
4137 struct sigmatel_spec *spec = codec->spec;
4138
4139 if (spec->kctls.list) {
4140 struct snd_kcontrol_new *kctl = spec->kctls.list;
4141 int i;
4142 for (i = 0; i < spec->kctls.used; i++)
4143 kfree(kctl[i].name);
4144 }
4145 snd_array_free(&spec->kctls);
4146}
4147
Matt2f2f4252005-04-13 14:45:30 +02004148static void stac92xx_free(struct hda_codec *codec)
4149{
Mattc7d4b2f2005-06-27 14:59:41 +02004150 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004151
4152 if (! spec)
4153 return;
4154
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004155 stac92xx_free_jacks(codec);
4156 snd_array_free(&spec->events);
Richard Fish11b44bb2006-08-23 18:31:34 +02004157
Mattc7d4b2f2005-06-27 14:59:41 +02004158 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004159 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02004160}
4161
Matt4e550962005-07-04 17:51:39 +02004162static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4163 unsigned int flag)
4164{
Takashi Iwai8ce841982009-01-22 16:59:20 +01004165 unsigned int old_ctl, pin_ctl;
4166
4167 pin_ctl = snd_hda_codec_read(codec, nid,
Matt4e550962005-07-04 17:51:39 +02004168 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02004169
Takashi Iwaif9acba42007-05-29 18:01:06 +02004170 if (pin_ctl & AC_PINCTL_IN_EN) {
4171 /*
4172 * we need to check the current set-up direction of
4173 * shared input pins since they can be switched via
4174 * "xxx as Output" mixer switch
4175 */
4176 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004177 if (nid == spec->line_switch || nid == spec->mic_switch)
Takashi Iwaif9acba42007-05-29 18:01:06 +02004178 return;
4179 }
4180
Takashi Iwai8ce841982009-01-22 16:59:20 +01004181 old_ctl = pin_ctl;
Steve Longerbeam7b043892007-05-03 20:50:03 +02004182 /* if setting pin direction bits, clear the current
4183 direction bits first */
4184 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4185 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4186
Takashi Iwai8ce841982009-01-22 16:59:20 +01004187 pin_ctl |= flag;
4188 if (old_ctl != pin_ctl)
4189 snd_hda_codec_write_cache(codec, nid, 0,
4190 AC_VERB_SET_PIN_WIDGET_CONTROL,
4191 pin_ctl);
Matt4e550962005-07-04 17:51:39 +02004192}
4193
4194static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4195 unsigned int flag)
4196{
4197 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4198 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai8ce841982009-01-22 16:59:20 +01004199 if (pin_ctl & flag)
4200 snd_hda_codec_write_cache(codec, nid, 0,
4201 AC_VERB_SET_PIN_WIDGET_CONTROL,
4202 pin_ctl & ~flag);
Matt4e550962005-07-04 17:51:39 +02004203}
4204
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004205static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02004206{
4207 if (!nid)
4208 return 0;
4209 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004210 & (1 << 31))
4211 return 1;
Takashi Iwai314634b2006-09-21 11:56:18 +02004212 return 0;
4213}
4214
Takashi Iwaid7a89432008-11-12 09:48:04 +01004215/* return non-zero if the hp-pin of the given array index isn't
4216 * a jack-detection target
4217 */
4218static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4219{
4220 struct auto_pin_cfg *cfg = &spec->autocfg;
4221
4222 /* ignore sensing of shared line and mic jacks */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004223 if (cfg->hp_pins[i] == spec->line_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004224 return 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004225 if (cfg->hp_pins[i] == spec->mic_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004226 return 1;
4227 /* ignore if the pin is set as line-out */
4228 if (cfg->hp_pins[i] == spec->hp_switch)
4229 return 1;
4230 return 0;
4231}
4232
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004233static void stac92xx_hp_detect(struct hda_codec *codec)
Matt4e550962005-07-04 17:51:39 +02004234{
4235 struct sigmatel_spec *spec = codec->spec;
4236 struct auto_pin_cfg *cfg = &spec->autocfg;
4237 int i, presence;
4238
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004239 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004240 if (spec->gpio_mute)
4241 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4242 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4243
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004244 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004245 if (presence)
4246 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01004247 if (no_hp_sensing(spec, i))
4248 continue;
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004249 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4250 if (presence) {
4251 unsigned int pinctl;
4252 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4253 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4254 if (pinctl & AC_PINCTL_IN_EN)
4255 presence = 0; /* mic- or line-input */
4256 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004257 }
Matt4e550962005-07-04 17:51:39 +02004258
4259 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004260 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004261 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004262 stac92xx_reset_pinctl(codec, spec->hp_switch,
4263 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004264 for (i = 0; i < cfg->line_outs; i++)
4265 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4266 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004267 for (i = 0; i < cfg->speaker_outs; i++)
4268 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4269 AC_PINCTL_OUT_EN);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004270 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004271 stac_gpio_set(codec, spec->gpio_mask,
4272 spec->gpio_dir, spec->gpio_data &
4273 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02004274 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004275 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004276 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004277 stac92xx_set_pinctl(codec, spec->hp_switch,
4278 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004279 for (i = 0; i < cfg->line_outs; i++)
4280 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4281 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004282 for (i = 0; i < cfg->speaker_outs; i++)
4283 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4284 AC_PINCTL_OUT_EN);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004285 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004286 stac_gpio_set(codec, spec->gpio_mask,
4287 spec->gpio_dir, spec->gpio_data |
4288 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02004289 }
Takashi Iwaid7a89432008-11-12 09:48:04 +01004290 /* toggle hp outs */
4291 for (i = 0; i < cfg->hp_outs; i++) {
4292 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4293 if (no_hp_sensing(spec, i))
4294 continue;
4295 if (presence)
4296 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004297#if 0 /* FIXME */
4298/* Resetting the pinctl like below may lead to (a sort of) regressions
4299 * on some devices since they use the HP pin actually for line/speaker
4300 * outs although the default pin config shows a different pin (that is
4301 * wrong and useless).
4302 *
4303 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4304 * But, disabling the code below just works around it, and I'm too tired of
4305 * bug reports with such devices...
4306 */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004307 else
4308 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004309#endif /* FIXME */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004310 }
Matt4e550962005-07-04 17:51:39 +02004311}
4312
Takashi Iwaif73d3582008-11-25 08:21:51 +01004313static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4314 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004315{
4316 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004317 unsigned int idx, val;
4318
4319 for (idx = 0; idx < spec->num_pwrs; idx++) {
4320 if (spec->pwr_nids[idx] == nid)
4321 break;
4322 }
4323 if (idx >= spec->num_pwrs)
4324 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004325
4326 /* several codecs have two power down bits */
4327 if (spec->pwr_mapping)
4328 idx = spec->pwr_mapping[idx];
4329 else
4330 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004331
Takashi Iwaif73d3582008-11-25 08:21:51 +01004332 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4333 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004334 val &= ~idx;
4335 else
4336 val |= idx;
4337
4338 /* power down unused output ports */
4339 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004340}
4341
Takashi Iwaif73d3582008-11-25 08:21:51 +01004342static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4343{
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004344 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
Takashi Iwaif73d3582008-11-25 08:21:51 +01004345}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004346
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004347static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4348{
4349 struct sigmatel_spec *spec = codec->spec;
4350 struct sigmatel_jack *jacks = spec->jacks.list;
4351
4352 if (jacks) {
4353 int i;
4354 for (i = 0; i < spec->jacks.used; i++) {
4355 if (jacks->nid == nid) {
4356 unsigned int pin_ctl =
4357 snd_hda_codec_read(codec, nid,
4358 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4359 0x00);
4360 int type = jacks->type;
4361 if (type == (SND_JACK_LINEOUT
4362 | SND_JACK_HEADPHONE))
4363 type = (pin_ctl & AC_PINCTL_HP_EN)
4364 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4365 snd_jack_report(jacks->jack,
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004366 get_pin_presence(codec, nid)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004367 ? type : 0);
4368 }
4369 jacks++;
4370 }
4371 }
4372}
Matt2f2f4252005-04-13 14:45:30 +02004373
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004374static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
4375 unsigned char type)
4376{
4377 struct sigmatel_event *event = stac_get_event(codec, nid, type);
4378 if (!event)
4379 return;
4380 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4381}
4382
Takashi Iwai314634b2006-09-21 11:56:18 +02004383static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4384{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004385 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004386 struct sigmatel_event *event;
4387 int tag, data;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004388
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004389 tag = (res >> 26) & 0x7f;
4390 event = stac_get_event_from_tag(codec, tag);
4391 if (!event)
4392 return;
4393
4394 switch (event->type) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004395 case STAC_HP_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004396 stac92xx_hp_detect(codec);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004397 /* fallthru */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004398 case STAC_INSERT_EVENT:
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004399 case STAC_PWR_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004400 if (spec->num_pwrs > 0)
4401 stac92xx_pin_sense(codec, event->nid);
4402 stac92xx_report_jack(codec, event->nid);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004403 break;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004404 case STAC_VREF_EVENT:
4405 data = snd_hda_codec_read(codec, codec->afg, 0,
4406 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004407 /* toggle VREF state based on GPIOx status */
4408 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004409 !!(data & (1 << event->data)));
Matthew Ranostay72474be2008-10-09 09:32:17 -04004410 break;
Takashi Iwai314634b2006-09-21 11:56:18 +02004411 }
4412}
4413
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004414#ifdef CONFIG_PROC_FS
4415static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4416 struct hda_codec *codec, hda_nid_t nid)
4417{
4418 if (nid == codec->afg)
4419 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4420 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4421}
4422
4423static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4424 struct hda_codec *codec,
4425 unsigned int verb)
4426{
4427 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4428 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4429}
4430
4431/* stac92hd71bxx, stac92hd73xx */
4432static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4433 struct hda_codec *codec, hda_nid_t nid)
4434{
4435 stac92hd_proc_hook(buffer, codec, nid);
4436 if (nid == codec->afg)
4437 analog_loop_proc_hook(buffer, codec, 0xfa0);
4438}
4439
4440static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4441 struct hda_codec *codec, hda_nid_t nid)
4442{
4443 if (nid == codec->afg)
4444 analog_loop_proc_hook(buffer, codec, 0xfe0);
4445}
4446
4447static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4448 struct hda_codec *codec, hda_nid_t nid)
4449{
4450 if (nid == codec->afg)
4451 analog_loop_proc_hook(buffer, codec, 0xfeb);
4452}
4453#else
4454#define stac92hd_proc_hook NULL
4455#define stac92hd7x_proc_hook NULL
4456#define stac9205_proc_hook NULL
4457#define stac927x_proc_hook NULL
4458#endif
4459
Takashi Iwaicb53c622007-08-10 17:21:45 +02004460#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004461static int stac92xx_resume(struct hda_codec *codec)
4462{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004463 struct sigmatel_spec *spec = codec->spec;
4464
Takashi Iwai2c885872008-11-18 09:36:55 +01004465 stac92xx_init(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004466 snd_hda_codec_resume_amp(codec);
4467 snd_hda_codec_resume_cache(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01004468 /* fake event to set up pins again to override cached values */
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004469 if (spec->hp_detect)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004470 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4471 STAC_HP_EVENT);
Mattff6fdc32005-06-27 15:06:52 +02004472 return 0;
4473}
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004474
4475static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4476{
4477 struct sigmatel_spec *spec = codec->spec;
4478 if (spec->eapd_mask)
4479 stac_gpio_set(codec, spec->gpio_mask,
4480 spec->gpio_dir, spec->gpio_data &
4481 ~spec->eapd_mask);
4482 return 0;
4483}
Mattff6fdc32005-06-27 15:06:52 +02004484#endif
4485
Matt2f2f4252005-04-13 14:45:30 +02004486static struct hda_codec_ops stac92xx_patch_ops = {
4487 .build_controls = stac92xx_build_controls,
4488 .build_pcms = stac92xx_build_pcms,
4489 .init = stac92xx_init,
4490 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02004491 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004492#ifdef SND_HDA_NEEDS_RESUME
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004493 .suspend = stac92xx_suspend,
Mattff6fdc32005-06-27 15:06:52 +02004494 .resume = stac92xx_resume,
4495#endif
Matt2f2f4252005-04-13 14:45:30 +02004496};
4497
4498static int patch_stac9200(struct hda_codec *codec)
4499{
4500 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004501 int err;
Matt2f2f4252005-04-13 14:45:30 +02004502
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004503 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004504 if (spec == NULL)
4505 return -ENOMEM;
4506
4507 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004508 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004509 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004510 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4511 stac9200_models,
4512 stac9200_cfg_tbl);
Takashi Iwai330ee992009-02-20 14:33:36 +01004513 if (spec->board_config < 0)
Richard Fish11b44bb2006-08-23 18:31:34 +02004514 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01004515 else
4516 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004517 stac9200_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02004518
4519 spec->multiout.max_channels = 2;
4520 spec->multiout.num_dacs = 1;
4521 spec->multiout.dac_nids = stac9200_dac_nids;
4522 spec->adc_nids = stac9200_adc_nids;
4523 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02004524 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02004525 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004526 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004527 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004528
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02004529 if (spec->board_config == STAC_9200_M4 ||
4530 spec->board_config == STAC_9200_M4_2 ||
Tobin Davisbf277782008-02-03 20:31:47 +01004531 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02004532 spec->init = stac9200_eapd_init;
4533 else
4534 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004535 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004536
Takashi Iwai117f2572008-03-18 09:53:23 +01004537 if (spec->board_config == STAC_9200_PANASONIC) {
4538 spec->gpio_mask = spec->gpio_dir = 0x09;
4539 spec->gpio_data = 0x00;
4540 }
4541
Mattc7d4b2f2005-06-27 14:59:41 +02004542 err = stac9200_parse_auto_config(codec);
4543 if (err < 0) {
4544 stac92xx_free(codec);
4545 return err;
4546 }
Matt2f2f4252005-04-13 14:45:30 +02004547
Takashi Iwai2acc9dc2009-01-09 16:57:14 +01004548 /* CF-74 has no headphone detection, and the driver should *NOT*
4549 * do detection and HP/speaker toggle because the hardware does it.
4550 */
4551 if (spec->board_config == STAC_9200_PANASONIC)
4552 spec->hp_detect = 0;
4553
Matt2f2f4252005-04-13 14:45:30 +02004554 codec->patch_ops = stac92xx_patch_ops;
4555
4556 return 0;
4557}
4558
Tobin Davis8e21c342007-01-08 11:04:17 +01004559static int patch_stac925x(struct hda_codec *codec)
4560{
4561 struct sigmatel_spec *spec;
4562 int err;
4563
4564 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4565 if (spec == NULL)
4566 return -ENOMEM;
4567
4568 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004569 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01004570 spec->pin_nids = stac925x_pin_nids;
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02004571
4572 /* Check first for codec ID */
4573 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
4574 STAC_925x_MODELS,
4575 stac925x_models,
4576 stac925x_codec_id_cfg_tbl);
4577
4578 /* Now checks for PCI ID, if codec ID is not found */
4579 if (spec->board_config < 0)
4580 spec->board_config = snd_hda_check_board_config(codec,
4581 STAC_925x_MODELS,
Tobin Davis8e21c342007-01-08 11:04:17 +01004582 stac925x_models,
4583 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004584 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01004585 if (spec->board_config < 0)
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02004586 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
Tobin Davis2c11f952007-05-17 09:36:34 +02004587 "using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01004588 else
4589 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004590 stac925x_brd_tbl[spec->board_config]);
Tobin Davis8e21c342007-01-08 11:04:17 +01004591
4592 spec->multiout.max_channels = 2;
4593 spec->multiout.num_dacs = 1;
4594 spec->multiout.dac_nids = stac925x_dac_nids;
4595 spec->adc_nids = stac925x_adc_nids;
4596 spec->mux_nids = stac925x_mux_nids;
4597 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004598 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004599 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02004600 switch (codec->vendor_id) {
4601 case 0x83847632: /* STAC9202 */
4602 case 0x83847633: /* STAC9202D */
4603 case 0x83847636: /* STAC9251 */
4604 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02004605 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02004606 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004607 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4608 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02004609 break;
4610 default:
4611 spec->num_dmics = 0;
4612 break;
4613 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004614
4615 spec->init = stac925x_core_init;
4616 spec->mixer = stac925x_mixer;
4617
4618 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004619 if (!err) {
4620 if (spec->board_config < 0) {
4621 printk(KERN_WARNING "hda_codec: No auto-config is "
4622 "available, default to model=ref\n");
4623 spec->board_config = STAC_925x_REF;
4624 goto again;
4625 }
4626 err = -EINVAL;
4627 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004628 if (err < 0) {
4629 stac92xx_free(codec);
4630 return err;
4631 }
4632
4633 codec->patch_ops = stac92xx_patch_ops;
4634
4635 return 0;
4636}
4637
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004638static struct hda_input_mux stac92hd73xx_dmux = {
4639 .num_items = 4,
4640 .items = {
4641 { "Analog Inputs", 0x0b },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004642 { "Digital Mic 1", 0x09 },
4643 { "Digital Mic 2", 0x0a },
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004644 { "CD", 0x08 },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004645 }
4646};
4647
4648static int patch_stac92hd73xx(struct hda_codec *codec)
4649{
4650 struct sigmatel_spec *spec;
4651 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4652 int err = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004653 int num_dacs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004654
4655 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4656 if (spec == NULL)
4657 return -ENOMEM;
4658
4659 codec->spec = spec;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02004660 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004661 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4662 spec->pin_nids = stac92hd73xx_pin_nids;
4663 spec->board_config = snd_hda_check_board_config(codec,
4664 STAC_92HD73XX_MODELS,
4665 stac92hd73xx_models,
4666 stac92hd73xx_cfg_tbl);
4667again:
Takashi Iwai330ee992009-02-20 14:33:36 +01004668 if (spec->board_config < 0)
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004669 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4670 " STAC92HD73XX, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01004671 else
4672 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004673 stac92hd73xx_brd_tbl[spec->board_config]);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004674
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004675 num_dacs = snd_hda_get_connections(codec, 0x0a,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004676 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4677
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004678 if (num_dacs < 3 || num_dacs > 5) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004679 printk(KERN_WARNING "hda_codec: Could not determine "
4680 "number of channels defaulting to DAC count\n");
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004681 num_dacs = STAC92HD73_DAC_COUNT;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004682 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004683 switch (num_dacs) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004684 case 0x3: /* 6 Channel */
4685 spec->mixer = stac92hd73xx_6ch_mixer;
4686 spec->init = stac92hd73xx_6ch_core_init;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01004687 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004688 break;
4689 case 0x4: /* 8 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004690 spec->mixer = stac92hd73xx_8ch_mixer;
4691 spec->init = stac92hd73xx_8ch_core_init;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01004692 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004693 break;
4694 case 0x5: /* 10 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004695 spec->mixer = stac92hd73xx_10ch_mixer;
4696 spec->init = stac92hd73xx_10ch_core_init;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01004697 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
4698 break;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004699 }
4700 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004701
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004702 spec->aloopback_mask = 0x01;
4703 spec->aloopback_shift = 8;
4704
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004705 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004706 spec->mux_nids = stac92hd73xx_mux_nids;
4707 spec->adc_nids = stac92hd73xx_adc_nids;
4708 spec->dmic_nids = stac92hd73xx_dmic_nids;
4709 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004710 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostay89385032008-09-11 09:49:39 -04004711 spec->amp_nids = stac92hd73xx_amp_nids;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004712 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004713
4714 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4715 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01004716 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004717 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4718 sizeof(stac92hd73xx_dmux));
4719
Matthew Ranostaya7662642008-02-21 07:51:14 +01004720 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004721 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004722 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004723 /* fallthru */
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004724 case STAC_DELL_M6_AMIC:
4725 case STAC_DELL_M6_DMIC:
4726 case STAC_DELL_M6_BOTH:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004727 spec->num_smuxes = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004728 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4729 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004730 spec->eapd_switch = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004731 spec->num_amps = 1;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004732
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004733 if (spec->board_config != STAC_DELL_EQ)
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004734 spec->init = dell_m6_core_init;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004735 switch (spec->board_config) {
4736 case STAC_DELL_M6_AMIC: /* Analog Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01004737 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
Matthew Ranostaya7662642008-02-21 07:51:14 +01004738 spec->num_dmics = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004739 spec->private_dimux.num_items = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004740 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004741 case STAC_DELL_M6_DMIC: /* Digital Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01004742 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01004743 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004744 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004745 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004746 case STAC_DELL_M6_BOTH: /* Both */
Takashi Iwai330ee992009-02-20 14:33:36 +01004747 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
4748 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01004749 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004750 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004751 break;
4752 }
4753 break;
4754 default:
4755 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004756 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004757 spec->eapd_switch = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004758 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004759 if (spec->board_config > STAC_92HD73XX_REF) {
4760 /* GPIO0 High = Enable EAPD */
4761 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4762 spec->gpio_data = 0x01;
4763 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004764 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004765
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004766 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4767 spec->pwr_nids = stac92hd73xx_pwr_nids;
4768
Matthew Ranostayd9737752008-09-07 12:03:41 +02004769 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004770
4771 if (!err) {
4772 if (spec->board_config < 0) {
4773 printk(KERN_WARNING "hda_codec: No auto-config is "
4774 "available, default to model=ref\n");
4775 spec->board_config = STAC_92HD73XX_REF;
4776 goto again;
4777 }
4778 err = -EINVAL;
4779 }
4780
4781 if (err < 0) {
4782 stac92xx_free(codec);
4783 return err;
4784 }
4785
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01004786 if (spec->board_config == STAC_92HD73XX_NO_JD)
4787 spec->hp_detect = 0;
4788
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004789 codec->patch_ops = stac92xx_patch_ops;
4790
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004791 codec->proc_widget_hook = stac92hd7x_proc_hook;
4792
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004793 return 0;
4794}
4795
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004796static struct hda_input_mux stac92hd83xxx_dmux = {
4797 .num_items = 3,
4798 .items = {
4799 { "Analog Inputs", 0x03 },
4800 { "Digital Mic 1", 0x04 },
4801 { "Digital Mic 2", 0x05 },
4802 }
4803};
4804
4805static int patch_stac92hd83xxx(struct hda_codec *codec)
4806{
4807 struct sigmatel_spec *spec;
Matthew Ranostay65557f32009-01-20 16:50:25 -05004808 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004809 int err;
Matthew Ranostay65557f32009-01-20 16:50:25 -05004810 int num_dacs;
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05004811 hda_nid_t nid;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004812
4813 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4814 if (spec == NULL)
4815 return -ENOMEM;
4816
4817 codec->spec = spec;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004818 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004819 spec->mono_nid = 0x19;
4820 spec->digbeep_nid = 0x21;
4821 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4822 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4823 spec->adc_nids = stac92hd83xxx_adc_nids;
4824 spec->pwr_nids = stac92hd83xxx_pwr_nids;
Matthew Ranostayc15c5062009-01-13 13:30:07 -05004825 spec->amp_nids = stac92hd83xxx_amp_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004826 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4827 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004828 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004829
4830 spec->init = stac92hd83xxx_core_init;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004831 spec->mixer = stac92hd83xxx_mixer;
4832 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4833 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4834 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
Matthew Ranostayc15c5062009-01-13 13:30:07 -05004835 spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004836 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4837 spec->dinput_mux = &stac92hd83xxx_dmux;
4838 spec->pin_nids = stac92hd83xxx_pin_nids;
4839 spec->board_config = snd_hda_check_board_config(codec,
4840 STAC_92HD83XXX_MODELS,
4841 stac92hd83xxx_models,
4842 stac92hd83xxx_cfg_tbl);
4843again:
Takashi Iwai330ee992009-02-20 14:33:36 +01004844 if (spec->board_config < 0)
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004845 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4846 " STAC92HD83XXX, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01004847 else
4848 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004849 stac92hd83xxx_brd_tbl[spec->board_config]);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004850
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05004851 switch (codec->vendor_id) {
4852 case 0x111d7604:
4853 case 0x111d7605:
4854 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
4855 break;
4856 spec->num_pwrs = 0;
4857 break;
4858 }
4859
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004860 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4861 if (!err) {
4862 if (spec->board_config < 0) {
4863 printk(KERN_WARNING "hda_codec: No auto-config is "
4864 "available, default to model=ref\n");
4865 spec->board_config = STAC_92HD83XXX_REF;
4866 goto again;
4867 }
4868 err = -EINVAL;
4869 }
4870
4871 if (err < 0) {
4872 stac92xx_free(codec);
4873 return err;
4874 }
4875
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05004876 switch (spec->board_config) {
4877 case STAC_DELL_S14:
4878 nid = 0xf;
4879 break;
4880 default:
4881 nid = 0xe;
4882 break;
4883 }
4884
4885 num_dacs = snd_hda_get_connections(codec, nid,
4886 conn, STAC92HD83_DAC_COUNT + 1) - 1;
4887
4888 /* set port X to select the last DAC
4889 */
4890 snd_hda_codec_write_cache(codec, nid, 0,
4891 AC_VERB_SET_CONNECT_SEL, num_dacs);
4892
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004893 codec->patch_ops = stac92xx_patch_ops;
4894
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004895 codec->proc_widget_hook = stac92hd_proc_hook;
4896
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004897 return 0;
4898}
4899
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004900static struct hda_input_mux stac92hd71bxx_dmux_nomixer = {
4901 .num_items = 3,
4902 .items = {
4903 { "Analog Inputs", 0x00 },
4904 { "Digital Mic 1", 0x02 },
4905 { "Digital Mic 2", 0x03 },
4906 }
4907};
4908
4909static struct hda_input_mux stac92hd71bxx_dmux_amixer = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004910 .num_items = 4,
4911 .items = {
4912 { "Analog Inputs", 0x00 },
4913 { "Mixer", 0x01 },
4914 { "Digital Mic 1", 0x02 },
4915 { "Digital Mic 2", 0x03 },
4916 }
4917};
4918
Takashi Iwai330ee992009-02-20 14:33:36 +01004919/* get the pin connection (fixed, none, etc) */
4920static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
4921{
4922 struct sigmatel_spec *spec = codec->spec;
4923 unsigned int cfg;
4924
4925 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
4926 return get_defcfg_connect(cfg);
4927}
4928
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004929static int stac92hd71bxx_connected_ports(struct hda_codec *codec,
4930 hda_nid_t *nids, int num_nids)
4931{
4932 struct sigmatel_spec *spec = codec->spec;
4933 int idx, num;
4934 unsigned int def_conf;
4935
4936 for (num = 0; num < num_nids; num++) {
4937 for (idx = 0; idx < spec->num_pins; idx++)
4938 if (spec->pin_nids[idx] == nids[num])
4939 break;
4940 if (idx >= spec->num_pins)
4941 break;
Takashi Iwai330ee992009-02-20 14:33:36 +01004942 def_conf = stac_get_defcfg_connect(codec, idx);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004943 if (def_conf == AC_JACK_PORT_NONE)
4944 break;
4945 }
4946 return num;
4947}
4948
4949static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
4950 hda_nid_t dig0pin)
4951{
4952 struct sigmatel_spec *spec = codec->spec;
4953 int idx;
4954
4955 for (idx = 0; idx < spec->num_pins; idx++)
4956 if (spec->pin_nids[idx] == dig0pin)
4957 break;
4958 if ((idx + 2) >= spec->num_pins)
4959 return 0;
4960
4961 /* dig1pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01004962 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004963 return 2;
4964
4965 /* dig0pin + dig2pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01004966 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004967 return 2;
Takashi Iwai330ee992009-02-20 14:33:36 +01004968 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004969 return 1;
4970 else
4971 return 0;
4972}
4973
Matthew Ranostaye035b842007-11-06 11:53:55 +01004974static int patch_stac92hd71bxx(struct hda_codec *codec)
4975{
4976 struct sigmatel_spec *spec;
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05004977 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004978 int err = 0;
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004979 unsigned int ndmic_nids = 0;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004980
4981 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4982 if (spec == NULL)
4983 return -ENOMEM;
4984
4985 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004986 codec->patch_ops = stac92xx_patch_ops;
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05004987 spec->num_pins = STAC92HD71BXX_NUM_PINS;
4988 switch (codec->vendor_id) {
4989 case 0x111d76b6:
4990 case 0x111d76b7:
4991 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
4992 break;
4993 case 0x111d7603:
4994 case 0x111d7608:
4995 /* On 92HD75Bx 0x27 isn't a pin nid */
4996 spec->num_pins--;
4997 /* fallthrough */
4998 default:
4999 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
5000 }
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005001 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005002 spec->board_config = snd_hda_check_board_config(codec,
5003 STAC_92HD71BXX_MODELS,
5004 stac92hd71bxx_models,
5005 stac92hd71bxx_cfg_tbl);
5006again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005007 if (spec->board_config < 0)
Matthew Ranostaye035b842007-11-06 11:53:55 +01005008 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
5009 " STAC92HD71BXX, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01005010 else
5011 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005012 stac92hd71bxx_brd_tbl[spec->board_config]);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005013
Takashi Iwai41c3b642008-11-18 10:45:15 +01005014 if (spec->board_config > STAC_92HD71BXX_REF) {
5015 /* GPIO0 = EAPD */
5016 spec->gpio_mask = 0x01;
5017 spec->gpio_dir = 0x01;
5018 spec->gpio_data = 0x01;
5019 }
5020
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005021 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5022 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5023
Matthew Ranostay541eee82007-12-14 12:08:04 +01005024 switch (codec->vendor_id) {
5025 case 0x111d76b6: /* 4 Port without Analog Mixer */
5026 case 0x111d76b7:
Herton Ronaldo Krzesinski23c7b522009-02-08 19:51:28 -02005027 unmute_init++;
5028 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005029 case 0x111d76b4: /* 6 Port without Analog Mixer */
5030 case 0x111d76b5:
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005031 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_nomixer,
5032 sizeof(stac92hd71bxx_dmux_nomixer));
Matthew Ranostay541eee82007-12-14 12:08:04 +01005033 spec->mixer = stac92hd71bxx_mixer;
5034 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005035 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005036 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5037 stac92hd71bxx_dmic_nids,
5038 STAC92HD71BXX_NUM_DMICS);
5039 if (spec->num_dmics) {
5040 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5041 spec->dinput_mux = &spec->private_dimux;
5042 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
5043 }
Matthew Ranostay541eee82007-12-14 12:08:04 +01005044 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005045 case 0x111d7608: /* 5 Port with Analog Mixer */
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005046 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
5047 sizeof(stac92hd71bxx_dmux_amixer));
5048 spec->private_dimux.num_items--;
Takashi Iwai8e5f2622008-11-15 19:28:54 +01005049 switch (spec->board_config) {
5050 case STAC_HP_M4:
Matthew Ranostay72474be2008-10-09 09:32:17 -04005051 /* Enable VREF power saving on GPIO1 detect */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005052 err = stac_add_event(spec, codec->afg,
5053 STAC_VREF_EVENT, 0x02);
5054 if (err < 0)
5055 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005056 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay72474be2008-10-09 09:32:17 -04005057 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
5058 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005059 AC_VERB_SET_UNSOLICITED_ENABLE,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005060 AC_USRSP_EN | err);
Matthew Ranostay72474be2008-10-09 09:32:17 -04005061 spec->gpio_mask |= 0x02;
5062 break;
5063 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005064 if ((codec->revision_id & 0xf) == 0 ||
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005065 (codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005066 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005067
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005068 /* no output amps */
5069 spec->num_pwrs = 0;
5070 spec->mixer = stac92hd71bxx_analog_mixer;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005071 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005072
5073 /* disable VSW */
5074 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005075 unmute_init++;
Takashi Iwai330ee992009-02-20 14:33:36 +01005076 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5077 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005078 stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0;
5079 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5080 stac92hd71bxx_dmic_nids,
5081 STAC92HD71BXX_NUM_DMICS - 1);
5082 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5083 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 2;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005084 break;
5085 case 0x111d7603: /* 6 Port with Analog Mixer */
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005086 if ((codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005087 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005088
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005089 /* no output amps */
5090 spec->num_pwrs = 0;
5091 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005092 default:
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005093 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
5094 sizeof(stac92hd71bxx_dmux_amixer));
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005095 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005096 spec->mixer = stac92hd71bxx_analog_mixer;
5097 spec->init = stac92hd71bxx_analog_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005098 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005099 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5100 stac92hd71bxx_dmic_nids,
5101 STAC92HD71BXX_NUM_DMICS);
5102 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5103 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005104 }
5105
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005106 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5107 snd_hda_sequence_write_cache(codec, unmute_init);
5108
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005109 spec->aloopback_ctl = stac92hd71bxx_loopback;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005110 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005111 spec->aloopback_shift = 0;
5112
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005113 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005114 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005115 spec->mux_nids = stac92hd71bxx_mux_nids;
5116 spec->adc_nids = stac92hd71bxx_adc_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005117 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005118 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005119
5120 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5121 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005122 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005123
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005124 switch (spec->board_config) {
5125 case STAC_HP_M4:
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005126 /* enable internal microphone */
Takashi Iwai330ee992009-02-20 14:33:36 +01005127 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
Matthew Ranostayb9aea712008-10-09 08:37:28 -04005128 stac92xx_auto_set_pinctl(codec, 0x0e,
5129 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05005130 /* fallthru */
5131 case STAC_DELL_M4_2:
5132 spec->num_dmics = 0;
5133 spec->num_smuxes = 0;
5134 spec->num_dmuxes = 0;
5135 break;
5136 case STAC_DELL_M4_1:
5137 case STAC_DELL_M4_3:
5138 spec->num_dmics = 1;
5139 spec->num_smuxes = 0;
Takashi Iwaiea18aa42009-02-27 17:36:33 +01005140 spec->num_dmuxes = 1;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005141 break;
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005142 case STAC_HP_DV5:
Takashi Iwai330ee992009-02-20 14:33:36 +01005143 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005144 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
5145 break;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005146 };
5147
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005148 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005149 if (spec->dinput_mux)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005150 spec->private_dimux.num_items += spec->num_dmics - ndmic_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005151
Herton Ronaldo Krzesinski29d4ab42009-02-04 11:37:27 -05005152 err = stac92xx_parse_auto_config(codec, 0x21, 0);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005153 if (!err) {
5154 if (spec->board_config < 0) {
5155 printk(KERN_WARNING "hda_codec: No auto-config is "
5156 "available, default to model=ref\n");
5157 spec->board_config = STAC_92HD71BXX_REF;
5158 goto again;
5159 }
5160 err = -EINVAL;
5161 }
5162
5163 if (err < 0) {
5164 stac92xx_free(codec);
5165 return err;
5166 }
5167
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005168 codec->proc_widget_hook = stac92hd7x_proc_hook;
5169
Matthew Ranostaye035b842007-11-06 11:53:55 +01005170 return 0;
5171};
5172
Matt2f2f4252005-04-13 14:45:30 +02005173static int patch_stac922x(struct hda_codec *codec)
5174{
5175 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005176 int err;
Matt2f2f4252005-04-13 14:45:30 +02005177
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005178 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02005179 if (spec == NULL)
5180 return -ENOMEM;
5181
5182 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005183 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005184 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005185 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5186 stac922x_models,
5187 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08005188 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005189 spec->gpio_mask = spec->gpio_dir = 0x03;
5190 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005191 /* Intel Macs have all same PCI SSID, so we need to check
5192 * codec SSID to distinguish the exact models
5193 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005194 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005195 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005196
5197 case 0x106b0800:
5198 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02005199 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005200 case 0x106b0600:
5201 case 0x106b0700:
5202 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005203 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005204 case 0x106b0e00:
5205 case 0x106b0f00:
5206 case 0x106b1600:
5207 case 0x106b1700:
5208 case 0x106b0200:
5209 case 0x106b1e00:
5210 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005211 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005212 case 0x106b1a00:
5213 case 0x00000100:
5214 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02005215 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005216 case 0x106b0a00:
5217 case 0x106b2200:
5218 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02005219 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08005220 default:
5221 spec->board_config = STAC_INTEL_MAC_V3;
5222 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005223 }
5224 }
5225
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005226 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005227 if (spec->board_config < 0)
Richard Fish11b44bb2006-08-23 18:31:34 +02005228 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
5229 "using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01005230 else
5231 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005232 stac922x_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02005233
Matt2f2f4252005-04-13 14:45:30 +02005234 spec->adc_nids = stac922x_adc_nids;
5235 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005236 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005237 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005238 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005239 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02005240
5241 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02005242 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02005243
5244 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02005245
Matt Porter3cc08dc2006-01-23 15:27:49 +01005246 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005247 if (!err) {
5248 if (spec->board_config < 0) {
5249 printk(KERN_WARNING "hda_codec: No auto-config is "
5250 "available, default to model=ref\n");
5251 spec->board_config = STAC_D945_REF;
5252 goto again;
5253 }
5254 err = -EINVAL;
5255 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005256 if (err < 0) {
5257 stac92xx_free(codec);
5258 return err;
5259 }
5260
5261 codec->patch_ops = stac92xx_patch_ops;
5262
Takashi Iwai807a46362007-05-29 19:01:37 +02005263 /* Fix Mux capture level; max to 2 */
5264 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
5265 (0 << AC_AMPCAP_OFFSET_SHIFT) |
5266 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5267 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5268 (0 << AC_AMPCAP_MUTE_SHIFT));
5269
Matt Porter3cc08dc2006-01-23 15:27:49 +01005270 return 0;
5271}
5272
5273static int patch_stac927x(struct hda_codec *codec)
5274{
5275 struct sigmatel_spec *spec;
5276 int err;
5277
5278 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5279 if (spec == NULL)
5280 return -ENOMEM;
5281
5282 codec->spec = spec;
Matthew Ranostay45c1d852009-02-04 17:49:41 -05005283 codec->slave_dig_outs = stac927x_slave_dig_outs;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005284 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005285 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005286 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5287 stac927x_models,
5288 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005289 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005290 if (spec->board_config < 0)
Herton Ronaldo Krzesinskic98041f2009-02-11 20:33:15 -02005291 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
5292 "STAC927x, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01005293 else
5294 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005295 stac927x_brd_tbl[spec->board_config]);
Matt Porter3cc08dc2006-01-23 15:27:49 +01005296
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005297 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005298 spec->adc_nids = stac927x_adc_nids;
5299 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
5300 spec->mux_nids = stac927x_mux_nids;
5301 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005302 spec->smux_nids = stac927x_smux_nids;
5303 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04005304 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005305 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005306 spec->multiout.dac_nids = spec->dac_nids;
5307
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005308 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02005309 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005310 case STAC_D965_5ST:
5311 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005312 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005313 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005314 spec->num_dmics = 0;
5315
Tobin Davis93ed1502006-09-01 21:03:12 +02005316 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005317 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005318 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005319 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02005320 switch (codec->subsystem_id) {
5321 case 0x10280209:
5322 case 0x1028022e:
5323 /* correct the device field to SPDIF out */
Takashi Iwai330ee992009-02-20 14:33:36 +01005324 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
Matthew Ranostay780c8be2008-04-14 13:32:27 +02005325 break;
5326 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01005327 /* configure the analog microphone on some laptops */
Takashi Iwai330ee992009-02-20 14:33:36 +01005328 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01005329 /* correct the front output jack as a hp out */
Takashi Iwai330ee992009-02-20 14:33:36 +01005330 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01005331 /* correct the front input jack as a mic */
Takashi Iwai330ee992009-02-20 14:33:36 +01005332 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01005333 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005334 case STAC_DELL_3ST:
5335 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005336 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005337 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005338 spec->dmic_nids = stac927x_dmic_nids;
5339 spec->num_dmics = STAC927X_NUM_DMICS;
5340
Tobin Davis93ed1502006-09-01 21:03:12 +02005341 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005342 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005343 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005344 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005345 break;
5346 default:
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005347 if (spec->board_config > STAC_D965_REF) {
5348 /* GPIO0 High = Enable EAPD */
5349 spec->eapd_mask = spec->gpio_mask = 0x01;
5350 spec->gpio_dir = spec->gpio_data = 0x01;
5351 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005352 spec->num_dmics = 0;
5353
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005354 spec->init = stac927x_core_init;
5355 spec->mixer = stac927x_mixer;
5356 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005357
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005358 spec->num_pwrs = 0;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005359 spec->aloopback_ctl = stac927x_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005360 spec->aloopback_mask = 0x40;
5361 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005362 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005363
Matt Porter3cc08dc2006-01-23 15:27:49 +01005364 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005365 if (!err) {
5366 if (spec->board_config < 0) {
5367 printk(KERN_WARNING "hda_codec: No auto-config is "
5368 "available, default to model=ref\n");
5369 spec->board_config = STAC_D965_REF;
5370 goto again;
5371 }
5372 err = -EINVAL;
5373 }
Mattc7d4b2f2005-06-27 14:59:41 +02005374 if (err < 0) {
5375 stac92xx_free(codec);
5376 return err;
5377 }
Matt2f2f4252005-04-13 14:45:30 +02005378
5379 codec->patch_ops = stac92xx_patch_ops;
5380
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005381 codec->proc_widget_hook = stac927x_proc_hook;
5382
Takashi Iwai52987652008-01-16 16:09:47 +01005383 /*
5384 * !!FIXME!!
5385 * The STAC927x seem to require fairly long delays for certain
5386 * command sequences. With too short delays (even if the answer
5387 * is set to RIRB properly), it results in the silence output
5388 * on some hardwares like Dell.
5389 *
5390 * The below flag enables the longer delay (see get_response
5391 * in hda_intel.c).
5392 */
5393 codec->bus->needs_damn_long_delay = 1;
5394
Takashi Iwaie28d8322008-12-17 13:48:29 +01005395 /* no jack detecion for ref-no-jd model */
5396 if (spec->board_config == STAC_D965_REF_NO_JD)
5397 spec->hp_detect = 0;
5398
Matt2f2f4252005-04-13 14:45:30 +02005399 return 0;
5400}
5401
Matt Porterf3302a52006-07-31 12:49:34 +02005402static int patch_stac9205(struct hda_codec *codec)
5403{
5404 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02005405 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02005406
5407 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5408 if (spec == NULL)
5409 return -ENOMEM;
5410
5411 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005412 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005413 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005414 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
5415 stac9205_models,
5416 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005417 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005418 if (spec->board_config < 0)
Richard Fish11b44bb2006-08-23 18:31:34 +02005419 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01005420 else
5421 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005422 stac9205_brd_tbl[spec->board_config]);
Matt Porterf3302a52006-07-31 12:49:34 +02005423
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005424 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02005425 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005426 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02005427 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005428 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005429 spec->smux_nids = stac9205_smux_nids;
5430 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005431 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02005432 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005433 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005434 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005435 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02005436
5437 spec->init = stac9205_core_init;
5438 spec->mixer = stac9205_mixer;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005439 spec->aloopback_ctl = stac9205_loopback;
Matt Porterf3302a52006-07-31 12:49:34 +02005440
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005441 spec->aloopback_mask = 0x40;
5442 spec->aloopback_shift = 0;
Takashi Iwaid9a42682009-01-22 17:40:18 +01005443 /* Turn on/off EAPD per HP plugging */
5444 if (spec->board_config != STAC_9205_EAPD)
5445 spec->eapd_switch = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02005446 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02005447
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005448 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005449 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02005450 /* Enable SPDIF in/out */
Takashi Iwai330ee992009-02-20 14:33:36 +01005451 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
5452 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01005453
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005454 /* Enable unsol response for GPIO4/Dock HP connection */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005455 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
5456 if (err < 0)
5457 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005458 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005459 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
5460 snd_hda_codec_write_cache(codec, codec->afg, 0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005461 AC_VERB_SET_UNSOLICITED_ENABLE,
5462 AC_USRSP_EN | err);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005463
5464 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005465 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005466 spec->gpio_mask = 0x1b;
5467 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01005468 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005469 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02005470 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005471 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005472 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005473 case STAC_9205_REF:
5474 /* SPDIF-In enabled */
5475 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005476 default:
5477 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005478 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005479 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005480 break;
5481 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02005482
Matt Porterf3302a52006-07-31 12:49:34 +02005483 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005484 if (!err) {
5485 if (spec->board_config < 0) {
5486 printk(KERN_WARNING "hda_codec: No auto-config is "
5487 "available, default to model=ref\n");
5488 spec->board_config = STAC_9205_REF;
5489 goto again;
5490 }
5491 err = -EINVAL;
5492 }
Matt Porterf3302a52006-07-31 12:49:34 +02005493 if (err < 0) {
5494 stac92xx_free(codec);
5495 return err;
5496 }
5497
5498 codec->patch_ops = stac92xx_patch_ops;
5499
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005500 codec->proc_widget_hook = stac9205_proc_hook;
5501
Matt Porterf3302a52006-07-31 12:49:34 +02005502 return 0;
5503}
5504
Matt2f2f4252005-04-13 14:45:30 +02005505/*
Guillaume Munch6d859062006-08-22 17:15:47 +02005506 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01005507 */
5508
Takashi Iwai1e137f92009-01-21 07:41:22 +01005509static struct hda_verb stac9872_core_init[] = {
Takashi Iwai1624cb92007-07-05 13:10:51 +02005510 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005511 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5512 {}
5513};
5514
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005515static struct snd_kcontrol_new stac9872_mixer[] = {
5516 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5517 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005518 { } /* end */
5519};
5520
5521static hda_nid_t stac9872_pin_nids[] = {
5522 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
5523 0x11, 0x13, 0x14,
5524};
5525
5526static hda_nid_t stac9872_adc_nids[] = {
5527 0x8 /*,0x6*/
5528};
5529
5530static hda_nid_t stac9872_mux_nids[] = {
5531 0x15
5532};
5533
Guillaume Munch6d859062006-08-22 17:15:47 +02005534static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01005535{
5536 struct sigmatel_spec *spec;
Takashi Iwai1e137f92009-01-21 07:41:22 +01005537 int err;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005538
Takashi Iwaidb064e52006-03-16 16:04:58 +01005539 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5540 if (spec == NULL)
5541 return -ENOMEM;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005542 codec->spec = spec;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005543
Takashi Iwai1e137f92009-01-21 07:41:22 +01005544#if 0 /* no model right now */
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005545 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5546 stac9872_models,
5547 stac9872_cfg_tbl);
Takashi Iwai1e137f92009-01-21 07:41:22 +01005548#endif
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005549
Takashi Iwai1e137f92009-01-21 07:41:22 +01005550 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
5551 spec->pin_nids = stac9872_pin_nids;
5552 spec->multiout.dac_nids = spec->dac_nids;
5553 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
5554 spec->adc_nids = stac9872_adc_nids;
5555 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
5556 spec->mux_nids = stac9872_mux_nids;
5557 spec->mixer = stac9872_mixer;
5558 spec->init = stac9872_core_init;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005559
Takashi Iwai1e137f92009-01-21 07:41:22 +01005560 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
5561 if (err < 0) {
5562 stac92xx_free(codec);
5563 return -EINVAL;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005564 }
Takashi Iwai1e137f92009-01-21 07:41:22 +01005565 spec->input_mux = &spec->private_imux;
5566 codec->patch_ops = stac92xx_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005567 return 0;
5568}
5569
5570
5571/*
Matt2f2f4252005-04-13 14:45:30 +02005572 * patch entries
5573 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +01005574static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
Matt2f2f4252005-04-13 14:45:30 +02005575 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5576 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5577 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5578 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5579 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5580 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5581 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02005582 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5583 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5584 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5585 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5586 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5587 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01005588 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5589 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5590 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5591 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5592 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5593 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5594 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5595 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5596 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5597 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01005598 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5599 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5600 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5601 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5602 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5603 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02005604 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5605 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02005606 /* The following does not take into account .id=0x83847661 when subsys =
5607 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5608 * currently not fully supported.
5609 */
5610 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5611 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5612 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02005613 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5614 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5615 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5616 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5617 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5618 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5619 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5620 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005621 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005622 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5623 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005624 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01005625 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5626 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005627 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01005628 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5629 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5630 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5631 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5632 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5633 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5634 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5635 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02005636 {} /* terminator */
5637};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01005638
5639MODULE_ALIAS("snd-hda-codec-id:8384*");
5640MODULE_ALIAS("snd-hda-codec-id:111d*");
5641
5642MODULE_LICENSE("GPL");
5643MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
5644
5645static struct hda_codec_preset_list sigmatel_list = {
5646 .preset = snd_hda_preset_sigmatel,
5647 .owner = THIS_MODULE,
5648};
5649
5650static int __init patch_sigmatel_init(void)
5651{
5652 return snd_hda_add_codec_preset(&sigmatel_list);
5653}
5654
5655static void __exit patch_sigmatel_exit(void)
5656{
5657 snd_hda_delete_codec_preset(&sigmatel_list);
5658}
5659
5660module_init(patch_sigmatel_init)
5661module_exit(patch_sigmatel_exit)