blob: 66c0876bf734703774e6b451575c898a75578b23 [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,
Takashi Iwaifefd67f2009-07-30 18:03:05 +020043 STAC_LO_EVENT,
Takashi Iwai3d21d3f2009-07-29 14:32:56 +020044 STAC_MIC_EVENT,
Takashi Iwaic6e4c662008-11-25 11:58:19 +010045};
Matt4e550962005-07-04 17:51:39 +020046
Takashi Iwaif5fcc132006-11-24 17:07:44 +010047enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010048 STAC_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010049 STAC_REF,
Tobin Davisbf277782008-02-03 20:31:47 +010050 STAC_9200_OQO,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020051 STAC_9200_DELL_D21,
52 STAC_9200_DELL_D22,
53 STAC_9200_DELL_D23,
54 STAC_9200_DELL_M21,
55 STAC_9200_DELL_M22,
56 STAC_9200_DELL_M23,
57 STAC_9200_DELL_M24,
58 STAC_9200_DELL_M25,
59 STAC_9200_DELL_M26,
60 STAC_9200_DELL_M27,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +020061 STAC_9200_M4,
62 STAC_9200_M4_2,
Takashi Iwai117f2572008-03-18 09:53:23 +010063 STAC_9200_PANASONIC,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010064 STAC_9200_MODELS
65};
66
67enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010068 STAC_9205_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010069 STAC_9205_REF,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020070 STAC_9205_DELL_M42,
Tobin Davisae0a8ed2007-08-13 15:50:29 +020071 STAC_9205_DELL_M43,
72 STAC_9205_DELL_M44,
Takashi Iwaid9a42682009-01-22 17:40:18 +010073 STAC_9205_EAPD,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010074 STAC_9205_MODELS
75};
76
77enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010078 STAC_92HD73XX_AUTO,
Takashi Iwai9e43f0d2008-12-17 14:51:01 +010079 STAC_92HD73XX_NO_JD, /* no jack-detection */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010080 STAC_92HD73XX_REF,
Wu Fengguangae709442009-08-19 17:05:11 +080081 STAC_92HD73XX_INTEL,
Takashi Iwai661cd8f2008-11-25 15:18:29 +010082 STAC_DELL_M6_AMIC,
83 STAC_DELL_M6_DMIC,
84 STAC_DELL_M6_BOTH,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -050085 STAC_DELL_EQ,
Takashi Iwai842ae632009-09-02 07:43:08 +020086 STAC_ALIENWARE_M17X,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010087 STAC_92HD73XX_MODELS
88};
89
90enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010091 STAC_92HD83XXX_AUTO,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020092 STAC_92HD83XXX_REF,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -050093 STAC_92HD83XXX_PWR_REF,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -050094 STAC_DELL_S14,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020095 STAC_92HD83XXX_MODELS
96};
97
98enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010099 STAC_92HD71BXX_AUTO,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100100 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +0100101 STAC_DELL_M4_1,
102 STAC_DELL_M4_2,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -0500103 STAC_DELL_M4_3,
Matthew Ranostay6a14f582008-09-12 12:02:30 -0400104 STAC_HP_M4,
Takashi Iwai1b0652e2009-01-14 08:27:35 +0100105 STAC_HP_DV5,
Christoph Plattnerae6241f2009-03-08 23:19:05 +0100106 STAC_HP_HDX,
James Gardiner514bf542009-05-03 04:00:44 -0400107 STAC_HP_DV4_1222NR,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100108 STAC_92HD71BXX_MODELS
109};
110
111enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100112 STAC_925x_AUTO,
Tobin Davis8e21c342007-01-08 11:04:17 +0100113 STAC_925x_REF,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200114 STAC_M1,
115 STAC_M1_2,
116 STAC_M2,
Tobin Davis8e21c342007-01-08 11:04:17 +0100117 STAC_M2_2,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200118 STAC_M3,
119 STAC_M5,
120 STAC_M6,
Tobin Davis8e21c342007-01-08 11:04:17 +0100121 STAC_925x_MODELS
122};
123
124enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100125 STAC_922X_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100126 STAC_D945_REF,
127 STAC_D945GTP3,
128 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200129 STAC_INTEL_MAC_V1,
130 STAC_INTEL_MAC_V2,
131 STAC_INTEL_MAC_V3,
132 STAC_INTEL_MAC_V4,
133 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800134 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
135 * is given, one of the above models will be
136 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200137 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100138 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100139 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100140 STAC_MACBOOK_PRO_V1,
141 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200142 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200143 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300144 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200145 STAC_922X_DELL_D81,
146 STAC_922X_DELL_D82,
147 STAC_922X_DELL_M81,
148 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100149 STAC_922X_MODELS
150};
151
152enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100153 STAC_927X_AUTO,
Takashi Iwaie28d8322008-12-17 13:48:29 +0100154 STAC_D965_REF_NO_JD, /* no jack-detection */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100155 STAC_D965_REF,
156 STAC_D965_3ST,
157 STAC_D965_5ST,
Takashi Iwai679d92e2009-05-24 19:00:08 +0200158 STAC_D965_5ST_NO_FP,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200159 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100160 STAC_DELL_BIOS,
Takashi Iwai54930532009-10-11 17:38:29 +0200161 STAC_927X_VOLKNOB,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100162 STAC_927X_MODELS
163};
Matt Porter403d1942005-11-29 15:00:51 +0100164
Takashi Iwai307282c2009-03-12 18:17:58 +0100165enum {
166 STAC_9872_AUTO,
167 STAC_9872_VAIO,
168 STAC_9872_MODELS
169};
170
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400171struct sigmatel_event {
172 hda_nid_t nid;
Takashi Iwaic6e4c662008-11-25 11:58:19 +0100173 unsigned char type;
174 unsigned char tag;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400175 int data;
176};
177
178struct sigmatel_jack {
179 hda_nid_t nid;
180 int type;
181 struct snd_jack *jack;
182};
183
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200184struct sigmatel_mic_route {
185 hda_nid_t pin;
Takashi Iwai02d33322009-10-01 16:38:11 +0200186 signed char mux_idx;
187 signed char dmux_idx;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200188};
189
Matt2f2f4252005-04-13 14:45:30 +0200190struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100191 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200192 unsigned int num_mixers;
193
Matt Porter403d1942005-11-29 15:00:51 +0100194 int board_config;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -0500195 unsigned int eapd_switch: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200196 unsigned int surr_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100197 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100198 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400199 unsigned int spdif_mute: 1;
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100200 unsigned int check_volume_offset:1;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200201 unsigned int auto_mic:1;
Mattc7d4b2f2005-06-27 14:59:41 +0200202
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100203 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200204 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100205 unsigned int gpio_mask;
206 unsigned int gpio_dir;
207 unsigned int gpio_data;
208 unsigned int gpio_mute;
Takashi Iwai86d190e2009-05-26 15:18:58 +0200209 unsigned int gpio_led;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100210
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200211 /* stream */
212 unsigned int stream_delay;
213
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100214 /* analog loopback */
Takashi Iwaid78d7a92009-03-02 14:26:25 +0100215 struct snd_kcontrol_new *aloopback_ctl;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100216 unsigned char aloopback_mask;
217 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200218
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100219 /* power management */
220 unsigned int num_pwrs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200221 unsigned int *pwr_mapping;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100222 hda_nid_t *pwr_nids;
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100223 hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100224
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400225 /* jack detection */
226 struct snd_array jacks;
227
228 /* events */
229 struct snd_array events;
230
Matt2f2f4252005-04-13 14:45:30 +0200231 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100232 struct hda_input_mux *mono_mux;
233 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200234 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100235 hda_nid_t dac_nids[5];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100236 hda_nid_t hp_dacs[5];
237 hda_nid_t speaker_dacs[5];
Matt2f2f4252005-04-13 14:45:30 +0200238
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100239 int volume_offset;
240
Matt2f2f4252005-04-13 14:45:30 +0200241 /* capture */
242 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200243 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200244 hda_nid_t *mux_nids;
245 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200246 hda_nid_t *dmic_nids;
247 unsigned int num_dmics;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100248 hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100249 unsigned int num_dmuxes;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200250 hda_nid_t *smux_nids;
251 unsigned int num_smuxes;
Takashi Iwai5207e102009-07-30 13:09:08 +0200252 unsigned int num_analog_muxes;
Takashi Iwai6479c632009-07-28 18:20:25 +0200253
254 unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
255 unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
256 unsigned int num_caps; /* number of capture volume/switch elements */
257
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200258 struct sigmatel_mic_route ext_mic;
259 struct sigmatel_mic_route int_mic;
260
Matthew Ranostay65973632008-09-16 10:39:37 -0400261 const char **spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200262
Mattdabbed62005-06-14 10:19:34 +0200263 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100264 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200265 hda_nid_t anabeep_nid;
266 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200267
Matt2f2f4252005-04-13 14:45:30 +0200268 /* pin widgets */
269 hda_nid_t *pin_nids;
270 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200271
272 /* codec specific stuff */
273 struct hda_verb *init;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100274 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200275
276 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200277 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100278 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200279 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100280 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200281 struct hda_input_mux *sinput_mux;
282 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400283 unsigned int cur_amux;
284 hda_nid_t *amp_nids;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200285 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200286
Matt Porter403d1942005-11-29 15:00:51 +0100287 /* i/o switches */
288 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200289 unsigned int clfe_swap;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100290 hda_nid_t line_switch; /* shared line-in for input and output */
291 hda_nid_t mic_switch; /* shared mic-in for input and output */
292 hda_nid_t hp_switch; /* NID of HP as line-out */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200293 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200294
Mattc7d4b2f2005-06-27 14:59:41 +0200295 struct hda_pcm pcm_rec[2]; /* PCM information */
296
297 /* dynamic controls and input_mux */
298 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200299 struct snd_array kctls;
Matt Porter8b657272006-10-26 17:12:59 +0200300 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200301 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200302 struct hda_input_mux private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100303 struct hda_input_mux private_mono_mux;
Matt2f2f4252005-04-13 14:45:30 +0200304};
305
306static hda_nid_t stac9200_adc_nids[1] = {
307 0x03,
308};
309
310static hda_nid_t stac9200_mux_nids[1] = {
311 0x0c,
312};
313
314static hda_nid_t stac9200_dac_nids[1] = {
315 0x02,
316};
317
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100318static hda_nid_t stac92hd73xx_pwr_nids[8] = {
319 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
320 0x0f, 0x10, 0x11
321};
322
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400323static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
324 0x26, 0,
325};
326
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100327static hda_nid_t stac92hd73xx_adc_nids[2] = {
328 0x1a, 0x1b
329};
330
331#define STAC92HD73XX_NUM_DMICS 2
332static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
333 0x13, 0x14, 0
334};
335
336#define STAC92HD73_DAC_COUNT 5
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100337
Takashi Iwaie2aec172009-09-02 01:00:05 +0200338static hda_nid_t stac92hd73xx_mux_nids[2] = {
339 0x20, 0x21,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100340};
341
342static hda_nid_t stac92hd73xx_dmux_nids[2] = {
343 0x20, 0x21,
344};
345
Matthew Ranostayd9737752008-09-07 12:03:41 +0200346static hda_nid_t stac92hd73xx_smux_nids[2] = {
347 0x22, 0x23,
348};
349
Takashi Iwai6479c632009-07-28 18:20:25 +0200350#define STAC92HD73XX_NUM_CAPS 2
351static unsigned long stac92hd73xx_capvols[] = {
352 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
353 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
354};
355#define stac92hd73xx_capsws stac92hd73xx_capvols
356
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200357#define STAC92HD83_DAC_COUNT 3
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200358
Takashi Iwai667067d2009-08-13 18:14:42 +0200359static hda_nid_t stac92hd83xxx_mux_nids[2] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200360 0x17, 0x18,
361};
362
363static hda_nid_t stac92hd83xxx_adc_nids[2] = {
364 0x15, 0x16,
365};
366
367static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
368 0xa, 0xb, 0xd, 0xe,
369};
370
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400371static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
372 0x1e, 0,
373};
374
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200375static unsigned int stac92hd83xxx_pwr_mapping[4] = {
Matthew Ranostay87e88a72009-01-22 20:38:42 -0500376 0x03, 0x0c, 0x20, 0x40,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200377};
378
Takashi Iwai6479c632009-07-28 18:20:25 +0200379#define STAC92HD83XXX_NUM_CAPS 2
380static unsigned long stac92hd83xxx_capvols[] = {
381 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
382 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_OUTPUT),
383};
384#define stac92hd83xxx_capsws stac92hd83xxx_capvols
385
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100386static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
387 0x0a, 0x0d, 0x0f
388};
389
Matthew Ranostaye035b842007-11-06 11:53:55 +0100390static hda_nid_t stac92hd71bxx_adc_nids[2] = {
391 0x12, 0x13,
392};
393
394static hda_nid_t stac92hd71bxx_mux_nids[2] = {
395 0x1a, 0x1b
396};
397
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400398static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
399 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100400};
401
Matthew Ranostayd9737752008-09-07 12:03:41 +0200402static hda_nid_t stac92hd71bxx_smux_nids[2] = {
403 0x24, 0x25,
404};
405
Matthew Ranostaye035b842007-11-06 11:53:55 +0100406#define STAC92HD71BXX_NUM_DMICS 2
407static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
408 0x18, 0x19, 0
409};
410
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400411static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
412 0x22, 0
413};
414
Takashi Iwai6479c632009-07-28 18:20:25 +0200415#define STAC92HD71BXX_NUM_CAPS 2
416static unsigned long stac92hd71bxx_capvols[] = {
417 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
418 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
419};
420#define stac92hd71bxx_capsws stac92hd71bxx_capvols
421
Tobin Davis8e21c342007-01-08 11:04:17 +0100422static hda_nid_t stac925x_adc_nids[1] = {
423 0x03,
424};
425
426static hda_nid_t stac925x_mux_nids[1] = {
427 0x0f,
428};
429
430static hda_nid_t stac925x_dac_nids[1] = {
431 0x02,
432};
433
Takashi Iwaif6e98522007-10-16 14:27:04 +0200434#define STAC925X_NUM_DMICS 1
435static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
436 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200437};
438
Takashi Iwai1697055e2007-12-18 18:05:52 +0100439static hda_nid_t stac925x_dmux_nids[1] = {
440 0x14,
441};
442
Takashi Iwai6479c632009-07-28 18:20:25 +0200443static unsigned long stac925x_capvols[] = {
444 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
445};
446static unsigned long stac925x_capsws[] = {
447 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
448};
449
Matt2f2f4252005-04-13 14:45:30 +0200450static hda_nid_t stac922x_adc_nids[2] = {
451 0x06, 0x07,
452};
453
454static hda_nid_t stac922x_mux_nids[2] = {
455 0x12, 0x13,
456};
457
Takashi Iwai6479c632009-07-28 18:20:25 +0200458#define STAC922X_NUM_CAPS 2
459static unsigned long stac922x_capvols[] = {
460 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
461 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
462};
463#define stac922x_capsws stac922x_capvols
464
Matthew Ranostay45c1d852009-02-04 17:49:41 -0500465static hda_nid_t stac927x_slave_dig_outs[2] = {
466 0x1f, 0,
467};
468
Matt Porter3cc08dc2006-01-23 15:27:49 +0100469static hda_nid_t stac927x_adc_nids[3] = {
470 0x07, 0x08, 0x09
471};
472
473static hda_nid_t stac927x_mux_nids[3] = {
474 0x15, 0x16, 0x17
475};
476
Matthew Ranostayd9737752008-09-07 12:03:41 +0200477static hda_nid_t stac927x_smux_nids[1] = {
478 0x21,
479};
480
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100481static hda_nid_t stac927x_dac_nids[6] = {
482 0x02, 0x03, 0x04, 0x05, 0x06, 0
483};
484
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100485static hda_nid_t stac927x_dmux_nids[1] = {
486 0x1b,
487};
488
Matthew Ranostay7f168592007-10-18 17:38:17 +0200489#define STAC927X_NUM_DMICS 2
490static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
491 0x13, 0x14, 0
492};
493
Takashi Iwai6479c632009-07-28 18:20:25 +0200494#define STAC927X_NUM_CAPS 3
495static unsigned long stac927x_capvols[] = {
496 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
497 HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
498 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
499};
500static unsigned long stac927x_capsws[] = {
501 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
502 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
503 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
504};
505
Matthew Ranostay65973632008-09-16 10:39:37 -0400506static const char *stac927x_spdif_labels[5] = {
507 "Digital Playback", "ADAT", "Analog Mux 1",
508 "Analog Mux 2", "Analog Mux 3"
509};
510
Matt Porterf3302a52006-07-31 12:49:34 +0200511static hda_nid_t stac9205_adc_nids[2] = {
512 0x12, 0x13
513};
514
515static hda_nid_t stac9205_mux_nids[2] = {
516 0x19, 0x1a
517};
518
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100519static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100520 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100521};
522
Matthew Ranostayd9737752008-09-07 12:03:41 +0200523static hda_nid_t stac9205_smux_nids[1] = {
524 0x21,
525};
526
Takashi Iwaif6e98522007-10-16 14:27:04 +0200527#define STAC9205_NUM_DMICS 2
528static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
529 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200530};
531
Takashi Iwai6479c632009-07-28 18:20:25 +0200532#define STAC9205_NUM_CAPS 2
533static unsigned long stac9205_capvols[] = {
534 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
535 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
536};
537static unsigned long stac9205_capsws[] = {
538 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
539 HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
540};
541
Mattc7d4b2f2005-06-27 14:59:41 +0200542static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200543 0x08, 0x09, 0x0d, 0x0e,
544 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200545};
546
Tobin Davis8e21c342007-01-08 11:04:17 +0100547static hda_nid_t stac925x_pin_nids[8] = {
548 0x07, 0x08, 0x0a, 0x0b,
549 0x0c, 0x0d, 0x10, 0x11,
550};
551
Matt2f2f4252005-04-13 14:45:30 +0200552static hda_nid_t stac922x_pin_nids[10] = {
553 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
554 0x0f, 0x10, 0x11, 0x15, 0x1b,
555};
556
Matthew Ranostaya7662642008-02-21 07:51:14 +0100557static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100558 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
559 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200560 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100561};
562
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -0500563static hda_nid_t stac92hd83xxx_pin_nids[10] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200564 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -0500565 0x0f, 0x10, 0x11, 0x1f, 0x20,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200566};
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500567
568#define STAC92HD71BXX_NUM_PINS 13
569static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
570 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
571 0x00, 0x14, 0x18, 0x19, 0x1e,
572 0x1f, 0x20, 0x27
573};
574static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100575 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
576 0x0f, 0x14, 0x18, 0x19, 0x1e,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500577 0x1f, 0x20, 0x27
Matthew Ranostaye035b842007-11-06 11:53:55 +0100578};
579
Matt Porter3cc08dc2006-01-23 15:27:49 +0100580static hda_nid_t stac927x_pin_nids[14] = {
581 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
582 0x0f, 0x10, 0x11, 0x12, 0x13,
583 0x14, 0x21, 0x22, 0x23,
584};
585
Matt Porterf3302a52006-07-31 12:49:34 +0200586static hda_nid_t stac9205_pin_nids[12] = {
587 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
588 0x0f, 0x14, 0x16, 0x17, 0x18,
589 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200590};
591
Matt Porter8b657272006-10-26 17:12:59 +0200592static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
593 struct snd_ctl_elem_info *uinfo)
594{
595 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
596 struct sigmatel_spec *spec = codec->spec;
597 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
598}
599
600static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
601 struct snd_ctl_elem_value *ucontrol)
602{
603 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
604 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100605 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200606
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100607 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200608 return 0;
609}
610
611static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
612 struct snd_ctl_elem_value *ucontrol)
613{
614 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
615 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100616 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200617
618 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100619 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200620}
621
Matthew Ranostayd9737752008-09-07 12:03:41 +0200622static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
623 struct snd_ctl_elem_info *uinfo)
624{
625 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
626 struct sigmatel_spec *spec = codec->spec;
627 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
628}
629
630static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
631 struct snd_ctl_elem_value *ucontrol)
632{
633 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
634 struct sigmatel_spec *spec = codec->spec;
635 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
636
637 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
638 return 0;
639}
640
641static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
642 struct snd_ctl_elem_value *ucontrol)
643{
644 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
645 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400646 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200647 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400648 int err, val;
649 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200650
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400651 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200652 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400653 if (err < 0)
654 return err;
655
656 if (spec->spdif_mute) {
657 if (smux_idx == 0)
658 nid = spec->multiout.dig_out_nid;
659 else
660 nid = codec->slave_dig_outs[smux_idx - 1];
661 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100662 val = HDA_AMP_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400663 else
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100664 val = 0;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400665 /* un/mute SPDIF out */
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100666 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
667 HDA_AMP_MUTE, val);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400668 }
669 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200670}
671
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200672static unsigned int stac92xx_vref_set(struct hda_codec *codec,
673 hda_nid_t nid, unsigned int new_vref)
674{
Takashi Iwaib8621512009-06-22 08:00:10 +0200675 int error;
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200676 unsigned int pincfg;
677 pincfg = snd_hda_codec_read(codec, nid, 0,
678 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
679
680 pincfg &= 0xff;
681 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
682 pincfg |= new_vref;
683
684 if (new_vref == AC_PINCTL_VREF_HIZ)
685 pincfg |= AC_PINCTL_OUT_EN;
686 else
687 pincfg |= AC_PINCTL_IN_EN;
688
689 error = snd_hda_codec_write_cache(codec, nid, 0,
690 AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg);
691 if (error < 0)
692 return error;
693 else
694 return 1;
695}
696
697static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
698{
699 unsigned int vref;
700 vref = snd_hda_codec_read(codec, nid, 0,
701 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
702 vref &= AC_PINCTL_VREFEN;
703 return vref;
704}
705
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100706static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200707{
708 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
709 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200710 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200711}
712
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100713static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200714{
715 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
716 struct sigmatel_spec *spec = codec->spec;
717 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
718
719 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
720 return 0;
721}
722
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100723static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200724{
725 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
726 struct sigmatel_spec *spec = codec->spec;
727 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai5207e102009-07-30 13:09:08 +0200728 const struct hda_input_mux *imux = spec->input_mux;
729 unsigned int idx, prev_idx;
Matt2f2f4252005-04-13 14:45:30 +0200730
Takashi Iwai5207e102009-07-30 13:09:08 +0200731 idx = ucontrol->value.enumerated.item[0];
732 if (idx >= imux->num_items)
733 idx = imux->num_items - 1;
734 prev_idx = spec->cur_mux[adc_idx];
735 if (prev_idx == idx)
736 return 0;
737 if (idx < spec->num_analog_muxes) {
738 snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0,
739 AC_VERB_SET_CONNECT_SEL,
740 imux->items[idx].index);
741 if (prev_idx >= spec->num_analog_muxes) {
742 imux = spec->dinput_mux;
743 /* 0 = analog */
744 snd_hda_codec_write_cache(codec,
745 spec->dmux_nids[adc_idx], 0,
746 AC_VERB_SET_CONNECT_SEL,
747 imux->items[0].index);
748 }
749 } else {
750 imux = spec->dinput_mux;
751 snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0,
752 AC_VERB_SET_CONNECT_SEL,
753 imux->items[idx - 1].index);
754 }
755 spec->cur_mux[adc_idx] = idx;
756 return 1;
Matt2f2f4252005-04-13 14:45:30 +0200757}
758
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100759static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
760 struct snd_ctl_elem_info *uinfo)
761{
762 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
763 struct sigmatel_spec *spec = codec->spec;
764 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
765}
766
767static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
768 struct snd_ctl_elem_value *ucontrol)
769{
770 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
771 struct sigmatel_spec *spec = codec->spec;
772
773 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
774 return 0;
775}
776
777static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
778 struct snd_ctl_elem_value *ucontrol)
779{
780 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
781 struct sigmatel_spec *spec = codec->spec;
782
783 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
784 spec->mono_nid, &spec->cur_mmux);
785}
786
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200787#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
788
789static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
790 struct snd_ctl_elem_value *ucontrol)
791{
792 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100793 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200794 struct sigmatel_spec *spec = codec->spec;
795
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100796 ucontrol->value.integer.value[0] = !!(spec->aloopback &
797 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200798 return 0;
799}
800
801static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
802 struct snd_ctl_elem_value *ucontrol)
803{
804 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
805 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100806 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200807 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100808 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200809
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100810 idx_val = spec->aloopback_mask << idx;
811 if (ucontrol->value.integer.value[0])
812 val = spec->aloopback | idx_val;
813 else
814 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100815 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200816 return 0;
817
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100818 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200819
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100820 /* Only return the bits defined by the shift value of the
821 * first two bytes of the mask
822 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200823 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100824 kcontrol->private_value & 0xFFFF, 0x0);
825 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200826
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100827 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200828 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100829 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200830 } else {
831 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100832 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200833 }
834
835 snd_hda_codec_write_cache(codec, codec->afg, 0,
836 kcontrol->private_value >> 16, dac_mode);
837
838 return 1;
839}
840
Mattc7d4b2f2005-06-27 14:59:41 +0200841static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200842 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200843 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200844 {}
845};
846
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200847static struct hda_verb stac9200_eapd_init[] = {
848 /* set dac0mux for dac converter */
849 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
850 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
851 {}
852};
853
Matthew Ranostayd654a662008-03-14 08:46:51 +0100854static struct hda_verb dell_eq_core_init[] = {
855 /* set master volume to max value without distortion
856 * and direct control */
857 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100858 {}
859};
860
Takashi Iwaie2aec172009-09-02 01:00:05 +0200861static struct hda_verb stac92hd73xx_core_init[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100862 /* set master volume and direct control */
863 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100864 {}
865};
866
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200867static struct hda_verb stac92hd83xxx_core_init[] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200868 /* power state controls amps */
869 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200870 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200871};
872
Matthew Ranostaye035b842007-11-06 11:53:55 +0100873static struct hda_verb stac92hd71bxx_core_init[] = {
874 /* set master volume and direct control */
875 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200876 {}
Matthew Ranostay541eee82007-12-14 12:08:04 +0100877};
878
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500879static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
880 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
881 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100882 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
883 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100884 {}
885};
886
Tobin Davis8e21c342007-01-08 11:04:17 +0100887static struct hda_verb stac925x_core_init[] = {
888 /* set dac0mux for dac converter */
889 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaic9280d62009-01-15 17:31:00 +0100890 /* mute the master volume */
891 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Tobin Davis8e21c342007-01-08 11:04:17 +0100892 {}
893};
894
Mattc7d4b2f2005-06-27 14:59:41 +0200895static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200896 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200897 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200898 {}
899};
900
Tobin Davis93ed1502006-09-01 21:03:12 +0200901static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200902 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200903 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200904 /* unmute node 0x1b */
905 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
906 /* select node 0x03 as DAC */
907 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
908 {}
909};
910
Takashi Iwaiccca7cd2009-10-13 15:32:21 +0200911static struct hda_verb dell_3st_core_init[] = {
912 /* don't set delta bit */
913 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
914 /* unmute node 0x1b */
915 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
916 /* select node 0x03 as DAC */
917 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
918 {}
919};
920
Matt Porter3cc08dc2006-01-23 15:27:49 +0100921static struct hda_verb stac927x_core_init[] = {
922 /* set master volume and direct control */
923 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200924 /* enable analog pc beep path */
925 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100926 {}
927};
928
Takashi Iwai54930532009-10-11 17:38:29 +0200929static struct hda_verb stac927x_volknob_core_init[] = {
930 /* don't set delta bit */
931 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
932 /* enable analog pc beep path */
933 {0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
934 {}
935};
936
Matt Porterf3302a52006-07-31 12:49:34 +0200937static struct hda_verb stac9205_core_init[] = {
938 /* set master volume and direct control */
939 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200940 /* enable analog pc beep path */
941 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200942 {}
943};
944
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100945#define STAC_MONO_MUX \
946 { \
947 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
948 .name = "Mono Mux", \
949 .count = 1, \
950 .info = stac92xx_mono_mux_enum_info, \
951 .get = stac92xx_mono_mux_enum_get, \
952 .put = stac92xx_mono_mux_enum_put, \
953 }
954
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100955#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200956 { \
957 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
958 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100959 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200960 .info = stac92xx_aloopback_info, \
961 .get = stac92xx_aloopback_get, \
962 .put = stac92xx_aloopback_put, \
963 .private_value = verb_read | (verb_write << 16), \
964 }
965
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200966#define DC_BIAS(xname, idx, nid) \
967 { \
968 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
969 .name = xname, \
970 .index = idx, \
971 .info = stac92xx_dc_bias_info, \
972 .get = stac92xx_dc_bias_get, \
973 .put = stac92xx_dc_bias_put, \
974 .private_value = nid, \
975 }
976
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100977static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200978 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
979 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200980 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
981 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200982 { } /* end */
983};
984
Takashi Iwaid78d7a92009-03-02 14:26:25 +0100985static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
986 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
987 {}
988};
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100989
Takashi Iwaid78d7a92009-03-02 14:26:25 +0100990static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
991 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
992 {}
993};
994
995static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
996 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
997 {}
998};
999
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001000
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001001static struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
1002 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1003};
Matthew Ranostay541eee82007-12-14 12:08:04 +01001004
Tobin Davis8e21c342007-01-08 11:04:17 +01001005static struct snd_kcontrol_new stac925x_mixer[] = {
Takashi Iwaic9280d62009-01-15 17:31:00 +01001006 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
1007 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001008 { } /* end */
1009};
1010
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001011static struct snd_kcontrol_new stac9205_loopback[] = {
1012 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1013 {}
1014};
1015
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001016static struct snd_kcontrol_new stac927x_loopback[] = {
1017 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1018 {}
1019};
1020
Takashi Iwai1697055e2007-12-18 18:05:52 +01001021static struct snd_kcontrol_new stac_dmux_mixer = {
1022 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1023 .name = "Digital Input Source",
1024 /* count set later */
1025 .info = stac92xx_dmux_enum_info,
1026 .get = stac92xx_dmux_enum_get,
1027 .put = stac92xx_dmux_enum_put,
1028};
1029
Matthew Ranostayd9737752008-09-07 12:03:41 +02001030static struct snd_kcontrol_new stac_smux_mixer = {
1031 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001032 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001033 /* count set later */
1034 .info = stac92xx_smux_enum_info,
1035 .get = stac92xx_smux_enum_get,
1036 .put = stac92xx_smux_enum_put,
1037};
1038
Takashi Iwai2134ea42008-01-10 16:53:55 +01001039static const char *slave_vols[] = {
1040 "Front Playback Volume",
1041 "Surround Playback Volume",
1042 "Center Playback Volume",
1043 "LFE Playback Volume",
1044 "Side Playback Volume",
1045 "Headphone Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001046 "Speaker Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001047 NULL
1048};
1049
1050static const char *slave_sws[] = {
1051 "Front Playback Switch",
1052 "Surround Playback Switch",
1053 "Center Playback Switch",
1054 "LFE Playback Switch",
1055 "Side Playback Switch",
1056 "Headphone Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001057 "Speaker Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001058 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001059 NULL
1060};
1061
Takashi Iwai603c4012008-07-30 15:01:44 +02001062static void stac92xx_free_kctls(struct hda_codec *codec);
Takashi Iwaie4973e12008-11-18 09:32:42 +01001063static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
Takashi Iwai603c4012008-07-30 15:01:44 +02001064
Matt2f2f4252005-04-13 14:45:30 +02001065static int stac92xx_build_controls(struct hda_codec *codec)
1066{
1067 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaie4973e12008-11-18 09:32:42 +01001068 struct auto_pin_cfg *cfg = &spec->autocfg;
1069 hda_nid_t nid;
Matt2f2f4252005-04-13 14:45:30 +02001070 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001071 int i;
Matt2f2f4252005-04-13 14:45:30 +02001072
Takashi Iwai6479c632009-07-28 18:20:25 +02001073 if (spec->mixer) {
1074 err = snd_hda_add_new_ctls(codec, spec->mixer);
1075 if (err < 0)
1076 return err;
1077 }
Mattc7d4b2f2005-06-27 14:59:41 +02001078
1079 for (i = 0; i < spec->num_mixers; i++) {
1080 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1081 if (err < 0)
1082 return err;
1083 }
Takashi Iwai5207e102009-07-30 13:09:08 +02001084 if (!spec->auto_mic && spec->num_dmuxes > 0 &&
1085 snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
Takashi Iwai1697055e2007-12-18 18:05:52 +01001086 stac_dmux_mixer.count = spec->num_dmuxes;
Takashi Iwaid13bd412008-07-30 15:01:45 +02001087 err = snd_hda_ctl_add(codec,
Takashi Iwai1697055e2007-12-18 18:05:52 +01001088 snd_ctl_new1(&stac_dmux_mixer, codec));
1089 if (err < 0)
1090 return err;
1091 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001092 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001093 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1094 struct hda_input_mux *smux = &spec->private_smux;
1095 /* check for mute support on SPDIF out */
1096 if (wcaps & AC_WCAP_OUT_AMP) {
1097 smux->items[smux->num_items].label = "Off";
1098 smux->items[smux->num_items].index = 0;
1099 smux->num_items++;
1100 spec->spdif_mute = 1;
1101 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001102 stac_smux_mixer.count = spec->num_smuxes;
Takashi Iwai4f2d23e2008-12-19 10:14:13 +01001103 err = snd_hda_ctl_add(codec,
Matthew Ranostayd9737752008-09-07 12:03:41 +02001104 snd_ctl_new1(&stac_smux_mixer, codec));
1105 if (err < 0)
1106 return err;
1107 }
Mattc7d4b2f2005-06-27 14:59:41 +02001108
Mattdabbed62005-06-14 10:19:34 +02001109 if (spec->multiout.dig_out_nid) {
1110 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1111 if (err < 0)
1112 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001113 err = snd_hda_create_spdif_share_sw(codec,
1114 &spec->multiout);
1115 if (err < 0)
1116 return err;
1117 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001118 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001119 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001120 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1121 if (err < 0)
1122 return err;
1123 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001124
1125 /* if we have no master control, let's create it */
1126 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001127 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001128 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001129 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai7c7767e2009-01-20 15:28:38 +01001130 /* correct volume offset */
1131 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
Takashi Iwai2134ea42008-01-10 16:53:55 +01001132 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001133 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001134 if (err < 0)
1135 return err;
1136 }
1137 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1138 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1139 NULL, slave_sws);
1140 if (err < 0)
1141 return err;
1142 }
1143
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001144 if (spec->aloopback_ctl &&
1145 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1146 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1147 if (err < 0)
1148 return err;
1149 }
1150
Takashi Iwai603c4012008-07-30 15:01:44 +02001151 stac92xx_free_kctls(codec); /* no longer needed */
Takashi Iwaie4973e12008-11-18 09:32:42 +01001152
1153 /* create jack input elements */
1154 if (spec->hp_detect) {
1155 for (i = 0; i < cfg->hp_outs; i++) {
1156 int type = SND_JACK_HEADPHONE;
1157 nid = cfg->hp_pins[i];
1158 /* jack detection */
1159 if (cfg->hp_outs == i)
1160 type |= SND_JACK_LINEOUT;
1161 err = stac92xx_add_jack(codec, nid, type);
1162 if (err < 0)
1163 return err;
1164 }
1165 }
1166 for (i = 0; i < cfg->line_outs; i++) {
1167 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1168 SND_JACK_LINEOUT);
1169 if (err < 0)
1170 return err;
1171 }
1172 for (i = 0; i < AUTO_PIN_LAST; i++) {
1173 nid = cfg->input_pins[i];
1174 if (nid) {
1175 err = stac92xx_add_jack(codec, nid,
1176 SND_JACK_MICROPHONE);
1177 if (err < 0)
1178 return err;
1179 }
1180 }
1181
Mattdabbed62005-06-14 10:19:34 +02001182 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001183}
1184
Matt Porter403d1942005-11-29 15:00:51 +01001185static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001186 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001187 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1188};
1189
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001190static unsigned int gateway9200_m4_pin_configs[8] = {
1191 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1192 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1193};
1194static unsigned int gateway9200_m4_2_pin_configs[8] = {
1195 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1196 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1197};
1198
1199/*
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001200 STAC 9200 pin configs for
1201 102801A8
1202 102801DE
1203 102801E8
1204*/
1205static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001206 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1207 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001208};
1209
1210/*
1211 STAC 9200 pin configs for
1212 102801C0
1213 102801C1
1214*/
1215static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001216 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1217 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001218};
1219
1220/*
1221 STAC 9200 pin configs for
1222 102801C4 (Dell Dimension E310)
1223 102801C5
1224 102801C7
1225 102801D9
1226 102801DA
1227 102801E3
1228*/
1229static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001230 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1231 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001232};
1233
1234
1235/*
1236 STAC 9200-32 pin configs for
1237 102801B5 (Dell Inspiron 630m)
1238 102801D8 (Dell Inspiron 640m)
1239*/
1240static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001241 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1242 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001243};
1244
1245/*
1246 STAC 9200-32 pin configs for
1247 102801C2 (Dell Latitude D620)
1248 102801C8
1249 102801CC (Dell Latitude D820)
1250 102801D4
1251 102801D6
1252*/
1253static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001254 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1255 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001256};
1257
1258/*
1259 STAC 9200-32 pin configs for
1260 102801CE (Dell XPS M1710)
1261 102801CF (Dell Precision M90)
1262*/
1263static unsigned int dell9200_m23_pin_configs[8] = {
1264 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1265 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1266};
1267
1268/*
1269 STAC 9200-32 pin configs for
1270 102801C9
1271 102801CA
1272 102801CB (Dell Latitude 120L)
1273 102801D3
1274*/
1275static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001276 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1277 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001278};
1279
1280/*
1281 STAC 9200-32 pin configs for
1282 102801BD (Dell Inspiron E1505n)
1283 102801EE
1284 102801EF
1285*/
1286static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001287 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1288 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001289};
1290
1291/*
1292 STAC 9200-32 pin configs for
1293 102801F5 (Dell Inspiron 1501)
1294 102801F6
1295*/
1296static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001297 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1298 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001299};
1300
1301/*
1302 STAC 9200-32
1303 102801CD (Dell Inspiron E1705/9400)
1304*/
1305static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001306 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1307 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001308};
1309
Tobin Davisbf277782008-02-03 20:31:47 +01001310static unsigned int oqo9200_pin_configs[8] = {
1311 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1312 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1313};
1314
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001315
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001316static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1317 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001318 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001319 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1320 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1321 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1322 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1323 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1324 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1325 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1326 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1327 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1328 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001329 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1330 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001331 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001332};
1333
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001334static const char *stac9200_models[STAC_9200_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001335 [STAC_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001336 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001337 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001338 [STAC_9200_DELL_D21] = "dell-d21",
1339 [STAC_9200_DELL_D22] = "dell-d22",
1340 [STAC_9200_DELL_D23] = "dell-d23",
1341 [STAC_9200_DELL_M21] = "dell-m21",
1342 [STAC_9200_DELL_M22] = "dell-m22",
1343 [STAC_9200_DELL_M23] = "dell-m23",
1344 [STAC_9200_DELL_M24] = "dell-m24",
1345 [STAC_9200_DELL_M25] = "dell-m25",
1346 [STAC_9200_DELL_M26] = "dell-m26",
1347 [STAC_9200_DELL_M27] = "dell-m27",
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001348 [STAC_9200_M4] = "gateway-m4",
1349 [STAC_9200_M4_2] = "gateway-m4-2",
Takashi Iwai117f2572008-03-18 09:53:23 +01001350 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001351};
1352
1353static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1354 /* SigmaTel reference board */
1355 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1356 "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001357 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1358 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001359 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001360 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1361 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001362 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001363 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1364 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1365 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1366 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1367 "unknown Dell", STAC_9200_DELL_D22),
1368 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1369 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001370 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001371 "Dell Latitude D620", STAC_9200_DELL_M22),
1372 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1373 "unknown Dell", STAC_9200_DELL_D23),
1374 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1375 "unknown Dell", STAC_9200_DELL_D23),
1376 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1377 "unknown Dell", STAC_9200_DELL_M22),
1378 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1379 "unknown Dell", STAC_9200_DELL_M24),
1380 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1381 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001382 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001383 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001384 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001385 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001386 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001387 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001388 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001389 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001390 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001391 "Dell Precision M90", STAC_9200_DELL_M23),
1392 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1393 "unknown Dell", STAC_9200_DELL_M22),
1394 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1395 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001396 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001397 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001398 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001399 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1400 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1401 "unknown Dell", STAC_9200_DELL_D23),
1402 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1403 "unknown Dell", STAC_9200_DELL_D23),
1404 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1405 "unknown Dell", STAC_9200_DELL_D21),
1406 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1407 "unknown Dell", STAC_9200_DELL_D23),
1408 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1409 "unknown Dell", STAC_9200_DELL_D21),
1410 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1411 "unknown Dell", STAC_9200_DELL_M25),
1412 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1413 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001414 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001415 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1416 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1417 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001418 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001419 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001420 /* Gateway machines needs EAPD to be set on resume */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001421 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1422 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1423 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
Tobin Davisbf277782008-02-03 20:31:47 +01001424 /* OQO Mobile */
1425 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001426 {} /* terminator */
1427};
1428
Tobin Davis8e21c342007-01-08 11:04:17 +01001429static unsigned int ref925x_pin_configs[8] = {
1430 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001431 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001432};
1433
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001434static unsigned int stac925xM1_pin_configs[8] = {
1435 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1436 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001437};
1438
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001439static unsigned int stac925xM1_2_pin_configs[8] = {
1440 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1441 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1442};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001443
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001444static unsigned int stac925xM2_pin_configs[8] = {
1445 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1446 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis2c11f952007-05-17 09:36:34 +02001447};
1448
Tobin Davis8e21c342007-01-08 11:04:17 +01001449static unsigned int stac925xM2_2_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001450 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1451 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1452};
1453
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001454static unsigned int stac925xM3_pin_configs[8] = {
1455 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1456 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1457};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001458
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001459static unsigned int stac925xM5_pin_configs[8] = {
1460 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1461 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1462};
1463
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001464static unsigned int stac925xM6_pin_configs[8] = {
1465 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1466 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
Tobin Davis8e21c342007-01-08 11:04:17 +01001467};
1468
1469static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1470 [STAC_REF] = ref925x_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001471 [STAC_M1] = stac925xM1_pin_configs,
1472 [STAC_M1_2] = stac925xM1_2_pin_configs,
1473 [STAC_M2] = stac925xM2_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001474 [STAC_M2_2] = stac925xM2_2_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001475 [STAC_M3] = stac925xM3_pin_configs,
1476 [STAC_M5] = stac925xM5_pin_configs,
1477 [STAC_M6] = stac925xM6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001478};
1479
1480static const char *stac925x_models[STAC_925x_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001481 [STAC_925x_AUTO] = "auto",
Tobin Davis8e21c342007-01-08 11:04:17 +01001482 [STAC_REF] = "ref",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001483 [STAC_M1] = "m1",
1484 [STAC_M1_2] = "m1-2",
1485 [STAC_M2] = "m2",
Tobin Davis8e21c342007-01-08 11:04:17 +01001486 [STAC_M2_2] = "m2-2",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001487 [STAC_M3] = "m3",
1488 [STAC_M5] = "m5",
1489 [STAC_M6] = "m6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001490};
1491
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001492static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001493 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1494 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1495 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1496 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001497 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001498 /* Not sure about the brand name for those */
1499 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1500 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1501 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1502 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001503 {} /* terminator */
Tobin Davis8e21c342007-01-08 11:04:17 +01001504};
1505
1506static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1507 /* SigmaTel reference board */
1508 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001509 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001510 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001511
1512 /* Default table for unknown ID */
1513 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1514
Tobin Davis8e21c342007-01-08 11:04:17 +01001515 {} /* terminator */
1516};
1517
Matthew Ranostaya7662642008-02-21 07:51:14 +01001518static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001519 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1520 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1521 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001522 0x01452050,
1523};
1524
1525static unsigned int dell_m6_pin_configs[13] = {
1526 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001527 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001528 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1529 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001530};
1531
Takashi Iwai842ae632009-09-02 07:43:08 +02001532static unsigned int alienware_m17x_pin_configs[13] = {
1533 0x0321101f, 0x0321101f, 0x03a11020, 0x03014020,
1534 0x90170110, 0x4f0000f0, 0x4f0000f0, 0x4f0000f0,
1535 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1536 0x904601b0,
1537};
1538
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001539static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001540 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001541 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1542 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1543 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001544 [STAC_DELL_EQ] = dell_m6_pin_configs,
Takashi Iwai842ae632009-09-02 07:43:08 +02001545 [STAC_ALIENWARE_M17X] = alienware_m17x_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001546};
1547
1548static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001549 [STAC_92HD73XX_AUTO] = "auto",
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01001550 [STAC_92HD73XX_NO_JD] = "no-jd",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001551 [STAC_92HD73XX_REF] = "ref",
Wu Fengguangae709442009-08-19 17:05:11 +08001552 [STAC_92HD73XX_INTEL] = "intel",
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001553 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1554 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1555 [STAC_DELL_M6_BOTH] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001556 [STAC_DELL_EQ] = "dell-eq",
Takashi Iwai842ae632009-09-02 07:43:08 +02001557 [STAC_ALIENWARE_M17X] = "alienware",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001558};
1559
1560static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1561 /* SigmaTel reference board */
1562 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001563 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001564 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1565 "DFI LanParty", STAC_92HD73XX_REF),
Wu Fengguangae709442009-08-19 17:05:11 +08001566 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
1567 "Intel DG45ID", STAC_92HD73XX_INTEL),
1568 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
1569 "Intel DG45FC", STAC_92HD73XX_INTEL),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001570 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001571 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001572 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001573 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001574 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001575 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001576 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001577 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001578 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001579 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001580 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001581 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001582 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001583 "unknown Dell", STAC_DELL_M6_DMIC),
1584 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1585 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01001586 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001587 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Joerg Schirottkefa620e92008-12-19 08:13:49 +01001588 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1589 "Dell Studio 17", STAC_DELL_M6_DMIC),
Takashi Iwai626f5ce2009-07-28 00:54:39 +02001590 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
1591 "Dell Studio 1555", STAC_DELL_M6_DMIC),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001592 {} /* terminator */
1593};
1594
Takashi Iwai842ae632009-09-02 07:43:08 +02001595static struct snd_pci_quirk stac92hd73xx_codec_id_cfg_tbl[] = {
1596 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1,
1597 "Alienware M17x", STAC_ALIENWARE_M17X),
1598 {} /* terminator */
1599};
1600
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001601static unsigned int ref92hd83xxx_pin_configs[10] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001602 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1603 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001604 0x01451160, 0x98560170,
1605};
1606
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001607static unsigned int dell_s14_pin_configs[10] = {
Takashi Iwai69b56552009-09-15 12:37:42 +02001608 0x0221403f, 0x0221101f, 0x02a19020, 0x90170110,
1609 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a60160,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001610 0x40f000f0, 0x40f000f0,
1611};
1612
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001613static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1614 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001615 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001616 [STAC_DELL_S14] = dell_s14_pin_configs,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001617};
1618
1619static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001620 [STAC_92HD83XXX_AUTO] = "auto",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001621 [STAC_92HD83XXX_REF] = "ref",
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001622 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001623 [STAC_DELL_S14] = "dell-s14",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001624};
1625
1626static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1627 /* SigmaTel reference board */
1628 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Takashi Iwaif9d088b2009-01-13 11:54:49 +01001629 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001630 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1631 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001632 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1633 "unknown Dell", STAC_DELL_S14),
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -02001634 {} /* terminator */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001635};
1636
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001637static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001638 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001639 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001640 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1641 0x00000000
Matthew Ranostaye035b842007-11-06 11:53:55 +01001642};
1643
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001644static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001645 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001646 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001647 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1648 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001649};
1650
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001651static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001652 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1653 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001654 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1655 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001656};
1657
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001658static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001659 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1660 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001661 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1662 0x00000000
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001663};
1664
Matthew Ranostaye035b842007-11-06 11:53:55 +01001665static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1666 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001667 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1668 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001669 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001670 [STAC_HP_M4] = NULL,
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001671 [STAC_HP_DV5] = NULL,
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001672 [STAC_HP_HDX] = NULL,
James Gardiner514bf542009-05-03 04:00:44 -04001673 [STAC_HP_DV4_1222NR] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001674};
1675
1676static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001677 [STAC_92HD71BXX_AUTO] = "auto",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001678 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001679 [STAC_DELL_M4_1] = "dell-m4-1",
1680 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001681 [STAC_DELL_M4_3] = "dell-m4-3",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001682 [STAC_HP_M4] = "hp-m4",
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001683 [STAC_HP_DV5] = "hp-dv5",
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001684 [STAC_HP_HDX] = "hp-hdx",
James Gardiner514bf542009-05-03 04:00:44 -04001685 [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001686};
1687
1688static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1689 /* SigmaTel reference board */
1690 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1691 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001692 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1693 "DFI LanParty", STAC_92HD71BXX_REF),
James Gardiner514bf542009-05-03 04:00:44 -04001694 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
1695 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
Takashi Iwai58d83952009-03-13 17:04:34 +01001696 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1697 "HP", STAC_HP_DV5),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001698 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
1699 "HP dv4-7", STAC_HP_DV5),
1700 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1701 "HP dv4-7", STAC_HP_DV5),
Takashi Iwai6fce61a2009-03-10 07:48:57 +01001702 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1703 "HP HDX", STAC_HP_HDX), /* HDX18 */
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001704 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001705 "HP mini 1000", STAC_HP_M4),
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001706 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
Takashi Iwai6fce61a2009-03-10 07:48:57 +01001707 "HP HDX", STAC_HP_HDX), /* HDX16 */
Takashi Iwai6e34c032009-09-14 15:42:18 +02001708 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620,
1709 "HP dv6", STAC_HP_DV5),
Takashi Iwai1972d022009-08-06 08:44:43 +02001710 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
1711 "HP", STAC_HP_DV5),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001712 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1713 "unknown Dell", STAC_DELL_M4_1),
1714 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1715 "unknown Dell", STAC_DELL_M4_1),
1716 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1717 "unknown Dell", STAC_DELL_M4_1),
1718 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1719 "unknown Dell", STAC_DELL_M4_1),
1720 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1721 "unknown Dell", STAC_DELL_M4_1),
1722 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1723 "unknown Dell", STAC_DELL_M4_1),
1724 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1725 "unknown Dell", STAC_DELL_M4_1),
1726 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1727 "unknown Dell", STAC_DELL_M4_2),
1728 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1729 "unknown Dell", STAC_DELL_M4_2),
1730 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1731 "unknown Dell", STAC_DELL_M4_2),
1732 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1733 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001734 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1735 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001736 {} /* terminator */
1737};
1738
Matt Porter403d1942005-11-29 15:00:51 +01001739static unsigned int ref922x_pin_configs[10] = {
1740 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1741 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001742 0x40000100, 0x40000100,
1743};
1744
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001745/*
1746 STAC 922X pin configs for
1747 102801A7
1748 102801AB
1749 102801A9
1750 102801D1
1751 102801D2
1752*/
1753static unsigned int dell_922x_d81_pin_configs[10] = {
1754 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1755 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1756 0x01813122, 0x400001f2,
1757};
1758
1759/*
1760 STAC 922X pin configs for
1761 102801AC
1762 102801D0
1763*/
1764static unsigned int dell_922x_d82_pin_configs[10] = {
1765 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1766 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1767 0x01813122, 0x400001f1,
1768};
1769
1770/*
1771 STAC 922X pin configs for
1772 102801BF
1773*/
1774static unsigned int dell_922x_m81_pin_configs[10] = {
1775 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1776 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1777 0x40C003f1, 0x405003f0,
1778};
1779
1780/*
1781 STAC 9221 A1 pin configs for
1782 102801D7 (Dell XPS M1210)
1783*/
1784static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001785 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1786 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001787 0x508003f3, 0x405003f4,
1788};
1789
Matt Porter403d1942005-11-29 15:00:51 +01001790static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001791 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001792 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1793 0x02a19120, 0x40000100,
1794};
1795
1796static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001797 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1798 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001799 0x02a19320, 0x40000100,
1800};
1801
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001802static unsigned int intel_mac_v1_pin_configs[10] = {
1803 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1804 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001805 0x400000fc, 0x400000fb,
1806};
1807
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001808static unsigned int intel_mac_v2_pin_configs[10] = {
1809 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1810 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001811 0x400000fc, 0x400000fb,
1812};
1813
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001814static unsigned int intel_mac_v3_pin_configs[10] = {
1815 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1816 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1817 0x400000fc, 0x400000fb,
1818};
1819
1820static unsigned int intel_mac_v4_pin_configs[10] = {
1821 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1822 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1823 0x400000fc, 0x400000fb,
1824};
1825
1826static unsigned int intel_mac_v5_pin_configs[10] = {
1827 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1828 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1829 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001830};
1831
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001832static unsigned int ecs202_pin_configs[10] = {
1833 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1834 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1835 0x9037012e, 0x40e000f2,
1836};
Takashi Iwai76c08822007-06-19 12:17:42 +02001837
Takashi Iwai19039bd2006-06-28 15:52:16 +02001838static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001839 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001840 [STAC_D945GTP3] = d945gtp3_pin_configs,
1841 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001842 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1843 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1844 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1845 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1846 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001847 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001848 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001849 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1850 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1851 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1852 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1853 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1854 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001855 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001856 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1857 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1858 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1859 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001860};
1861
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001862static const char *stac922x_models[STAC_922X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001863 [STAC_922X_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001864 [STAC_D945_REF] = "ref",
1865 [STAC_D945GTP5] = "5stack",
1866 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001867 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1868 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1869 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1870 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1871 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001872 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001873 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001874 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001875 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001876 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1877 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001878 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001879 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001880 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001881 [STAC_922X_DELL_D81] = "dell-d81",
1882 [STAC_922X_DELL_D82] = "dell-d82",
1883 [STAC_922X_DELL_M81] = "dell-m81",
1884 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001885};
1886
1887static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1888 /* SigmaTel reference board */
1889 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1890 "DFI LanParty", STAC_D945_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001891 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1892 "DFI LanParty", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001893 /* Intel 945G based systems */
1894 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1895 "Intel D945G", STAC_D945GTP3),
1896 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1897 "Intel D945G", STAC_D945GTP3),
1898 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1899 "Intel D945G", STAC_D945GTP3),
1900 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1901 "Intel D945G", STAC_D945GTP3),
1902 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1903 "Intel D945G", STAC_D945GTP3),
1904 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1905 "Intel D945G", STAC_D945GTP3),
1906 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1907 "Intel D945G", STAC_D945GTP3),
1908 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1909 "Intel D945G", STAC_D945GTP3),
1910 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1911 "Intel D945G", STAC_D945GTP3),
1912 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1913 "Intel D945G", STAC_D945GTP3),
1914 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1915 "Intel D945G", STAC_D945GTP3),
1916 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1917 "Intel D945G", STAC_D945GTP3),
1918 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1919 "Intel D945G", STAC_D945GTP3),
1920 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1921 "Intel D945G", STAC_D945GTP3),
1922 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1923 "Intel D945G", STAC_D945GTP3),
1924 /* Intel D945G 5-stack systems */
1925 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1926 "Intel D945G", STAC_D945GTP5),
1927 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1928 "Intel D945G", STAC_D945GTP5),
1929 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1930 "Intel D945G", STAC_D945GTP5),
1931 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1932 "Intel D945G", STAC_D945GTP5),
1933 /* Intel 945P based systems */
1934 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1935 "Intel D945P", STAC_D945GTP3),
1936 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1937 "Intel D945P", STAC_D945GTP3),
1938 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1939 "Intel D945P", STAC_D945GTP3),
1940 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1941 "Intel D945P", STAC_D945GTP3),
1942 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1943 "Intel D945P", STAC_D945GTP3),
1944 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1945 "Intel D945P", STAC_D945GTP5),
Takashi Iwai8056d472009-01-23 09:09:43 +01001946 /* other intel */
1947 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
1948 "Intel D945", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001949 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08001950 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001951 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001952 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001953 /* Dell systems */
1954 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1955 "unknown Dell", STAC_922X_DELL_D81),
1956 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1957 "unknown Dell", STAC_922X_DELL_D81),
1958 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1959 "unknown Dell", STAC_922X_DELL_D81),
1960 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1961 "unknown Dell", STAC_922X_DELL_D82),
1962 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1963 "unknown Dell", STAC_922X_DELL_M81),
1964 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1965 "unknown Dell", STAC_922X_DELL_D82),
1966 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1967 "unknown Dell", STAC_922X_DELL_D81),
1968 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1969 "unknown Dell", STAC_922X_DELL_D81),
1970 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1971 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001972 /* ECS/PC Chips boards */
Takashi Iwaidea0a502009-02-09 17:14:52 +01001973 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
Herton Ronaldo Krzesinski8663ae52009-02-08 19:50:34 -02001974 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01001975 {} /* terminator */
1976};
1977
Matt Porter3cc08dc2006-01-23 15:27:49 +01001978static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02001979 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1980 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1981 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1982 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01001983};
1984
Tobin Davis93ed1502006-09-01 21:03:12 +02001985static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02001986 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1987 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1988 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1989 0x40000100, 0x40000100
1990};
1991
Tobin Davis93ed1502006-09-01 21:03:12 +02001992static unsigned int d965_5st_pin_configs[14] = {
1993 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1994 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1995 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1996 0x40000100, 0x40000100
1997};
1998
Takashi Iwai679d92e2009-05-24 19:00:08 +02001999static unsigned int d965_5st_no_fp_pin_configs[14] = {
2000 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
2001 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2002 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2003 0x40000100, 0x40000100
2004};
2005
Tobin Davis4ff076e2007-08-07 11:48:12 +02002006static unsigned int dell_3st_pin_configs[14] = {
2007 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2008 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002009 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002010 0x40c003fc, 0x40000100
2011};
2012
Tobin Davis93ed1502006-09-01 21:03:12 +02002013static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002014 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002015 [STAC_D965_REF] = ref927x_pin_configs,
2016 [STAC_D965_3ST] = d965_3st_pin_configs,
2017 [STAC_D965_5ST] = d965_5st_pin_configs,
Takashi Iwai679d92e2009-05-24 19:00:08 +02002018 [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002019 [STAC_DELL_3ST] = dell_3st_pin_configs,
2020 [STAC_DELL_BIOS] = NULL,
Takashi Iwai54930532009-10-11 17:38:29 +02002021 [STAC_927X_VOLKNOB] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002022};
2023
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002024static const char *stac927x_models[STAC_927X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002025 [STAC_927X_AUTO] = "auto",
Takashi Iwaie28d8322008-12-17 13:48:29 +01002026 [STAC_D965_REF_NO_JD] = "ref-no-jd",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002027 [STAC_D965_REF] = "ref",
2028 [STAC_D965_3ST] = "3stack",
2029 [STAC_D965_5ST] = "5stack",
Takashi Iwai679d92e2009-05-24 19:00:08 +02002030 [STAC_D965_5ST_NO_FP] = "5stack-no-fp",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002031 [STAC_DELL_3ST] = "dell-3stack",
2032 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwai54930532009-10-11 17:38:29 +02002033 [STAC_927X_VOLKNOB] = "volknob",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002034};
2035
2036static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2037 /* SigmaTel reference board */
2038 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2039 "DFI LanParty", STAC_D965_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002040 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2041 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002042 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002043 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2044 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002045 /* 965 based 3 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002046 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2047 "Intel D965", STAC_D965_3ST),
2048 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2049 "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002050 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002051 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002052 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002053 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2054 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002055 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002056 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2057 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002058 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Chengu Wang84d3dc22009-07-30 19:43:55 +08002059 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002060 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2061 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2062 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2063 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002064 /* 965 based 5 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002065 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2066 "Intel D965", STAC_D965_5ST),
2067 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2068 "Intel D965", STAC_D965_5ST),
Takashi Iwai54930532009-10-11 17:38:29 +02002069 /* volume-knob fixes */
2070 SND_PCI_QUIRK_VENDOR(0x10cf, "FSC", STAC_927X_VOLKNOB),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002071 {} /* terminator */
2072};
2073
Matt Porterf3302a52006-07-31 12:49:34 +02002074static unsigned int ref9205_pin_configs[12] = {
2075 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002076 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002077 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002078};
2079
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002080/*
2081 STAC 9205 pin configs for
2082 102801F1
2083 102801F2
2084 102801FC
2085 102801FD
2086 10280204
2087 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002088 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002089*/
2090static unsigned int dell_9205_m42_pin_configs[12] = {
2091 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2092 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2093 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2094};
2095
2096/*
2097 STAC 9205 pin configs for
2098 102801F9
2099 102801FA
2100 102801FE
2101 102801FF (Dell Precision M4300)
2102 10280206
2103 10280200
2104 10280201
2105*/
2106static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002107 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2108 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2109 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2110};
2111
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002112static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002113 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2114 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2115 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2116};
2117
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002118static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002119 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002120 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2121 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2122 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Takashi Iwaid9a42682009-01-22 17:40:18 +01002123 [STAC_9205_EAPD] = NULL,
Matt Porterf3302a52006-07-31 12:49:34 +02002124};
2125
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002126static const char *stac9205_models[STAC_9205_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002127 [STAC_9205_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002128 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002129 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002130 [STAC_9205_DELL_M43] = "dell-m43",
2131 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaid9a42682009-01-22 17:40:18 +01002132 [STAC_9205_EAPD] = "eapd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002133};
2134
2135static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2136 /* SigmaTel reference board */
2137 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2138 "DFI LanParty", STAC_9205_REF),
Herton Ronaldo Krzesinski02358fc2009-07-04 01:44:59 -03002139 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
2140 "SigmaTel", STAC_9205_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002141 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2142 "DFI LanParty", STAC_9205_REF),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002143 /* Dell */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002144 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2145 "unknown Dell", STAC_9205_DELL_M42),
2146 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2147 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002148 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002149 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002150 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2151 "Dell Precision", STAC_9205_DELL_M43),
2152 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2153 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002154 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2155 "unknown Dell", STAC_9205_DELL_M42),
2156 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2157 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002158 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2159 "Dell Precision", STAC_9205_DELL_M43),
2160 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002161 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002162 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2163 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002164 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2165 "Dell Precision", STAC_9205_DELL_M43),
2166 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2167 "Dell Precision", STAC_9205_DELL_M43),
2168 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2169 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002170 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2171 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002172 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2173 "Dell Vostro 1500", STAC_9205_DELL_M42),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002174 /* Gateway */
Hao Song42b95f02009-07-20 15:01:16 +08002175 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002176 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
Matt Porterf3302a52006-07-31 12:49:34 +02002177 {} /* terminator */
2178};
2179
Takashi Iwai330ee992009-02-20 14:33:36 +01002180static void stac92xx_set_config_regs(struct hda_codec *codec,
2181 unsigned int *pincfgs)
Matt2f2f4252005-04-13 14:45:30 +02002182{
2183 int i;
2184 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002185
Takashi Iwai330ee992009-02-20 14:33:36 +01002186 if (!pincfgs)
2187 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002188
Matthew Ranostay87d48362007-07-17 11:52:24 +02002189 for (i = 0; i < spec->num_pins; i++)
Takashi Iwai330ee992009-02-20 14:33:36 +01002190 if (spec->pin_nids[i] && pincfgs[i])
2191 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2192 pincfgs[i]);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002193}
2194
Matt2f2f4252005-04-13 14:45:30 +02002195/*
2196 * Analog playback callbacks
2197 */
2198static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2199 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002200 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002201{
2202 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002203 if (spec->stream_delay)
2204 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002205 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2206 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002207}
2208
2209static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2210 struct hda_codec *codec,
2211 unsigned int stream_tag,
2212 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002213 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002214{
2215 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002216 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002217}
2218
2219static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2220 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002221 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002222{
2223 struct sigmatel_spec *spec = codec->spec;
2224 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2225}
2226
2227/*
Mattdabbed62005-06-14 10:19:34 +02002228 * Digital playback callbacks
2229 */
2230static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2231 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002232 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002233{
2234 struct sigmatel_spec *spec = codec->spec;
2235 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2236}
2237
2238static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2239 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002240 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002241{
2242 struct sigmatel_spec *spec = codec->spec;
2243 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2244}
2245
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002246static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2247 struct hda_codec *codec,
2248 unsigned int stream_tag,
2249 unsigned int format,
2250 struct snd_pcm_substream *substream)
2251{
2252 struct sigmatel_spec *spec = codec->spec;
2253 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2254 stream_tag, format, substream);
2255}
2256
Takashi Iwai9411e212009-02-13 11:32:28 +01002257static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2258 struct hda_codec *codec,
2259 struct snd_pcm_substream *substream)
2260{
2261 struct sigmatel_spec *spec = codec->spec;
2262 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2263}
2264
Mattdabbed62005-06-14 10:19:34 +02002265
2266/*
Matt2f2f4252005-04-13 14:45:30 +02002267 * Analog capture callbacks
2268 */
2269static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2270 struct hda_codec *codec,
2271 unsigned int stream_tag,
2272 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002273 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002274{
2275 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002276 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002277
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002278 if (spec->powerdown_adcs) {
2279 msleep(40);
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002280 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002281 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2282 }
2283 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002284 return 0;
2285}
2286
2287static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2288 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002289 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002290{
2291 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002292 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002293
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002294 snd_hda_codec_cleanup_stream(codec, nid);
2295 if (spec->powerdown_adcs)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002296 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002297 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002298 return 0;
2299}
2300
Mattdabbed62005-06-14 10:19:34 +02002301static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2302 .substreams = 1,
2303 .channels_min = 2,
2304 .channels_max = 2,
2305 /* NID is set in stac92xx_build_pcms */
2306 .ops = {
2307 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002308 .close = stac92xx_dig_playback_pcm_close,
Takashi Iwai9411e212009-02-13 11:32:28 +01002309 .prepare = stac92xx_dig_playback_pcm_prepare,
2310 .cleanup = stac92xx_dig_playback_pcm_cleanup
Mattdabbed62005-06-14 10:19:34 +02002311 },
2312};
2313
2314static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2315 .substreams = 1,
2316 .channels_min = 2,
2317 .channels_max = 2,
2318 /* NID is set in stac92xx_build_pcms */
2319};
2320
Matt2f2f4252005-04-13 14:45:30 +02002321static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2322 .substreams = 1,
2323 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002324 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002325 .nid = 0x02, /* NID to query formats and rates */
2326 .ops = {
2327 .open = stac92xx_playback_pcm_open,
2328 .prepare = stac92xx_playback_pcm_prepare,
2329 .cleanup = stac92xx_playback_pcm_cleanup
2330 },
2331};
2332
Matt Porter3cc08dc2006-01-23 15:27:49 +01002333static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2334 .substreams = 1,
2335 .channels_min = 2,
2336 .channels_max = 2,
2337 .nid = 0x06, /* NID to query formats and rates */
2338 .ops = {
2339 .open = stac92xx_playback_pcm_open,
2340 .prepare = stac92xx_playback_pcm_prepare,
2341 .cleanup = stac92xx_playback_pcm_cleanup
2342 },
2343};
2344
Matt2f2f4252005-04-13 14:45:30 +02002345static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002346 .channels_min = 2,
2347 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002348 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002349 .ops = {
2350 .prepare = stac92xx_capture_pcm_prepare,
2351 .cleanup = stac92xx_capture_pcm_cleanup
2352 },
2353};
2354
2355static int stac92xx_build_pcms(struct hda_codec *codec)
2356{
2357 struct sigmatel_spec *spec = codec->spec;
2358 struct hda_pcm *info = spec->pcm_rec;
2359
2360 codec->num_pcms = 1;
2361 codec->pcm_info = info;
2362
Mattc7d4b2f2005-06-27 14:59:41 +02002363 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002364 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Takashi Iwai00a602d2009-01-23 11:55:42 +01002365 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2366 spec->multiout.dac_nids[0];
Matt2f2f4252005-04-13 14:45:30 +02002367 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002368 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002369 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002370
2371 if (spec->alt_switch) {
2372 codec->num_pcms++;
2373 info++;
2374 info->name = "STAC92xx Analog Alt";
2375 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2376 }
Matt2f2f4252005-04-13 14:45:30 +02002377
Mattdabbed62005-06-14 10:19:34 +02002378 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2379 codec->num_pcms++;
2380 info++;
2381 info->name = "STAC92xx Digital";
Takashi Iwai0852d7a2009-02-11 11:35:15 +01002382 info->pcm_type = spec->autocfg.dig_out_type[0];
Mattdabbed62005-06-14 10:19:34 +02002383 if (spec->multiout.dig_out_nid) {
2384 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2385 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2386 }
2387 if (spec->dig_in_nid) {
2388 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2389 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2390 }
2391 }
2392
Matt2f2f4252005-04-13 14:45:30 +02002393 return 0;
2394}
2395
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002396static unsigned int stac92xx_get_default_vref(struct hda_codec *codec,
2397 hda_nid_t nid)
Takashi Iwaic960a032006-03-23 17:06:28 +01002398{
Takashi Iwai1327a322009-03-23 13:07:47 +01002399 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01002400 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2401 if (pincap & AC_PINCAP_VREF_100)
2402 return AC_PINCTL_VREF_100;
2403 if (pincap & AC_PINCAP_VREF_80)
2404 return AC_PINCTL_VREF_80;
2405 if (pincap & AC_PINCAP_VREF_50)
2406 return AC_PINCTL_VREF_50;
2407 if (pincap & AC_PINCAP_VREF_GRD)
2408 return AC_PINCTL_VREF_GRD;
2409 return 0;
2410}
2411
Matt Porter403d1942005-11-29 15:00:51 +01002412static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2413
2414{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002415 snd_hda_codec_write_cache(codec, nid, 0,
2416 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002417}
2418
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002419#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2420
2421static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2422 struct snd_ctl_elem_value *ucontrol)
2423{
2424 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2425 struct sigmatel_spec *spec = codec->spec;
2426
Takashi Iwaid7a89432008-11-12 09:48:04 +01002427 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002428 return 0;
2429}
2430
Takashi Iwai62558ce2009-07-29 14:23:09 +02002431static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002432
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002433static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2434 struct snd_ctl_elem_value *ucontrol)
2435{
2436 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2437 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002438 int nid = kcontrol->private_value;
2439
2440 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002441
2442 /* check to be sure that the ports are upto date with
2443 * switch changes
2444 */
Takashi Iwai62558ce2009-07-29 14:23:09 +02002445 stac_issue_unsol_event(codec, nid);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002446
2447 return 1;
2448}
2449
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002450static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
2451 struct snd_ctl_elem_info *uinfo)
2452{
2453 int i;
2454 static char *texts[] = {
2455 "Mic In", "Line In", "Line Out"
2456 };
2457
2458 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2459 struct sigmatel_spec *spec = codec->spec;
2460 hda_nid_t nid = kcontrol->private_value;
2461
2462 if (nid == spec->mic_switch || nid == spec->line_switch)
2463 i = 3;
2464 else
2465 i = 2;
2466
2467 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2468 uinfo->value.enumerated.items = i;
2469 uinfo->count = 1;
2470 if (uinfo->value.enumerated.item >= i)
2471 uinfo->value.enumerated.item = i-1;
2472 strcpy(uinfo->value.enumerated.name,
2473 texts[uinfo->value.enumerated.item]);
2474
2475 return 0;
2476}
2477
2478static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
2479 struct snd_ctl_elem_value *ucontrol)
2480{
2481 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2482 hda_nid_t nid = kcontrol->private_value;
2483 unsigned int vref = stac92xx_vref_get(codec, nid);
2484
2485 if (vref == stac92xx_get_default_vref(codec, nid))
2486 ucontrol->value.enumerated.item[0] = 0;
2487 else if (vref == AC_PINCTL_VREF_GRD)
2488 ucontrol->value.enumerated.item[0] = 1;
2489 else if (vref == AC_PINCTL_VREF_HIZ)
2490 ucontrol->value.enumerated.item[0] = 2;
2491
2492 return 0;
2493}
2494
2495static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
2496 struct snd_ctl_elem_value *ucontrol)
2497{
2498 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2499 unsigned int new_vref = 0;
Takashi Iwaib8621512009-06-22 08:00:10 +02002500 int error;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002501 hda_nid_t nid = kcontrol->private_value;
2502
2503 if (ucontrol->value.enumerated.item[0] == 0)
2504 new_vref = stac92xx_get_default_vref(codec, nid);
2505 else if (ucontrol->value.enumerated.item[0] == 1)
2506 new_vref = AC_PINCTL_VREF_GRD;
2507 else if (ucontrol->value.enumerated.item[0] == 2)
2508 new_vref = AC_PINCTL_VREF_HIZ;
2509 else
2510 return 0;
2511
2512 if (new_vref != stac92xx_vref_get(codec, nid)) {
2513 error = stac92xx_vref_set(codec, nid, new_vref);
2514 return error;
2515 }
2516
2517 return 0;
2518}
2519
2520static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
2521 struct snd_ctl_elem_info *uinfo)
2522{
2523 static char *texts[2];
2524 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2525 struct sigmatel_spec *spec = codec->spec;
2526
2527 if (kcontrol->private_value == spec->line_switch)
2528 texts[0] = "Line In";
2529 else
2530 texts[0] = "Mic In";
2531 texts[1] = "Line Out";
2532 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2533 uinfo->value.enumerated.items = 2;
2534 uinfo->count = 1;
2535
2536 if (uinfo->value.enumerated.item >= 2)
2537 uinfo->value.enumerated.item = 1;
2538 strcpy(uinfo->value.enumerated.name,
2539 texts[uinfo->value.enumerated.item]);
2540
2541 return 0;
2542}
Matt Porter403d1942005-11-29 15:00:51 +01002543
2544static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2545{
2546 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2547 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002548 hda_nid_t nid = kcontrol->private_value;
2549 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
Matt Porter403d1942005-11-29 15:00:51 +01002550
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002551 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
Matt Porter403d1942005-11-29 15:00:51 +01002552 return 0;
2553}
2554
2555static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2556{
2557 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2558 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002559 hda_nid_t nid = kcontrol->private_value;
2560 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2561 unsigned short val = !!ucontrol->value.enumerated.item[0];
Matt Porter403d1942005-11-29 15:00:51 +01002562
2563 spec->io_switch[io_idx] = val;
2564
2565 if (val)
2566 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002567 else {
2568 unsigned int pinctl = AC_PINCTL_IN_EN;
2569 if (io_idx) /* set VREF for mic */
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002570 pinctl |= stac92xx_get_default_vref(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01002571 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2572 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002573
2574 /* check the auto-mute again: we need to mute/unmute the speaker
2575 * appropriately according to the pin direction
2576 */
2577 if (spec->hp_detect)
Takashi Iwai62558ce2009-07-29 14:23:09 +02002578 stac_issue_unsol_event(codec, nid);
Jiang Zhe40c1d302007-11-12 13:05:16 +01002579
Matt Porter403d1942005-11-29 15:00:51 +01002580 return 1;
2581}
2582
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002583#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2584
2585static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2586 struct snd_ctl_elem_value *ucontrol)
2587{
2588 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2589 struct sigmatel_spec *spec = codec->spec;
2590
2591 ucontrol->value.integer.value[0] = spec->clfe_swap;
2592 return 0;
2593}
2594
2595static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2596 struct snd_ctl_elem_value *ucontrol)
2597{
2598 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2599 struct sigmatel_spec *spec = codec->spec;
2600 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002601 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002602
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002603 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002604 return 0;
2605
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002606 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002607
2608 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2609 spec->clfe_swap ? 0x4 : 0x0);
2610
2611 return 1;
2612}
2613
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002614#define STAC_CODEC_HP_SWITCH(xname) \
2615 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2616 .name = xname, \
2617 .index = 0, \
2618 .info = stac92xx_hp_switch_info, \
2619 .get = stac92xx_hp_switch_get, \
2620 .put = stac92xx_hp_switch_put, \
2621 }
2622
Matt Porter403d1942005-11-29 15:00:51 +01002623#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2624 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2625 .name = xname, \
2626 .index = 0, \
2627 .info = stac92xx_io_switch_info, \
2628 .get = stac92xx_io_switch_get, \
2629 .put = stac92xx_io_switch_put, \
2630 .private_value = xpval, \
2631 }
2632
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002633#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2634 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2635 .name = xname, \
2636 .index = 0, \
2637 .info = stac92xx_clfe_switch_info, \
2638 .get = stac92xx_clfe_switch_get, \
2639 .put = stac92xx_clfe_switch_put, \
2640 .private_value = xpval, \
2641 }
Matt Porter403d1942005-11-29 15:00:51 +01002642
Mattc7d4b2f2005-06-27 14:59:41 +02002643enum {
2644 STAC_CTL_WIDGET_VOL,
2645 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002646 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002647 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002648 STAC_CTL_WIDGET_IO_SWITCH,
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02002649 STAC_CTL_WIDGET_CLFE_SWITCH,
2650 STAC_CTL_WIDGET_DC_BIAS
Mattc7d4b2f2005-06-27 14:59:41 +02002651};
2652
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002653static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002654 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2655 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002656 STAC_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002657 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002658 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002659 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02002660 DC_BIAS(NULL, 0, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002661};
2662
2663/* add dynamic controls */
Takashi Iwaie3c75962009-01-23 11:57:22 +01002664static struct snd_kcontrol_new *
2665stac_control_new(struct sigmatel_spec *spec,
2666 struct snd_kcontrol_new *ktemp,
2667 const char *name)
Mattc7d4b2f2005-06-27 14:59:41 +02002668{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002669 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002670
Takashi Iwai603c4012008-07-30 15:01:44 +02002671 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2672 knew = snd_array_new(&spec->kctls);
2673 if (!knew)
Takashi Iwaie3c75962009-01-23 11:57:22 +01002674 return NULL;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002675 *knew = *ktemp;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002676 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002677 if (!knew->name) {
2678 /* roolback */
2679 memset(knew, 0, sizeof(*knew));
2680 spec->kctls.alloced--;
2681 return NULL;
2682 }
2683 return knew;
2684}
2685
2686static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2687 struct snd_kcontrol_new *ktemp,
2688 int idx, const char *name,
2689 unsigned long val)
2690{
2691 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
2692 if (!knew)
Mattc7d4b2f2005-06-27 14:59:41 +02002693 return -ENOMEM;
Takashi Iwaie3c75962009-01-23 11:57:22 +01002694 knew->index = idx;
Mattc7d4b2f2005-06-27 14:59:41 +02002695 knew->private_value = val;
Mattc7d4b2f2005-06-27 14:59:41 +02002696 return 0;
2697}
2698
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002699static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2700 int type, int idx, const char *name,
2701 unsigned long val)
2702{
2703 return stac92xx_add_control_temp(spec,
2704 &stac92xx_control_templates[type],
2705 idx, name, val);
2706}
2707
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002708
2709/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002710static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2711 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002712{
2713 return stac92xx_add_control_idx(spec, type, 0, name, val);
2714}
2715
Takashi Iwaie3c75962009-01-23 11:57:22 +01002716static struct snd_kcontrol_new stac_input_src_temp = {
2717 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2718 .name = "Input Source",
2719 .info = stac92xx_mux_enum_info,
2720 .get = stac92xx_mux_enum_get,
2721 .put = stac92xx_mux_enum_put,
2722};
2723
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002724static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
2725 hda_nid_t nid, int idx)
2726{
2727 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
2728 int control = 0;
2729 struct sigmatel_spec *spec = codec->spec;
2730 char name[22];
2731
2732 if (!((get_defcfg_connect(def_conf)) & AC_JACK_PORT_FIXED)) {
2733 if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
2734 && nid == spec->line_switch)
2735 control = STAC_CTL_WIDGET_IO_SWITCH;
2736 else if (snd_hda_query_pin_caps(codec, nid)
2737 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
2738 control = STAC_CTL_WIDGET_DC_BIAS;
2739 else if (nid == spec->mic_switch)
2740 control = STAC_CTL_WIDGET_IO_SWITCH;
2741 }
2742
2743 if (control) {
2744 strcpy(name, auto_pin_cfg_labels[idx]);
2745 return stac92xx_add_control(codec->spec, control,
2746 strcat(name, " Jack Mode"), nid);
2747 }
2748
2749 return 0;
2750}
2751
Takashi Iwaie3c75962009-01-23 11:57:22 +01002752static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2753{
2754 struct snd_kcontrol_new *knew;
2755 struct hda_input_mux *imux = &spec->private_imux;
2756
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02002757 if (spec->auto_mic)
2758 return 0; /* no need for input source */
Takashi Iwaie3c75962009-01-23 11:57:22 +01002759 if (!spec->num_adcs || imux->num_items <= 1)
2760 return 0; /* no need for input source control */
2761 knew = stac_control_new(spec, &stac_input_src_temp,
2762 stac_input_src_temp.name);
2763 if (!knew)
2764 return -ENOMEM;
2765 knew->count = spec->num_adcs;
2766 return 0;
2767}
2768
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002769/* check whether the line-input can be used as line-out */
2770static hda_nid_t check_line_out_switch(struct hda_codec *codec)
Matt Porter403d1942005-11-29 15:00:51 +01002771{
2772 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002773 struct auto_pin_cfg *cfg = &spec->autocfg;
2774 hda_nid_t nid;
2775 unsigned int pincap;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002776
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002777 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2778 return 0;
2779 nid = cfg->input_pins[AUTO_PIN_LINE];
Takashi Iwai1327a322009-03-23 13:07:47 +01002780 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002781 if (pincap & AC_PINCAP_OUT)
2782 return nid;
Matt Porter403d1942005-11-29 15:00:51 +01002783 return 0;
2784}
2785
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002786/* check whether the mic-input can be used as line-out */
2787static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2788{
2789 struct sigmatel_spec *spec = codec->spec;
2790 struct auto_pin_cfg *cfg = &spec->autocfg;
2791 unsigned int def_conf, pincap;
2792 unsigned int mic_pin;
2793
2794 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2795 return 0;
2796 mic_pin = AUTO_PIN_MIC;
2797 for (;;) {
2798 hda_nid_t nid = cfg->input_pins[mic_pin];
Takashi Iwai330ee992009-02-20 14:33:36 +01002799 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002800 /* some laptops have an internal analog microphone
2801 * which can't be used as a output */
2802 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
Takashi Iwai1327a322009-03-23 13:07:47 +01002803 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002804 if (pincap & AC_PINCAP_OUT)
2805 return nid;
2806 }
2807 if (mic_pin == AUTO_PIN_MIC)
2808 mic_pin = AUTO_PIN_FRONT_MIC;
2809 else
2810 break;
2811 }
2812 return 0;
2813}
Steve Longerbeam7b043892007-05-03 20:50:03 +02002814
2815static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2816{
2817 int i;
2818
2819 for (i = 0; i < spec->multiout.num_dacs; i++) {
2820 if (spec->multiout.dac_nids[i] == nid)
2821 return 1;
2822 }
2823
2824 return 0;
2825}
2826
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002827static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2828{
2829 int i;
2830 if (is_in_dac_nids(spec, nid))
2831 return 1;
2832 for (i = 0; i < spec->autocfg.hp_outs; i++)
2833 if (spec->hp_dacs[i] == nid)
2834 return 1;
2835 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2836 if (spec->speaker_dacs[i] == nid)
2837 return 1;
2838 return 0;
2839}
2840
2841static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2842{
2843 struct sigmatel_spec *spec = codec->spec;
2844 int j, conn_len;
2845 hda_nid_t conn[HDA_MAX_CONNECTIONS];
2846 unsigned int wcaps, wtype;
2847
2848 conn_len = snd_hda_get_connections(codec, nid, conn,
2849 HDA_MAX_CONNECTIONS);
2850 for (j = 0; j < conn_len; j++) {
Takashi Iwai14bafe32009-03-23 16:35:39 +01002851 wcaps = get_wcaps(codec, conn[j]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02002852 wtype = get_wcaps_type(wcaps);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002853 /* we check only analog outputs */
2854 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2855 continue;
2856 /* if this route has a free DAC, assign it */
2857 if (!check_all_dac_nids(spec, conn[j])) {
2858 if (conn_len > 1) {
2859 /* select this DAC in the pin's input mux */
2860 snd_hda_codec_write_cache(codec, nid, 0,
2861 AC_VERB_SET_CONNECT_SEL, j);
2862 }
2863 return conn[j];
2864 }
2865 }
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01002866 /* if all DACs are already assigned, connect to the primary DAC */
2867 if (conn_len > 1) {
2868 for (j = 0; j < conn_len; j++) {
2869 if (conn[j] == spec->multiout.dac_nids[0]) {
2870 snd_hda_codec_write_cache(codec, nid, 0,
2871 AC_VERB_SET_CONNECT_SEL, j);
2872 break;
2873 }
2874 }
2875 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002876 return 0;
2877}
2878
2879static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2880static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2881
Matt Porter3cc08dc2006-01-23 15:27:49 +01002882/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02002883 * Fill in the dac_nids table from the parsed pin configuration
2884 * This function only works when every pin in line_out_pins[]
2885 * contains atleast one DAC in its connection list. Some 92xx
2886 * codecs are not connected directly to a DAC, such as the 9200
2887 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002888 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002889static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02002890{
2891 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002892 struct auto_pin_cfg *cfg = &spec->autocfg;
2893 int i;
2894 hda_nid_t nid, dac;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002895
Mattc7d4b2f2005-06-27 14:59:41 +02002896 for (i = 0; i < cfg->line_outs; i++) {
2897 nid = cfg->line_out_pins[i];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002898 dac = get_unassigned_dac(codec, nid);
2899 if (!dac) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002900 if (spec->multiout.num_dacs > 0) {
2901 /* we have already working output pins,
2902 * so let's drop the broken ones again
2903 */
2904 cfg->line_outs = spec->multiout.num_dacs;
2905 break;
2906 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002907 /* error out, no available DAC found */
2908 snd_printk(KERN_ERR
2909 "%s: No available DAC for pin 0x%x\n",
2910 __func__, nid);
2911 return -ENODEV;
2912 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002913 add_spec_dacs(spec, dac);
2914 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002915
Takashi Iwai139e0712009-03-06 12:10:41 +01002916 for (i = 0; i < cfg->hp_outs; i++) {
2917 nid = cfg->hp_pins[i];
2918 dac = get_unassigned_dac(codec, nid);
2919 if (dac) {
2920 if (!spec->multiout.hp_nid)
2921 spec->multiout.hp_nid = dac;
2922 else
2923 add_spec_extra_dacs(spec, dac);
2924 }
2925 spec->hp_dacs[i] = dac;
2926 }
2927
2928 for (i = 0; i < cfg->speaker_outs; i++) {
2929 nid = cfg->speaker_pins[i];
2930 dac = get_unassigned_dac(codec, nid);
2931 if (dac)
2932 add_spec_extra_dacs(spec, dac);
2933 spec->speaker_dacs[i] = dac;
2934 }
2935
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002936 /* add line-in as output */
2937 nid = check_line_out_switch(codec);
2938 if (nid) {
2939 dac = get_unassigned_dac(codec, nid);
2940 if (dac) {
2941 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
2942 nid, cfg->line_outs);
2943 cfg->line_out_pins[cfg->line_outs] = nid;
2944 cfg->line_outs++;
2945 spec->line_switch = nid;
2946 add_spec_dacs(spec, dac);
2947 }
2948 }
2949 /* add mic as output */
2950 nid = check_mic_out_switch(codec);
2951 if (nid) {
2952 dac = get_unassigned_dac(codec, nid);
2953 if (dac) {
2954 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
2955 nid, cfg->line_outs);
2956 cfg->line_out_pins[cfg->line_outs] = nid;
2957 cfg->line_outs++;
2958 spec->mic_switch = nid;
2959 add_spec_dacs(spec, dac);
Steve Longerbeam7b043892007-05-03 20:50:03 +02002960 }
Mattc7d4b2f2005-06-27 14:59:41 +02002961 }
2962
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002963 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
Steve Longerbeam7b043892007-05-03 20:50:03 +02002964 spec->multiout.num_dacs,
2965 spec->multiout.dac_nids[0],
2966 spec->multiout.dac_nids[1],
2967 spec->multiout.dac_nids[2],
2968 spec->multiout.dac_nids[3],
2969 spec->multiout.dac_nids[4]);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002970
Mattc7d4b2f2005-06-27 14:59:41 +02002971 return 0;
2972}
2973
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002974/* create volume control/switch for the given prefx type */
Takashi Iwai668b9652009-03-06 10:13:24 +01002975static int create_controls_idx(struct hda_codec *codec, const char *pfx,
2976 int idx, hda_nid_t nid, int chs)
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002977{
Takashi Iwai7c7767e2009-01-20 15:28:38 +01002978 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002979 char name[32];
2980 int err;
2981
Takashi Iwai7c7767e2009-01-20 15:28:38 +01002982 if (!spec->check_volume_offset) {
2983 unsigned int caps, step, nums, db_scale;
2984 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
2985 step = (caps & AC_AMPCAP_STEP_SIZE) >>
2986 AC_AMPCAP_STEP_SIZE_SHIFT;
2987 step = (step + 1) * 25; /* in .01dB unit */
2988 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
2989 AC_AMPCAP_NUM_STEPS_SHIFT;
2990 db_scale = nums * step;
2991 /* if dB scale is over -64dB, and finer enough,
2992 * let's reduce it to half
2993 */
2994 if (db_scale > 6400 && nums >= 0x1f)
2995 spec->volume_offset = nums / 2;
2996 spec->check_volume_offset = 1;
2997 }
2998
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002999 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01003000 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003001 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3002 spec->volume_offset));
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003003 if (err < 0)
3004 return err;
3005 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01003006 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003007 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3008 if (err < 0)
3009 return err;
3010 return 0;
3011}
3012
Takashi Iwai668b9652009-03-06 10:13:24 +01003013#define create_controls(codec, pfx, nid, chs) \
3014 create_controls_idx(codec, pfx, 0, nid, chs)
3015
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003016static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3017{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003018 if (spec->multiout.num_dacs > 4) {
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003019 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3020 return 1;
3021 } else {
3022 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
3023 spec->multiout.num_dacs++;
3024 }
3025 return 0;
3026}
3027
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003028static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003029{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003030 int i;
3031 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3032 if (!spec->multiout.extra_out_nid[i]) {
3033 spec->multiout.extra_out_nid[i] = nid;
3034 return 0;
3035 }
3036 }
3037 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3038 return 1;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003039}
3040
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003041/* Create output controls
3042 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3043 */
3044static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3045 const hda_nid_t *pins,
3046 const hda_nid_t *dac_nids,
3047 int type)
Mattc7d4b2f2005-06-27 14:59:41 +02003048{
Takashi Iwai76624532008-12-19 10:09:47 +01003049 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003050 static const char *chname[4] = {
3051 "Front", "Surround", NULL /*CLFE*/, "Side"
3052 };
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003053 hda_nid_t nid;
Takashi Iwai91589232008-12-19 15:59:40 +01003054 int i, err;
3055 unsigned int wid_caps;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003056
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003057 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
Takashi Iwaiffd0e562009-04-16 12:20:24 +02003058 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
3059 wid_caps = get_wcaps(codec, pins[i]);
3060 if (wid_caps & AC_WCAP_UNSOL_CAP)
3061 spec->hp_detect = 1;
3062 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003063 nid = dac_nids[i];
3064 if (!nid)
3065 continue;
3066 if (type != AUTO_PIN_HP_OUT && i == 2) {
Mattc7d4b2f2005-06-27 14:59:41 +02003067 /* Center/LFE */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003068 err = create_controls(codec, "Center", nid, 1);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003069 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003070 return err;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003071 err = create_controls(codec, "LFE", nid, 2);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003072 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003073 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003074
3075 wid_caps = get_wcaps(codec, nid);
3076
3077 if (wid_caps & AC_WCAP_LR_SWAP) {
3078 err = stac92xx_add_control(spec,
3079 STAC_CTL_WIDGET_CLFE_SWITCH,
3080 "Swap Center/LFE Playback Switch", nid);
3081
3082 if (err < 0)
3083 return err;
3084 }
3085
Mattc7d4b2f2005-06-27 14:59:41 +02003086 } else {
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003087 const char *name;
Takashi Iwai668b9652009-03-06 10:13:24 +01003088 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003089 switch (type) {
3090 case AUTO_PIN_HP_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01003091 name = "Headphone";
3092 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003093 break;
3094 case AUTO_PIN_SPEAKER_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01003095 name = "Speaker";
3096 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003097 break;
3098 default:
3099 name = chname[i];
Takashi Iwai668b9652009-03-06 10:13:24 +01003100 idx = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003101 break;
Takashi Iwai76624532008-12-19 10:09:47 +01003102 }
Takashi Iwai668b9652009-03-06 10:13:24 +01003103 err = create_controls_idx(codec, name, idx, nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003104 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003105 return err;
3106 }
3107 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003108 return 0;
3109}
3110
Takashi Iwai6479c632009-07-28 18:20:25 +02003111static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
3112 unsigned long sw, int idx)
3113{
3114 int err;
3115 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
Takashi Iwaibf677bd2009-07-30 09:24:29 +02003116 "Capture Volume", vol);
Takashi Iwai6479c632009-07-28 18:20:25 +02003117 if (err < 0)
3118 return err;
3119 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx,
Takashi Iwaibf677bd2009-07-30 09:24:29 +02003120 "Capture Switch", sw);
Takashi Iwai6479c632009-07-28 18:20:25 +02003121 if (err < 0)
3122 return err;
3123 return 0;
3124}
3125
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003126/* add playback controls from the parsed DAC table */
3127static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3128 const struct auto_pin_cfg *cfg)
3129{
3130 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003131 hda_nid_t nid;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003132 int err;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003133 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003134
3135 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3136 spec->multiout.dac_nids,
3137 cfg->line_out_type);
3138 if (err < 0)
3139 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003140
Takashi Iwaia9cb5c92008-11-24 07:51:11 +01003141 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003142 err = stac92xx_add_control(spec,
3143 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01003144 "Headphone as Line Out Switch",
3145 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003146 if (err < 0)
3147 return err;
3148 }
3149
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003150 for (idx = AUTO_PIN_MIC; idx <= AUTO_PIN_FRONT_LINE; idx++) {
3151 nid = cfg->input_pins[idx];
3152 if (nid) {
3153 err = stac92xx_add_jack_mode_control(codec, nid, idx);
3154 if (err < 0)
3155 return err;
3156 }
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003157 }
Matt Porter403d1942005-11-29 15:00:51 +01003158
Mattc7d4b2f2005-06-27 14:59:41 +02003159 return 0;
3160}
3161
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003162/* add playback controls for Speaker and HP outputs */
3163static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3164 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003165{
3166 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003167 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02003168
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003169 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3170 spec->hp_dacs, AUTO_PIN_HP_OUT);
3171 if (err < 0)
3172 return err;
3173
3174 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3175 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3176 if (err < 0)
3177 return err;
3178
Mattc7d4b2f2005-06-27 14:59:41 +02003179 return 0;
3180}
3181
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003182/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003183static const char *stac92xx_mono_labels[4] = {
3184 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003185};
3186
3187/* create mono mux for mono out on capable codecs */
3188static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3189{
3190 struct sigmatel_spec *spec = codec->spec;
3191 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3192 int i, num_cons;
3193 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3194
3195 num_cons = snd_hda_get_connections(codec,
3196 spec->mono_nid,
3197 con_lst,
3198 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003199 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003200 return -EINVAL;
3201
3202 for (i = 0; i < num_cons; i++) {
3203 mono_mux->items[mono_mux->num_items].label =
3204 stac92xx_mono_labels[i];
3205 mono_mux->items[mono_mux->num_items].index = i;
3206 mono_mux->num_items++;
3207 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003208
3209 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3210 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003211}
3212
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003213/* create PC beep volume controls */
3214static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3215 hda_nid_t nid)
3216{
3217 struct sigmatel_spec *spec = codec->spec;
3218 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3219 int err;
3220
3221 /* check for mute support for the the amp */
3222 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3223 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3224 "PC Beep Playback Switch",
3225 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3226 if (err < 0)
3227 return err;
3228 }
3229
3230 /* check to see if there is volume support for the amp */
3231 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3232 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3233 "PC Beep Playback Volume",
3234 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3235 if (err < 0)
3236 return err;
3237 }
3238 return 0;
3239}
3240
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003241#ifdef CONFIG_SND_HDA_INPUT_BEEP
3242#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3243
3244static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3245 struct snd_ctl_elem_value *ucontrol)
3246{
3247 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3248 ucontrol->value.integer.value[0] = codec->beep->enabled;
3249 return 0;
3250}
3251
3252static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3253 struct snd_ctl_elem_value *ucontrol)
3254{
3255 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3256 int enabled = !!ucontrol->value.integer.value[0];
3257 if (codec->beep->enabled != enabled) {
3258 codec->beep->enabled = enabled;
3259 return 1;
3260 }
3261 return 0;
3262}
3263
3264static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3265 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3266 .info = stac92xx_dig_beep_switch_info,
3267 .get = stac92xx_dig_beep_switch_get,
3268 .put = stac92xx_dig_beep_switch_put,
3269};
3270
3271static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3272{
3273 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3274 0, "PC Beep Playback Switch", 0);
3275}
3276#endif
3277
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003278static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3279{
3280 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai667067d2009-08-13 18:14:42 +02003281 int i, j, err = 0;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003282
3283 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02003284 hda_nid_t nid;
3285 unsigned int wcaps;
3286 unsigned long val;
3287
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003288 nid = spec->mux_nids[i];
3289 wcaps = get_wcaps(codec, nid);
Takashi Iwai667067d2009-08-13 18:14:42 +02003290 if (!(wcaps & AC_WCAP_OUT_AMP))
3291 continue;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003292
Takashi Iwai667067d2009-08-13 18:14:42 +02003293 /* check whether already the same control was created as
3294 * normal Capture Volume.
3295 */
3296 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3297 for (j = 0; j < spec->num_caps; j++) {
3298 if (spec->capvols[j] == val)
3299 break;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003300 }
Takashi Iwai667067d2009-08-13 18:14:42 +02003301 if (j < spec->num_caps)
3302 continue;
3303
3304 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i,
3305 "Mux Capture Volume", val);
3306 if (err < 0)
3307 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003308 }
3309 return 0;
3310};
3311
Matthew Ranostayd9737752008-09-07 12:03:41 +02003312static const char *stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003313 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003314};
3315
3316static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3317{
3318 struct sigmatel_spec *spec = codec->spec;
3319 struct hda_input_mux *spdif_mux = &spec->private_smux;
Matthew Ranostay65973632008-09-16 10:39:37 -04003320 const char **labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003321 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003322 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003323
3324 num_cons = snd_hda_get_connections(codec,
3325 spec->smux_nids[0],
3326 con_lst,
3327 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003328 if (num_cons <= 0)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003329 return -EINVAL;
3330
Matthew Ranostay65973632008-09-16 10:39:37 -04003331 if (!labels)
3332 labels = stac92xx_spdif_labels;
3333
Matthew Ranostayd9737752008-09-07 12:03:41 +02003334 for (i = 0; i < num_cons; i++) {
Matthew Ranostay65973632008-09-16 10:39:37 -04003335 spdif_mux->items[spdif_mux->num_items].label = labels[i];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003336 spdif_mux->items[spdif_mux->num_items].index = i;
3337 spdif_mux->num_items++;
3338 }
3339
3340 return 0;
3341}
3342
Matt Porter8b657272006-10-26 17:12:59 +02003343/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003344static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003345 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3346 "Digital Mic 3", "Digital Mic 4"
3347};
3348
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003349static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
3350 hda_nid_t nid)
3351{
3352 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
3353 int i, nums;
3354
3355 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
3356 for (i = 0; i < nums; i++)
3357 if (conn[i] == nid)
3358 return i;
3359 return -1;
3360}
3361
Takashi Iwai667067d2009-08-13 18:14:42 +02003362/* create a volume assigned to the given pin (only if supported) */
Takashi Iwai96f845d2009-08-29 00:49:36 +02003363/* return 1 if the volume control is created */
Takashi Iwai667067d2009-08-13 18:14:42 +02003364static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwai96f845d2009-08-29 00:49:36 +02003365 const char *label, int direction)
Takashi Iwai667067d2009-08-13 18:14:42 +02003366{
3367 unsigned int caps, nums;
3368 char name[32];
Takashi Iwai96f845d2009-08-29 00:49:36 +02003369 int err;
Takashi Iwai667067d2009-08-13 18:14:42 +02003370
Takashi Iwai96f845d2009-08-29 00:49:36 +02003371 if (direction == HDA_OUTPUT)
3372 caps = AC_WCAP_OUT_AMP;
3373 else
3374 caps = AC_WCAP_IN_AMP;
3375 if (!(get_wcaps(codec, nid) & caps))
Takashi Iwai667067d2009-08-13 18:14:42 +02003376 return 0;
Takashi Iwai96f845d2009-08-29 00:49:36 +02003377 caps = query_amp_caps(codec, nid, direction);
Takashi Iwai667067d2009-08-13 18:14:42 +02003378 nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
3379 if (!nums)
3380 return 0;
3381 snprintf(name, sizeof(name), "%s Capture Volume", label);
Takashi Iwai96f845d2009-08-29 00:49:36 +02003382 err = stac92xx_add_control(codec->spec, STAC_CTL_WIDGET_VOL, name,
3383 HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction));
3384 if (err < 0)
3385 return err;
3386 return 1;
Takashi Iwai667067d2009-08-13 18:14:42 +02003387}
3388
Matt Porter8b657272006-10-26 17:12:59 +02003389/* create playback/capture controls for input pins on dmic capable codecs */
3390static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3391 const struct auto_pin_cfg *cfg)
3392{
3393 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai5207e102009-07-30 13:09:08 +02003394 struct hda_input_mux *imux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003395 struct hda_input_mux *dimux = &spec->private_dimux;
Takashi Iwai5207e102009-07-30 13:09:08 +02003396 int err, i, active_mics;
3397 unsigned int def_conf;
Matt Porter8b657272006-10-26 17:12:59 +02003398
3399 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3400 dimux->items[dimux->num_items].index = 0;
3401 dimux->num_items++;
3402
Takashi Iwai5207e102009-07-30 13:09:08 +02003403 active_mics = 0;
3404 for (i = 0; i < spec->num_dmics; i++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02003405 /* check the validity: sometimes it's a dead vendor-spec node */
3406 if (get_wcaps_type(get_wcaps(codec, spec->dmic_nids[i]))
3407 != AC_WID_PIN)
3408 continue;
Takashi Iwai5207e102009-07-30 13:09:08 +02003409 def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
3410 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)
3411 active_mics++;
3412 }
3413
Matt Porter8b657272006-10-26 17:12:59 +02003414 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003415 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003416 int index;
Takashi Iwai5207e102009-07-30 13:09:08 +02003417 const char *label;
Matt Porter8b657272006-10-26 17:12:59 +02003418
Takashi Iwai667067d2009-08-13 18:14:42 +02003419 nid = spec->dmic_nids[i];
3420 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
3421 continue;
3422 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Matt Porter8b657272006-10-26 17:12:59 +02003423 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3424 continue;
3425
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003426 index = get_connection_index(codec, spec->dmux_nids[0], nid);
3427 if (index < 0)
3428 continue;
3429
Takashi Iwai5207e102009-07-30 13:09:08 +02003430 if (active_mics == 1)
3431 label = "Digital Mic";
3432 else
3433 label = stac92xx_dmic_labels[dimux->num_items];
3434
Takashi Iwai96f845d2009-08-29 00:49:36 +02003435 err = create_elem_capture_vol(codec, nid, label, HDA_INPUT);
Takashi Iwai667067d2009-08-13 18:14:42 +02003436 if (err < 0)
3437 return err;
Takashi Iwai96f845d2009-08-29 00:49:36 +02003438 if (!err) {
3439 err = create_elem_capture_vol(codec, nid, label,
3440 HDA_OUTPUT);
3441 if (err < 0)
3442 return err;
3443 }
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003444
Takashi Iwai5207e102009-07-30 13:09:08 +02003445 dimux->items[dimux->num_items].label = label;
Matt Porter8b657272006-10-26 17:12:59 +02003446 dimux->items[dimux->num_items].index = index;
3447 dimux->num_items++;
Takashi Iwai5207e102009-07-30 13:09:08 +02003448 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1) {
3449 imux->items[imux->num_items].label = label;
3450 imux->items[imux->num_items].index = index;
3451 imux->num_items++;
3452 }
Matt Porter8b657272006-10-26 17:12:59 +02003453 }
3454
3455 return 0;
3456}
3457
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003458static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
3459 hda_nid_t *fixed, hda_nid_t *ext)
3460{
3461 unsigned int cfg;
3462
3463 if (!nid)
3464 return 0;
3465 cfg = snd_hda_codec_get_pincfg(codec, nid);
3466 switch (get_defcfg_connect(cfg)) {
3467 case AC_JACK_PORT_FIXED:
3468 if (*fixed)
3469 return 1; /* already occupied */
3470 *fixed = nid;
3471 break;
3472 case AC_JACK_PORT_COMPLEX:
3473 if (*ext)
3474 return 1; /* already occupied */
3475 *ext = nid;
3476 break;
3477 }
3478 return 0;
3479}
3480
3481static int set_mic_route(struct hda_codec *codec,
3482 struct sigmatel_mic_route *mic,
3483 hda_nid_t pin)
3484{
3485 struct sigmatel_spec *spec = codec->spec;
3486 struct auto_pin_cfg *cfg = &spec->autocfg;
3487 int i;
3488
3489 mic->pin = pin;
3490 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++)
3491 if (pin == cfg->input_pins[i])
3492 break;
3493 if (i <= AUTO_PIN_FRONT_MIC) {
3494 /* analog pin */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003495 i = get_connection_index(codec, spec->mux_nids[0], pin);
3496 if (i < 0)
3497 return -1;
3498 mic->mux_idx = i;
Takashi Iwai02d33322009-10-01 16:38:11 +02003499 mic->dmux_idx = -1;
3500 if (spec->dmux_nids)
3501 mic->dmux_idx = get_connection_index(codec,
3502 spec->dmux_nids[0],
3503 spec->mux_nids[0]);
Takashi Iwaida2a2aa2009-08-10 07:44:09 +02003504 } else if (spec->dmux_nids) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003505 /* digital pin */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003506 i = get_connection_index(codec, spec->dmux_nids[0], pin);
3507 if (i < 0)
3508 return -1;
3509 mic->dmux_idx = i;
Takashi Iwai02d33322009-10-01 16:38:11 +02003510 mic->mux_idx = -1;
3511 if (spec->mux_nids)
3512 mic->mux_idx = get_connection_index(codec,
3513 spec->mux_nids[0],
3514 spec->dmux_nids[0]);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003515 }
3516 return 0;
3517}
3518
3519/* return non-zero if the device is for automatic mic switch */
3520static int stac_check_auto_mic(struct hda_codec *codec)
3521{
3522 struct sigmatel_spec *spec = codec->spec;
3523 struct auto_pin_cfg *cfg = &spec->autocfg;
3524 hda_nid_t fixed, ext;
3525 int i;
3526
3527 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++) {
3528 if (cfg->input_pins[i])
3529 return 0; /* must be exclusively mics */
3530 }
3531 fixed = ext = 0;
3532 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++)
3533 if (check_mic_pin(codec, cfg->input_pins[i], &fixed, &ext))
3534 return 0;
3535 for (i = 0; i < spec->num_dmics; i++)
3536 if (check_mic_pin(codec, spec->dmic_nids[i], &fixed, &ext))
3537 return 0;
3538 if (!fixed || !ext)
3539 return 0;
3540 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
3541 return 0; /* no unsol support */
3542 if (set_mic_route(codec, &spec->ext_mic, ext) ||
3543 set_mic_route(codec, &spec->int_mic, fixed))
3544 return 0; /* something is wrong */
3545 return 1;
3546}
3547
Mattc7d4b2f2005-06-27 14:59:41 +02003548/* create playback/capture controls for input pins */
3549static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3550{
3551 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003552 struct hda_input_mux *imux = &spec->private_imux;
Takashi Iwai667067d2009-08-13 18:14:42 +02003553 int i, j;
Mattc7d4b2f2005-06-27 14:59:41 +02003554
3555 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02003556 hda_nid_t nid = cfg->input_pins[i];
3557 int index, err;
Mattc7d4b2f2005-06-27 14:59:41 +02003558
Takashi Iwai667067d2009-08-13 18:14:42 +02003559 if (!nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02003560 continue;
3561 index = -1;
3562 for (j = 0; j < spec->num_muxes; j++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02003563 index = get_connection_index(codec, spec->mux_nids[j],
3564 nid);
3565 if (index >= 0)
3566 break;
Mattc7d4b2f2005-06-27 14:59:41 +02003567 }
Takashi Iwai667067d2009-08-13 18:14:42 +02003568 if (index < 0)
3569 continue;
3570
3571 err = create_elem_capture_vol(codec, nid,
Takashi Iwai96f845d2009-08-29 00:49:36 +02003572 auto_pin_cfg_labels[i],
3573 HDA_INPUT);
Takashi Iwai667067d2009-08-13 18:14:42 +02003574 if (err < 0)
3575 return err;
3576
Takashi Iwai314634b2006-09-21 11:56:18 +02003577 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3578 imux->items[imux->num_items].index = index;
3579 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003580 }
Takashi Iwai5207e102009-07-30 13:09:08 +02003581 spec->num_analog_muxes = imux->num_items;
Mattc7d4b2f2005-06-27 14:59:41 +02003582
Steve Longerbeam7b043892007-05-03 20:50:03 +02003583 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003584 /*
3585 * Set the current input for the muxes.
3586 * The STAC9221 has two input muxes with identical source
3587 * NID lists. Hopefully this won't get confused.
3588 */
3589 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003590 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3591 AC_VERB_SET_CONNECT_SEL,
3592 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003593 }
3594 }
3595
Mattc7d4b2f2005-06-27 14:59:41 +02003596 return 0;
3597}
3598
Mattc7d4b2f2005-06-27 14:59:41 +02003599static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3600{
3601 struct sigmatel_spec *spec = codec->spec;
3602 int i;
3603
3604 for (i = 0; i < spec->autocfg.line_outs; i++) {
3605 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3606 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3607 }
3608}
3609
3610static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3611{
3612 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003613 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003614
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003615 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3616 hda_nid_t pin;
3617 pin = spec->autocfg.hp_pins[i];
3618 if (pin) /* connect to front */
3619 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3620 }
3621 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3622 hda_nid_t pin;
3623 pin = spec->autocfg.speaker_pins[i];
3624 if (pin) /* connect to front */
3625 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3626 }
Mattc7d4b2f2005-06-27 14:59:41 +02003627}
3628
Matt Porter3cc08dc2006-01-23 15:27:49 +01003629static 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 +02003630{
3631 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003632 int hp_swap = 0;
Takashi Iwai6479c632009-07-28 18:20:25 +02003633 int i, err;
Mattc7d4b2f2005-06-27 14:59:41 +02003634
Matt Porter8b657272006-10-26 17:12:59 +02003635 if ((err = snd_hda_parse_pin_def_config(codec,
3636 &spec->autocfg,
3637 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003638 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003639 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003640 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003641
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003642 /* If we have no real line-out pin and multiple hp-outs, HPs should
3643 * be set up as multi-channel outputs.
3644 */
3645 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3646 spec->autocfg.hp_outs > 1) {
3647 /* Copy hp_outs to line_outs, backup line_outs in
3648 * speaker_outs so that the following routines can handle
3649 * HP pins as primary outputs.
3650 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003651 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003652 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3653 sizeof(spec->autocfg.line_out_pins));
3654 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3655 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3656 sizeof(spec->autocfg.hp_pins));
3657 spec->autocfg.line_outs = spec->autocfg.hp_outs;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003658 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3659 spec->autocfg.hp_outs = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003660 hp_swap = 1;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003661 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003662 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003663 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3664 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003665 u32 caps = query_amp_caps(codec,
3666 spec->autocfg.mono_out_pin, dir);
3667 hda_nid_t conn_list[1];
3668
3669 /* get the mixer node and then the mono mux if it exists */
3670 if (snd_hda_get_connections(codec,
3671 spec->autocfg.mono_out_pin, conn_list, 1) &&
3672 snd_hda_get_connections(codec, conn_list[0],
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003673 conn_list, 1) > 0) {
Matthew Ranostay09a99952008-01-24 11:49:21 +01003674
3675 int wcaps = get_wcaps(codec, conn_list[0]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02003676 int wid_type = get_wcaps_type(wcaps);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003677 /* LR swap check, some stac925x have a mux that
3678 * changes the DACs output path instead of the
3679 * mono-mux path.
3680 */
3681 if (wid_type == AC_WID_AUD_SEL &&
3682 !(wcaps & AC_WCAP_LR_SWAP))
3683 spec->mono_nid = conn_list[0];
3684 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003685 if (dir) {
3686 hda_nid_t nid = spec->autocfg.mono_out_pin;
3687
3688 /* most mono outs have a least a mute/unmute switch */
3689 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3690 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3691 "Mono Playback Switch",
3692 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003693 if (err < 0)
3694 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003695 /* check for volume support for the amp */
3696 if ((caps & AC_AMPCAP_NUM_STEPS)
3697 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3698 err = stac92xx_add_control(spec,
3699 STAC_CTL_WIDGET_VOL,
3700 "Mono Playback Volume",
3701 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3702 if (err < 0)
3703 return err;
3704 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003705 }
3706
3707 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3708 AC_PINCTL_OUT_EN);
3709 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003710
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003711 if (!spec->multiout.num_dacs) {
3712 err = stac92xx_auto_fill_dac_nids(codec);
3713 if (err < 0)
Takashi Iwai19039bd2006-06-28 15:52:16 +02003714 return err;
Takashi Iwaic9280d62009-01-15 17:31:00 +01003715 err = stac92xx_auto_create_multi_out_ctls(codec,
3716 &spec->autocfg);
3717 if (err < 0)
3718 return err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003719 }
Mattc7d4b2f2005-06-27 14:59:41 +02003720
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003721 /* setup analog beep controls */
3722 if (spec->anabeep_nid > 0) {
3723 err = stac92xx_auto_create_beep_ctls(codec,
3724 spec->anabeep_nid);
3725 if (err < 0)
3726 return err;
3727 }
3728
3729 /* setup digital beep controls and input device */
3730#ifdef CONFIG_SND_HDA_INPUT_BEEP
3731 if (spec->digbeep_nid > 0) {
3732 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003733 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003734
3735 err = stac92xx_auto_create_beep_ctls(codec, nid);
3736 if (err < 0)
3737 return err;
3738 err = snd_hda_attach_beep_device(codec, nid);
3739 if (err < 0)
3740 return err;
Takashi Iwaifa797962009-05-19 12:50:04 +02003741 /* IDT/STAC codecs have linear beep tone parameter */
3742 codec->beep->linear_tone = 1;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003743 /* if no beep switch is available, make its own one */
3744 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3745 if (codec->beep &&
3746 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3747 err = stac92xx_beep_switch_ctl(codec);
3748 if (err < 0)
3749 return err;
3750 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003751 }
3752#endif
3753
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003754 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003755 if (err < 0)
3756 return err;
3757
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003758 /* All output parsing done, now restore the swapped hp pins */
3759 if (hp_swap) {
3760 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3761 sizeof(spec->autocfg.hp_pins));
3762 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3763 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3764 spec->autocfg.line_outs = 0;
3765 }
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003766
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003767 if (stac_check_auto_mic(codec)) {
3768 spec->auto_mic = 1;
3769 /* only one capture for auto-mic */
3770 spec->num_adcs = 1;
3771 spec->num_caps = 1;
3772 spec->num_muxes = 1;
3773 }
3774
Takashi Iwai6479c632009-07-28 18:20:25 +02003775 for (i = 0; i < spec->num_caps; i++) {
3776 err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
3777 spec->capsws[i], i);
3778 if (err < 0)
3779 return err;
3780 }
3781
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003782 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003783 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003784 return err;
3785
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003786 if (spec->mono_nid > 0) {
3787 err = stac92xx_auto_create_mono_output_ctls(codec);
3788 if (err < 0)
3789 return err;
3790 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003791 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003792 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3793 &spec->autocfg)) < 0)
3794 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003795 if (spec->num_muxes > 0) {
3796 err = stac92xx_auto_create_mux_input_ctls(codec);
3797 if (err < 0)
3798 return err;
3799 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003800 if (spec->num_smuxes > 0) {
3801 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3802 if (err < 0)
3803 return err;
3804 }
Matt Porter8b657272006-10-26 17:12:59 +02003805
Takashi Iwaie3c75962009-01-23 11:57:22 +01003806 err = stac92xx_add_input_source(spec);
3807 if (err < 0)
3808 return err;
3809
Mattc7d4b2f2005-06-27 14:59:41 +02003810 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003811 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003812 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003813
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003814 if (spec->autocfg.dig_outs)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003815 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003816 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003817 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003818
Takashi Iwai603c4012008-07-30 15:01:44 +02003819 if (spec->kctls.list)
3820 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003821
3822 spec->input_mux = &spec->private_imux;
Matthew Ranostayf8ccbf62008-12-20 17:36:28 -05003823 if (!spec->dinput_mux)
3824 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003825 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003826 spec->mono_mux = &spec->private_mono_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003827 return 1;
3828}
3829
Takashi Iwai82bc9552006-03-21 11:24:42 +01003830/* add playback controls for HP output */
3831static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3832 struct auto_pin_cfg *cfg)
3833{
3834 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003835 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003836 unsigned int wid_caps;
3837
3838 if (! pin)
3839 return 0;
3840
3841 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003842 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003843 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003844
3845 return 0;
3846}
3847
Richard Fish160ea0d2006-09-06 13:58:25 +02003848/* add playback controls for LFE output */
3849static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3850 struct auto_pin_cfg *cfg)
3851{
3852 struct sigmatel_spec *spec = codec->spec;
3853 int err;
3854 hda_nid_t lfe_pin = 0x0;
3855 int i;
3856
3857 /*
3858 * search speaker outs and line outs for a mono speaker pin
3859 * with an amp. If one is found, add LFE controls
3860 * for it.
3861 */
3862 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3863 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003864 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003865 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3866 if (wcaps == AC_WCAP_OUT_AMP)
3867 /* found a mono speaker with an amp, must be lfe */
3868 lfe_pin = pin;
3869 }
3870
3871 /* if speaker_outs is 0, then speakers may be in line_outs */
3872 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3873 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3874 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003875 unsigned int defcfg;
Takashi Iwai330ee992009-02-20 14:33:36 +01003876 defcfg = snd_hda_codec_get_pincfg(codec, pin);
Harvey Harrison8b551782008-02-29 11:56:48 +01003877 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003878 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003879 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3880 if (wcaps == AC_WCAP_OUT_AMP)
3881 /* found a mono speaker with an amp,
3882 must be lfe */
3883 lfe_pin = pin;
3884 }
3885 }
3886 }
3887
3888 if (lfe_pin) {
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003889 err = create_controls(codec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003890 if (err < 0)
3891 return err;
3892 }
3893
3894 return 0;
3895}
3896
Mattc7d4b2f2005-06-27 14:59:41 +02003897static int stac9200_parse_auto_config(struct hda_codec *codec)
3898{
3899 struct sigmatel_spec *spec = codec->spec;
3900 int err;
3901
Kailang Yangdf694da2005-12-05 19:42:22 +01003902 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003903 return err;
3904
3905 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3906 return err;
3907
Takashi Iwai82bc9552006-03-21 11:24:42 +01003908 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3909 return err;
3910
Richard Fish160ea0d2006-09-06 13:58:25 +02003911 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3912 return err;
3913
Takashi Iwai355a0ec2008-11-11 16:46:19 +01003914 if (spec->num_muxes > 0) {
3915 err = stac92xx_auto_create_mux_input_ctls(codec);
3916 if (err < 0)
3917 return err;
3918 }
3919
Takashi Iwaie3c75962009-01-23 11:57:22 +01003920 err = stac92xx_add_input_source(spec);
3921 if (err < 0)
3922 return err;
3923
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003924 if (spec->autocfg.dig_outs)
Mattc7d4b2f2005-06-27 14:59:41 +02003925 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003926 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003927 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003928
Takashi Iwai603c4012008-07-30 15:01:44 +02003929 if (spec->kctls.list)
3930 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003931
3932 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003933 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003934
3935 return 1;
3936}
3937
Sam Revitch62fe78e2006-05-10 15:09:17 +02003938/*
3939 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3940 * funky external mute control using GPIO pins.
3941 */
3942
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003943static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003944 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003945{
3946 unsigned int gpiostate, gpiomask, gpiodir;
3947
3948 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3949 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003950 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003951
3952 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3953 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003954 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003955
3956 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3957 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003958 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003959
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003960 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003961 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3962
3963 snd_hda_codec_write(codec, codec->afg, 0,
3964 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003965 snd_hda_codec_read(codec, codec->afg, 0,
3966 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003967
3968 msleep(1);
3969
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003970 snd_hda_codec_read(codec, codec->afg, 0,
3971 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003972}
3973
Takashi Iwai8c8145b2009-06-22 17:00:38 +02003974#ifdef CONFIG_SND_HDA_INPUT_JACK
Takashi Iwai95c09092009-04-14 16:15:29 +02003975static void stac92xx_free_jack_priv(struct snd_jack *jack)
3976{
3977 struct sigmatel_jack *jacks = jack->private_data;
3978 jacks->nid = 0;
3979 jacks->jack = NULL;
3980}
3981#endif
3982
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003983static int stac92xx_add_jack(struct hda_codec *codec,
3984 hda_nid_t nid, int type)
3985{
Takashi Iwai8c8145b2009-06-22 17:00:38 +02003986#ifdef CONFIG_SND_HDA_INPUT_JACK
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003987 struct sigmatel_spec *spec = codec->spec;
3988 struct sigmatel_jack *jack;
Takashi Iwai330ee992009-02-20 14:33:36 +01003989 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003990 int connectivity = get_defcfg_connect(def_conf);
3991 char name[32];
Takashi Iwai95c09092009-04-14 16:15:29 +02003992 int err;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003993
3994 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
3995 return 0;
3996
3997 snd_array_init(&spec->jacks, sizeof(*jack), 32);
3998 jack = snd_array_new(&spec->jacks);
3999 if (!jack)
4000 return -ENOMEM;
4001 jack->nid = nid;
4002 jack->type = type;
4003
Takashi Iwai86de7412009-07-22 16:02:46 +02004004 snprintf(name, sizeof(name), "%s at %s %s Jack",
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004005 snd_hda_get_jack_type(def_conf),
4006 snd_hda_get_jack_connectivity(def_conf),
4007 snd_hda_get_jack_location(def_conf));
4008
Takashi Iwai95c09092009-04-14 16:15:29 +02004009 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
4010 if (err < 0) {
4011 jack->nid = 0;
4012 return err;
4013 }
4014 jack->jack->private_data = jack;
4015 jack->jack->private_free = stac92xx_free_jack_priv;
Takashi Iwaie4973e12008-11-18 09:32:42 +01004016#endif
Takashi Iwai95c09092009-04-14 16:15:29 +02004017 return 0;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004018}
4019
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004020static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
4021 unsigned char type, int data)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004022{
4023 struct sigmatel_event *event;
4024
4025 snd_array_init(&spec->events, sizeof(*event), 32);
4026 event = snd_array_new(&spec->events);
4027 if (!event)
4028 return -ENOMEM;
4029 event->nid = nid;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004030 event->type = type;
4031 event->tag = spec->events.used;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004032 event->data = data;
4033
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004034 return event->tag;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004035}
4036
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004037static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
Takashi Iwai62558ce2009-07-29 14:23:09 +02004038 hda_nid_t nid)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004039{
4040 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004041 struct sigmatel_event *event = spec->events.list;
4042 int i;
4043
4044 for (i = 0; i < spec->events.used; i++, event++) {
Takashi Iwai62558ce2009-07-29 14:23:09 +02004045 if (event->nid == nid)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004046 return event;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004047 }
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004048 return NULL;
4049}
4050
4051static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
4052 unsigned char tag)
4053{
4054 struct sigmatel_spec *spec = codec->spec;
4055 struct sigmatel_event *event = spec->events.list;
4056 int i;
4057
4058 for (i = 0; i < spec->events.used; i++, event++) {
4059 if (event->tag == tag)
4060 return event;
4061 }
4062 return NULL;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004063}
4064
Takashi Iwai62558ce2009-07-29 14:23:09 +02004065/* check if given nid is a valid pin and no other events are assigned
4066 * to it. If OK, assign the event, set the unsol flag, and returns 1.
4067 * Otherwise, returns zero.
4068 */
4069static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
4070 unsigned int type)
Takashi Iwai314634b2006-09-21 11:56:18 +02004071{
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004072 struct sigmatel_event *event;
4073 int tag;
4074
4075 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
Takashi Iwai62558ce2009-07-29 14:23:09 +02004076 return 0;
4077 event = stac_get_event(codec, nid);
4078 if (event) {
4079 if (event->type != type)
4080 return 0;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004081 tag = event->tag;
Takashi Iwai62558ce2009-07-29 14:23:09 +02004082 } else {
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004083 tag = stac_add_event(codec->spec, nid, type, 0);
Takashi Iwai62558ce2009-07-29 14:23:09 +02004084 if (tag < 0)
4085 return 0;
4086 }
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004087 snd_hda_codec_write_cache(codec, nid, 0,
4088 AC_VERB_SET_UNSOLICITED_ENABLE,
4089 AC_USRSP_EN | tag);
Takashi Iwai62558ce2009-07-29 14:23:09 +02004090 return 1;
Takashi Iwai314634b2006-09-21 11:56:18 +02004091}
4092
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004093static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
4094{
4095 int i;
4096 for (i = 0; i < cfg->hp_outs; i++)
4097 if (cfg->hp_pins[i] == nid)
4098 return 1; /* nid is a HP-Out */
4099
4100 return 0; /* nid is not a HP-Out */
4101};
4102
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004103static void stac92xx_power_down(struct hda_codec *codec)
4104{
4105 struct sigmatel_spec *spec = codec->spec;
4106
4107 /* power down inactive DACs */
4108 hda_nid_t *dac;
4109 for (dac = spec->dac_list; *dac; dac++)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004110 if (!check_all_dac_nids(spec, *dac))
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004111 snd_hda_codec_write(codec, *dac, 0,
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004112 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4113}
4114
Takashi Iwaif73d3582008-11-25 08:21:51 +01004115static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4116 int enable);
4117
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004118/* override some hints from the hwdep entry */
4119static void stac_store_hints(struct hda_codec *codec)
4120{
4121 struct sigmatel_spec *spec = codec->spec;
4122 const char *p;
4123 int val;
4124
4125 val = snd_hda_get_bool_hint(codec, "hp_detect");
4126 if (val >= 0)
4127 spec->hp_detect = val;
4128 p = snd_hda_get_hint(codec, "gpio_mask");
4129 if (p) {
4130 spec->gpio_mask = simple_strtoul(p, NULL, 0);
4131 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
4132 spec->gpio_mask;
4133 }
4134 p = snd_hda_get_hint(codec, "gpio_dir");
4135 if (p)
4136 spec->gpio_dir = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4137 p = snd_hda_get_hint(codec, "gpio_data");
4138 if (p)
4139 spec->gpio_data = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4140 p = snd_hda_get_hint(codec, "eapd_mask");
4141 if (p)
4142 spec->eapd_mask = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4143 val = snd_hda_get_bool_hint(codec, "eapd_switch");
4144 if (val >= 0)
4145 spec->eapd_switch = val;
4146}
4147
Mattc7d4b2f2005-06-27 14:59:41 +02004148static int stac92xx_init(struct hda_codec *codec)
4149{
4150 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004151 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004152 unsigned int gpio;
Takashi Iwaie4973e12008-11-18 09:32:42 +01004153 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02004154
Mattc7d4b2f2005-06-27 14:59:41 +02004155 snd_hda_sequence_write(codec, spec->init);
4156
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004157 /* power down adcs initially */
4158 if (spec->powerdown_adcs)
4159 for (i = 0; i < spec->num_adcs; i++)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004160 snd_hda_codec_write(codec,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004161 spec->adc_nids[i], 0,
4162 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004163
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004164 /* override some hints */
4165 stac_store_hints(codec);
4166
Takashi Iwaif73d3582008-11-25 08:21:51 +01004167 /* set up GPIO */
4168 gpio = spec->gpio_data;
4169 /* turn on EAPD statically when spec->eapd_switch isn't set.
4170 * otherwise, unsol event will turn it on/off dynamically
4171 */
4172 if (!spec->eapd_switch)
4173 gpio |= spec->eapd_mask;
4174 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4175
Takashi Iwai82bc9552006-03-21 11:24:42 +01004176 /* set up pins */
4177 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02004178 /* Enable unsolicited responses on the HP widget */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004179 for (i = 0; i < cfg->hp_outs; i++) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004180 hda_nid_t nid = cfg->hp_pins[i];
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004181 enable_pin_detect(codec, nid, STAC_HP_EVENT);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004182 }
Takashi Iwai1c4bdf92009-08-13 08:23:24 +02004183 if (cfg->line_out_type == AUTO_PIN_LINE_OUT &&
4184 cfg->speaker_outs > 0) {
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004185 /* enable pin-detect for line-outs as well */
Takashi Iwai15cfa2b2009-08-03 14:23:33 +02004186 for (i = 0; i < cfg->line_outs; i++) {
4187 hda_nid_t nid = cfg->line_out_pins[i];
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004188 enable_pin_detect(codec, nid, STAC_LO_EVENT);
4189 }
4190 }
4191
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01004192 /* force to enable the first line-out; the others are set up
4193 * in unsol_event
4194 */
4195 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004196 AC_PINCTL_OUT_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004197 /* fake event to set up pins */
Takashi Iwai5f380eb2009-09-14 15:36:14 +02004198 if (cfg->hp_pins[0])
4199 stac_issue_unsol_event(codec, cfg->hp_pins[0]);
4200 else if (cfg->line_out_pins[0])
4201 stac_issue_unsol_event(codec, cfg->line_out_pins[0]);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004202 } else {
4203 stac92xx_auto_init_multi_out(codec);
4204 stac92xx_auto_init_hp_out(codec);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004205 for (i = 0; i < cfg->hp_outs; i++)
4206 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004207 }
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004208 if (spec->auto_mic) {
Takashi Iwai15b4f292009-07-29 16:32:55 +02004209 /* initialize connection to analog input */
Takashi Iwaida2a2aa2009-08-10 07:44:09 +02004210 if (spec->dmux_nids)
4211 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
Takashi Iwai15b4f292009-07-29 16:32:55 +02004212 AC_VERB_SET_CONNECT_SEL, 0);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004213 if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
4214 stac_issue_unsol_event(codec, spec->ext_mic.pin);
4215 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01004216 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01004217 hda_nid_t nid = cfg->input_pins[i];
4218 if (nid) {
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004219 unsigned int pinctl, conf;
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004220 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
4221 /* for mic pins, force to initialize */
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02004222 pinctl = stac92xx_get_default_vref(codec, nid);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004223 pinctl |= AC_PINCTL_IN_EN;
4224 stac92xx_auto_set_pinctl(codec, nid, pinctl);
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004225 } else {
4226 pinctl = snd_hda_codec_read(codec, nid, 0,
4227 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4228 /* if PINCTL already set then skip */
Takashi Iwai5dd17cb2009-05-07 16:22:53 +02004229 /* Also, if both INPUT and OUTPUT are set,
4230 * it must be a BIOS bug; need to override, too
4231 */
4232 if (!(pinctl & AC_PINCTL_IN_EN) ||
4233 (pinctl & AC_PINCTL_OUT_EN)) {
4234 pinctl &= ~AC_PINCTL_OUT_EN;
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004235 pinctl |= AC_PINCTL_IN_EN;
4236 stac92xx_auto_set_pinctl(codec, nid,
4237 pinctl);
4238 }
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004239 }
Takashi Iwai330ee992009-02-20 14:33:36 +01004240 conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004241 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
Takashi Iwai62558ce2009-07-29 14:23:09 +02004242 if (enable_pin_detect(codec, nid,
4243 STAC_INSERT_EVENT))
4244 stac_issue_unsol_event(codec, nid);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004245 }
Takashi Iwaic960a032006-03-23 17:06:28 +01004246 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01004247 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004248 for (i = 0; i < spec->num_dmics; i++)
4249 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4250 AC_PINCTL_IN_EN);
Takashi Iwai0852d7a2009-02-11 11:35:15 +01004251 if (cfg->dig_out_pins[0])
4252 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
Takashi Iwai82bc9552006-03-21 11:24:42 +01004253 AC_PINCTL_OUT_EN);
4254 if (cfg->dig_in_pin)
4255 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4256 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004257 for (i = 0; i < spec->num_pwrs; i++) {
4258 hda_nid_t nid = spec->pwr_nids[i];
4259 int pinctl, def_conf;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004260
Takashi Iwaieb632122008-12-19 16:39:48 +01004261 /* power on when no jack detection is available */
4262 if (!spec->hp_detect) {
4263 stac_toggle_power_map(codec, nid, 1);
4264 continue;
4265 }
4266
4267 if (is_nid_hp_pin(cfg, nid))
Takashi Iwaif73d3582008-11-25 08:21:51 +01004268 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004269
Takashi Iwaif73d3582008-11-25 08:21:51 +01004270 pinctl = snd_hda_codec_read(codec, nid, 0,
4271 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4272 /* outputs are only ports capable of power management
4273 * any attempts on powering down a input port cause the
4274 * referenced VREF to act quirky.
4275 */
Takashi Iwaieb632122008-12-19 16:39:48 +01004276 if (pinctl & AC_PINCTL_IN_EN) {
4277 stac_toggle_power_map(codec, nid, 1);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004278 continue;
Takashi Iwaieb632122008-12-19 16:39:48 +01004279 }
Takashi Iwai330ee992009-02-20 14:33:36 +01004280 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004281 def_conf = get_defcfg_connect(def_conf);
4282 /* skip any ports that don't have jacks since presence
4283 * detection is useless */
4284 if (def_conf != AC_JACK_PORT_COMPLEX) {
4285 if (def_conf != AC_JACK_PORT_NONE)
4286 stac_toggle_power_map(codec, nid, 1);
4287 continue;
4288 }
Takashi Iwai62558ce2009-07-29 14:23:09 +02004289 if (enable_pin_detect(codec, nid, STAC_PWR_EVENT))
4290 stac_issue_unsol_event(codec, nid);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004291 }
4292 if (spec->dac_list)
4293 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02004294 return 0;
4295}
4296
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004297static void stac92xx_free_jacks(struct hda_codec *codec)
4298{
Takashi Iwai8c8145b2009-06-22 17:00:38 +02004299#ifdef CONFIG_SND_HDA_INPUT_JACK
Takashi Iwaib94d35392008-11-21 09:08:06 +01004300 /* free jack instances manually when clearing/reconfiguring */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004301 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaib94d35392008-11-21 09:08:06 +01004302 if (!codec->bus->shutdown && spec->jacks.list) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004303 struct sigmatel_jack *jacks = spec->jacks.list;
4304 int i;
Takashi Iwai95c09092009-04-14 16:15:29 +02004305 for (i = 0; i < spec->jacks.used; i++, jacks++) {
4306 if (jacks->jack)
4307 snd_device_free(codec->bus->card, jacks->jack);
4308 }
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004309 }
4310 snd_array_free(&spec->jacks);
Takashi Iwaie4973e12008-11-18 09:32:42 +01004311#endif
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004312}
4313
Takashi Iwai603c4012008-07-30 15:01:44 +02004314static void stac92xx_free_kctls(struct hda_codec *codec)
4315{
4316 struct sigmatel_spec *spec = codec->spec;
4317
4318 if (spec->kctls.list) {
4319 struct snd_kcontrol_new *kctl = spec->kctls.list;
4320 int i;
4321 for (i = 0; i < spec->kctls.used; i++)
4322 kfree(kctl[i].name);
4323 }
4324 snd_array_free(&spec->kctls);
4325}
4326
Matt2f2f4252005-04-13 14:45:30 +02004327static void stac92xx_free(struct hda_codec *codec)
4328{
Mattc7d4b2f2005-06-27 14:59:41 +02004329 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004330
4331 if (! spec)
4332 return;
4333
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004334 stac92xx_free_jacks(codec);
4335 snd_array_free(&spec->events);
Richard Fish11b44bb2006-08-23 18:31:34 +02004336
Mattc7d4b2f2005-06-27 14:59:41 +02004337 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004338 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02004339}
4340
Matt4e550962005-07-04 17:51:39 +02004341static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4342 unsigned int flag)
4343{
Takashi Iwai8ce84192009-01-22 16:59:20 +01004344 unsigned int old_ctl, pin_ctl;
4345
4346 pin_ctl = snd_hda_codec_read(codec, nid,
Matt4e550962005-07-04 17:51:39 +02004347 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02004348
Takashi Iwaif9acba42007-05-29 18:01:06 +02004349 if (pin_ctl & AC_PINCTL_IN_EN) {
4350 /*
4351 * we need to check the current set-up direction of
4352 * shared input pins since they can be switched via
4353 * "xxx as Output" mixer switch
4354 */
4355 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004356 if (nid == spec->line_switch || nid == spec->mic_switch)
Takashi Iwaif9acba42007-05-29 18:01:06 +02004357 return;
4358 }
4359
Takashi Iwai8ce84192009-01-22 16:59:20 +01004360 old_ctl = pin_ctl;
Steve Longerbeam7b043892007-05-03 20:50:03 +02004361 /* if setting pin direction bits, clear the current
4362 direction bits first */
4363 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4364 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4365
Takashi Iwai8ce84192009-01-22 16:59:20 +01004366 pin_ctl |= flag;
4367 if (old_ctl != pin_ctl)
4368 snd_hda_codec_write_cache(codec, nid, 0,
4369 AC_VERB_SET_PIN_WIDGET_CONTROL,
4370 pin_ctl);
Matt4e550962005-07-04 17:51:39 +02004371}
4372
4373static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4374 unsigned int flag)
4375{
4376 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4377 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai8ce84192009-01-22 16:59:20 +01004378 if (pin_ctl & flag)
4379 snd_hda_codec_write_cache(codec, nid, 0,
4380 AC_VERB_SET_PIN_WIDGET_CONTROL,
4381 pin_ctl & ~flag);
Matt4e550962005-07-04 17:51:39 +02004382}
4383
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004384static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02004385{
4386 if (!nid)
4387 return 0;
4388 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004389 & (1 << 31))
4390 return 1;
Takashi Iwai314634b2006-09-21 11:56:18 +02004391 return 0;
4392}
4393
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004394static void stac92xx_line_out_detect(struct hda_codec *codec,
4395 int presence)
4396{
4397 struct sigmatel_spec *spec = codec->spec;
4398 struct auto_pin_cfg *cfg = &spec->autocfg;
4399 int i;
4400
4401 for (i = 0; i < cfg->line_outs; i++) {
4402 if (presence)
4403 break;
4404 presence = get_pin_presence(codec, cfg->line_out_pins[i]);
4405 if (presence) {
4406 unsigned int pinctl;
4407 pinctl = snd_hda_codec_read(codec,
4408 cfg->line_out_pins[i], 0,
4409 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4410 if (pinctl & AC_PINCTL_IN_EN)
4411 presence = 0; /* mic- or line-input */
4412 }
4413 }
4414
4415 if (presence) {
4416 /* disable speakers */
4417 for (i = 0; i < cfg->speaker_outs; i++)
4418 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4419 AC_PINCTL_OUT_EN);
4420 if (spec->eapd_mask && spec->eapd_switch)
4421 stac_gpio_set(codec, spec->gpio_mask,
4422 spec->gpio_dir, spec->gpio_data &
4423 ~spec->eapd_mask);
4424 } else {
4425 /* enable speakers */
4426 for (i = 0; i < cfg->speaker_outs; i++)
4427 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4428 AC_PINCTL_OUT_EN);
4429 if (spec->eapd_mask && spec->eapd_switch)
4430 stac_gpio_set(codec, spec->gpio_mask,
4431 spec->gpio_dir, spec->gpio_data |
4432 spec->eapd_mask);
4433 }
4434}
4435
Takashi Iwaid7a89432008-11-12 09:48:04 +01004436/* return non-zero if the hp-pin of the given array index isn't
4437 * a jack-detection target
4438 */
4439static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4440{
4441 struct auto_pin_cfg *cfg = &spec->autocfg;
4442
4443 /* ignore sensing of shared line and mic jacks */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004444 if (cfg->hp_pins[i] == spec->line_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004445 return 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004446 if (cfg->hp_pins[i] == spec->mic_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004447 return 1;
4448 /* ignore if the pin is set as line-out */
4449 if (cfg->hp_pins[i] == spec->hp_switch)
4450 return 1;
4451 return 0;
4452}
4453
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004454static void stac92xx_hp_detect(struct hda_codec *codec)
Matt4e550962005-07-04 17:51:39 +02004455{
4456 struct sigmatel_spec *spec = codec->spec;
4457 struct auto_pin_cfg *cfg = &spec->autocfg;
4458 int i, presence;
4459
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004460 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004461 if (spec->gpio_mute)
4462 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4463 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4464
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004465 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004466 if (presence)
4467 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01004468 if (no_hp_sensing(spec, i))
4469 continue;
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004470 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4471 if (presence) {
4472 unsigned int pinctl;
4473 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4474 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4475 if (pinctl & AC_PINCTL_IN_EN)
4476 presence = 0; /* mic- or line-input */
4477 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004478 }
Matt4e550962005-07-04 17:51:39 +02004479
4480 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004481 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004482 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004483 stac92xx_reset_pinctl(codec, spec->hp_switch,
4484 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004485 for (i = 0; i < cfg->line_outs; i++)
4486 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4487 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004488 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004489 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004490 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004491 stac92xx_set_pinctl(codec, spec->hp_switch,
4492 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004493 for (i = 0; i < cfg->line_outs; i++)
4494 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4495 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004496 }
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004497 stac92xx_line_out_detect(codec, presence);
Takashi Iwaid7a89432008-11-12 09:48:04 +01004498 /* toggle hp outs */
4499 for (i = 0; i < cfg->hp_outs; i++) {
4500 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4501 if (no_hp_sensing(spec, i))
4502 continue;
4503 if (presence)
4504 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004505#if 0 /* FIXME */
4506/* Resetting the pinctl like below may lead to (a sort of) regressions
4507 * on some devices since they use the HP pin actually for line/speaker
4508 * outs although the default pin config shows a different pin (that is
4509 * wrong and useless).
4510 *
4511 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4512 * But, disabling the code below just works around it, and I'm too tired of
4513 * bug reports with such devices...
4514 */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004515 else
4516 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004517#endif /* FIXME */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004518 }
Matt4e550962005-07-04 17:51:39 +02004519}
4520
Takashi Iwaif73d3582008-11-25 08:21:51 +01004521static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4522 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004523{
4524 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004525 unsigned int idx, val;
4526
4527 for (idx = 0; idx < spec->num_pwrs; idx++) {
4528 if (spec->pwr_nids[idx] == nid)
4529 break;
4530 }
4531 if (idx >= spec->num_pwrs)
4532 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004533
4534 /* several codecs have two power down bits */
4535 if (spec->pwr_mapping)
4536 idx = spec->pwr_mapping[idx];
4537 else
4538 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004539
Takashi Iwaif73d3582008-11-25 08:21:51 +01004540 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4541 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004542 val &= ~idx;
4543 else
4544 val |= idx;
4545
4546 /* power down unused output ports */
4547 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004548}
4549
Takashi Iwaif73d3582008-11-25 08:21:51 +01004550static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4551{
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004552 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
Takashi Iwaif73d3582008-11-25 08:21:51 +01004553}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004554
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004555static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4556{
4557 struct sigmatel_spec *spec = codec->spec;
4558 struct sigmatel_jack *jacks = spec->jacks.list;
4559
4560 if (jacks) {
4561 int i;
4562 for (i = 0; i < spec->jacks.used; i++) {
4563 if (jacks->nid == nid) {
4564 unsigned int pin_ctl =
4565 snd_hda_codec_read(codec, nid,
4566 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4567 0x00);
4568 int type = jacks->type;
4569 if (type == (SND_JACK_LINEOUT
4570 | SND_JACK_HEADPHONE))
4571 type = (pin_ctl & AC_PINCTL_HP_EN)
4572 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4573 snd_jack_report(jacks->jack,
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004574 get_pin_presence(codec, nid)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004575 ? type : 0);
4576 }
4577 jacks++;
4578 }
4579 }
4580}
Matt2f2f4252005-04-13 14:45:30 +02004581
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004582static void stac92xx_mic_detect(struct hda_codec *codec)
4583{
4584 struct sigmatel_spec *spec = codec->spec;
4585 struct sigmatel_mic_route *mic;
4586
4587 if (get_pin_presence(codec, spec->ext_mic.pin))
4588 mic = &spec->ext_mic;
4589 else
4590 mic = &spec->int_mic;
Takashi Iwai02d33322009-10-01 16:38:11 +02004591 if (mic->dmux_idx >= 0)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004592 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4593 AC_VERB_SET_CONNECT_SEL,
4594 mic->dmux_idx);
Takashi Iwai02d33322009-10-01 16:38:11 +02004595 if (mic->mux_idx >= 0)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004596 snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
4597 AC_VERB_SET_CONNECT_SEL,
4598 mic->mux_idx);
4599}
4600
Takashi Iwai62558ce2009-07-29 14:23:09 +02004601static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004602{
Takashi Iwai62558ce2009-07-29 14:23:09 +02004603 struct sigmatel_event *event = stac_get_event(codec, nid);
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004604 if (!event)
4605 return;
4606 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4607}
4608
Takashi Iwai314634b2006-09-21 11:56:18 +02004609static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4610{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004611 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004612 struct sigmatel_event *event;
4613 int tag, data;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004614
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004615 tag = (res >> 26) & 0x7f;
4616 event = stac_get_event_from_tag(codec, tag);
4617 if (!event)
4618 return;
4619
4620 switch (event->type) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004621 case STAC_HP_EVENT:
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004622 case STAC_LO_EVENT:
Takashi Iwai16ffe322009-08-04 13:40:54 +02004623 stac92xx_hp_detect(codec);
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004624 break;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004625 case STAC_MIC_EVENT:
4626 stac92xx_mic_detect(codec);
4627 break;
4628 }
4629
4630 switch (event->type) {
4631 case STAC_HP_EVENT:
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004632 case STAC_LO_EVENT:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004633 case STAC_MIC_EVENT:
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004634 case STAC_INSERT_EVENT:
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004635 case STAC_PWR_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004636 if (spec->num_pwrs > 0)
4637 stac92xx_pin_sense(codec, event->nid);
4638 stac92xx_report_jack(codec, event->nid);
Matthew Ranostayfd60cc82009-04-06 09:30:46 -04004639
4640 switch (codec->subsystem_id) {
4641 case 0x103c308f:
4642 if (event->nid == 0xb) {
4643 int pin = AC_PINCTL_IN_EN;
4644
4645 if (get_pin_presence(codec, 0xa)
4646 && get_pin_presence(codec, 0xb))
4647 pin |= AC_PINCTL_VREF_80;
4648 if (!get_pin_presence(codec, 0xb))
4649 pin |= AC_PINCTL_VREF_80;
4650
4651 /* toggle VREF state based on mic + hp pin
4652 * status
4653 */
4654 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
4655 }
4656 }
Matthew Ranostay72474be2008-10-09 09:32:17 -04004657 break;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004658 case STAC_VREF_EVENT:
4659 data = snd_hda_codec_read(codec, codec->afg, 0,
4660 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004661 /* toggle VREF state based on GPIOx status */
4662 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004663 !!(data & (1 << event->data)));
Matthew Ranostay72474be2008-10-09 09:32:17 -04004664 break;
Takashi Iwai314634b2006-09-21 11:56:18 +02004665 }
4666}
4667
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004668#ifdef CONFIG_PROC_FS
4669static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4670 struct hda_codec *codec, hda_nid_t nid)
4671{
4672 if (nid == codec->afg)
4673 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4674 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4675}
4676
4677static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4678 struct hda_codec *codec,
4679 unsigned int verb)
4680{
4681 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4682 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4683}
4684
4685/* stac92hd71bxx, stac92hd73xx */
4686static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4687 struct hda_codec *codec, hda_nid_t nid)
4688{
4689 stac92hd_proc_hook(buffer, codec, nid);
4690 if (nid == codec->afg)
4691 analog_loop_proc_hook(buffer, codec, 0xfa0);
4692}
4693
4694static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4695 struct hda_codec *codec, hda_nid_t nid)
4696{
4697 if (nid == codec->afg)
4698 analog_loop_proc_hook(buffer, codec, 0xfe0);
4699}
4700
4701static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4702 struct hda_codec *codec, hda_nid_t nid)
4703{
4704 if (nid == codec->afg)
4705 analog_loop_proc_hook(buffer, codec, 0xfeb);
4706}
4707#else
4708#define stac92hd_proc_hook NULL
4709#define stac92hd7x_proc_hook NULL
4710#define stac9205_proc_hook NULL
4711#define stac927x_proc_hook NULL
4712#endif
4713
Takashi Iwaicb53c622007-08-10 17:21:45 +02004714#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004715static int stac92xx_resume(struct hda_codec *codec)
4716{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004717 struct sigmatel_spec *spec = codec->spec;
4718
Takashi Iwai2c885872008-11-18 09:36:55 +01004719 stac92xx_init(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004720 snd_hda_codec_resume_amp(codec);
4721 snd_hda_codec_resume_cache(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01004722 /* fake event to set up pins again to override cached values */
Takashi Iwai5f380eb2009-09-14 15:36:14 +02004723 if (spec->hp_detect) {
4724 if (spec->autocfg.hp_pins[0])
4725 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]);
4726 else if (spec->autocfg.line_out_pins[0])
4727 stac_issue_unsol_event(codec,
4728 spec->autocfg.line_out_pins[0]);
4729 }
Mattff6fdc32005-06-27 15:06:52 +02004730 return 0;
4731}
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004732
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004733/*
James Gardiner514bf542009-05-03 04:00:44 -04004734 * using power check for controlling mute led of HP notebooks
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004735 * check for mute state only on Speakers (nid = 0x10)
4736 *
4737 * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise
4738 * the LED is NOT working properly !
James Gardiner514bf542009-05-03 04:00:44 -04004739 *
4740 * Changed name to reflect that it now works for any designated
4741 * model, not just HP HDX.
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004742 */
4743
4744#ifdef CONFIG_SND_HDA_POWER_SAVE
James Gardiner514bf542009-05-03 04:00:44 -04004745static int stac92xx_hp_check_power_status(struct hda_codec *codec,
Takashi Iwai6fce61a2009-03-10 07:48:57 +01004746 hda_nid_t nid)
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004747{
4748 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai6fce61a2009-03-10 07:48:57 +01004749
4750 if (nid == 0x10) {
4751 if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004752 HDA_AMP_MUTE)
Takashi Iwai86d190e2009-05-26 15:18:58 +02004753 spec->gpio_data &= ~spec->gpio_led; /* orange */
Takashi Iwaiba84bfc2009-05-30 08:59:03 +02004754 else
4755 spec->gpio_data |= spec->gpio_led; /* white */
Takashi Iwai6fce61a2009-03-10 07:48:57 +01004756
4757 stac_gpio_set(codec, spec->gpio_mask,
4758 spec->gpio_dir,
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004759 spec->gpio_data);
4760 }
4761
4762 return 0;
4763}
4764#endif
4765
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004766static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4767{
4768 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai05ff7e12009-07-22 12:39:24 +02004769 int i;
4770 hda_nid_t nid;
4771
4772 /* reset each pin before powering down DAC/ADC to avoid click noise */
4773 nid = codec->start_nid;
4774 for (i = 0; i < codec->num_nodes; i++, nid++) {
4775 unsigned int wcaps = get_wcaps(codec, nid);
Takashi Iwaia22d5432009-07-27 12:54:26 +02004776 unsigned int wid_type = get_wcaps_type(wcaps);
Takashi Iwai05ff7e12009-07-22 12:39:24 +02004777 if (wid_type == AC_WID_PIN)
4778 snd_hda_codec_read(codec, nid, 0,
4779 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
4780 }
4781
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004782 if (spec->eapd_mask)
4783 stac_gpio_set(codec, spec->gpio_mask,
4784 spec->gpio_dir, spec->gpio_data &
4785 ~spec->eapd_mask);
4786 return 0;
4787}
Mattff6fdc32005-06-27 15:06:52 +02004788#endif
4789
Matt2f2f4252005-04-13 14:45:30 +02004790static struct hda_codec_ops stac92xx_patch_ops = {
4791 .build_controls = stac92xx_build_controls,
4792 .build_pcms = stac92xx_build_pcms,
4793 .init = stac92xx_init,
4794 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02004795 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004796#ifdef SND_HDA_NEEDS_RESUME
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004797 .suspend = stac92xx_suspend,
Mattff6fdc32005-06-27 15:06:52 +02004798 .resume = stac92xx_resume,
4799#endif
Matt2f2f4252005-04-13 14:45:30 +02004800};
4801
4802static int patch_stac9200(struct hda_codec *codec)
4803{
4804 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004805 int err;
Matt2f2f4252005-04-13 14:45:30 +02004806
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004807 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004808 if (spec == NULL)
4809 return -ENOMEM;
4810
4811 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004812 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004813 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004814 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4815 stac9200_models,
4816 stac9200_cfg_tbl);
Takashi Iwai330ee992009-02-20 14:33:36 +01004817 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02004818 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4819 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01004820 else
4821 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004822 stac9200_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02004823
4824 spec->multiout.max_channels = 2;
4825 spec->multiout.num_dacs = 1;
4826 spec->multiout.dac_nids = stac9200_dac_nids;
4827 spec->adc_nids = stac9200_adc_nids;
4828 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02004829 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02004830 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004831 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004832 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004833
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02004834 if (spec->board_config == STAC_9200_M4 ||
4835 spec->board_config == STAC_9200_M4_2 ||
Tobin Davisbf277782008-02-03 20:31:47 +01004836 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02004837 spec->init = stac9200_eapd_init;
4838 else
4839 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004840 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004841
Takashi Iwai117f2572008-03-18 09:53:23 +01004842 if (spec->board_config == STAC_9200_PANASONIC) {
4843 spec->gpio_mask = spec->gpio_dir = 0x09;
4844 spec->gpio_data = 0x00;
4845 }
4846
Mattc7d4b2f2005-06-27 14:59:41 +02004847 err = stac9200_parse_auto_config(codec);
4848 if (err < 0) {
4849 stac92xx_free(codec);
4850 return err;
4851 }
Matt2f2f4252005-04-13 14:45:30 +02004852
Takashi Iwai2acc9dc2009-01-09 16:57:14 +01004853 /* CF-74 has no headphone detection, and the driver should *NOT*
4854 * do detection and HP/speaker toggle because the hardware does it.
4855 */
4856 if (spec->board_config == STAC_9200_PANASONIC)
4857 spec->hp_detect = 0;
4858
Matt2f2f4252005-04-13 14:45:30 +02004859 codec->patch_ops = stac92xx_patch_ops;
4860
4861 return 0;
4862}
4863
Tobin Davis8e21c342007-01-08 11:04:17 +01004864static int patch_stac925x(struct hda_codec *codec)
4865{
4866 struct sigmatel_spec *spec;
4867 int err;
4868
4869 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4870 if (spec == NULL)
4871 return -ENOMEM;
4872
4873 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004874 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01004875 spec->pin_nids = stac925x_pin_nids;
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02004876
4877 /* Check first for codec ID */
4878 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
4879 STAC_925x_MODELS,
4880 stac925x_models,
4881 stac925x_codec_id_cfg_tbl);
4882
4883 /* Now checks for PCI ID, if codec ID is not found */
4884 if (spec->board_config < 0)
4885 spec->board_config = snd_hda_check_board_config(codec,
4886 STAC_925x_MODELS,
Tobin Davis8e21c342007-01-08 11:04:17 +01004887 stac925x_models,
4888 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004889 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01004890 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02004891 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4892 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01004893 else
4894 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004895 stac925x_brd_tbl[spec->board_config]);
Tobin Davis8e21c342007-01-08 11:04:17 +01004896
4897 spec->multiout.max_channels = 2;
4898 spec->multiout.num_dacs = 1;
4899 spec->multiout.dac_nids = stac925x_dac_nids;
4900 spec->adc_nids = stac925x_adc_nids;
4901 spec->mux_nids = stac925x_mux_nids;
4902 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004903 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004904 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02004905 switch (codec->vendor_id) {
4906 case 0x83847632: /* STAC9202 */
4907 case 0x83847633: /* STAC9202D */
4908 case 0x83847636: /* STAC9251 */
4909 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02004910 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02004911 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004912 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4913 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02004914 break;
4915 default:
4916 spec->num_dmics = 0;
4917 break;
4918 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004919
4920 spec->init = stac925x_core_init;
4921 spec->mixer = stac925x_mixer;
Takashi Iwai6479c632009-07-28 18:20:25 +02004922 spec->num_caps = 1;
4923 spec->capvols = stac925x_capvols;
4924 spec->capsws = stac925x_capsws;
Tobin Davis8e21c342007-01-08 11:04:17 +01004925
4926 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004927 if (!err) {
4928 if (spec->board_config < 0) {
4929 printk(KERN_WARNING "hda_codec: No auto-config is "
4930 "available, default to model=ref\n");
4931 spec->board_config = STAC_925x_REF;
4932 goto again;
4933 }
4934 err = -EINVAL;
4935 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004936 if (err < 0) {
4937 stac92xx_free(codec);
4938 return err;
4939 }
4940
4941 codec->patch_ops = stac92xx_patch_ops;
4942
4943 return 0;
4944}
4945
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004946static int patch_stac92hd73xx(struct hda_codec *codec)
4947{
4948 struct sigmatel_spec *spec;
4949 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4950 int err = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004951 int num_dacs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004952
4953 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4954 if (spec == NULL)
4955 return -ENOMEM;
4956
4957 codec->spec = spec;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02004958 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004959 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4960 spec->pin_nids = stac92hd73xx_pin_nids;
4961 spec->board_config = snd_hda_check_board_config(codec,
4962 STAC_92HD73XX_MODELS,
4963 stac92hd73xx_models,
4964 stac92hd73xx_cfg_tbl);
Takashi Iwai842ae632009-09-02 07:43:08 +02004965 /* check codec subsystem id if not found */
4966 if (spec->board_config < 0)
4967 spec->board_config =
4968 snd_hda_check_board_codec_sid_config(codec,
4969 STAC_92HD73XX_MODELS, stac92hd73xx_models,
4970 stac92hd73xx_codec_id_cfg_tbl);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004971again:
Takashi Iwai330ee992009-02-20 14:33:36 +01004972 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02004973 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4974 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01004975 else
4976 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004977 stac92hd73xx_brd_tbl[spec->board_config]);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004978
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004979 num_dacs = snd_hda_get_connections(codec, 0x0a,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004980 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4981
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004982 if (num_dacs < 3 || num_dacs > 5) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004983 printk(KERN_WARNING "hda_codec: Could not determine "
4984 "number of channels defaulting to DAC count\n");
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004985 num_dacs = STAC92HD73_DAC_COUNT;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004986 }
Takashi Iwaie2aec172009-09-02 01:00:05 +02004987 spec->init = stac92hd73xx_core_init;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004988 switch (num_dacs) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004989 case 0x3: /* 6 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01004990 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004991 break;
4992 case 0x4: /* 8 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01004993 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004994 break;
4995 case 0x5: /* 10 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01004996 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
4997 break;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004998 }
4999 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005000
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005001 spec->aloopback_mask = 0x01;
5002 spec->aloopback_shift = 8;
5003
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005004 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005005 spec->mux_nids = stac92hd73xx_mux_nids;
5006 spec->adc_nids = stac92hd73xx_adc_nids;
5007 spec->dmic_nids = stac92hd73xx_dmic_nids;
5008 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005009 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005010
5011 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
5012 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01005013 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005014
Takashi Iwai6479c632009-07-28 18:20:25 +02005015 spec->num_caps = STAC92HD73XX_NUM_CAPS;
5016 spec->capvols = stac92hd73xx_capvols;
5017 spec->capsws = stac92hd73xx_capsws;
5018
Matthew Ranostaya7662642008-02-21 07:51:14 +01005019 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005020 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01005021 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005022 /* fallthru */
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005023 case STAC_DELL_M6_AMIC:
5024 case STAC_DELL_M6_DMIC:
5025 case STAC_DELL_M6_BOTH:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005026 spec->num_smuxes = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005027 spec->eapd_switch = 0;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005028
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005029 switch (spec->board_config) {
5030 case STAC_DELL_M6_AMIC: /* Analog Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01005031 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005032 spec->num_dmics = 0;
5033 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005034 case STAC_DELL_M6_DMIC: /* Digital Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01005035 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005036 spec->num_dmics = 1;
5037 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005038 case STAC_DELL_M6_BOTH: /* Both */
Takashi Iwai330ee992009-02-20 14:33:36 +01005039 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5040 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005041 spec->num_dmics = 1;
5042 break;
5043 }
5044 break;
Takashi Iwai842ae632009-09-02 07:43:08 +02005045 case STAC_ALIENWARE_M17X:
5046 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
5047 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
5048 spec->eapd_switch = 0;
5049 break;
Matthew Ranostaya7662642008-02-21 07:51:14 +01005050 default:
5051 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005052 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005053 spec->eapd_switch = 1;
Takashi Iwai5207e102009-07-30 13:09:08 +02005054 break;
Matthew Ranostaya7662642008-02-21 07:51:14 +01005055 }
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02005056 if (spec->board_config != STAC_92HD73XX_REF) {
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005057 /* GPIO0 High = Enable EAPD */
5058 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5059 spec->gpio_data = 0x01;
5060 }
Matthew Ranostaya7662642008-02-21 07:51:14 +01005061
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005062 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
5063 spec->pwr_nids = stac92hd73xx_pwr_nids;
5064
Matthew Ranostayd9737752008-09-07 12:03:41 +02005065 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005066
5067 if (!err) {
5068 if (spec->board_config < 0) {
5069 printk(KERN_WARNING "hda_codec: No auto-config is "
5070 "available, default to model=ref\n");
5071 spec->board_config = STAC_92HD73XX_REF;
5072 goto again;
5073 }
5074 err = -EINVAL;
5075 }
5076
5077 if (err < 0) {
5078 stac92xx_free(codec);
5079 return err;
5080 }
5081
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01005082 if (spec->board_config == STAC_92HD73XX_NO_JD)
5083 spec->hp_detect = 0;
5084
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005085 codec->patch_ops = stac92xx_patch_ops;
5086
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005087 codec->proc_widget_hook = stac92hd7x_proc_hook;
5088
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005089 return 0;
5090}
5091
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005092static int patch_stac92hd83xxx(struct hda_codec *codec)
5093{
5094 struct sigmatel_spec *spec;
Matthew Ranostay65557f32009-01-20 16:50:25 -05005095 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005096 int err;
Matthew Ranostay65557f32009-01-20 16:50:25 -05005097 int num_dacs;
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05005098 hda_nid_t nid;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005099
5100 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5101 if (spec == NULL)
5102 return -ENOMEM;
5103
5104 codec->spec = spec;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005105 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005106 spec->digbeep_nid = 0x21;
Takashi Iwai667067d2009-08-13 18:14:42 +02005107 spec->mux_nids = stac92hd83xxx_mux_nids;
5108 spec->num_muxes = ARRAY_SIZE(stac92hd83xxx_mux_nids);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005109 spec->adc_nids = stac92hd83xxx_adc_nids;
Takashi Iwai7570ef12009-08-15 11:57:53 +02005110 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005111 spec->pwr_nids = stac92hd83xxx_pwr_nids;
5112 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
5113 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005114 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005115
5116 spec->init = stac92hd83xxx_core_init;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005117 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005118 spec->pin_nids = stac92hd83xxx_pin_nids;
Takashi Iwai6479c632009-07-28 18:20:25 +02005119 spec->num_caps = STAC92HD83XXX_NUM_CAPS;
5120 spec->capvols = stac92hd83xxx_capvols;
5121 spec->capsws = stac92hd83xxx_capsws;
5122
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005123 spec->board_config = snd_hda_check_board_config(codec,
5124 STAC_92HD83XXX_MODELS,
5125 stac92hd83xxx_models,
5126 stac92hd83xxx_cfg_tbl);
5127again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005128 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005129 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5130 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005131 else
5132 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005133 stac92hd83xxx_brd_tbl[spec->board_config]);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005134
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05005135 switch (codec->vendor_id) {
5136 case 0x111d7604:
5137 case 0x111d7605:
Matthew Ranostayff2e7332009-04-01 14:49:48 -04005138 case 0x111d76d5:
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05005139 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
5140 break;
5141 spec->num_pwrs = 0;
5142 break;
5143 }
5144
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005145 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
5146 if (!err) {
5147 if (spec->board_config < 0) {
5148 printk(KERN_WARNING "hda_codec: No auto-config is "
5149 "available, default to model=ref\n");
5150 spec->board_config = STAC_92HD83XXX_REF;
5151 goto again;
5152 }
5153 err = -EINVAL;
5154 }
5155
5156 if (err < 0) {
5157 stac92xx_free(codec);
5158 return err;
5159 }
5160
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05005161 switch (spec->board_config) {
5162 case STAC_DELL_S14:
5163 nid = 0xf;
5164 break;
5165 default:
5166 nid = 0xe;
5167 break;
5168 }
5169
5170 num_dacs = snd_hda_get_connections(codec, nid,
5171 conn, STAC92HD83_DAC_COUNT + 1) - 1;
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02005172 if (num_dacs < 0)
5173 num_dacs = STAC92HD83_DAC_COUNT;
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05005174
5175 /* set port X to select the last DAC
5176 */
5177 snd_hda_codec_write_cache(codec, nid, 0,
5178 AC_VERB_SET_CONNECT_SEL, num_dacs);
5179
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005180 codec->patch_ops = stac92xx_patch_ops;
5181
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005182 codec->proc_widget_hook = stac92hd_proc_hook;
5183
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005184 return 0;
5185}
5186
Takashi Iwai330ee992009-02-20 14:33:36 +01005187/* get the pin connection (fixed, none, etc) */
5188static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
5189{
5190 struct sigmatel_spec *spec = codec->spec;
5191 unsigned int cfg;
5192
5193 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
5194 return get_defcfg_connect(cfg);
5195}
5196
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005197static int stac92hd71bxx_connected_ports(struct hda_codec *codec,
5198 hda_nid_t *nids, int num_nids)
5199{
5200 struct sigmatel_spec *spec = codec->spec;
5201 int idx, num;
5202 unsigned int def_conf;
5203
5204 for (num = 0; num < num_nids; num++) {
5205 for (idx = 0; idx < spec->num_pins; idx++)
5206 if (spec->pin_nids[idx] == nids[num])
5207 break;
5208 if (idx >= spec->num_pins)
5209 break;
Takashi Iwai330ee992009-02-20 14:33:36 +01005210 def_conf = stac_get_defcfg_connect(codec, idx);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005211 if (def_conf == AC_JACK_PORT_NONE)
5212 break;
5213 }
5214 return num;
5215}
5216
5217static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
5218 hda_nid_t dig0pin)
5219{
5220 struct sigmatel_spec *spec = codec->spec;
5221 int idx;
5222
5223 for (idx = 0; idx < spec->num_pins; idx++)
5224 if (spec->pin_nids[idx] == dig0pin)
5225 break;
5226 if ((idx + 2) >= spec->num_pins)
5227 return 0;
5228
5229 /* dig1pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01005230 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005231 return 2;
5232
5233 /* dig0pin + dig2pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01005234 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005235 return 2;
Takashi Iwai330ee992009-02-20 14:33:36 +01005236 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005237 return 1;
5238 else
5239 return 0;
5240}
5241
Matthew Ranostaye035b842007-11-06 11:53:55 +01005242static int patch_stac92hd71bxx(struct hda_codec *codec)
5243{
5244 struct sigmatel_spec *spec;
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005245 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005246 int err = 0;
5247
5248 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5249 if (spec == NULL)
5250 return -ENOMEM;
5251
5252 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005253 codec->patch_ops = stac92xx_patch_ops;
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05005254 spec->num_pins = STAC92HD71BXX_NUM_PINS;
5255 switch (codec->vendor_id) {
5256 case 0x111d76b6:
5257 case 0x111d76b7:
5258 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
5259 break;
5260 case 0x111d7603:
5261 case 0x111d7608:
5262 /* On 92HD75Bx 0x27 isn't a pin nid */
5263 spec->num_pins--;
5264 /* fallthrough */
5265 default:
5266 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
5267 }
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005268 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005269 spec->board_config = snd_hda_check_board_config(codec,
5270 STAC_92HD71BXX_MODELS,
5271 stac92hd71bxx_models,
5272 stac92hd71bxx_cfg_tbl);
5273again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005274 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005275 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5276 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005277 else
5278 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005279 stac92hd71bxx_brd_tbl[spec->board_config]);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005280
Takashi Iwaifc64b262009-09-14 15:33:01 +02005281 if (spec->board_config != STAC_92HD71BXX_REF) {
Takashi Iwai41c3b642008-11-18 10:45:15 +01005282 /* GPIO0 = EAPD */
5283 spec->gpio_mask = 0x01;
5284 spec->gpio_dir = 0x01;
5285 spec->gpio_data = 0x01;
5286 }
5287
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005288 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5289 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5290
Takashi Iwai6479c632009-07-28 18:20:25 +02005291 spec->num_caps = STAC92HD71BXX_NUM_CAPS;
5292 spec->capvols = stac92hd71bxx_capvols;
5293 spec->capsws = stac92hd71bxx_capsws;
5294
Matthew Ranostay541eee82007-12-14 12:08:04 +01005295 switch (codec->vendor_id) {
5296 case 0x111d76b6: /* 4 Port without Analog Mixer */
5297 case 0x111d76b7:
Herton Ronaldo Krzesinski23c7b522009-02-08 19:51:28 -02005298 unmute_init++;
5299 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005300 case 0x111d76b4: /* 6 Port without Analog Mixer */
5301 case 0x111d76b5:
Matthew Ranostay541eee82007-12-14 12:08:04 +01005302 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005303 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005304 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5305 stac92hd71bxx_dmic_nids,
5306 STAC92HD71BXX_NUM_DMICS);
Matthew Ranostay541eee82007-12-14 12:08:04 +01005307 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005308 case 0x111d7608: /* 5 Port with Analog Mixer */
Takashi Iwai8e5f2622008-11-15 19:28:54 +01005309 switch (spec->board_config) {
5310 case STAC_HP_M4:
Matthew Ranostay72474be2008-10-09 09:32:17 -04005311 /* Enable VREF power saving on GPIO1 detect */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005312 err = stac_add_event(spec, codec->afg,
5313 STAC_VREF_EVENT, 0x02);
5314 if (err < 0)
5315 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005316 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay72474be2008-10-09 09:32:17 -04005317 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
5318 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005319 AC_VERB_SET_UNSOLICITED_ENABLE,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005320 AC_USRSP_EN | err);
Matthew Ranostay72474be2008-10-09 09:32:17 -04005321 spec->gpio_mask |= 0x02;
5322 break;
5323 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005324 if ((codec->revision_id & 0xf) == 0 ||
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005325 (codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005326 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005327
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005328 /* no output amps */
5329 spec->num_pwrs = 0;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005330 /* disable VSW */
Takashi Iwai26a27982009-07-29 16:28:09 +02005331 spec->init = stac92hd71bxx_core_init;
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005332 unmute_init++;
Takashi Iwai330ee992009-02-20 14:33:36 +01005333 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5334 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005335 stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0;
5336 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5337 stac92hd71bxx_dmic_nids,
5338 STAC92HD71BXX_NUM_DMICS - 1);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005339 break;
5340 case 0x111d7603: /* 6 Port with Analog Mixer */
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005341 if ((codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005342 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005343
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005344 /* no output amps */
5345 spec->num_pwrs = 0;
5346 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005347 default:
Takashi Iwai26a27982009-07-29 16:28:09 +02005348 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005349 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005350 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5351 stac92hd71bxx_dmic_nids,
5352 STAC92HD71BXX_NUM_DMICS);
Takashi Iwai5207e102009-07-30 13:09:08 +02005353 break;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005354 }
5355
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005356 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5357 snd_hda_sequence_write_cache(codec, unmute_init);
5358
Takashi Iwaib20f3b82009-06-02 01:20:22 +02005359 /* Some HP machines seem to have unstable codec communications
5360 * especially with ATI fglrx driver. For recovering from the
5361 * CORB/RIRB stall, allow the BUS reset and keep always sync
5362 */
5363 if (spec->board_config == STAC_HP_DV5) {
5364 codec->bus->sync_write = 1;
5365 codec->bus->allow_bus_reset = 1;
5366 }
5367
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005368 spec->aloopback_ctl = stac92hd71bxx_loopback;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005369 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005370 spec->aloopback_shift = 0;
5371
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005372 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005373 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005374 spec->mux_nids = stac92hd71bxx_mux_nids;
5375 spec->adc_nids = stac92hd71bxx_adc_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005376 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005377 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005378
5379 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5380 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Takashi Iwai5207e102009-07-30 13:09:08 +02005381 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005382 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005383
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005384 switch (spec->board_config) {
5385 case STAC_HP_M4:
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005386 /* enable internal microphone */
Takashi Iwai330ee992009-02-20 14:33:36 +01005387 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
Matthew Ranostayb9aea712008-10-09 08:37:28 -04005388 stac92xx_auto_set_pinctl(codec, 0x0e,
5389 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05005390 /* fallthru */
5391 case STAC_DELL_M4_2:
5392 spec->num_dmics = 0;
5393 spec->num_smuxes = 0;
5394 spec->num_dmuxes = 0;
5395 break;
5396 case STAC_DELL_M4_1:
5397 case STAC_DELL_M4_3:
5398 spec->num_dmics = 1;
5399 spec->num_smuxes = 0;
Takashi Iwaiea18aa42009-02-27 17:36:33 +01005400 spec->num_dmuxes = 1;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005401 break;
James Gardiner514bf542009-05-03 04:00:44 -04005402 case STAC_HP_DV4_1222NR:
5403 spec->num_dmics = 1;
5404 /* I don't know if it needs 1 or 2 smuxes - will wait for
5405 * bug reports to fix if needed
5406 */
5407 spec->num_smuxes = 1;
5408 spec->num_dmuxes = 1;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005409 spec->gpio_led = 0x01;
James Gardiner514bf542009-05-03 04:00:44 -04005410 /* fallthrough */
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005411 case STAC_HP_DV5:
Takashi Iwai330ee992009-02-20 14:33:36 +01005412 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005413 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
Takashi Iwai6e34c032009-09-14 15:42:18 +02005414 /* HP dv6 gives the headphone pin as a line-out. Thus we
5415 * need to set hp_detect flag here to force to enable HP
5416 * detection.
5417 */
5418 spec->hp_detect = 1;
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005419 break;
Christoph Plattnerae6241f2009-03-08 23:19:05 +01005420 case STAC_HP_HDX:
5421 spec->num_dmics = 1;
5422 spec->num_dmuxes = 1;
5423 spec->num_smuxes = 1;
Christoph Plattner443e26d2009-03-10 00:05:56 +01005424 /* orange/white mute led on GPIO3, orange=0, white=1 */
Takashi Iwai86d190e2009-05-26 15:18:58 +02005425 spec->gpio_led = 0x08;
5426 break;
5427 }
Christoph Plattner443e26d2009-03-10 00:05:56 +01005428
Takashi Iwai86d190e2009-05-26 15:18:58 +02005429#ifdef CONFIG_SND_HDA_POWER_SAVE
5430 if (spec->gpio_led) {
5431 spec->gpio_mask |= spec->gpio_led;
5432 spec->gpio_dir |= spec->gpio_led;
5433 spec->gpio_data |= spec->gpio_led;
Christoph Plattner443e26d2009-03-10 00:05:56 +01005434 /* register check_power_status callback. */
Takashi Iwai6fce61a2009-03-10 07:48:57 +01005435 codec->patch_ops.check_power_status =
Takashi Iwai86d190e2009-05-26 15:18:58 +02005436 stac92xx_hp_check_power_status;
5437 }
Christoph Plattner443e26d2009-03-10 00:05:56 +01005438#endif
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005439
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005440 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005441
Herton Ronaldo Krzesinski29d4ab42009-02-04 11:37:27 -05005442 err = stac92xx_parse_auto_config(codec, 0x21, 0);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005443 if (!err) {
5444 if (spec->board_config < 0) {
5445 printk(KERN_WARNING "hda_codec: No auto-config is "
5446 "available, default to model=ref\n");
5447 spec->board_config = STAC_92HD71BXX_REF;
5448 goto again;
5449 }
5450 err = -EINVAL;
5451 }
5452
5453 if (err < 0) {
5454 stac92xx_free(codec);
5455 return err;
5456 }
5457
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005458 codec->proc_widget_hook = stac92hd7x_proc_hook;
5459
Matthew Ranostaye035b842007-11-06 11:53:55 +01005460 return 0;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005461}
Matthew Ranostaye035b842007-11-06 11:53:55 +01005462
Matt2f2f4252005-04-13 14:45:30 +02005463static int patch_stac922x(struct hda_codec *codec)
5464{
5465 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005466 int err;
Matt2f2f4252005-04-13 14:45:30 +02005467
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005468 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02005469 if (spec == NULL)
5470 return -ENOMEM;
5471
5472 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005473 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005474 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005475 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5476 stac922x_models,
5477 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08005478 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005479 spec->gpio_mask = spec->gpio_dir = 0x03;
5480 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005481 /* Intel Macs have all same PCI SSID, so we need to check
5482 * codec SSID to distinguish the exact models
5483 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005484 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005485 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005486
5487 case 0x106b0800:
5488 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02005489 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005490 case 0x106b0600:
5491 case 0x106b0700:
5492 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005493 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005494 case 0x106b0e00:
5495 case 0x106b0f00:
5496 case 0x106b1600:
5497 case 0x106b1700:
5498 case 0x106b0200:
5499 case 0x106b1e00:
5500 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005501 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005502 case 0x106b1a00:
5503 case 0x00000100:
5504 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02005505 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005506 case 0x106b0a00:
5507 case 0x106b2200:
5508 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02005509 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08005510 default:
5511 spec->board_config = STAC_INTEL_MAC_V3;
5512 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005513 }
5514 }
5515
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005516 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005517 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005518 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5519 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005520 else
5521 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005522 stac922x_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02005523
Matt2f2f4252005-04-13 14:45:30 +02005524 spec->adc_nids = stac922x_adc_nids;
5525 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005526 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005527 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005528 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005529 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02005530
5531 spec->init = stac922x_core_init;
Takashi Iwai6479c632009-07-28 18:20:25 +02005532
5533 spec->num_caps = STAC922X_NUM_CAPS;
5534 spec->capvols = stac922x_capvols;
5535 spec->capsws = stac922x_capsws;
Mattc7d4b2f2005-06-27 14:59:41 +02005536
5537 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02005538
Matt Porter3cc08dc2006-01-23 15:27:49 +01005539 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005540 if (!err) {
5541 if (spec->board_config < 0) {
5542 printk(KERN_WARNING "hda_codec: No auto-config is "
5543 "available, default to model=ref\n");
5544 spec->board_config = STAC_D945_REF;
5545 goto again;
5546 }
5547 err = -EINVAL;
5548 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005549 if (err < 0) {
5550 stac92xx_free(codec);
5551 return err;
5552 }
5553
5554 codec->patch_ops = stac92xx_patch_ops;
5555
Takashi Iwai807a46362007-05-29 19:01:37 +02005556 /* Fix Mux capture level; max to 2 */
5557 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
5558 (0 << AC_AMPCAP_OFFSET_SHIFT) |
5559 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5560 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5561 (0 << AC_AMPCAP_MUTE_SHIFT));
5562
Matt Porter3cc08dc2006-01-23 15:27:49 +01005563 return 0;
5564}
5565
5566static int patch_stac927x(struct hda_codec *codec)
5567{
5568 struct sigmatel_spec *spec;
5569 int err;
5570
5571 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5572 if (spec == NULL)
5573 return -ENOMEM;
5574
5575 codec->spec = spec;
Matthew Ranostay45c1d852009-02-04 17:49:41 -05005576 codec->slave_dig_outs = stac927x_slave_dig_outs;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005577 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005578 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005579 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5580 stac927x_models,
5581 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005582 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005583 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005584 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5585 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005586 else
5587 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005588 stac927x_brd_tbl[spec->board_config]);
Matt Porter3cc08dc2006-01-23 15:27:49 +01005589
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005590 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005591 spec->adc_nids = stac927x_adc_nids;
5592 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
5593 spec->mux_nids = stac927x_mux_nids;
5594 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005595 spec->smux_nids = stac927x_smux_nids;
5596 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04005597 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005598 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005599 spec->multiout.dac_nids = spec->dac_nids;
5600
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02005601 if (spec->board_config != STAC_D965_REF) {
5602 /* GPIO0 High = Enable EAPD */
5603 spec->eapd_mask = spec->gpio_mask = 0x01;
5604 spec->gpio_dir = spec->gpio_data = 0x01;
5605 }
5606
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005607 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02005608 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005609 case STAC_D965_5ST:
5610 /* GPIO0 High = Enable EAPD */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005611 spec->num_dmics = 0;
Tobin Davis93ed1502006-09-01 21:03:12 +02005612 spec->init = d965_core_init;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005613 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005614 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02005615 switch (codec->subsystem_id) {
5616 case 0x10280209:
5617 case 0x1028022e:
5618 /* correct the device field to SPDIF out */
Takashi Iwai330ee992009-02-20 14:33:36 +01005619 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
Matthew Ranostay780c8be2008-04-14 13:32:27 +02005620 break;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005621 }
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01005622 /* configure the analog microphone on some laptops */
Takashi Iwai330ee992009-02-20 14:33:36 +01005623 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01005624 /* correct the front output jack as a hp out */
Takashi Iwai330ee992009-02-20 14:33:36 +01005625 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01005626 /* correct the front input jack as a mic */
Takashi Iwai330ee992009-02-20 14:33:36 +01005627 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01005628 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005629 case STAC_DELL_3ST:
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02005630 if (codec->subsystem_id != 0x1028022f) {
5631 /* GPIO2 High = Enable EAPD */
5632 spec->eapd_mask = spec->gpio_mask = 0x04;
5633 spec->gpio_dir = spec->gpio_data = 0x04;
5634 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005635 spec->dmic_nids = stac927x_dmic_nids;
5636 spec->num_dmics = STAC927X_NUM_DMICS;
5637
Takashi Iwaiccca7cd2009-10-13 15:32:21 +02005638 spec->init = dell_3st_core_init;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005639 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005640 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005641 break;
Takashi Iwai54930532009-10-11 17:38:29 +02005642 case STAC_927X_VOLKNOB:
5643 spec->num_dmics = 0;
5644 spec->init = stac927x_volknob_core_init;
5645 break;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005646 default:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005647 spec->num_dmics = 0;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005648 spec->init = stac927x_core_init;
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02005649 break;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005650 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005651
Takashi Iwai6479c632009-07-28 18:20:25 +02005652 spec->num_caps = STAC927X_NUM_CAPS;
5653 spec->capvols = stac927x_capvols;
5654 spec->capsws = stac927x_capsws;
5655
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005656 spec->num_pwrs = 0;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005657 spec->aloopback_ctl = stac927x_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005658 spec->aloopback_mask = 0x40;
5659 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005660 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005661
Matt Porter3cc08dc2006-01-23 15:27:49 +01005662 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005663 if (!err) {
5664 if (spec->board_config < 0) {
5665 printk(KERN_WARNING "hda_codec: No auto-config is "
5666 "available, default to model=ref\n");
5667 spec->board_config = STAC_D965_REF;
5668 goto again;
5669 }
5670 err = -EINVAL;
5671 }
Mattc7d4b2f2005-06-27 14:59:41 +02005672 if (err < 0) {
5673 stac92xx_free(codec);
5674 return err;
5675 }
Matt2f2f4252005-04-13 14:45:30 +02005676
5677 codec->patch_ops = stac92xx_patch_ops;
5678
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005679 codec->proc_widget_hook = stac927x_proc_hook;
5680
Takashi Iwai52987652008-01-16 16:09:47 +01005681 /*
5682 * !!FIXME!!
5683 * The STAC927x seem to require fairly long delays for certain
5684 * command sequences. With too short delays (even if the answer
5685 * is set to RIRB properly), it results in the silence output
5686 * on some hardwares like Dell.
5687 *
5688 * The below flag enables the longer delay (see get_response
5689 * in hda_intel.c).
5690 */
5691 codec->bus->needs_damn_long_delay = 1;
5692
Takashi Iwaie28d8322008-12-17 13:48:29 +01005693 /* no jack detecion for ref-no-jd model */
5694 if (spec->board_config == STAC_D965_REF_NO_JD)
5695 spec->hp_detect = 0;
5696
Matt2f2f4252005-04-13 14:45:30 +02005697 return 0;
5698}
5699
Matt Porterf3302a52006-07-31 12:49:34 +02005700static int patch_stac9205(struct hda_codec *codec)
5701{
5702 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02005703 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02005704
5705 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5706 if (spec == NULL)
5707 return -ENOMEM;
5708
5709 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005710 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005711 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005712 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
5713 stac9205_models,
5714 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005715 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005716 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005717 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5718 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005719 else
5720 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005721 stac9205_brd_tbl[spec->board_config]);
Matt Porterf3302a52006-07-31 12:49:34 +02005722
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005723 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02005724 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005725 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02005726 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005727 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005728 spec->smux_nids = stac9205_smux_nids;
5729 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005730 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02005731 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005732 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005733 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005734 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02005735
5736 spec->init = stac9205_core_init;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005737 spec->aloopback_ctl = stac9205_loopback;
Matt Porterf3302a52006-07-31 12:49:34 +02005738
Takashi Iwai6479c632009-07-28 18:20:25 +02005739 spec->num_caps = STAC9205_NUM_CAPS;
5740 spec->capvols = stac9205_capvols;
5741 spec->capsws = stac9205_capsws;
5742
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005743 spec->aloopback_mask = 0x40;
5744 spec->aloopback_shift = 0;
Takashi Iwaid9a42682009-01-22 17:40:18 +01005745 /* Turn on/off EAPD per HP plugging */
5746 if (spec->board_config != STAC_9205_EAPD)
5747 spec->eapd_switch = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02005748 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02005749
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005750 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005751 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02005752 /* Enable SPDIF in/out */
Takashi Iwai330ee992009-02-20 14:33:36 +01005753 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
5754 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01005755
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005756 /* Enable unsol response for GPIO4/Dock HP connection */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005757 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
5758 if (err < 0)
5759 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005760 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005761 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
5762 snd_hda_codec_write_cache(codec, codec->afg, 0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005763 AC_VERB_SET_UNSOLICITED_ENABLE,
5764 AC_USRSP_EN | err);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005765
5766 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005767 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005768 spec->gpio_mask = 0x1b;
5769 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01005770 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005771 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02005772 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005773 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005774 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005775 case STAC_9205_REF:
5776 /* SPDIF-In enabled */
5777 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005778 default:
5779 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005780 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005781 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005782 break;
5783 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02005784
Matt Porterf3302a52006-07-31 12:49:34 +02005785 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005786 if (!err) {
5787 if (spec->board_config < 0) {
5788 printk(KERN_WARNING "hda_codec: No auto-config is "
5789 "available, default to model=ref\n");
5790 spec->board_config = STAC_9205_REF;
5791 goto again;
5792 }
5793 err = -EINVAL;
5794 }
Matt Porterf3302a52006-07-31 12:49:34 +02005795 if (err < 0) {
5796 stac92xx_free(codec);
5797 return err;
5798 }
5799
5800 codec->patch_ops = stac92xx_patch_ops;
5801
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005802 codec->proc_widget_hook = stac9205_proc_hook;
5803
Matt Porterf3302a52006-07-31 12:49:34 +02005804 return 0;
5805}
5806
Matt2f2f4252005-04-13 14:45:30 +02005807/*
Guillaume Munch6d859062006-08-22 17:15:47 +02005808 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01005809 */
5810
Takashi Iwai1e137f92009-01-21 07:41:22 +01005811static struct hda_verb stac9872_core_init[] = {
Takashi Iwai1624cb92007-07-05 13:10:51 +02005812 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005813 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5814 {}
5815};
5816
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005817static hda_nid_t stac9872_pin_nids[] = {
5818 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
5819 0x11, 0x13, 0x14,
5820};
5821
5822static hda_nid_t stac9872_adc_nids[] = {
5823 0x8 /*,0x6*/
5824};
5825
5826static hda_nid_t stac9872_mux_nids[] = {
5827 0x15
5828};
5829
Takashi Iwai6479c632009-07-28 18:20:25 +02005830static unsigned long stac9872_capvols[] = {
5831 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
5832};
5833#define stac9872_capsws stac9872_capvols
5834
Takashi Iwai307282c2009-03-12 18:17:58 +01005835static unsigned int stac9872_vaio_pin_configs[9] = {
5836 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
5837 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
5838 0x90a7013e
5839};
5840
5841static const char *stac9872_models[STAC_9872_MODELS] = {
5842 [STAC_9872_AUTO] = "auto",
5843 [STAC_9872_VAIO] = "vaio",
5844};
5845
5846static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
5847 [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
5848};
5849
5850static struct snd_pci_quirk stac9872_cfg_tbl[] = {
Takashi Iwaib04add92009-07-20 08:01:36 +02005851 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
5852 "Sony VAIO F/S", STAC_9872_VAIO),
Takashi Iwai307282c2009-03-12 18:17:58 +01005853 {} /* terminator */
5854};
5855
Guillaume Munch6d859062006-08-22 17:15:47 +02005856static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01005857{
5858 struct sigmatel_spec *spec;
Takashi Iwai1e137f92009-01-21 07:41:22 +01005859 int err;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005860
Takashi Iwaidb064e52006-03-16 16:04:58 +01005861 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5862 if (spec == NULL)
5863 return -ENOMEM;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005864 codec->spec = spec;
Takashi Iwaib04add92009-07-20 08:01:36 +02005865 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
5866 spec->pin_nids = stac9872_pin_nids;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005867
5868 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5869 stac9872_models,
5870 stac9872_cfg_tbl);
Takashi Iwai307282c2009-03-12 18:17:58 +01005871 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005872 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5873 codec->chip_name);
Takashi Iwai307282c2009-03-12 18:17:58 +01005874 else
5875 stac92xx_set_config_regs(codec,
5876 stac9872_brd_tbl[spec->board_config]);
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005877
Takashi Iwai1e137f92009-01-21 07:41:22 +01005878 spec->multiout.dac_nids = spec->dac_nids;
5879 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
5880 spec->adc_nids = stac9872_adc_nids;
5881 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
5882 spec->mux_nids = stac9872_mux_nids;
Takashi Iwai1e137f92009-01-21 07:41:22 +01005883 spec->init = stac9872_core_init;
Takashi Iwai6479c632009-07-28 18:20:25 +02005884 spec->num_caps = 1;
5885 spec->capvols = stac9872_capvols;
5886 spec->capsws = stac9872_capsws;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005887
Takashi Iwai1e137f92009-01-21 07:41:22 +01005888 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
5889 if (err < 0) {
5890 stac92xx_free(codec);
5891 return -EINVAL;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005892 }
Takashi Iwai1e137f92009-01-21 07:41:22 +01005893 spec->input_mux = &spec->private_imux;
5894 codec->patch_ops = stac92xx_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005895 return 0;
5896}
5897
5898
5899/*
Matt2f2f4252005-04-13 14:45:30 +02005900 * patch entries
5901 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +01005902static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
Matt2f2f4252005-04-13 14:45:30 +02005903 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5904 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5905 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5906 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5907 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5908 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5909 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02005910 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5911 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5912 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5913 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5914 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5915 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01005916 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5917 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5918 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5919 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5920 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5921 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5922 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5923 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5924 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5925 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01005926 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5927 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5928 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5929 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5930 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5931 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02005932 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5933 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02005934 /* The following does not take into account .id=0x83847661 when subsys =
5935 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5936 * currently not fully supported.
5937 */
5938 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5939 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5940 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Simos Xenitellisa5c0f882009-06-10 16:33:31 +01005941 { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
Matt Porterf3302a52006-07-31 12:49:34 +02005942 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5943 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5944 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5945 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5946 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5947 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5948 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5949 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005950 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005951 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5952 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayff2e7332009-04-01 14:49:48 -04005953 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005954 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01005955 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5956 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005957 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01005958 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5959 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5960 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5961 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5962 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5963 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5964 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5965 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02005966 {} /* terminator */
5967};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01005968
5969MODULE_ALIAS("snd-hda-codec-id:8384*");
5970MODULE_ALIAS("snd-hda-codec-id:111d*");
5971
5972MODULE_LICENSE("GPL");
5973MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
5974
5975static struct hda_codec_preset_list sigmatel_list = {
5976 .preset = snd_hda_preset_sigmatel,
5977 .owner = THIS_MODULE,
5978};
5979
5980static int __init patch_sigmatel_init(void)
5981{
5982 return snd_hda_add_codec_preset(&sigmatel_list);
5983}
5984
5985static void __exit patch_sigmatel_exit(void)
5986{
5987 snd_hda_delete_codec_preset(&sigmatel_list);
5988}
5989
5990module_init(patch_sigmatel_init)
5991module_exit(patch_sigmatel_exit)