blob: 48f4a36c4813849b827a30b88df011dcf195caa8 [file] [log] [blame]
Matt2f2f4252005-04-13 14:45:30 +02001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for SigmaTel STAC92xx
5 *
6 * Copyright (c) 2005 Embedded Alley Solutions, Inc.
Matt Porter403d1942005-11-29 15:00:51 +01007 * Matt Porter <mporter@embeddedalley.com>
Matt2f2f4252005-04-13 14:45:30 +02008 *
9 * Based on patch_cmedia.c and patch_realtek.c
10 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
11 *
12 * This driver is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This driver is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */
26
Matt2f2f4252005-04-13 14:45:30 +020027#include <linux/init.h>
28#include <linux/delay.h>
29#include <linux/slab.h>
30#include <linux/pci.h>
31#include <sound/core.h>
Mattc7d4b2f2005-06-27 14:59:41 +020032#include <sound/asoundef.h>
Matthew Ranostay45a6ac12008-10-15 14:45:38 -040033#include <sound/jack.h>
Matt2f2f4252005-04-13 14:45:30 +020034#include "hda_codec.h"
35#include "hda_local.h"
Matthew Ranostay1cd22242008-07-18 18:20:52 +020036#include "hda_beep.h"
Matt2f2f4252005-04-13 14:45:30 +020037
Takashi Iwaic6e4c662008-11-25 11:58:19 +010038enum {
39 STAC_VREF_EVENT = 1,
40 STAC_INSERT_EVENT,
41 STAC_PWR_EVENT,
42 STAC_HP_EVENT,
43};
Matt4e550962005-07-04 17:51:39 +020044
Takashi Iwaif5fcc132006-11-24 17:07:44 +010045enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010046 STAC_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010047 STAC_REF,
Tobin Davisbf277782008-02-03 20:31:47 +010048 STAC_9200_OQO,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020049 STAC_9200_DELL_D21,
50 STAC_9200_DELL_D22,
51 STAC_9200_DELL_D23,
52 STAC_9200_DELL_M21,
53 STAC_9200_DELL_M22,
54 STAC_9200_DELL_M23,
55 STAC_9200_DELL_M24,
56 STAC_9200_DELL_M25,
57 STAC_9200_DELL_M26,
58 STAC_9200_DELL_M27,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +020059 STAC_9200_M4,
60 STAC_9200_M4_2,
Takashi Iwai117f2572008-03-18 09:53:23 +010061 STAC_9200_PANASONIC,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010062 STAC_9200_MODELS
63};
64
65enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010066 STAC_9205_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010067 STAC_9205_REF,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020068 STAC_9205_DELL_M42,
Tobin Davisae0a8ed2007-08-13 15:50:29 +020069 STAC_9205_DELL_M43,
70 STAC_9205_DELL_M44,
Takashi Iwaid9a42682009-01-22 17:40:18 +010071 STAC_9205_EAPD,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010072 STAC_9205_MODELS
73};
74
75enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010076 STAC_92HD73XX_AUTO,
Takashi Iwai9e43f0d2008-12-17 14:51:01 +010077 STAC_92HD73XX_NO_JD, /* no jack-detection */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010078 STAC_92HD73XX_REF,
Takashi Iwai661cd8f2008-11-25 15:18:29 +010079 STAC_DELL_M6_AMIC,
80 STAC_DELL_M6_DMIC,
81 STAC_DELL_M6_BOTH,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -050082 STAC_DELL_EQ,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010083 STAC_92HD73XX_MODELS
84};
85
86enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010087 STAC_92HD83XXX_AUTO,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020088 STAC_92HD83XXX_REF,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -050089 STAC_92HD83XXX_PWR_REF,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -050090 STAC_DELL_S14,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020091 STAC_92HD83XXX_MODELS
92};
93
94enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010095 STAC_92HD71BXX_AUTO,
Matthew Ranostaye035b842007-11-06 11:53:55 +010096 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010097 STAC_DELL_M4_1,
98 STAC_DELL_M4_2,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -050099 STAC_DELL_M4_3,
Matthew Ranostay6a14f582008-09-12 12:02:30 -0400100 STAC_HP_M4,
Takashi Iwai1b0652e2009-01-14 08:27:35 +0100101 STAC_HP_DV5,
Christoph Plattnerae6241f2009-03-08 23:19:05 +0100102 STAC_HP_HDX,
James Gardiner514bf542009-05-03 04:00:44 -0400103 STAC_HP_DV4_1222NR,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100104 STAC_92HD71BXX_MODELS
105};
106
107enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100108 STAC_925x_AUTO,
Tobin Davis8e21c342007-01-08 11:04:17 +0100109 STAC_925x_REF,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200110 STAC_M1,
111 STAC_M1_2,
112 STAC_M2,
Tobin Davis8e21c342007-01-08 11:04:17 +0100113 STAC_M2_2,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200114 STAC_M3,
115 STAC_M5,
116 STAC_M6,
Tobin Davis8e21c342007-01-08 11:04:17 +0100117 STAC_925x_MODELS
118};
119
120enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100121 STAC_922X_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100122 STAC_D945_REF,
123 STAC_D945GTP3,
124 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200125 STAC_INTEL_MAC_V1,
126 STAC_INTEL_MAC_V2,
127 STAC_INTEL_MAC_V3,
128 STAC_INTEL_MAC_V4,
129 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800130 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
131 * is given, one of the above models will be
132 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200133 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100134 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100135 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100136 STAC_MACBOOK_PRO_V1,
137 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200138 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200139 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300140 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200141 STAC_922X_DELL_D81,
142 STAC_922X_DELL_D82,
143 STAC_922X_DELL_M81,
144 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100145 STAC_922X_MODELS
146};
147
148enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100149 STAC_927X_AUTO,
Takashi Iwaie28d8322008-12-17 13:48:29 +0100150 STAC_D965_REF_NO_JD, /* no jack-detection */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100151 STAC_D965_REF,
152 STAC_D965_3ST,
153 STAC_D965_5ST,
Takashi Iwai679d92e2009-05-24 19:00:08 +0200154 STAC_D965_5ST_NO_FP,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200155 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100156 STAC_DELL_BIOS,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100157 STAC_927X_MODELS
158};
Matt Porter403d1942005-11-29 15:00:51 +0100159
Takashi Iwai307282c2009-03-12 18:17:58 +0100160enum {
161 STAC_9872_AUTO,
162 STAC_9872_VAIO,
163 STAC_9872_MODELS
164};
165
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400166struct sigmatel_event {
167 hda_nid_t nid;
Takashi Iwaic6e4c662008-11-25 11:58:19 +0100168 unsigned char type;
169 unsigned char tag;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400170 int data;
171};
172
173struct sigmatel_jack {
174 hda_nid_t nid;
175 int type;
176 struct snd_jack *jack;
177};
178
Matt2f2f4252005-04-13 14:45:30 +0200179struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100180 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200181 unsigned int num_mixers;
182
Matt Porter403d1942005-11-29 15:00:51 +0100183 int board_config;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -0500184 unsigned int eapd_switch: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200185 unsigned int surr_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100186 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100187 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400188 unsigned int spdif_mute: 1;
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100189 unsigned int check_volume_offset:1;
Mattc7d4b2f2005-06-27 14:59:41 +0200190
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100191 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200192 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100193 unsigned int gpio_mask;
194 unsigned int gpio_dir;
195 unsigned int gpio_data;
196 unsigned int gpio_mute;
Takashi Iwai86d190e2009-05-26 15:18:58 +0200197 unsigned int gpio_led;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100198
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200199 /* stream */
200 unsigned int stream_delay;
201
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100202 /* analog loopback */
Takashi Iwaid78d7a92009-03-02 14:26:25 +0100203 struct snd_kcontrol_new *aloopback_ctl;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100204 unsigned char aloopback_mask;
205 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200206
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100207 /* power management */
208 unsigned int num_pwrs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200209 unsigned int *pwr_mapping;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100210 hda_nid_t *pwr_nids;
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100211 hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100212
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400213 /* jack detection */
214 struct snd_array jacks;
215
216 /* events */
217 struct snd_array events;
218
Matt2f2f4252005-04-13 14:45:30 +0200219 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100220 struct hda_input_mux *mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400221 struct hda_input_mux *amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100222 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200223 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100224 hda_nid_t dac_nids[5];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100225 hda_nid_t hp_dacs[5];
226 hda_nid_t speaker_dacs[5];
Matt2f2f4252005-04-13 14:45:30 +0200227
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100228 int volume_offset;
229
Matt2f2f4252005-04-13 14:45:30 +0200230 /* capture */
231 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200232 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200233 hda_nid_t *mux_nids;
234 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200235 hda_nid_t *dmic_nids;
236 unsigned int num_dmics;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100237 hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100238 unsigned int num_dmuxes;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200239 hda_nid_t *smux_nids;
240 unsigned int num_smuxes;
Matthew Ranostay65973632008-09-16 10:39:37 -0400241 const char **spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200242
Mattdabbed62005-06-14 10:19:34 +0200243 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100244 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200245 hda_nid_t anabeep_nid;
246 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200247
Matt2f2f4252005-04-13 14:45:30 +0200248 /* pin widgets */
249 hda_nid_t *pin_nids;
250 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200251
252 /* codec specific stuff */
253 struct hda_verb *init;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100254 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200255
256 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200257 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100258 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200259 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100260 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200261 struct hda_input_mux *sinput_mux;
262 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400263 unsigned int cur_amux;
264 hda_nid_t *amp_nids;
265 unsigned int num_amps;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200266 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200267
Matt Porter403d1942005-11-29 15:00:51 +0100268 /* i/o switches */
269 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200270 unsigned int clfe_swap;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100271 hda_nid_t line_switch; /* shared line-in for input and output */
272 hda_nid_t mic_switch; /* shared mic-in for input and output */
273 hda_nid_t hp_switch; /* NID of HP as line-out */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200274 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200275
Mattc7d4b2f2005-06-27 14:59:41 +0200276 struct hda_pcm pcm_rec[2]; /* PCM information */
277
278 /* dynamic controls and input_mux */
279 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200280 struct snd_array kctls;
Matt Porter8b657272006-10-26 17:12:59 +0200281 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200282 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200283 struct hda_input_mux private_smux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400284 struct hda_input_mux private_amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100285 struct hda_input_mux private_mono_mux;
Matt2f2f4252005-04-13 14:45:30 +0200286};
287
288static hda_nid_t stac9200_adc_nids[1] = {
289 0x03,
290};
291
292static hda_nid_t stac9200_mux_nids[1] = {
293 0x0c,
294};
295
296static hda_nid_t stac9200_dac_nids[1] = {
297 0x02,
298};
299
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100300static hda_nid_t stac92hd73xx_pwr_nids[8] = {
301 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
302 0x0f, 0x10, 0x11
303};
304
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400305static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
306 0x26, 0,
307};
308
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100309static hda_nid_t stac92hd73xx_adc_nids[2] = {
310 0x1a, 0x1b
311};
312
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400313#define DELL_M6_AMP 2
314static hda_nid_t stac92hd73xx_amp_nids[3] = {
315 0x0b, 0x0c, 0x0e
Matthew Ranostay89385032008-09-11 09:49:39 -0400316};
317
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100318#define STAC92HD73XX_NUM_DMICS 2
319static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
320 0x13, 0x14, 0
321};
322
323#define STAC92HD73_DAC_COUNT 5
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100324
325static hda_nid_t stac92hd73xx_mux_nids[4] = {
326 0x28, 0x29, 0x2a, 0x2b,
327};
328
329static hda_nid_t stac92hd73xx_dmux_nids[2] = {
330 0x20, 0x21,
331};
332
Matthew Ranostayd9737752008-09-07 12:03:41 +0200333static hda_nid_t stac92hd73xx_smux_nids[2] = {
334 0x22, 0x23,
335};
336
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200337#define STAC92HD83XXX_NUM_DMICS 2
338static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
339 0x11, 0x12, 0
340};
341
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200342#define STAC92HD83_DAC_COUNT 3
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200343
344static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
345 0x17, 0x18,
346};
347
348static hda_nid_t stac92hd83xxx_adc_nids[2] = {
349 0x15, 0x16,
350};
351
352static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
353 0xa, 0xb, 0xd, 0xe,
354};
355
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400356static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
357 0x1e, 0,
358};
359
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200360static unsigned int stac92hd83xxx_pwr_mapping[4] = {
Matthew Ranostay87e88a72009-01-22 20:38:42 -0500361 0x03, 0x0c, 0x20, 0x40,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200362};
363
Takashi Iwai9248f262009-01-14 09:40:25 +0100364static hda_nid_t stac92hd83xxx_amp_nids[1] = {
Matthew Ranostayc15c5062009-01-13 13:30:07 -0500365 0xc,
366};
367
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100368static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
369 0x0a, 0x0d, 0x0f
370};
371
Matthew Ranostaye035b842007-11-06 11:53:55 +0100372static hda_nid_t stac92hd71bxx_adc_nids[2] = {
373 0x12, 0x13,
374};
375
376static hda_nid_t stac92hd71bxx_mux_nids[2] = {
377 0x1a, 0x1b
378};
379
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400380static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
381 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100382};
383
Matthew Ranostayd9737752008-09-07 12:03:41 +0200384static hda_nid_t stac92hd71bxx_smux_nids[2] = {
385 0x24, 0x25,
386};
387
Matthew Ranostaye035b842007-11-06 11:53:55 +0100388#define STAC92HD71BXX_NUM_DMICS 2
389static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
390 0x18, 0x19, 0
391};
392
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400393static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
394 0x22, 0
395};
396
Tobin Davis8e21c342007-01-08 11:04:17 +0100397static hda_nid_t stac925x_adc_nids[1] = {
398 0x03,
399};
400
401static hda_nid_t stac925x_mux_nids[1] = {
402 0x0f,
403};
404
405static hda_nid_t stac925x_dac_nids[1] = {
406 0x02,
407};
408
Takashi Iwaif6e98522007-10-16 14:27:04 +0200409#define STAC925X_NUM_DMICS 1
410static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
411 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200412};
413
Takashi Iwai1697055e2007-12-18 18:05:52 +0100414static hda_nid_t stac925x_dmux_nids[1] = {
415 0x14,
416};
417
Matt2f2f4252005-04-13 14:45:30 +0200418static hda_nid_t stac922x_adc_nids[2] = {
419 0x06, 0x07,
420};
421
422static hda_nid_t stac922x_mux_nids[2] = {
423 0x12, 0x13,
424};
425
Matthew Ranostay45c1d852009-02-04 17:49:41 -0500426static hda_nid_t stac927x_slave_dig_outs[2] = {
427 0x1f, 0,
428};
429
Matt Porter3cc08dc2006-01-23 15:27:49 +0100430static hda_nid_t stac927x_adc_nids[3] = {
431 0x07, 0x08, 0x09
432};
433
434static hda_nid_t stac927x_mux_nids[3] = {
435 0x15, 0x16, 0x17
436};
437
Matthew Ranostayd9737752008-09-07 12:03:41 +0200438static hda_nid_t stac927x_smux_nids[1] = {
439 0x21,
440};
441
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100442static hda_nid_t stac927x_dac_nids[6] = {
443 0x02, 0x03, 0x04, 0x05, 0x06, 0
444};
445
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100446static hda_nid_t stac927x_dmux_nids[1] = {
447 0x1b,
448};
449
Matthew Ranostay7f168592007-10-18 17:38:17 +0200450#define STAC927X_NUM_DMICS 2
451static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
452 0x13, 0x14, 0
453};
454
Matthew Ranostay65973632008-09-16 10:39:37 -0400455static const char *stac927x_spdif_labels[5] = {
456 "Digital Playback", "ADAT", "Analog Mux 1",
457 "Analog Mux 2", "Analog Mux 3"
458};
459
Matt Porterf3302a52006-07-31 12:49:34 +0200460static hda_nid_t stac9205_adc_nids[2] = {
461 0x12, 0x13
462};
463
464static hda_nid_t stac9205_mux_nids[2] = {
465 0x19, 0x1a
466};
467
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100468static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100469 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100470};
471
Matthew Ranostayd9737752008-09-07 12:03:41 +0200472static hda_nid_t stac9205_smux_nids[1] = {
473 0x21,
474};
475
Takashi Iwaif6e98522007-10-16 14:27:04 +0200476#define STAC9205_NUM_DMICS 2
477static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
478 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200479};
480
Mattc7d4b2f2005-06-27 14:59:41 +0200481static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200482 0x08, 0x09, 0x0d, 0x0e,
483 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200484};
485
Tobin Davis8e21c342007-01-08 11:04:17 +0100486static hda_nid_t stac925x_pin_nids[8] = {
487 0x07, 0x08, 0x0a, 0x0b,
488 0x0c, 0x0d, 0x10, 0x11,
489};
490
Matt2f2f4252005-04-13 14:45:30 +0200491static hda_nid_t stac922x_pin_nids[10] = {
492 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
493 0x0f, 0x10, 0x11, 0x15, 0x1b,
494};
495
Matthew Ranostaya7662642008-02-21 07:51:14 +0100496static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100497 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
498 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200499 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100500};
501
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -0500502static hda_nid_t stac92hd83xxx_pin_nids[10] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200503 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -0500504 0x0f, 0x10, 0x11, 0x1f, 0x20,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200505};
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500506
507#define STAC92HD71BXX_NUM_PINS 13
508static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
509 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
510 0x00, 0x14, 0x18, 0x19, 0x1e,
511 0x1f, 0x20, 0x27
512};
513static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100514 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
515 0x0f, 0x14, 0x18, 0x19, 0x1e,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500516 0x1f, 0x20, 0x27
Matthew Ranostaye035b842007-11-06 11:53:55 +0100517};
518
Matt Porter3cc08dc2006-01-23 15:27:49 +0100519static hda_nid_t stac927x_pin_nids[14] = {
520 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
521 0x0f, 0x10, 0x11, 0x12, 0x13,
522 0x14, 0x21, 0x22, 0x23,
523};
524
Matt Porterf3302a52006-07-31 12:49:34 +0200525static hda_nid_t stac9205_pin_nids[12] = {
526 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
527 0x0f, 0x14, 0x16, 0x17, 0x18,
528 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200529};
530
Matthew Ranostay89385032008-09-11 09:49:39 -0400531#define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
532
533static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
534 struct snd_ctl_elem_value *ucontrol)
535{
536 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
537 struct sigmatel_spec *spec = codec->spec;
538 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
539
540 kcontrol->private_value ^= get_amp_nid(kcontrol);
541 kcontrol->private_value |= nid;
542
543 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
544}
545
546static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
547 struct snd_ctl_elem_value *ucontrol)
548{
549 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
550 struct sigmatel_spec *spec = codec->spec;
551 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
552
553 kcontrol->private_value ^= get_amp_nid(kcontrol);
554 kcontrol->private_value |= nid;
555
556 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
557}
558
Matt Porter8b657272006-10-26 17:12:59 +0200559static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
560 struct snd_ctl_elem_info *uinfo)
561{
562 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
563 struct sigmatel_spec *spec = codec->spec;
564 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
565}
566
567static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
568 struct snd_ctl_elem_value *ucontrol)
569{
570 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
571 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100572 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200573
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100574 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200575 return 0;
576}
577
578static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
579 struct snd_ctl_elem_value *ucontrol)
580{
581 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
582 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100583 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200584
585 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100586 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200587}
588
Matthew Ranostayd9737752008-09-07 12:03:41 +0200589static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
590 struct snd_ctl_elem_info *uinfo)
591{
592 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
593 struct sigmatel_spec *spec = codec->spec;
594 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
595}
596
597static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
598 struct snd_ctl_elem_value *ucontrol)
599{
600 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
601 struct sigmatel_spec *spec = codec->spec;
602 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
603
604 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
605 return 0;
606}
607
608static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
609 struct snd_ctl_elem_value *ucontrol)
610{
611 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
612 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400613 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200614 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400615 int err, val;
616 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200617
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400618 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200619 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400620 if (err < 0)
621 return err;
622
623 if (spec->spdif_mute) {
624 if (smux_idx == 0)
625 nid = spec->multiout.dig_out_nid;
626 else
627 nid = codec->slave_dig_outs[smux_idx - 1];
628 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100629 val = HDA_AMP_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400630 else
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100631 val = 0;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400632 /* un/mute SPDIF out */
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100633 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
634 HDA_AMP_MUTE, val);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400635 }
636 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200637}
638
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200639static unsigned int stac92xx_vref_set(struct hda_codec *codec,
640 hda_nid_t nid, unsigned int new_vref)
641{
642 unsigned int error;
643 unsigned int pincfg;
644 pincfg = snd_hda_codec_read(codec, nid, 0,
645 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
646
647 pincfg &= 0xff;
648 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
649 pincfg |= new_vref;
650
651 if (new_vref == AC_PINCTL_VREF_HIZ)
652 pincfg |= AC_PINCTL_OUT_EN;
653 else
654 pincfg |= AC_PINCTL_IN_EN;
655
656 error = snd_hda_codec_write_cache(codec, nid, 0,
657 AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg);
658 if (error < 0)
659 return error;
660 else
661 return 1;
662}
663
664static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
665{
666 unsigned int vref;
667 vref = snd_hda_codec_read(codec, nid, 0,
668 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
669 vref &= AC_PINCTL_VREFEN;
670 return vref;
671}
672
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100673static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200674{
675 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
676 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200677 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200678}
679
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100680static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200681{
682 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
683 struct sigmatel_spec *spec = codec->spec;
684 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
685
686 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
687 return 0;
688}
689
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100690static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200691{
692 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
693 struct sigmatel_spec *spec = codec->spec;
694 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
695
Mattc7d4b2f2005-06-27 14:59:41 +0200696 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200697 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
698}
699
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100700static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
701 struct snd_ctl_elem_info *uinfo)
702{
703 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
704 struct sigmatel_spec *spec = codec->spec;
705 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
706}
707
708static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
709 struct snd_ctl_elem_value *ucontrol)
710{
711 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
712 struct sigmatel_spec *spec = codec->spec;
713
714 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
715 return 0;
716}
717
718static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
719 struct snd_ctl_elem_value *ucontrol)
720{
721 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
722 struct sigmatel_spec *spec = codec->spec;
723
724 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
725 spec->mono_nid, &spec->cur_mmux);
726}
727
Matthew Ranostay89385032008-09-11 09:49:39 -0400728static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
729 struct snd_ctl_elem_info *uinfo)
730{
731 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
732 struct sigmatel_spec *spec = codec->spec;
733 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
734}
735
736static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
737 struct snd_ctl_elem_value *ucontrol)
738{
739 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
740 struct sigmatel_spec *spec = codec->spec;
741
742 ucontrol->value.enumerated.item[0] = spec->cur_amux;
743 return 0;
744}
745
746static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
747 struct snd_ctl_elem_value *ucontrol)
748{
749 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
750 struct sigmatel_spec *spec = codec->spec;
751 struct snd_kcontrol *ctl =
752 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
753 if (!ctl)
754 return -EINVAL;
755
756 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
757 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
758
759 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
760 0, &spec->cur_amux);
761}
762
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200763#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
764
765static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
766 struct snd_ctl_elem_value *ucontrol)
767{
768 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100769 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200770 struct sigmatel_spec *spec = codec->spec;
771
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100772 ucontrol->value.integer.value[0] = !!(spec->aloopback &
773 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200774 return 0;
775}
776
777static int stac92xx_aloopback_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;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100782 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200783 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100784 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200785
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100786 idx_val = spec->aloopback_mask << idx;
787 if (ucontrol->value.integer.value[0])
788 val = spec->aloopback | idx_val;
789 else
790 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100791 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200792 return 0;
793
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100794 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200795
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100796 /* Only return the bits defined by the shift value of the
797 * first two bytes of the mask
798 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200799 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100800 kcontrol->private_value & 0xFFFF, 0x0);
801 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200802
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100803 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200804 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100805 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200806 } else {
807 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100808 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200809 }
810
811 snd_hda_codec_write_cache(codec, codec->afg, 0,
812 kcontrol->private_value >> 16, dac_mode);
813
814 return 1;
815}
816
Mattc7d4b2f2005-06-27 14:59:41 +0200817static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200818 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200819 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200820 {}
821};
822
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200823static struct hda_verb stac9200_eapd_init[] = {
824 /* set dac0mux for dac converter */
825 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
826 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
827 {}
828};
829
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100830static struct hda_verb stac92hd73xx_6ch_core_init[] = {
831 /* set master volume and direct control */
832 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100833 /* setup adcs to point to mixer */
834 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
835 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100836 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
837 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
838 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
839 /* setup import muxs */
840 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
841 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
842 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
843 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
844 {}
845};
846
Matthew Ranostayd654a662008-03-14 08:46:51 +0100847static struct hda_verb dell_eq_core_init[] = {
848 /* set master volume to max value without distortion
849 * and direct control */
850 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100851 /* setup adcs to point to mixer */
852 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
853 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
854 /* setup import muxs */
855 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
856 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
857 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
858 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
859 {}
860};
861
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100862static struct hda_verb dell_m6_core_init[] = {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -0500863 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100864 /* setup adcs to point to mixer */
865 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
866 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
867 /* setup import muxs */
868 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
869 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
870 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
871 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
872 {}
873};
874
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100875static struct hda_verb stac92hd73xx_8ch_core_init[] = {
876 /* set master volume and direct control */
877 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100878 /* setup adcs to point to mixer */
879 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
880 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100881 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
882 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
883 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
884 /* setup import muxs */
885 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
886 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
887 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
888 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
889 {}
890};
891
892static struct hda_verb stac92hd73xx_10ch_core_init[] = {
893 /* set master volume and direct control */
894 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100895 /* dac3 is connected to import3 mux */
896 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100897 /* setup adcs to point to mixer */
898 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
899 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100900 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
901 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
902 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
903 /* setup import muxs */
904 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
905 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
906 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
907 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
908 {}
909};
910
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200911static struct hda_verb stac92hd83xxx_core_init[] = {
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -0500912 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1},
913 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1},
914 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200915
916 /* power state controls amps */
917 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200918 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200919};
920
Matthew Ranostaye035b842007-11-06 11:53:55 +0100921static struct hda_verb stac92hd71bxx_core_init[] = {
922 /* set master volume and direct control */
923 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200924 {}
Matthew Ranostay541eee82007-12-14 12:08:04 +0100925};
926
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500927#define HD_DISABLE_PORTF 1
Matthew Ranostay541eee82007-12-14 12:08:04 +0100928static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200929 /* start of config #1 */
930
931 /* connect port 0f to audio mixer */
932 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200933 /* start of config #2 */
934
Matthew Ranostay541eee82007-12-14 12:08:04 +0100935 /* set master volume and direct control */
936 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500937 {}
938};
939
940static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
941 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
942 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100943 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
944 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100945 {}
946};
947
Tobin Davis8e21c342007-01-08 11:04:17 +0100948static struct hda_verb stac925x_core_init[] = {
949 /* set dac0mux for dac converter */
950 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaic9280d62009-01-15 17:31:00 +0100951 /* mute the master volume */
952 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Tobin Davis8e21c342007-01-08 11:04:17 +0100953 {}
954};
955
Mattc7d4b2f2005-06-27 14:59:41 +0200956static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200957 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200958 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200959 {}
960};
961
Tobin Davis93ed1502006-09-01 21:03:12 +0200962static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200963 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200964 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200965 /* unmute node 0x1b */
966 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
967 /* select node 0x03 as DAC */
968 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
969 {}
970};
971
Matt Porter3cc08dc2006-01-23 15:27:49 +0100972static struct hda_verb stac927x_core_init[] = {
973 /* set master volume and direct control */
974 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200975 /* enable analog pc beep path */
976 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100977 {}
978};
979
Matt Porterf3302a52006-07-31 12:49:34 +0200980static struct hda_verb stac9205_core_init[] = {
981 /* set master volume and direct control */
982 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200983 /* enable analog pc beep path */
984 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200985 {}
986};
987
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100988#define STAC_MONO_MUX \
989 { \
990 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
991 .name = "Mono Mux", \
992 .count = 1, \
993 .info = stac92xx_mono_mux_enum_info, \
994 .get = stac92xx_mono_mux_enum_get, \
995 .put = stac92xx_mono_mux_enum_put, \
996 }
997
Matthew Ranostay89385032008-09-11 09:49:39 -0400998#define STAC_AMP_MUX \
999 { \
1000 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1001 .name = "Amp Selector Capture Switch", \
1002 .count = 1, \
1003 .info = stac92xx_amp_mux_enum_info, \
1004 .get = stac92xx_amp_mux_enum_get, \
1005 .put = stac92xx_amp_mux_enum_put, \
1006 }
1007
1008#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
1009 { \
1010 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1011 .name = xname, \
1012 .index = 0, \
1013 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1014 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1015 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
1016 .info = stac92xx_amp_volume_info, \
1017 .get = stac92xx_amp_volume_get, \
1018 .put = stac92xx_amp_volume_put, \
1019 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
1020 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
1021 }
1022
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001023#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +02001024 { \
1025 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1026 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001027 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +02001028 .info = stac92xx_aloopback_info, \
1029 .get = stac92xx_aloopback_get, \
1030 .put = stac92xx_aloopback_put, \
1031 .private_value = verb_read | (verb_write << 16), \
1032 }
1033
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02001034#define DC_BIAS(xname, idx, nid) \
1035 { \
1036 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1037 .name = xname, \
1038 .index = idx, \
1039 .info = stac92xx_dc_bias_info, \
1040 .get = stac92xx_dc_bias_get, \
1041 .put = stac92xx_dc_bias_put, \
1042 .private_value = nid, \
1043 }
1044
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001045static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +02001046 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
1047 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001048 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
1049 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001050 { } /* end */
1051};
1052
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04001053#define DELL_M6_MIXER 6
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001054static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04001055 /* start of config #1 */
1056 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1057 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1058
1059 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1060 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1061
1062 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1063 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1064
1065 /* start of config #2 */
1066 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1067 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1068
1069 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1070 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1071
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001072 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1073 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1074
1075 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1076 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1077
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001078 { } /* end */
1079};
1080
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001081static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
1082 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1083 {}
1084};
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001085
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001086static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
1087 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1088 {}
1089};
1090
1091static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
1092 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1093 {}
1094};
1095
1096static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001097 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1098 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1099
1100 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1101 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1102
1103 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1104 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1105
1106 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1107 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1108
1109 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1110 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1111
1112 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1113 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1114
1115 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1116 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1117 { } /* end */
1118};
1119
1120static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001121 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1122 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1123
1124 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1125 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1126
1127 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1128 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1129
1130 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1131 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1132
1133 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1134 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1135
1136 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1137 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1138
1139 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1140 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1141 { } /* end */
1142};
1143
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001144
1145static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1146 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1147 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1148
1149 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1150 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1151
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001152 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT),
1153 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001154
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001155 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT),
1156 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001157
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001158 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT),
1159 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001160
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001161 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT),
1162 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001163
1164 /*
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001165 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT),
1166 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001167 */
1168 { } /* end */
1169};
1170
Matthew Ranostay541eee82007-12-14 12:08:04 +01001171static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostay9b359472007-11-07 13:03:12 +01001172 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1173 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay9b359472007-11-07 13:03:12 +01001174
1175 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1176 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001177 /* analog pc-beep replaced with digital beep support */
1178 /*
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001179 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1180 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001181 */
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001182
Matthew Ranostay687cb982008-10-11 13:52:43 -04001183 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1184 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001185
Matthew Ranostay687cb982008-10-11 13:52:43 -04001186 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1187 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001188
1189 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1190 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1191
1192 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1193 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001194 { } /* end */
1195};
1196
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001197static struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
1198 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1199};
Matthew Ranostay541eee82007-12-14 12:08:04 +01001200
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001201static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +01001202 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1203 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001204
1205 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1206 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001207 { } /* end */
1208};
1209
Tobin Davis8e21c342007-01-08 11:04:17 +01001210static struct snd_kcontrol_new stac925x_mixer[] = {
Takashi Iwaic9280d62009-01-15 17:31:00 +01001211 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
1212 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001213 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +02001214 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001215 { } /* end */
1216};
1217
Takashi Iwaid1d985f2006-11-23 19:27:12 +01001218static struct snd_kcontrol_new stac9205_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001219 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1220 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001221
1222 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1223 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001224 { } /* end */
1225};
1226
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001227static struct snd_kcontrol_new stac9205_loopback[] = {
1228 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1229 {}
1230};
1231
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001232/* This needs to be generated dynamically based on sequence */
1233static struct snd_kcontrol_new stac922x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001234 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1235 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001236
1237 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1238 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001239 { } /* end */
1240};
1241
1242
1243static struct snd_kcontrol_new stac927x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001244 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1245 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001246
1247 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1248 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001249
1250 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1251 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
Matt Porterf3302a52006-07-31 12:49:34 +02001252 { } /* end */
1253};
1254
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001255static struct snd_kcontrol_new stac927x_loopback[] = {
1256 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1257 {}
1258};
1259
Takashi Iwai1697055e2007-12-18 18:05:52 +01001260static struct snd_kcontrol_new stac_dmux_mixer = {
1261 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1262 .name = "Digital Input Source",
1263 /* count set later */
1264 .info = stac92xx_dmux_enum_info,
1265 .get = stac92xx_dmux_enum_get,
1266 .put = stac92xx_dmux_enum_put,
1267};
1268
Matthew Ranostayd9737752008-09-07 12:03:41 +02001269static struct snd_kcontrol_new stac_smux_mixer = {
1270 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001271 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001272 /* count set later */
1273 .info = stac92xx_smux_enum_info,
1274 .get = stac92xx_smux_enum_get,
1275 .put = stac92xx_smux_enum_put,
1276};
1277
Takashi Iwai2134ea42008-01-10 16:53:55 +01001278static const char *slave_vols[] = {
1279 "Front Playback Volume",
1280 "Surround Playback Volume",
1281 "Center Playback Volume",
1282 "LFE Playback Volume",
1283 "Side Playback Volume",
1284 "Headphone Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001285 "Speaker Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001286 NULL
1287};
1288
1289static const char *slave_sws[] = {
1290 "Front Playback Switch",
1291 "Surround Playback Switch",
1292 "Center Playback Switch",
1293 "LFE Playback Switch",
1294 "Side Playback Switch",
1295 "Headphone Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001296 "Speaker Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001297 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001298 NULL
1299};
1300
Takashi Iwai603c4012008-07-30 15:01:44 +02001301static void stac92xx_free_kctls(struct hda_codec *codec);
Takashi Iwaie4973e12008-11-18 09:32:42 +01001302static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
Takashi Iwai603c4012008-07-30 15:01:44 +02001303
Matt2f2f4252005-04-13 14:45:30 +02001304static int stac92xx_build_controls(struct hda_codec *codec)
1305{
1306 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaie4973e12008-11-18 09:32:42 +01001307 struct auto_pin_cfg *cfg = &spec->autocfg;
1308 hda_nid_t nid;
Matt2f2f4252005-04-13 14:45:30 +02001309 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001310 int i;
Matt2f2f4252005-04-13 14:45:30 +02001311
1312 err = snd_hda_add_new_ctls(codec, spec->mixer);
1313 if (err < 0)
1314 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001315
1316 for (i = 0; i < spec->num_mixers; i++) {
1317 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1318 if (err < 0)
1319 return err;
1320 }
Takashi Iwai1697055e2007-12-18 18:05:52 +01001321 if (spec->num_dmuxes > 0) {
1322 stac_dmux_mixer.count = spec->num_dmuxes;
Takashi Iwaid13bd412008-07-30 15:01:45 +02001323 err = snd_hda_ctl_add(codec,
Takashi Iwai1697055e2007-12-18 18:05:52 +01001324 snd_ctl_new1(&stac_dmux_mixer, codec));
1325 if (err < 0)
1326 return err;
1327 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001328 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001329 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1330 struct hda_input_mux *smux = &spec->private_smux;
1331 /* check for mute support on SPDIF out */
1332 if (wcaps & AC_WCAP_OUT_AMP) {
1333 smux->items[smux->num_items].label = "Off";
1334 smux->items[smux->num_items].index = 0;
1335 smux->num_items++;
1336 spec->spdif_mute = 1;
1337 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001338 stac_smux_mixer.count = spec->num_smuxes;
Takashi Iwai4f2d23e2008-12-19 10:14:13 +01001339 err = snd_hda_ctl_add(codec,
Matthew Ranostayd9737752008-09-07 12:03:41 +02001340 snd_ctl_new1(&stac_smux_mixer, codec));
1341 if (err < 0)
1342 return err;
1343 }
Mattc7d4b2f2005-06-27 14:59:41 +02001344
Mattdabbed62005-06-14 10:19:34 +02001345 if (spec->multiout.dig_out_nid) {
1346 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1347 if (err < 0)
1348 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001349 err = snd_hda_create_spdif_share_sw(codec,
1350 &spec->multiout);
1351 if (err < 0)
1352 return err;
1353 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001354 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001355 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001356 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1357 if (err < 0)
1358 return err;
1359 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001360
1361 /* if we have no master control, let's create it */
1362 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001363 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001364 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001365 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai7c7767e2009-01-20 15:28:38 +01001366 /* correct volume offset */
1367 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
Takashi Iwai2134ea42008-01-10 16:53:55 +01001368 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001369 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001370 if (err < 0)
1371 return err;
1372 }
1373 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1374 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1375 NULL, slave_sws);
1376 if (err < 0)
1377 return err;
1378 }
1379
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001380 if (spec->aloopback_ctl &&
1381 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1382 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1383 if (err < 0)
1384 return err;
1385 }
1386
Takashi Iwai603c4012008-07-30 15:01:44 +02001387 stac92xx_free_kctls(codec); /* no longer needed */
Takashi Iwaie4973e12008-11-18 09:32:42 +01001388
1389 /* create jack input elements */
1390 if (spec->hp_detect) {
1391 for (i = 0; i < cfg->hp_outs; i++) {
1392 int type = SND_JACK_HEADPHONE;
1393 nid = cfg->hp_pins[i];
1394 /* jack detection */
1395 if (cfg->hp_outs == i)
1396 type |= SND_JACK_LINEOUT;
1397 err = stac92xx_add_jack(codec, nid, type);
1398 if (err < 0)
1399 return err;
1400 }
1401 }
1402 for (i = 0; i < cfg->line_outs; i++) {
1403 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1404 SND_JACK_LINEOUT);
1405 if (err < 0)
1406 return err;
1407 }
1408 for (i = 0; i < AUTO_PIN_LAST; i++) {
1409 nid = cfg->input_pins[i];
1410 if (nid) {
1411 err = stac92xx_add_jack(codec, nid,
1412 SND_JACK_MICROPHONE);
1413 if (err < 0)
1414 return err;
1415 }
1416 }
1417
Mattdabbed62005-06-14 10:19:34 +02001418 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001419}
1420
Matt Porter403d1942005-11-29 15:00:51 +01001421static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001422 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001423 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1424};
1425
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001426static unsigned int gateway9200_m4_pin_configs[8] = {
1427 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1428 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1429};
1430static unsigned int gateway9200_m4_2_pin_configs[8] = {
1431 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1432 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1433};
1434
1435/*
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001436 STAC 9200 pin configs for
1437 102801A8
1438 102801DE
1439 102801E8
1440*/
1441static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001442 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1443 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001444};
1445
1446/*
1447 STAC 9200 pin configs for
1448 102801C0
1449 102801C1
1450*/
1451static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001452 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1453 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001454};
1455
1456/*
1457 STAC 9200 pin configs for
1458 102801C4 (Dell Dimension E310)
1459 102801C5
1460 102801C7
1461 102801D9
1462 102801DA
1463 102801E3
1464*/
1465static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001466 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1467 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001468};
1469
1470
1471/*
1472 STAC 9200-32 pin configs for
1473 102801B5 (Dell Inspiron 630m)
1474 102801D8 (Dell Inspiron 640m)
1475*/
1476static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001477 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1478 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001479};
1480
1481/*
1482 STAC 9200-32 pin configs for
1483 102801C2 (Dell Latitude D620)
1484 102801C8
1485 102801CC (Dell Latitude D820)
1486 102801D4
1487 102801D6
1488*/
1489static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001490 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1491 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001492};
1493
1494/*
1495 STAC 9200-32 pin configs for
1496 102801CE (Dell XPS M1710)
1497 102801CF (Dell Precision M90)
1498*/
1499static unsigned int dell9200_m23_pin_configs[8] = {
1500 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1501 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1502};
1503
1504/*
1505 STAC 9200-32 pin configs for
1506 102801C9
1507 102801CA
1508 102801CB (Dell Latitude 120L)
1509 102801D3
1510*/
1511static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001512 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1513 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001514};
1515
1516/*
1517 STAC 9200-32 pin configs for
1518 102801BD (Dell Inspiron E1505n)
1519 102801EE
1520 102801EF
1521*/
1522static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001523 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1524 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001525};
1526
1527/*
1528 STAC 9200-32 pin configs for
1529 102801F5 (Dell Inspiron 1501)
1530 102801F6
1531*/
1532static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001533 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1534 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001535};
1536
1537/*
1538 STAC 9200-32
1539 102801CD (Dell Inspiron E1705/9400)
1540*/
1541static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001542 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1543 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001544};
1545
Tobin Davisbf277782008-02-03 20:31:47 +01001546static unsigned int oqo9200_pin_configs[8] = {
1547 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1548 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1549};
1550
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001551
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001552static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1553 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001554 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001555 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1556 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1557 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1558 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1559 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1560 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1561 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1562 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1563 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1564 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001565 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1566 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001567 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001568};
1569
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001570static const char *stac9200_models[STAC_9200_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001571 [STAC_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001572 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001573 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001574 [STAC_9200_DELL_D21] = "dell-d21",
1575 [STAC_9200_DELL_D22] = "dell-d22",
1576 [STAC_9200_DELL_D23] = "dell-d23",
1577 [STAC_9200_DELL_M21] = "dell-m21",
1578 [STAC_9200_DELL_M22] = "dell-m22",
1579 [STAC_9200_DELL_M23] = "dell-m23",
1580 [STAC_9200_DELL_M24] = "dell-m24",
1581 [STAC_9200_DELL_M25] = "dell-m25",
1582 [STAC_9200_DELL_M26] = "dell-m26",
1583 [STAC_9200_DELL_M27] = "dell-m27",
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001584 [STAC_9200_M4] = "gateway-m4",
1585 [STAC_9200_M4_2] = "gateway-m4-2",
Takashi Iwai117f2572008-03-18 09:53:23 +01001586 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001587};
1588
1589static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1590 /* SigmaTel reference board */
1591 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1592 "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001593 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1594 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001595 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001596 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1597 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001598 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001599 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1600 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1601 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1602 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1603 "unknown Dell", STAC_9200_DELL_D22),
1604 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1605 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001606 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001607 "Dell Latitude D620", STAC_9200_DELL_M22),
1608 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1609 "unknown Dell", STAC_9200_DELL_D23),
1610 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1611 "unknown Dell", STAC_9200_DELL_D23),
1612 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1613 "unknown Dell", STAC_9200_DELL_M22),
1614 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1615 "unknown Dell", STAC_9200_DELL_M24),
1616 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1617 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001618 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001619 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001620 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001621 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001622 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001623 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001624 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001625 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001626 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001627 "Dell Precision M90", STAC_9200_DELL_M23),
1628 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1629 "unknown Dell", STAC_9200_DELL_M22),
1630 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1631 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001632 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001633 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001634 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001635 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1636 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1637 "unknown Dell", STAC_9200_DELL_D23),
1638 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1639 "unknown Dell", STAC_9200_DELL_D23),
1640 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1641 "unknown Dell", STAC_9200_DELL_D21),
1642 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1643 "unknown Dell", STAC_9200_DELL_D23),
1644 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1645 "unknown Dell", STAC_9200_DELL_D21),
1646 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1647 "unknown Dell", STAC_9200_DELL_M25),
1648 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1649 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001650 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001651 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1652 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1653 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001654 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001655 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001656 /* Gateway machines needs EAPD to be set on resume */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001657 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1658 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1659 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
Tobin Davisbf277782008-02-03 20:31:47 +01001660 /* OQO Mobile */
1661 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001662 {} /* terminator */
1663};
1664
Tobin Davis8e21c342007-01-08 11:04:17 +01001665static unsigned int ref925x_pin_configs[8] = {
1666 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001667 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001668};
1669
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001670static unsigned int stac925xM1_pin_configs[8] = {
1671 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1672 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001673};
1674
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001675static unsigned int stac925xM1_2_pin_configs[8] = {
1676 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1677 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1678};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001679
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001680static unsigned int stac925xM2_pin_configs[8] = {
1681 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1682 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis2c11f952007-05-17 09:36:34 +02001683};
1684
Tobin Davis8e21c342007-01-08 11:04:17 +01001685static unsigned int stac925xM2_2_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001686 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1687 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1688};
1689
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001690static unsigned int stac925xM3_pin_configs[8] = {
1691 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1692 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1693};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001694
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001695static unsigned int stac925xM5_pin_configs[8] = {
1696 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1697 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1698};
1699
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001700static unsigned int stac925xM6_pin_configs[8] = {
1701 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1702 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
Tobin Davis8e21c342007-01-08 11:04:17 +01001703};
1704
1705static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1706 [STAC_REF] = ref925x_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001707 [STAC_M1] = stac925xM1_pin_configs,
1708 [STAC_M1_2] = stac925xM1_2_pin_configs,
1709 [STAC_M2] = stac925xM2_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001710 [STAC_M2_2] = stac925xM2_2_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001711 [STAC_M3] = stac925xM3_pin_configs,
1712 [STAC_M5] = stac925xM5_pin_configs,
1713 [STAC_M6] = stac925xM6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001714};
1715
1716static const char *stac925x_models[STAC_925x_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001717 [STAC_925x_AUTO] = "auto",
Tobin Davis8e21c342007-01-08 11:04:17 +01001718 [STAC_REF] = "ref",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001719 [STAC_M1] = "m1",
1720 [STAC_M1_2] = "m1-2",
1721 [STAC_M2] = "m2",
Tobin Davis8e21c342007-01-08 11:04:17 +01001722 [STAC_M2_2] = "m2-2",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001723 [STAC_M3] = "m3",
1724 [STAC_M5] = "m5",
1725 [STAC_M6] = "m6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001726};
1727
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001728static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001729 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1730 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1731 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1732 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001733 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001734 /* Not sure about the brand name for those */
1735 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1736 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1737 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1738 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001739 {} /* terminator */
Tobin Davis8e21c342007-01-08 11:04:17 +01001740};
1741
1742static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1743 /* SigmaTel reference board */
1744 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001745 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001746 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001747
1748 /* Default table for unknown ID */
1749 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1750
Tobin Davis8e21c342007-01-08 11:04:17 +01001751 {} /* terminator */
1752};
1753
Matthew Ranostaya7662642008-02-21 07:51:14 +01001754static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001755 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1756 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1757 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001758 0x01452050,
1759};
1760
1761static unsigned int dell_m6_pin_configs[13] = {
1762 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001763 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001764 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1765 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001766};
1767
1768static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001769 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001770 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1771 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1772 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001773 [STAC_DELL_EQ] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001774};
1775
1776static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001777 [STAC_92HD73XX_AUTO] = "auto",
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01001778 [STAC_92HD73XX_NO_JD] = "no-jd",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001779 [STAC_92HD73XX_REF] = "ref",
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001780 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1781 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1782 [STAC_DELL_M6_BOTH] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001783 [STAC_DELL_EQ] = "dell-eq",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001784};
1785
1786static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1787 /* SigmaTel reference board */
1788 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001789 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001790 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1791 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001792 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001793 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001794 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001795 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001796 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001797 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001798 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001799 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001800 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001801 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001802 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001803 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001804 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001805 "unknown Dell", STAC_DELL_M6_DMIC),
1806 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1807 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01001808 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001809 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Joerg Schirottkefa620e92008-12-19 08:13:49 +01001810 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1811 "Dell Studio 17", STAC_DELL_M6_DMIC),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001812 {} /* terminator */
1813};
1814
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001815static unsigned int ref92hd83xxx_pin_configs[10] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001816 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1817 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001818 0x01451160, 0x98560170,
1819};
1820
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001821static unsigned int dell_s14_pin_configs[10] = {
1822 0x02214030, 0x02211010, 0x02a19020, 0x01014050,
1823 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160,
1824 0x40f000f0, 0x40f000f0,
1825};
1826
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001827static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1828 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001829 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001830 [STAC_DELL_S14] = dell_s14_pin_configs,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001831};
1832
1833static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001834 [STAC_92HD83XXX_AUTO] = "auto",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001835 [STAC_92HD83XXX_REF] = "ref",
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001836 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001837 [STAC_DELL_S14] = "dell-s14",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001838};
1839
1840static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1841 /* SigmaTel reference board */
1842 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Takashi Iwaif9d088b2009-01-13 11:54:49 +01001843 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001844 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1845 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001846 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1847 "unknown Dell", STAC_DELL_S14),
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -02001848 {} /* terminator */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001849};
1850
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001851static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001852 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001853 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001854 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1855 0x00000000
Matthew Ranostaye035b842007-11-06 11:53:55 +01001856};
1857
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001858static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001859 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001860 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001861 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1862 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001863};
1864
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001865static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001866 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1867 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001868 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1869 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001870};
1871
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001872static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001873 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1874 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001875 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1876 0x00000000
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001877};
1878
Matthew Ranostaye035b842007-11-06 11:53:55 +01001879static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1880 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001881 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1882 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001883 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001884 [STAC_HP_M4] = NULL,
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001885 [STAC_HP_DV5] = NULL,
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001886 [STAC_HP_HDX] = NULL,
James Gardiner514bf542009-05-03 04:00:44 -04001887 [STAC_HP_DV4_1222NR] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001888};
1889
1890static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001891 [STAC_92HD71BXX_AUTO] = "auto",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001892 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001893 [STAC_DELL_M4_1] = "dell-m4-1",
1894 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001895 [STAC_DELL_M4_3] = "dell-m4-3",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001896 [STAC_HP_M4] = "hp-m4",
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001897 [STAC_HP_DV5] = "hp-dv5",
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001898 [STAC_HP_HDX] = "hp-hdx",
James Gardiner514bf542009-05-03 04:00:44 -04001899 [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001900};
1901
1902static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1903 /* SigmaTel reference board */
1904 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1905 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001906 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1907 "DFI LanParty", STAC_92HD71BXX_REF),
James Gardiner514bf542009-05-03 04:00:44 -04001908 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
1909 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
Takashi Iwai58d83952009-03-13 17:04:34 +01001910 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1911 "HP", STAC_HP_DV5),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001912 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
1913 "HP dv4-7", STAC_HP_DV5),
1914 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1915 "HP dv4-7", STAC_HP_DV5),
Takashi Iwai6fce61a2009-03-10 07:48:57 +01001916 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1917 "HP HDX", STAC_HP_HDX), /* HDX18 */
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001918 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001919 "HP mini 1000", STAC_HP_M4),
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001920 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
Takashi Iwai6fce61a2009-03-10 07:48:57 +01001921 "HP HDX", STAC_HP_HDX), /* HDX16 */
Matthew Ranostaya7662642008-02-21 07:51:14 +01001922 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1923 "unknown Dell", STAC_DELL_M4_1),
1924 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1925 "unknown Dell", STAC_DELL_M4_1),
1926 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1927 "unknown Dell", STAC_DELL_M4_1),
1928 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1929 "unknown Dell", STAC_DELL_M4_1),
1930 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1931 "unknown Dell", STAC_DELL_M4_1),
1932 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1933 "unknown Dell", STAC_DELL_M4_1),
1934 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1935 "unknown Dell", STAC_DELL_M4_1),
1936 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1937 "unknown Dell", STAC_DELL_M4_2),
1938 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1939 "unknown Dell", STAC_DELL_M4_2),
1940 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1941 "unknown Dell", STAC_DELL_M4_2),
1942 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1943 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001944 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1945 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001946 {} /* terminator */
1947};
1948
Matt Porter403d1942005-11-29 15:00:51 +01001949static unsigned int ref922x_pin_configs[10] = {
1950 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1951 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001952 0x40000100, 0x40000100,
1953};
1954
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001955/*
1956 STAC 922X pin configs for
1957 102801A7
1958 102801AB
1959 102801A9
1960 102801D1
1961 102801D2
1962*/
1963static unsigned int dell_922x_d81_pin_configs[10] = {
1964 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1965 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1966 0x01813122, 0x400001f2,
1967};
1968
1969/*
1970 STAC 922X pin configs for
1971 102801AC
1972 102801D0
1973*/
1974static unsigned int dell_922x_d82_pin_configs[10] = {
1975 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1976 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1977 0x01813122, 0x400001f1,
1978};
1979
1980/*
1981 STAC 922X pin configs for
1982 102801BF
1983*/
1984static unsigned int dell_922x_m81_pin_configs[10] = {
1985 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1986 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1987 0x40C003f1, 0x405003f0,
1988};
1989
1990/*
1991 STAC 9221 A1 pin configs for
1992 102801D7 (Dell XPS M1210)
1993*/
1994static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001995 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1996 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001997 0x508003f3, 0x405003f4,
1998};
1999
Matt Porter403d1942005-11-29 15:00:51 +01002000static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01002001 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01002002 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2003 0x02a19120, 0x40000100,
2004};
2005
2006static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01002007 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
2008 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01002009 0x02a19320, 0x40000100,
2010};
2011
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002012static unsigned int intel_mac_v1_pin_configs[10] = {
2013 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
2014 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01002015 0x400000fc, 0x400000fb,
2016};
2017
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002018static unsigned int intel_mac_v2_pin_configs[10] = {
2019 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
2020 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02002021 0x400000fc, 0x400000fb,
2022};
2023
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002024static unsigned int intel_mac_v3_pin_configs[10] = {
2025 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
2026 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
2027 0x400000fc, 0x400000fb,
2028};
2029
2030static unsigned int intel_mac_v4_pin_configs[10] = {
2031 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
2032 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
2033 0x400000fc, 0x400000fb,
2034};
2035
2036static unsigned int intel_mac_v5_pin_configs[10] = {
2037 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
2038 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
2039 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02002040};
2041
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002042static unsigned int ecs202_pin_configs[10] = {
2043 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
2044 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
2045 0x9037012e, 0x40e000f2,
2046};
Takashi Iwai76c08822007-06-19 12:17:42 +02002047
Takashi Iwai19039bd2006-06-28 15:52:16 +02002048static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002049 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02002050 [STAC_D945GTP3] = d945gtp3_pin_configs,
2051 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002052 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
2053 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
2054 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
2055 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
2056 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08002057 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002058 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002059 [STAC_MACMINI] = intel_mac_v3_pin_configs,
2060 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
2061 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
2062 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
2063 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
2064 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002065 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002066 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
2067 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
2068 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
2069 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01002070};
2071
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002072static const char *stac922x_models[STAC_922X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002073 [STAC_922X_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002074 [STAC_D945_REF] = "ref",
2075 [STAC_D945GTP5] = "5stack",
2076 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002077 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
2078 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
2079 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
2080 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
2081 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08002082 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002083 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002084 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01002085 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01002086 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
2087 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02002088 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02002089 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002090 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002091 [STAC_922X_DELL_D81] = "dell-d81",
2092 [STAC_922X_DELL_D82] = "dell-d82",
2093 [STAC_922X_DELL_M81] = "dell-m81",
2094 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002095};
2096
2097static struct snd_pci_quirk stac922x_cfg_tbl[] = {
2098 /* SigmaTel reference board */
2099 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2100 "DFI LanParty", STAC_D945_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002101 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2102 "DFI LanParty", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002103 /* Intel 945G based systems */
2104 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2105 "Intel D945G", STAC_D945GTP3),
2106 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2107 "Intel D945G", STAC_D945GTP3),
2108 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2109 "Intel D945G", STAC_D945GTP3),
2110 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2111 "Intel D945G", STAC_D945GTP3),
2112 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2113 "Intel D945G", STAC_D945GTP3),
2114 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2115 "Intel D945G", STAC_D945GTP3),
2116 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2117 "Intel D945G", STAC_D945GTP3),
2118 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2119 "Intel D945G", STAC_D945GTP3),
2120 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2121 "Intel D945G", STAC_D945GTP3),
2122 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2123 "Intel D945G", STAC_D945GTP3),
2124 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2125 "Intel D945G", STAC_D945GTP3),
2126 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2127 "Intel D945G", STAC_D945GTP3),
2128 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2129 "Intel D945G", STAC_D945GTP3),
2130 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2131 "Intel D945G", STAC_D945GTP3),
2132 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2133 "Intel D945G", STAC_D945GTP3),
2134 /* Intel D945G 5-stack systems */
2135 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2136 "Intel D945G", STAC_D945GTP5),
2137 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2138 "Intel D945G", STAC_D945GTP5),
2139 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2140 "Intel D945G", STAC_D945GTP5),
2141 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2142 "Intel D945G", STAC_D945GTP5),
2143 /* Intel 945P based systems */
2144 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2145 "Intel D945P", STAC_D945GTP3),
2146 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2147 "Intel D945P", STAC_D945GTP3),
2148 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2149 "Intel D945P", STAC_D945GTP3),
2150 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2151 "Intel D945P", STAC_D945GTP3),
2152 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2153 "Intel D945P", STAC_D945GTP3),
2154 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2155 "Intel D945P", STAC_D945GTP5),
Takashi Iwai8056d472009-01-23 09:09:43 +01002156 /* other intel */
2157 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2158 "Intel D945", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002159 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08002160 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002161 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08002162 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002163 /* Dell systems */
2164 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2165 "unknown Dell", STAC_922X_DELL_D81),
2166 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2167 "unknown Dell", STAC_922X_DELL_D81),
2168 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2169 "unknown Dell", STAC_922X_DELL_D81),
2170 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2171 "unknown Dell", STAC_922X_DELL_D82),
2172 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2173 "unknown Dell", STAC_922X_DELL_M81),
2174 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2175 "unknown Dell", STAC_922X_DELL_D82),
2176 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2177 "unknown Dell", STAC_922X_DELL_D81),
2178 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2179 "unknown Dell", STAC_922X_DELL_D81),
2180 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2181 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002182 /* ECS/PC Chips boards */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002183 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
Herton Ronaldo Krzesinski8663ae52009-02-08 19:50:34 -02002184 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01002185 {} /* terminator */
2186};
2187
Matt Porter3cc08dc2006-01-23 15:27:49 +01002188static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002189 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2190 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2191 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2192 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002193};
2194
Tobin Davis93ed1502006-09-01 21:03:12 +02002195static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002196 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2197 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2198 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2199 0x40000100, 0x40000100
2200};
2201
Tobin Davis93ed1502006-09-01 21:03:12 +02002202static unsigned int d965_5st_pin_configs[14] = {
2203 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2204 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2205 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2206 0x40000100, 0x40000100
2207};
2208
Takashi Iwai679d92e2009-05-24 19:00:08 +02002209static unsigned int d965_5st_no_fp_pin_configs[14] = {
2210 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
2211 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2212 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2213 0x40000100, 0x40000100
2214};
2215
Tobin Davis4ff076e2007-08-07 11:48:12 +02002216static unsigned int dell_3st_pin_configs[14] = {
2217 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2218 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002219 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002220 0x40c003fc, 0x40000100
2221};
2222
Tobin Davis93ed1502006-09-01 21:03:12 +02002223static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002224 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002225 [STAC_D965_REF] = ref927x_pin_configs,
2226 [STAC_D965_3ST] = d965_3st_pin_configs,
2227 [STAC_D965_5ST] = d965_5st_pin_configs,
Takashi Iwai679d92e2009-05-24 19:00:08 +02002228 [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002229 [STAC_DELL_3ST] = dell_3st_pin_configs,
2230 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002231};
2232
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002233static const char *stac927x_models[STAC_927X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002234 [STAC_927X_AUTO] = "auto",
Takashi Iwaie28d8322008-12-17 13:48:29 +01002235 [STAC_D965_REF_NO_JD] = "ref-no-jd",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002236 [STAC_D965_REF] = "ref",
2237 [STAC_D965_3ST] = "3stack",
2238 [STAC_D965_5ST] = "5stack",
Takashi Iwai679d92e2009-05-24 19:00:08 +02002239 [STAC_D965_5ST_NO_FP] = "5stack-no-fp",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002240 [STAC_DELL_3ST] = "dell-3stack",
2241 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002242};
2243
2244static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2245 /* SigmaTel reference board */
2246 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2247 "DFI LanParty", STAC_D965_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002248 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2249 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002250 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002251 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2252 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002253 /* 965 based 3 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002254 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2255 "Intel D965", STAC_D965_3ST),
2256 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2257 "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002258 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002259 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002260 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002261 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2262 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002263 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002264 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2265 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002266 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02002267 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002268 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2269 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2270 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2271 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002272 /* 965 based 5 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002273 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2274 "Intel D965", STAC_D965_5ST),
2275 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2276 "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002277 {} /* terminator */
2278};
2279
Matt Porterf3302a52006-07-31 12:49:34 +02002280static unsigned int ref9205_pin_configs[12] = {
2281 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002282 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002283 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002284};
2285
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002286/*
2287 STAC 9205 pin configs for
2288 102801F1
2289 102801F2
2290 102801FC
2291 102801FD
2292 10280204
2293 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002294 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002295*/
2296static unsigned int dell_9205_m42_pin_configs[12] = {
2297 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2298 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2299 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2300};
2301
2302/*
2303 STAC 9205 pin configs for
2304 102801F9
2305 102801FA
2306 102801FE
2307 102801FF (Dell Precision M4300)
2308 10280206
2309 10280200
2310 10280201
2311*/
2312static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002313 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2314 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2315 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2316};
2317
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002318static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002319 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2320 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2321 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2322};
2323
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002324static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002325 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002326 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2327 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2328 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Takashi Iwaid9a42682009-01-22 17:40:18 +01002329 [STAC_9205_EAPD] = NULL,
Matt Porterf3302a52006-07-31 12:49:34 +02002330};
2331
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002332static const char *stac9205_models[STAC_9205_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002333 [STAC_9205_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002334 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002335 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002336 [STAC_9205_DELL_M43] = "dell-m43",
2337 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaid9a42682009-01-22 17:40:18 +01002338 [STAC_9205_EAPD] = "eapd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002339};
2340
2341static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2342 /* SigmaTel reference board */
2343 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2344 "DFI LanParty", STAC_9205_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002345 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2346 "DFI LanParty", STAC_9205_REF),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002347 /* Dell */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002348 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2349 "unknown Dell", STAC_9205_DELL_M42),
2350 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2351 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002352 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002353 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002354 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2355 "Dell Precision", STAC_9205_DELL_M43),
2356 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2357 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002358 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2359 "unknown Dell", STAC_9205_DELL_M42),
2360 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2361 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002362 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2363 "Dell Precision", STAC_9205_DELL_M43),
2364 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002365 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002366 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2367 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002368 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2369 "Dell Precision", STAC_9205_DELL_M43),
2370 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2371 "Dell Precision", STAC_9205_DELL_M43),
2372 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2373 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002374 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2375 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002376 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2377 "Dell Vostro 1500", STAC_9205_DELL_M42),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002378 /* Gateway */
2379 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
Matt Porterf3302a52006-07-31 12:49:34 +02002380 {} /* terminator */
2381};
2382
Takashi Iwai330ee992009-02-20 14:33:36 +01002383static void stac92xx_set_config_regs(struct hda_codec *codec,
2384 unsigned int *pincfgs)
Matt2f2f4252005-04-13 14:45:30 +02002385{
2386 int i;
2387 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002388
Takashi Iwai330ee992009-02-20 14:33:36 +01002389 if (!pincfgs)
2390 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002391
Matthew Ranostay87d48362007-07-17 11:52:24 +02002392 for (i = 0; i < spec->num_pins; i++)
Takashi Iwai330ee992009-02-20 14:33:36 +01002393 if (spec->pin_nids[i] && pincfgs[i])
2394 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2395 pincfgs[i]);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002396}
2397
Matt2f2f4252005-04-13 14:45:30 +02002398/*
2399 * Analog playback callbacks
2400 */
2401static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2402 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002403 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002404{
2405 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002406 if (spec->stream_delay)
2407 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002408 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2409 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002410}
2411
2412static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2413 struct hda_codec *codec,
2414 unsigned int stream_tag,
2415 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002416 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002417{
2418 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002419 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002420}
2421
2422static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2423 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002424 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002425{
2426 struct sigmatel_spec *spec = codec->spec;
2427 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2428}
2429
2430/*
Mattdabbed62005-06-14 10:19:34 +02002431 * Digital playback callbacks
2432 */
2433static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2434 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002435 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002436{
2437 struct sigmatel_spec *spec = codec->spec;
2438 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2439}
2440
2441static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2442 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002443 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002444{
2445 struct sigmatel_spec *spec = codec->spec;
2446 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2447}
2448
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002449static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2450 struct hda_codec *codec,
2451 unsigned int stream_tag,
2452 unsigned int format,
2453 struct snd_pcm_substream *substream)
2454{
2455 struct sigmatel_spec *spec = codec->spec;
2456 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2457 stream_tag, format, substream);
2458}
2459
Takashi Iwai9411e212009-02-13 11:32:28 +01002460static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2461 struct hda_codec *codec,
2462 struct snd_pcm_substream *substream)
2463{
2464 struct sigmatel_spec *spec = codec->spec;
2465 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2466}
2467
Mattdabbed62005-06-14 10:19:34 +02002468
2469/*
Matt2f2f4252005-04-13 14:45:30 +02002470 * Analog capture callbacks
2471 */
2472static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2473 struct hda_codec *codec,
2474 unsigned int stream_tag,
2475 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002476 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002477{
2478 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002479 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002480
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002481 if (spec->powerdown_adcs) {
2482 msleep(40);
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002483 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002484 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2485 }
2486 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002487 return 0;
2488}
2489
2490static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2491 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002492 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002493{
2494 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002495 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002496
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002497 snd_hda_codec_cleanup_stream(codec, nid);
2498 if (spec->powerdown_adcs)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002499 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002500 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002501 return 0;
2502}
2503
Mattdabbed62005-06-14 10:19:34 +02002504static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2505 .substreams = 1,
2506 .channels_min = 2,
2507 .channels_max = 2,
2508 /* NID is set in stac92xx_build_pcms */
2509 .ops = {
2510 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002511 .close = stac92xx_dig_playback_pcm_close,
Takashi Iwai9411e212009-02-13 11:32:28 +01002512 .prepare = stac92xx_dig_playback_pcm_prepare,
2513 .cleanup = stac92xx_dig_playback_pcm_cleanup
Mattdabbed62005-06-14 10:19:34 +02002514 },
2515};
2516
2517static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2518 .substreams = 1,
2519 .channels_min = 2,
2520 .channels_max = 2,
2521 /* NID is set in stac92xx_build_pcms */
2522};
2523
Matt2f2f4252005-04-13 14:45:30 +02002524static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2525 .substreams = 1,
2526 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002527 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002528 .nid = 0x02, /* NID to query formats and rates */
2529 .ops = {
2530 .open = stac92xx_playback_pcm_open,
2531 .prepare = stac92xx_playback_pcm_prepare,
2532 .cleanup = stac92xx_playback_pcm_cleanup
2533 },
2534};
2535
Matt Porter3cc08dc2006-01-23 15:27:49 +01002536static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2537 .substreams = 1,
2538 .channels_min = 2,
2539 .channels_max = 2,
2540 .nid = 0x06, /* NID to query formats and rates */
2541 .ops = {
2542 .open = stac92xx_playback_pcm_open,
2543 .prepare = stac92xx_playback_pcm_prepare,
2544 .cleanup = stac92xx_playback_pcm_cleanup
2545 },
2546};
2547
Matt2f2f4252005-04-13 14:45:30 +02002548static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002549 .channels_min = 2,
2550 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002551 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002552 .ops = {
2553 .prepare = stac92xx_capture_pcm_prepare,
2554 .cleanup = stac92xx_capture_pcm_cleanup
2555 },
2556};
2557
2558static int stac92xx_build_pcms(struct hda_codec *codec)
2559{
2560 struct sigmatel_spec *spec = codec->spec;
2561 struct hda_pcm *info = spec->pcm_rec;
2562
2563 codec->num_pcms = 1;
2564 codec->pcm_info = info;
2565
Mattc7d4b2f2005-06-27 14:59:41 +02002566 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002567 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Takashi Iwai00a602d2009-01-23 11:55:42 +01002568 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2569 spec->multiout.dac_nids[0];
Matt2f2f4252005-04-13 14:45:30 +02002570 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002571 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002572 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002573
2574 if (spec->alt_switch) {
2575 codec->num_pcms++;
2576 info++;
2577 info->name = "STAC92xx Analog Alt";
2578 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2579 }
Matt2f2f4252005-04-13 14:45:30 +02002580
Mattdabbed62005-06-14 10:19:34 +02002581 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2582 codec->num_pcms++;
2583 info++;
2584 info->name = "STAC92xx Digital";
Takashi Iwai0852d7a2009-02-11 11:35:15 +01002585 info->pcm_type = spec->autocfg.dig_out_type[0];
Mattdabbed62005-06-14 10:19:34 +02002586 if (spec->multiout.dig_out_nid) {
2587 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2588 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2589 }
2590 if (spec->dig_in_nid) {
2591 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2592 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2593 }
2594 }
2595
Matt2f2f4252005-04-13 14:45:30 +02002596 return 0;
2597}
2598
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002599static unsigned int stac92xx_get_default_vref(struct hda_codec *codec,
2600 hda_nid_t nid)
Takashi Iwaic960a032006-03-23 17:06:28 +01002601{
Takashi Iwai1327a322009-03-23 13:07:47 +01002602 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01002603 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2604 if (pincap & AC_PINCAP_VREF_100)
2605 return AC_PINCTL_VREF_100;
2606 if (pincap & AC_PINCAP_VREF_80)
2607 return AC_PINCTL_VREF_80;
2608 if (pincap & AC_PINCAP_VREF_50)
2609 return AC_PINCTL_VREF_50;
2610 if (pincap & AC_PINCAP_VREF_GRD)
2611 return AC_PINCTL_VREF_GRD;
2612 return 0;
2613}
2614
Matt Porter403d1942005-11-29 15:00:51 +01002615static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2616
2617{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002618 snd_hda_codec_write_cache(codec, nid, 0,
2619 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002620}
2621
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002622#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2623
2624static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2625 struct snd_ctl_elem_value *ucontrol)
2626{
2627 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2628 struct sigmatel_spec *spec = codec->spec;
2629
Takashi Iwaid7a89432008-11-12 09:48:04 +01002630 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002631 return 0;
2632}
2633
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002634static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
2635 unsigned char type);
2636
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002637static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2638 struct snd_ctl_elem_value *ucontrol)
2639{
2640 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2641 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002642 int nid = kcontrol->private_value;
2643
2644 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002645
2646 /* check to be sure that the ports are upto date with
2647 * switch changes
2648 */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002649 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002650
2651 return 1;
2652}
2653
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002654static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
2655 struct snd_ctl_elem_info *uinfo)
2656{
2657 int i;
2658 static char *texts[] = {
2659 "Mic In", "Line In", "Line Out"
2660 };
2661
2662 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2663 struct sigmatel_spec *spec = codec->spec;
2664 hda_nid_t nid = kcontrol->private_value;
2665
2666 if (nid == spec->mic_switch || nid == spec->line_switch)
2667 i = 3;
2668 else
2669 i = 2;
2670
2671 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2672 uinfo->value.enumerated.items = i;
2673 uinfo->count = 1;
2674 if (uinfo->value.enumerated.item >= i)
2675 uinfo->value.enumerated.item = i-1;
2676 strcpy(uinfo->value.enumerated.name,
2677 texts[uinfo->value.enumerated.item]);
2678
2679 return 0;
2680}
2681
2682static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
2683 struct snd_ctl_elem_value *ucontrol)
2684{
2685 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2686 hda_nid_t nid = kcontrol->private_value;
2687 unsigned int vref = stac92xx_vref_get(codec, nid);
2688
2689 if (vref == stac92xx_get_default_vref(codec, nid))
2690 ucontrol->value.enumerated.item[0] = 0;
2691 else if (vref == AC_PINCTL_VREF_GRD)
2692 ucontrol->value.enumerated.item[0] = 1;
2693 else if (vref == AC_PINCTL_VREF_HIZ)
2694 ucontrol->value.enumerated.item[0] = 2;
2695
2696 return 0;
2697}
2698
2699static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
2700 struct snd_ctl_elem_value *ucontrol)
2701{
2702 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2703 unsigned int new_vref = 0;
2704 unsigned int error;
2705 hda_nid_t nid = kcontrol->private_value;
2706
2707 if (ucontrol->value.enumerated.item[0] == 0)
2708 new_vref = stac92xx_get_default_vref(codec, nid);
2709 else if (ucontrol->value.enumerated.item[0] == 1)
2710 new_vref = AC_PINCTL_VREF_GRD;
2711 else if (ucontrol->value.enumerated.item[0] == 2)
2712 new_vref = AC_PINCTL_VREF_HIZ;
2713 else
2714 return 0;
2715
2716 if (new_vref != stac92xx_vref_get(codec, nid)) {
2717 error = stac92xx_vref_set(codec, nid, new_vref);
2718 return error;
2719 }
2720
2721 return 0;
2722}
2723
2724static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
2725 struct snd_ctl_elem_info *uinfo)
2726{
2727 static char *texts[2];
2728 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2729 struct sigmatel_spec *spec = codec->spec;
2730
2731 if (kcontrol->private_value == spec->line_switch)
2732 texts[0] = "Line In";
2733 else
2734 texts[0] = "Mic In";
2735 texts[1] = "Line Out";
2736 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2737 uinfo->value.enumerated.items = 2;
2738 uinfo->count = 1;
2739
2740 if (uinfo->value.enumerated.item >= 2)
2741 uinfo->value.enumerated.item = 1;
2742 strcpy(uinfo->value.enumerated.name,
2743 texts[uinfo->value.enumerated.item]);
2744
2745 return 0;
2746}
Matt Porter403d1942005-11-29 15:00:51 +01002747
2748static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2749{
2750 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2751 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002752 hda_nid_t nid = kcontrol->private_value;
2753 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
Matt Porter403d1942005-11-29 15:00:51 +01002754
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002755 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
Matt Porter403d1942005-11-29 15:00:51 +01002756 return 0;
2757}
2758
2759static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2760{
2761 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2762 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002763 hda_nid_t nid = kcontrol->private_value;
2764 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2765 unsigned short val = !!ucontrol->value.enumerated.item[0];
Matt Porter403d1942005-11-29 15:00:51 +01002766
2767 spec->io_switch[io_idx] = val;
2768
2769 if (val)
2770 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002771 else {
2772 unsigned int pinctl = AC_PINCTL_IN_EN;
2773 if (io_idx) /* set VREF for mic */
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002774 pinctl |= stac92xx_get_default_vref(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01002775 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2776 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002777
2778 /* check the auto-mute again: we need to mute/unmute the speaker
2779 * appropriately according to the pin direction
2780 */
2781 if (spec->hp_detect)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002782 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
Jiang Zhe40c1d302007-11-12 13:05:16 +01002783
Matt Porter403d1942005-11-29 15:00:51 +01002784 return 1;
2785}
2786
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002787#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2788
2789static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2790 struct snd_ctl_elem_value *ucontrol)
2791{
2792 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2793 struct sigmatel_spec *spec = codec->spec;
2794
2795 ucontrol->value.integer.value[0] = spec->clfe_swap;
2796 return 0;
2797}
2798
2799static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2800 struct snd_ctl_elem_value *ucontrol)
2801{
2802 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2803 struct sigmatel_spec *spec = codec->spec;
2804 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002805 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002806
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002807 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002808 return 0;
2809
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002810 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002811
2812 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2813 spec->clfe_swap ? 0x4 : 0x0);
2814
2815 return 1;
2816}
2817
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002818#define STAC_CODEC_HP_SWITCH(xname) \
2819 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2820 .name = xname, \
2821 .index = 0, \
2822 .info = stac92xx_hp_switch_info, \
2823 .get = stac92xx_hp_switch_get, \
2824 .put = stac92xx_hp_switch_put, \
2825 }
2826
Matt Porter403d1942005-11-29 15:00:51 +01002827#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2828 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2829 .name = xname, \
2830 .index = 0, \
2831 .info = stac92xx_io_switch_info, \
2832 .get = stac92xx_io_switch_get, \
2833 .put = stac92xx_io_switch_put, \
2834 .private_value = xpval, \
2835 }
2836
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002837#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2838 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2839 .name = xname, \
2840 .index = 0, \
2841 .info = stac92xx_clfe_switch_info, \
2842 .get = stac92xx_clfe_switch_get, \
2843 .put = stac92xx_clfe_switch_put, \
2844 .private_value = xpval, \
2845 }
Matt Porter403d1942005-11-29 15:00:51 +01002846
Mattc7d4b2f2005-06-27 14:59:41 +02002847enum {
2848 STAC_CTL_WIDGET_VOL,
2849 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002850 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002851 STAC_CTL_WIDGET_AMP_MUX,
2852 STAC_CTL_WIDGET_AMP_VOL,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002853 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002854 STAC_CTL_WIDGET_IO_SWITCH,
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02002855 STAC_CTL_WIDGET_CLFE_SWITCH,
2856 STAC_CTL_WIDGET_DC_BIAS
Mattc7d4b2f2005-06-27 14:59:41 +02002857};
2858
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002859static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002860 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2861 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002862 STAC_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002863 STAC_AMP_MUX,
2864 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002865 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002866 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002867 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02002868 DC_BIAS(NULL, 0, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002869};
2870
2871/* add dynamic controls */
Takashi Iwaie3c75962009-01-23 11:57:22 +01002872static struct snd_kcontrol_new *
2873stac_control_new(struct sigmatel_spec *spec,
2874 struct snd_kcontrol_new *ktemp,
2875 const char *name)
Mattc7d4b2f2005-06-27 14:59:41 +02002876{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002877 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002878
Takashi Iwai603c4012008-07-30 15:01:44 +02002879 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2880 knew = snd_array_new(&spec->kctls);
2881 if (!knew)
Takashi Iwaie3c75962009-01-23 11:57:22 +01002882 return NULL;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002883 *knew = *ktemp;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002884 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002885 if (!knew->name) {
2886 /* roolback */
2887 memset(knew, 0, sizeof(*knew));
2888 spec->kctls.alloced--;
2889 return NULL;
2890 }
2891 return knew;
2892}
2893
2894static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2895 struct snd_kcontrol_new *ktemp,
2896 int idx, const char *name,
2897 unsigned long val)
2898{
2899 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
2900 if (!knew)
Mattc7d4b2f2005-06-27 14:59:41 +02002901 return -ENOMEM;
Takashi Iwaie3c75962009-01-23 11:57:22 +01002902 knew->index = idx;
Mattc7d4b2f2005-06-27 14:59:41 +02002903 knew->private_value = val;
Mattc7d4b2f2005-06-27 14:59:41 +02002904 return 0;
2905}
2906
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002907static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2908 int type, int idx, const char *name,
2909 unsigned long val)
2910{
2911 return stac92xx_add_control_temp(spec,
2912 &stac92xx_control_templates[type],
2913 idx, name, val);
2914}
2915
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002916
2917/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002918static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2919 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002920{
2921 return stac92xx_add_control_idx(spec, type, 0, name, val);
2922}
2923
Takashi Iwaie3c75962009-01-23 11:57:22 +01002924static struct snd_kcontrol_new stac_input_src_temp = {
2925 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2926 .name = "Input Source",
2927 .info = stac92xx_mux_enum_info,
2928 .get = stac92xx_mux_enum_get,
2929 .put = stac92xx_mux_enum_put,
2930};
2931
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002932static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
2933 hda_nid_t nid, int idx)
2934{
2935 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
2936 int control = 0;
2937 struct sigmatel_spec *spec = codec->spec;
2938 char name[22];
2939
2940 if (!((get_defcfg_connect(def_conf)) & AC_JACK_PORT_FIXED)) {
2941 if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
2942 && nid == spec->line_switch)
2943 control = STAC_CTL_WIDGET_IO_SWITCH;
2944 else if (snd_hda_query_pin_caps(codec, nid)
2945 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
2946 control = STAC_CTL_WIDGET_DC_BIAS;
2947 else if (nid == spec->mic_switch)
2948 control = STAC_CTL_WIDGET_IO_SWITCH;
2949 }
2950
2951 if (control) {
2952 strcpy(name, auto_pin_cfg_labels[idx]);
2953 return stac92xx_add_control(codec->spec, control,
2954 strcat(name, " Jack Mode"), nid);
2955 }
2956
2957 return 0;
2958}
2959
Takashi Iwaie3c75962009-01-23 11:57:22 +01002960static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2961{
2962 struct snd_kcontrol_new *knew;
2963 struct hda_input_mux *imux = &spec->private_imux;
2964
2965 if (!spec->num_adcs || imux->num_items <= 1)
2966 return 0; /* no need for input source control */
2967 knew = stac_control_new(spec, &stac_input_src_temp,
2968 stac_input_src_temp.name);
2969 if (!knew)
2970 return -ENOMEM;
2971 knew->count = spec->num_adcs;
2972 return 0;
2973}
2974
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002975/* check whether the line-input can be used as line-out */
2976static hda_nid_t check_line_out_switch(struct hda_codec *codec)
Matt Porter403d1942005-11-29 15:00:51 +01002977{
2978 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002979 struct auto_pin_cfg *cfg = &spec->autocfg;
2980 hda_nid_t nid;
2981 unsigned int pincap;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002982
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002983 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2984 return 0;
2985 nid = cfg->input_pins[AUTO_PIN_LINE];
Takashi Iwai1327a322009-03-23 13:07:47 +01002986 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002987 if (pincap & AC_PINCAP_OUT)
2988 return nid;
Matt Porter403d1942005-11-29 15:00:51 +01002989 return 0;
2990}
2991
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002992/* check whether the mic-input can be used as line-out */
2993static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2994{
2995 struct sigmatel_spec *spec = codec->spec;
2996 struct auto_pin_cfg *cfg = &spec->autocfg;
2997 unsigned int def_conf, pincap;
2998 unsigned int mic_pin;
2999
3000 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
3001 return 0;
3002 mic_pin = AUTO_PIN_MIC;
3003 for (;;) {
3004 hda_nid_t nid = cfg->input_pins[mic_pin];
Takashi Iwai330ee992009-02-20 14:33:36 +01003005 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003006 /* some laptops have an internal analog microphone
3007 * which can't be used as a output */
3008 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
Takashi Iwai1327a322009-03-23 13:07:47 +01003009 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003010 if (pincap & AC_PINCAP_OUT)
3011 return nid;
3012 }
3013 if (mic_pin == AUTO_PIN_MIC)
3014 mic_pin = AUTO_PIN_FRONT_MIC;
3015 else
3016 break;
3017 }
3018 return 0;
3019}
Steve Longerbeam7b043892007-05-03 20:50:03 +02003020
3021static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
3022{
3023 int i;
3024
3025 for (i = 0; i < spec->multiout.num_dacs; i++) {
3026 if (spec->multiout.dac_nids[i] == nid)
3027 return 1;
3028 }
3029
3030 return 0;
3031}
3032
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003033static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
3034{
3035 int i;
3036 if (is_in_dac_nids(spec, nid))
3037 return 1;
3038 for (i = 0; i < spec->autocfg.hp_outs; i++)
3039 if (spec->hp_dacs[i] == nid)
3040 return 1;
3041 for (i = 0; i < spec->autocfg.speaker_outs; i++)
3042 if (spec->speaker_dacs[i] == nid)
3043 return 1;
3044 return 0;
3045}
3046
3047static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
3048{
3049 struct sigmatel_spec *spec = codec->spec;
3050 int j, conn_len;
3051 hda_nid_t conn[HDA_MAX_CONNECTIONS];
3052 unsigned int wcaps, wtype;
3053
3054 conn_len = snd_hda_get_connections(codec, nid, conn,
3055 HDA_MAX_CONNECTIONS);
3056 for (j = 0; j < conn_len; j++) {
Takashi Iwai14bafe32009-03-23 16:35:39 +01003057 wcaps = get_wcaps(codec, conn[j]);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003058 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3059 /* we check only analog outputs */
3060 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
3061 continue;
3062 /* if this route has a free DAC, assign it */
3063 if (!check_all_dac_nids(spec, conn[j])) {
3064 if (conn_len > 1) {
3065 /* select this DAC in the pin's input mux */
3066 snd_hda_codec_write_cache(codec, nid, 0,
3067 AC_VERB_SET_CONNECT_SEL, j);
3068 }
3069 return conn[j];
3070 }
3071 }
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01003072 /* if all DACs are already assigned, connect to the primary DAC */
3073 if (conn_len > 1) {
3074 for (j = 0; j < conn_len; j++) {
3075 if (conn[j] == spec->multiout.dac_nids[0]) {
3076 snd_hda_codec_write_cache(codec, nid, 0,
3077 AC_VERB_SET_CONNECT_SEL, j);
3078 break;
3079 }
3080 }
3081 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003082 return 0;
3083}
3084
3085static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3086static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3087
Matt Porter3cc08dc2006-01-23 15:27:49 +01003088/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02003089 * Fill in the dac_nids table from the parsed pin configuration
3090 * This function only works when every pin in line_out_pins[]
3091 * contains atleast one DAC in its connection list. Some 92xx
3092 * codecs are not connected directly to a DAC, such as the 9200
3093 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01003094 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003095static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02003096{
3097 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003098 struct auto_pin_cfg *cfg = &spec->autocfg;
3099 int i;
3100 hda_nid_t nid, dac;
Steve Longerbeam7b043892007-05-03 20:50:03 +02003101
Mattc7d4b2f2005-06-27 14:59:41 +02003102 for (i = 0; i < cfg->line_outs; i++) {
3103 nid = cfg->line_out_pins[i];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003104 dac = get_unassigned_dac(codec, nid);
3105 if (!dac) {
Takashi Iwaidf802952007-07-02 19:18:00 +02003106 if (spec->multiout.num_dacs > 0) {
3107 /* we have already working output pins,
3108 * so let's drop the broken ones again
3109 */
3110 cfg->line_outs = spec->multiout.num_dacs;
3111 break;
3112 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02003113 /* error out, no available DAC found */
3114 snd_printk(KERN_ERR
3115 "%s: No available DAC for pin 0x%x\n",
3116 __func__, nid);
3117 return -ENODEV;
3118 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003119 add_spec_dacs(spec, dac);
3120 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02003121
Takashi Iwai139e0712009-03-06 12:10:41 +01003122 for (i = 0; i < cfg->hp_outs; i++) {
3123 nid = cfg->hp_pins[i];
3124 dac = get_unassigned_dac(codec, nid);
3125 if (dac) {
3126 if (!spec->multiout.hp_nid)
3127 spec->multiout.hp_nid = dac;
3128 else
3129 add_spec_extra_dacs(spec, dac);
3130 }
3131 spec->hp_dacs[i] = dac;
3132 }
3133
3134 for (i = 0; i < cfg->speaker_outs; i++) {
3135 nid = cfg->speaker_pins[i];
3136 dac = get_unassigned_dac(codec, nid);
3137 if (dac)
3138 add_spec_extra_dacs(spec, dac);
3139 spec->speaker_dacs[i] = dac;
3140 }
3141
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003142 /* add line-in as output */
3143 nid = check_line_out_switch(codec);
3144 if (nid) {
3145 dac = get_unassigned_dac(codec, nid);
3146 if (dac) {
3147 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
3148 nid, cfg->line_outs);
3149 cfg->line_out_pins[cfg->line_outs] = nid;
3150 cfg->line_outs++;
3151 spec->line_switch = nid;
3152 add_spec_dacs(spec, dac);
3153 }
3154 }
3155 /* add mic as output */
3156 nid = check_mic_out_switch(codec);
3157 if (nid) {
3158 dac = get_unassigned_dac(codec, nid);
3159 if (dac) {
3160 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
3161 nid, cfg->line_outs);
3162 cfg->line_out_pins[cfg->line_outs] = nid;
3163 cfg->line_outs++;
3164 spec->mic_switch = nid;
3165 add_spec_dacs(spec, dac);
Steve Longerbeam7b043892007-05-03 20:50:03 +02003166 }
Mattc7d4b2f2005-06-27 14:59:41 +02003167 }
3168
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003169 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
Steve Longerbeam7b043892007-05-03 20:50:03 +02003170 spec->multiout.num_dacs,
3171 spec->multiout.dac_nids[0],
3172 spec->multiout.dac_nids[1],
3173 spec->multiout.dac_nids[2],
3174 spec->multiout.dac_nids[3],
3175 spec->multiout.dac_nids[4]);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003176
Mattc7d4b2f2005-06-27 14:59:41 +02003177 return 0;
3178}
3179
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003180/* create volume control/switch for the given prefx type */
Takashi Iwai668b9652009-03-06 10:13:24 +01003181static int create_controls_idx(struct hda_codec *codec, const char *pfx,
3182 int idx, hda_nid_t nid, int chs)
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003183{
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003184 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003185 char name[32];
3186 int err;
3187
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003188 if (!spec->check_volume_offset) {
3189 unsigned int caps, step, nums, db_scale;
3190 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3191 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3192 AC_AMPCAP_STEP_SIZE_SHIFT;
3193 step = (step + 1) * 25; /* in .01dB unit */
3194 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3195 AC_AMPCAP_NUM_STEPS_SHIFT;
3196 db_scale = nums * step;
3197 /* if dB scale is over -64dB, and finer enough,
3198 * let's reduce it to half
3199 */
3200 if (db_scale > 6400 && nums >= 0x1f)
3201 spec->volume_offset = nums / 2;
3202 spec->check_volume_offset = 1;
3203 }
3204
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003205 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01003206 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003207 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3208 spec->volume_offset));
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003209 if (err < 0)
3210 return err;
3211 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01003212 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003213 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3214 if (err < 0)
3215 return err;
3216 return 0;
3217}
3218
Takashi Iwai668b9652009-03-06 10:13:24 +01003219#define create_controls(codec, pfx, nid, chs) \
3220 create_controls_idx(codec, pfx, 0, nid, chs)
3221
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003222static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3223{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003224 if (spec->multiout.num_dacs > 4) {
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003225 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3226 return 1;
3227 } else {
3228 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
3229 spec->multiout.num_dacs++;
3230 }
3231 return 0;
3232}
3233
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003234static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003235{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003236 int i;
3237 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3238 if (!spec->multiout.extra_out_nid[i]) {
3239 spec->multiout.extra_out_nid[i] = nid;
3240 return 0;
3241 }
3242 }
3243 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3244 return 1;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003245}
3246
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003247/* Create output controls
3248 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3249 */
3250static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3251 const hda_nid_t *pins,
3252 const hda_nid_t *dac_nids,
3253 int type)
Mattc7d4b2f2005-06-27 14:59:41 +02003254{
Takashi Iwai76624532008-12-19 10:09:47 +01003255 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003256 static const char *chname[4] = {
3257 "Front", "Surround", NULL /*CLFE*/, "Side"
3258 };
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003259 hda_nid_t nid;
Takashi Iwai91589232008-12-19 15:59:40 +01003260 int i, err;
3261 unsigned int wid_caps;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003262
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003263 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
Takashi Iwaiffd0e562009-04-16 12:20:24 +02003264 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
3265 wid_caps = get_wcaps(codec, pins[i]);
3266 if (wid_caps & AC_WCAP_UNSOL_CAP)
3267 spec->hp_detect = 1;
3268 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003269 nid = dac_nids[i];
3270 if (!nid)
3271 continue;
3272 if (type != AUTO_PIN_HP_OUT && i == 2) {
Mattc7d4b2f2005-06-27 14:59:41 +02003273 /* Center/LFE */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003274 err = create_controls(codec, "Center", nid, 1);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003275 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003276 return err;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003277 err = create_controls(codec, "LFE", nid, 2);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003278 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003279 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003280
3281 wid_caps = get_wcaps(codec, nid);
3282
3283 if (wid_caps & AC_WCAP_LR_SWAP) {
3284 err = stac92xx_add_control(spec,
3285 STAC_CTL_WIDGET_CLFE_SWITCH,
3286 "Swap Center/LFE Playback Switch", nid);
3287
3288 if (err < 0)
3289 return err;
3290 }
3291
Mattc7d4b2f2005-06-27 14:59:41 +02003292 } else {
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003293 const char *name;
Takashi Iwai668b9652009-03-06 10:13:24 +01003294 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003295 switch (type) {
3296 case AUTO_PIN_HP_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01003297 name = "Headphone";
3298 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003299 break;
3300 case AUTO_PIN_SPEAKER_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01003301 name = "Speaker";
3302 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003303 break;
3304 default:
3305 name = chname[i];
Takashi Iwai668b9652009-03-06 10:13:24 +01003306 idx = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003307 break;
Takashi Iwai76624532008-12-19 10:09:47 +01003308 }
Takashi Iwai668b9652009-03-06 10:13:24 +01003309 err = create_controls_idx(codec, name, idx, nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003310 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003311 return err;
3312 }
3313 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003314 return 0;
3315}
3316
3317/* add playback controls from the parsed DAC table */
3318static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3319 const struct auto_pin_cfg *cfg)
3320{
3321 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003322 hda_nid_t nid;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003323 int err;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003324 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003325
3326 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3327 spec->multiout.dac_nids,
3328 cfg->line_out_type);
3329 if (err < 0)
3330 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003331
Takashi Iwaia9cb5c92008-11-24 07:51:11 +01003332 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003333 err = stac92xx_add_control(spec,
3334 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01003335 "Headphone as Line Out Switch",
3336 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003337 if (err < 0)
3338 return err;
3339 }
3340
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003341 for (idx = AUTO_PIN_MIC; idx <= AUTO_PIN_FRONT_LINE; idx++) {
3342 nid = cfg->input_pins[idx];
3343 if (nid) {
3344 err = stac92xx_add_jack_mode_control(codec, nid, idx);
3345 if (err < 0)
3346 return err;
3347 }
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003348 }
Matt Porter403d1942005-11-29 15:00:51 +01003349
Mattc7d4b2f2005-06-27 14:59:41 +02003350 return 0;
3351}
3352
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003353/* add playback controls for Speaker and HP outputs */
3354static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3355 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003356{
3357 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003358 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02003359
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003360 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3361 spec->hp_dacs, AUTO_PIN_HP_OUT);
3362 if (err < 0)
3363 return err;
3364
3365 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3366 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3367 if (err < 0)
3368 return err;
3369
Mattc7d4b2f2005-06-27 14:59:41 +02003370 return 0;
3371}
3372
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003373/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003374static const char *stac92xx_mono_labels[4] = {
3375 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003376};
3377
3378/* create mono mux for mono out on capable codecs */
3379static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3380{
3381 struct sigmatel_spec *spec = codec->spec;
3382 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3383 int i, num_cons;
3384 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3385
3386 num_cons = snd_hda_get_connections(codec,
3387 spec->mono_nid,
3388 con_lst,
3389 HDA_MAX_NUM_INPUTS);
3390 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3391 return -EINVAL;
3392
3393 for (i = 0; i < num_cons; i++) {
3394 mono_mux->items[mono_mux->num_items].label =
3395 stac92xx_mono_labels[i];
3396 mono_mux->items[mono_mux->num_items].index = i;
3397 mono_mux->num_items++;
3398 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003399
3400 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3401 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003402}
3403
Matthew Ranostay89385032008-09-11 09:49:39 -04003404/* labels for amp mux outputs */
3405static const char *stac92xx_amp_labels[3] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04003406 "Front Microphone", "Microphone", "Line In",
Matthew Ranostay89385032008-09-11 09:49:39 -04003407};
3408
3409/* create amp out controls mux on capable codecs */
3410static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3411{
3412 struct sigmatel_spec *spec = codec->spec;
3413 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3414 int i, err;
3415
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003416 for (i = 0; i < spec->num_amps; i++) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003417 amp_mux->items[amp_mux->num_items].label =
3418 stac92xx_amp_labels[i];
3419 amp_mux->items[amp_mux->num_items].index = i;
3420 amp_mux->num_items++;
3421 }
3422
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003423 if (spec->num_amps > 1) {
3424 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3425 "Amp Selector Capture Switch", 0);
3426 if (err < 0)
3427 return err;
3428 }
Matthew Ranostay89385032008-09-11 09:49:39 -04003429 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3430 "Amp Capture Volume",
3431 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3432}
3433
3434
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003435/* create PC beep volume controls */
3436static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3437 hda_nid_t nid)
3438{
3439 struct sigmatel_spec *spec = codec->spec;
3440 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3441 int err;
3442
3443 /* check for mute support for the the amp */
3444 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3445 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3446 "PC Beep Playback Switch",
3447 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3448 if (err < 0)
3449 return err;
3450 }
3451
3452 /* check to see if there is volume support for the amp */
3453 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3454 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3455 "PC Beep Playback Volume",
3456 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3457 if (err < 0)
3458 return err;
3459 }
3460 return 0;
3461}
3462
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003463#ifdef CONFIG_SND_HDA_INPUT_BEEP
3464#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3465
3466static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3467 struct snd_ctl_elem_value *ucontrol)
3468{
3469 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3470 ucontrol->value.integer.value[0] = codec->beep->enabled;
3471 return 0;
3472}
3473
3474static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3475 struct snd_ctl_elem_value *ucontrol)
3476{
3477 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3478 int enabled = !!ucontrol->value.integer.value[0];
3479 if (codec->beep->enabled != enabled) {
3480 codec->beep->enabled = enabled;
3481 return 1;
3482 }
3483 return 0;
3484}
3485
3486static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3487 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3488 .info = stac92xx_dig_beep_switch_info,
3489 .get = stac92xx_dig_beep_switch_get,
3490 .put = stac92xx_dig_beep_switch_put,
3491};
3492
3493static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3494{
3495 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3496 0, "PC Beep Playback Switch", 0);
3497}
3498#endif
3499
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003500static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3501{
3502 struct sigmatel_spec *spec = codec->spec;
3503 int wcaps, nid, i, err = 0;
3504
3505 for (i = 0; i < spec->num_muxes; i++) {
3506 nid = spec->mux_nids[i];
3507 wcaps = get_wcaps(codec, nid);
3508
3509 if (wcaps & AC_WCAP_OUT_AMP) {
3510 err = stac92xx_add_control_idx(spec,
3511 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3512 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3513 if (err < 0)
3514 return err;
3515 }
3516 }
3517 return 0;
3518};
3519
Matthew Ranostayd9737752008-09-07 12:03:41 +02003520static const char *stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003521 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003522};
3523
3524static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3525{
3526 struct sigmatel_spec *spec = codec->spec;
3527 struct hda_input_mux *spdif_mux = &spec->private_smux;
Matthew Ranostay65973632008-09-16 10:39:37 -04003528 const char **labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003529 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003530 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003531
3532 num_cons = snd_hda_get_connections(codec,
3533 spec->smux_nids[0],
3534 con_lst,
3535 HDA_MAX_NUM_INPUTS);
Matthew Ranostay65973632008-09-16 10:39:37 -04003536 if (!num_cons)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003537 return -EINVAL;
3538
Matthew Ranostay65973632008-09-16 10:39:37 -04003539 if (!labels)
3540 labels = stac92xx_spdif_labels;
3541
Matthew Ranostayd9737752008-09-07 12:03:41 +02003542 for (i = 0; i < num_cons; i++) {
Matthew Ranostay65973632008-09-16 10:39:37 -04003543 spdif_mux->items[spdif_mux->num_items].label = labels[i];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003544 spdif_mux->items[spdif_mux->num_items].index = i;
3545 spdif_mux->num_items++;
3546 }
3547
3548 return 0;
3549}
3550
Matt Porter8b657272006-10-26 17:12:59 +02003551/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003552static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003553 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3554 "Digital Mic 3", "Digital Mic 4"
3555};
3556
3557/* create playback/capture controls for input pins on dmic capable codecs */
3558static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3559 const struct auto_pin_cfg *cfg)
3560{
3561 struct sigmatel_spec *spec = codec->spec;
3562 struct hda_input_mux *dimux = &spec->private_dimux;
3563 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003564 int err, i, j;
3565 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02003566
3567 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3568 dimux->items[dimux->num_items].index = 0;
3569 dimux->num_items++;
3570
3571 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003572 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003573 int index;
3574 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003575 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02003576 unsigned int def_conf;
3577
Takashi Iwai330ee992009-02-20 14:33:36 +01003578 def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
Matt Porter8b657272006-10-26 17:12:59 +02003579 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3580 continue;
3581
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003582 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02003583 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003584 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02003585 con_lst,
3586 HDA_MAX_NUM_INPUTS);
3587 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003588 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02003589 index = j;
3590 goto found;
3591 }
3592 continue;
3593found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003594 wcaps = get_wcaps(codec, nid) &
3595 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003596
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003597 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003598 sprintf(name, "%s Capture Volume",
3599 stac92xx_dmic_labels[dimux->num_items]);
3600
3601 err = stac92xx_add_control(spec,
3602 STAC_CTL_WIDGET_VOL,
3603 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003604 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3605 (wcaps & AC_WCAP_OUT_AMP) ?
3606 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003607 if (err < 0)
3608 return err;
3609 }
3610
Matt Porter8b657272006-10-26 17:12:59 +02003611 dimux->items[dimux->num_items].label =
3612 stac92xx_dmic_labels[dimux->num_items];
3613 dimux->items[dimux->num_items].index = index;
3614 dimux->num_items++;
3615 }
3616
3617 return 0;
3618}
3619
Mattc7d4b2f2005-06-27 14:59:41 +02003620/* create playback/capture controls for input pins */
3621static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3622{
3623 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003624 struct hda_input_mux *imux = &spec->private_imux;
3625 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3626 int i, j, k;
3627
3628 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003629 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02003630
Takashi Iwai314634b2006-09-21 11:56:18 +02003631 if (!cfg->input_pins[i])
3632 continue;
3633 index = -1;
3634 for (j = 0; j < spec->num_muxes; j++) {
3635 int num_cons;
3636 num_cons = snd_hda_get_connections(codec,
3637 spec->mux_nids[j],
3638 con_lst,
3639 HDA_MAX_NUM_INPUTS);
3640 for (k = 0; k < num_cons; k++)
3641 if (con_lst[k] == cfg->input_pins[i]) {
3642 index = k;
3643 goto found;
3644 }
Mattc7d4b2f2005-06-27 14:59:41 +02003645 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003646 continue;
3647 found:
3648 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3649 imux->items[imux->num_items].index = index;
3650 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003651 }
3652
Steve Longerbeam7b043892007-05-03 20:50:03 +02003653 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003654 /*
3655 * Set the current input for the muxes.
3656 * The STAC9221 has two input muxes with identical source
3657 * NID lists. Hopefully this won't get confused.
3658 */
3659 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003660 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3661 AC_VERB_SET_CONNECT_SEL,
3662 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003663 }
3664 }
3665
Mattc7d4b2f2005-06-27 14:59:41 +02003666 return 0;
3667}
3668
Mattc7d4b2f2005-06-27 14:59:41 +02003669static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3670{
3671 struct sigmatel_spec *spec = codec->spec;
3672 int i;
3673
3674 for (i = 0; i < spec->autocfg.line_outs; i++) {
3675 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3676 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3677 }
3678}
3679
3680static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3681{
3682 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003683 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003684
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003685 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3686 hda_nid_t pin;
3687 pin = spec->autocfg.hp_pins[i];
3688 if (pin) /* connect to front */
3689 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3690 }
3691 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3692 hda_nid_t pin;
3693 pin = spec->autocfg.speaker_pins[i];
3694 if (pin) /* connect to front */
3695 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3696 }
Mattc7d4b2f2005-06-27 14:59:41 +02003697}
3698
Matt Porter3cc08dc2006-01-23 15:27:49 +01003699static 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 +02003700{
3701 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003702 int hp_swap = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003703 int err;
3704
Matt Porter8b657272006-10-26 17:12:59 +02003705 if ((err = snd_hda_parse_pin_def_config(codec,
3706 &spec->autocfg,
3707 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003708 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003709 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003710 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003711
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003712 /* If we have no real line-out pin and multiple hp-outs, HPs should
3713 * be set up as multi-channel outputs.
3714 */
3715 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3716 spec->autocfg.hp_outs > 1) {
3717 /* Copy hp_outs to line_outs, backup line_outs in
3718 * speaker_outs so that the following routines can handle
3719 * HP pins as primary outputs.
3720 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003721 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003722 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3723 sizeof(spec->autocfg.line_out_pins));
3724 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3725 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3726 sizeof(spec->autocfg.hp_pins));
3727 spec->autocfg.line_outs = spec->autocfg.hp_outs;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003728 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3729 spec->autocfg.hp_outs = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003730 hp_swap = 1;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003731 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003732 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003733 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3734 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003735 u32 caps = query_amp_caps(codec,
3736 spec->autocfg.mono_out_pin, dir);
3737 hda_nid_t conn_list[1];
3738
3739 /* get the mixer node and then the mono mux if it exists */
3740 if (snd_hda_get_connections(codec,
3741 spec->autocfg.mono_out_pin, conn_list, 1) &&
3742 snd_hda_get_connections(codec, conn_list[0],
3743 conn_list, 1)) {
3744
3745 int wcaps = get_wcaps(codec, conn_list[0]);
3746 int wid_type = (wcaps & AC_WCAP_TYPE)
3747 >> AC_WCAP_TYPE_SHIFT;
3748 /* LR swap check, some stac925x have a mux that
3749 * changes the DACs output path instead of the
3750 * mono-mux path.
3751 */
3752 if (wid_type == AC_WID_AUD_SEL &&
3753 !(wcaps & AC_WCAP_LR_SWAP))
3754 spec->mono_nid = conn_list[0];
3755 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003756 if (dir) {
3757 hda_nid_t nid = spec->autocfg.mono_out_pin;
3758
3759 /* most mono outs have a least a mute/unmute switch */
3760 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3761 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3762 "Mono Playback Switch",
3763 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003764 if (err < 0)
3765 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003766 /* check for volume support for the amp */
3767 if ((caps & AC_AMPCAP_NUM_STEPS)
3768 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3769 err = stac92xx_add_control(spec,
3770 STAC_CTL_WIDGET_VOL,
3771 "Mono Playback Volume",
3772 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3773 if (err < 0)
3774 return err;
3775 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003776 }
3777
3778 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3779 AC_PINCTL_OUT_EN);
3780 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003781
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003782 if (!spec->multiout.num_dacs) {
3783 err = stac92xx_auto_fill_dac_nids(codec);
3784 if (err < 0)
Takashi Iwai19039bd2006-06-28 15:52:16 +02003785 return err;
Takashi Iwaic9280d62009-01-15 17:31:00 +01003786 err = stac92xx_auto_create_multi_out_ctls(codec,
3787 &spec->autocfg);
3788 if (err < 0)
3789 return err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003790 }
Mattc7d4b2f2005-06-27 14:59:41 +02003791
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003792 /* setup analog beep controls */
3793 if (spec->anabeep_nid > 0) {
3794 err = stac92xx_auto_create_beep_ctls(codec,
3795 spec->anabeep_nid);
3796 if (err < 0)
3797 return err;
3798 }
3799
3800 /* setup digital beep controls and input device */
3801#ifdef CONFIG_SND_HDA_INPUT_BEEP
3802 if (spec->digbeep_nid > 0) {
3803 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003804 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003805
3806 err = stac92xx_auto_create_beep_ctls(codec, nid);
3807 if (err < 0)
3808 return err;
3809 err = snd_hda_attach_beep_device(codec, nid);
3810 if (err < 0)
3811 return err;
Takashi Iwaifa797962009-05-19 12:50:04 +02003812 /* IDT/STAC codecs have linear beep tone parameter */
3813 codec->beep->linear_tone = 1;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003814 /* if no beep switch is available, make its own one */
3815 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3816 if (codec->beep &&
3817 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3818 err = stac92xx_beep_switch_ctl(codec);
3819 if (err < 0)
3820 return err;
3821 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003822 }
3823#endif
3824
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003825 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003826 if (err < 0)
3827 return err;
3828
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003829 /* All output parsing done, now restore the swapped hp pins */
3830 if (hp_swap) {
3831 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3832 sizeof(spec->autocfg.hp_pins));
3833 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3834 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3835 spec->autocfg.line_outs = 0;
3836 }
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003837
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003838 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003839 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003840 return err;
3841
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003842 if (spec->mono_nid > 0) {
3843 err = stac92xx_auto_create_mono_output_ctls(codec);
3844 if (err < 0)
3845 return err;
3846 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003847 if (spec->num_amps > 0) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003848 err = stac92xx_auto_create_amp_output_ctls(codec);
3849 if (err < 0)
3850 return err;
3851 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003852 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003853 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3854 &spec->autocfg)) < 0)
3855 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003856 if (spec->num_muxes > 0) {
3857 err = stac92xx_auto_create_mux_input_ctls(codec);
3858 if (err < 0)
3859 return err;
3860 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003861 if (spec->num_smuxes > 0) {
3862 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3863 if (err < 0)
3864 return err;
3865 }
Matt Porter8b657272006-10-26 17:12:59 +02003866
Takashi Iwaie3c75962009-01-23 11:57:22 +01003867 err = stac92xx_add_input_source(spec);
3868 if (err < 0)
3869 return err;
3870
Mattc7d4b2f2005-06-27 14:59:41 +02003871 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003872 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003873 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003874
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003875 if (spec->autocfg.dig_outs)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003876 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003877 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003878 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003879
Takashi Iwai603c4012008-07-30 15:01:44 +02003880 if (spec->kctls.list)
3881 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003882
3883 spec->input_mux = &spec->private_imux;
Matthew Ranostayf8ccbf62008-12-20 17:36:28 -05003884 if (!spec->dinput_mux)
3885 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003886 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003887 spec->mono_mux = &spec->private_mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -04003888 spec->amp_mux = &spec->private_amp_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003889 return 1;
3890}
3891
Takashi Iwai82bc9552006-03-21 11:24:42 +01003892/* add playback controls for HP output */
3893static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3894 struct auto_pin_cfg *cfg)
3895{
3896 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003897 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003898 unsigned int wid_caps;
3899
3900 if (! pin)
3901 return 0;
3902
3903 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003904 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003905 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003906
3907 return 0;
3908}
3909
Richard Fish160ea0d2006-09-06 13:58:25 +02003910/* add playback controls for LFE output */
3911static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3912 struct auto_pin_cfg *cfg)
3913{
3914 struct sigmatel_spec *spec = codec->spec;
3915 int err;
3916 hda_nid_t lfe_pin = 0x0;
3917 int i;
3918
3919 /*
3920 * search speaker outs and line outs for a mono speaker pin
3921 * with an amp. If one is found, add LFE controls
3922 * for it.
3923 */
3924 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3925 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003926 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003927 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3928 if (wcaps == AC_WCAP_OUT_AMP)
3929 /* found a mono speaker with an amp, must be lfe */
3930 lfe_pin = pin;
3931 }
3932
3933 /* if speaker_outs is 0, then speakers may be in line_outs */
3934 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3935 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3936 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003937 unsigned int defcfg;
Takashi Iwai330ee992009-02-20 14:33:36 +01003938 defcfg = snd_hda_codec_get_pincfg(codec, pin);
Harvey Harrison8b551782008-02-29 11:56:48 +01003939 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003940 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003941 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3942 if (wcaps == AC_WCAP_OUT_AMP)
3943 /* found a mono speaker with an amp,
3944 must be lfe */
3945 lfe_pin = pin;
3946 }
3947 }
3948 }
3949
3950 if (lfe_pin) {
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003951 err = create_controls(codec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003952 if (err < 0)
3953 return err;
3954 }
3955
3956 return 0;
3957}
3958
Mattc7d4b2f2005-06-27 14:59:41 +02003959static int stac9200_parse_auto_config(struct hda_codec *codec)
3960{
3961 struct sigmatel_spec *spec = codec->spec;
3962 int err;
3963
Kailang Yangdf694da2005-12-05 19:42:22 +01003964 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003965 return err;
3966
3967 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3968 return err;
3969
Takashi Iwai82bc9552006-03-21 11:24:42 +01003970 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3971 return err;
3972
Richard Fish160ea0d2006-09-06 13:58:25 +02003973 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3974 return err;
3975
Takashi Iwai355a0ec2008-11-11 16:46:19 +01003976 if (spec->num_muxes > 0) {
3977 err = stac92xx_auto_create_mux_input_ctls(codec);
3978 if (err < 0)
3979 return err;
3980 }
3981
Takashi Iwaie3c75962009-01-23 11:57:22 +01003982 err = stac92xx_add_input_source(spec);
3983 if (err < 0)
3984 return err;
3985
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003986 if (spec->autocfg.dig_outs)
Mattc7d4b2f2005-06-27 14:59:41 +02003987 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003988 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003989 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003990
Takashi Iwai603c4012008-07-30 15:01:44 +02003991 if (spec->kctls.list)
3992 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003993
3994 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003995 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003996
3997 return 1;
3998}
3999
Sam Revitch62fe78e2006-05-10 15:09:17 +02004000/*
4001 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
4002 * funky external mute control using GPIO pins.
4003 */
4004
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004005static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004006 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02004007{
4008 unsigned int gpiostate, gpiomask, gpiodir;
4009
4010 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
4011 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004012 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02004013
4014 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
4015 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004016 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02004017
4018 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
4019 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004020 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02004021
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004022 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004023 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
4024
4025 snd_hda_codec_write(codec, codec->afg, 0,
4026 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004027 snd_hda_codec_read(codec, codec->afg, 0,
4028 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004029
4030 msleep(1);
4031
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004032 snd_hda_codec_read(codec, codec->afg, 0,
4033 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004034}
4035
Takashi Iwai95c09092009-04-14 16:15:29 +02004036#ifdef CONFIG_SND_JACK
4037static void stac92xx_free_jack_priv(struct snd_jack *jack)
4038{
4039 struct sigmatel_jack *jacks = jack->private_data;
4040 jacks->nid = 0;
4041 jacks->jack = NULL;
4042}
4043#endif
4044
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004045static int stac92xx_add_jack(struct hda_codec *codec,
4046 hda_nid_t nid, int type)
4047{
Takashi Iwaie4973e12008-11-18 09:32:42 +01004048#ifdef CONFIG_SND_JACK
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004049 struct sigmatel_spec *spec = codec->spec;
4050 struct sigmatel_jack *jack;
Takashi Iwai330ee992009-02-20 14:33:36 +01004051 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004052 int connectivity = get_defcfg_connect(def_conf);
4053 char name[32];
Takashi Iwai95c09092009-04-14 16:15:29 +02004054 int err;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004055
4056 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
4057 return 0;
4058
4059 snd_array_init(&spec->jacks, sizeof(*jack), 32);
4060 jack = snd_array_new(&spec->jacks);
4061 if (!jack)
4062 return -ENOMEM;
4063 jack->nid = nid;
4064 jack->type = type;
4065
4066 sprintf(name, "%s at %s %s Jack",
4067 snd_hda_get_jack_type(def_conf),
4068 snd_hda_get_jack_connectivity(def_conf),
4069 snd_hda_get_jack_location(def_conf));
4070
Takashi Iwai95c09092009-04-14 16:15:29 +02004071 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
4072 if (err < 0) {
4073 jack->nid = 0;
4074 return err;
4075 }
4076 jack->jack->private_data = jack;
4077 jack->jack->private_free = stac92xx_free_jack_priv;
Takashi Iwaie4973e12008-11-18 09:32:42 +01004078#endif
Takashi Iwai95c09092009-04-14 16:15:29 +02004079 return 0;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004080}
4081
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004082static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
4083 unsigned char type, int data)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004084{
4085 struct sigmatel_event *event;
4086
4087 snd_array_init(&spec->events, sizeof(*event), 32);
4088 event = snd_array_new(&spec->events);
4089 if (!event)
4090 return -ENOMEM;
4091 event->nid = nid;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004092 event->type = type;
4093 event->tag = spec->events.used;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004094 event->data = data;
4095
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004096 return event->tag;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004097}
4098
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004099static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
4100 hda_nid_t nid, unsigned char type)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004101{
4102 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004103 struct sigmatel_event *event = spec->events.list;
4104 int i;
4105
4106 for (i = 0; i < spec->events.used; i++, event++) {
4107 if (event->nid == nid && event->type == type)
4108 return event;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004109 }
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004110 return NULL;
4111}
4112
4113static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
4114 unsigned char tag)
4115{
4116 struct sigmatel_spec *spec = codec->spec;
4117 struct sigmatel_event *event = spec->events.list;
4118 int i;
4119
4120 for (i = 0; i < spec->events.used; i++, event++) {
4121 if (event->tag == tag)
4122 return event;
4123 }
4124 return NULL;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004125}
4126
Takashi Iwai314634b2006-09-21 11:56:18 +02004127static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004128 unsigned int type)
Takashi Iwai314634b2006-09-21 11:56:18 +02004129{
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004130 struct sigmatel_event *event;
4131 int tag;
4132
4133 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
4134 return;
4135 event = stac_get_event(codec, nid, type);
4136 if (event)
4137 tag = event->tag;
4138 else
4139 tag = stac_add_event(codec->spec, nid, type, 0);
4140 if (tag < 0)
4141 return;
4142 snd_hda_codec_write_cache(codec, nid, 0,
4143 AC_VERB_SET_UNSOLICITED_ENABLE,
4144 AC_USRSP_EN | tag);
Takashi Iwai314634b2006-09-21 11:56:18 +02004145}
4146
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004147static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
4148{
4149 int i;
4150 for (i = 0; i < cfg->hp_outs; i++)
4151 if (cfg->hp_pins[i] == nid)
4152 return 1; /* nid is a HP-Out */
4153
4154 return 0; /* nid is not a HP-Out */
4155};
4156
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004157static void stac92xx_power_down(struct hda_codec *codec)
4158{
4159 struct sigmatel_spec *spec = codec->spec;
4160
4161 /* power down inactive DACs */
4162 hda_nid_t *dac;
4163 for (dac = spec->dac_list; *dac; dac++)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004164 if (!check_all_dac_nids(spec, *dac))
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004165 snd_hda_codec_write(codec, *dac, 0,
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004166 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4167}
4168
Takashi Iwaif73d3582008-11-25 08:21:51 +01004169static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4170 int enable);
4171
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004172/* override some hints from the hwdep entry */
4173static void stac_store_hints(struct hda_codec *codec)
4174{
4175 struct sigmatel_spec *spec = codec->spec;
4176 const char *p;
4177 int val;
4178
4179 val = snd_hda_get_bool_hint(codec, "hp_detect");
4180 if (val >= 0)
4181 spec->hp_detect = val;
4182 p = snd_hda_get_hint(codec, "gpio_mask");
4183 if (p) {
4184 spec->gpio_mask = simple_strtoul(p, NULL, 0);
4185 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
4186 spec->gpio_mask;
4187 }
4188 p = snd_hda_get_hint(codec, "gpio_dir");
4189 if (p)
4190 spec->gpio_dir = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4191 p = snd_hda_get_hint(codec, "gpio_data");
4192 if (p)
4193 spec->gpio_data = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4194 p = snd_hda_get_hint(codec, "eapd_mask");
4195 if (p)
4196 spec->eapd_mask = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4197 val = snd_hda_get_bool_hint(codec, "eapd_switch");
4198 if (val >= 0)
4199 spec->eapd_switch = val;
4200}
4201
Mattc7d4b2f2005-06-27 14:59:41 +02004202static int stac92xx_init(struct hda_codec *codec)
4203{
4204 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004205 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004206 unsigned int gpio;
Takashi Iwaie4973e12008-11-18 09:32:42 +01004207 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02004208
Mattc7d4b2f2005-06-27 14:59:41 +02004209 snd_hda_sequence_write(codec, spec->init);
4210
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004211 /* power down adcs initially */
4212 if (spec->powerdown_adcs)
4213 for (i = 0; i < spec->num_adcs; i++)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004214 snd_hda_codec_write(codec,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004215 spec->adc_nids[i], 0,
4216 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004217
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004218 /* override some hints */
4219 stac_store_hints(codec);
4220
Takashi Iwaif73d3582008-11-25 08:21:51 +01004221 /* set up GPIO */
4222 gpio = spec->gpio_data;
4223 /* turn on EAPD statically when spec->eapd_switch isn't set.
4224 * otherwise, unsol event will turn it on/off dynamically
4225 */
4226 if (!spec->eapd_switch)
4227 gpio |= spec->eapd_mask;
4228 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4229
Takashi Iwai82bc9552006-03-21 11:24:42 +01004230 /* set up pins */
4231 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02004232 /* Enable unsolicited responses on the HP widget */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004233 for (i = 0; i < cfg->hp_outs; i++) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004234 hda_nid_t nid = cfg->hp_pins[i];
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004235 enable_pin_detect(codec, nid, STAC_HP_EVENT);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004236 }
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01004237 /* force to enable the first line-out; the others are set up
4238 * in unsol_event
4239 */
4240 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004241 AC_PINCTL_OUT_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004242 /* fake event to set up pins */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004243 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4244 STAC_HP_EVENT);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004245 } else {
4246 stac92xx_auto_init_multi_out(codec);
4247 stac92xx_auto_init_hp_out(codec);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004248 for (i = 0; i < cfg->hp_outs; i++)
4249 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004250 }
4251 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01004252 hda_nid_t nid = cfg->input_pins[i];
4253 if (nid) {
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004254 unsigned int pinctl, conf;
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004255 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
4256 /* for mic pins, force to initialize */
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02004257 pinctl = stac92xx_get_default_vref(codec, nid);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004258 pinctl |= AC_PINCTL_IN_EN;
4259 stac92xx_auto_set_pinctl(codec, nid, pinctl);
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004260 } else {
4261 pinctl = snd_hda_codec_read(codec, nid, 0,
4262 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4263 /* if PINCTL already set then skip */
Takashi Iwai5dd17cb2009-05-07 16:22:53 +02004264 /* Also, if both INPUT and OUTPUT are set,
4265 * it must be a BIOS bug; need to override, too
4266 */
4267 if (!(pinctl & AC_PINCTL_IN_EN) ||
4268 (pinctl & AC_PINCTL_OUT_EN)) {
4269 pinctl &= ~AC_PINCTL_OUT_EN;
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004270 pinctl |= AC_PINCTL_IN_EN;
4271 stac92xx_auto_set_pinctl(codec, nid,
4272 pinctl);
4273 }
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004274 }
Takashi Iwai330ee992009-02-20 14:33:36 +01004275 conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004276 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4277 enable_pin_detect(codec, nid,
4278 STAC_INSERT_EVENT);
4279 stac_issue_unsol_event(codec, nid,
4280 STAC_INSERT_EVENT);
4281 }
Takashi Iwaic960a032006-03-23 17:06:28 +01004282 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01004283 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004284 for (i = 0; i < spec->num_dmics; i++)
4285 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4286 AC_PINCTL_IN_EN);
Takashi Iwai0852d7a2009-02-11 11:35:15 +01004287 if (cfg->dig_out_pins[0])
4288 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
Takashi Iwai82bc9552006-03-21 11:24:42 +01004289 AC_PINCTL_OUT_EN);
4290 if (cfg->dig_in_pin)
4291 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4292 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004293 for (i = 0; i < spec->num_pwrs; i++) {
4294 hda_nid_t nid = spec->pwr_nids[i];
4295 int pinctl, def_conf;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004296
Takashi Iwaieb632122008-12-19 16:39:48 +01004297 /* power on when no jack detection is available */
4298 if (!spec->hp_detect) {
4299 stac_toggle_power_map(codec, nid, 1);
4300 continue;
4301 }
4302
4303 if (is_nid_hp_pin(cfg, nid))
Takashi Iwaif73d3582008-11-25 08:21:51 +01004304 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004305
Takashi Iwaif73d3582008-11-25 08:21:51 +01004306 pinctl = snd_hda_codec_read(codec, nid, 0,
4307 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4308 /* outputs are only ports capable of power management
4309 * any attempts on powering down a input port cause the
4310 * referenced VREF to act quirky.
4311 */
Takashi Iwaieb632122008-12-19 16:39:48 +01004312 if (pinctl & AC_PINCTL_IN_EN) {
4313 stac_toggle_power_map(codec, nid, 1);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004314 continue;
Takashi Iwaieb632122008-12-19 16:39:48 +01004315 }
Takashi Iwai330ee992009-02-20 14:33:36 +01004316 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004317 def_conf = get_defcfg_connect(def_conf);
4318 /* skip any ports that don't have jacks since presence
4319 * detection is useless */
4320 if (def_conf != AC_JACK_PORT_COMPLEX) {
4321 if (def_conf != AC_JACK_PORT_NONE)
4322 stac_toggle_power_map(codec, nid, 1);
4323 continue;
4324 }
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004325 if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) {
4326 enable_pin_detect(codec, nid, STAC_PWR_EVENT);
4327 stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT);
4328 }
Takashi Iwaif73d3582008-11-25 08:21:51 +01004329 }
4330 if (spec->dac_list)
4331 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02004332 return 0;
4333}
4334
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004335static void stac92xx_free_jacks(struct hda_codec *codec)
4336{
Takashi Iwaie4973e12008-11-18 09:32:42 +01004337#ifdef CONFIG_SND_JACK
Takashi Iwaib94d3532008-11-21 09:08:06 +01004338 /* free jack instances manually when clearing/reconfiguring */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004339 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaib94d3532008-11-21 09:08:06 +01004340 if (!codec->bus->shutdown && spec->jacks.list) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004341 struct sigmatel_jack *jacks = spec->jacks.list;
4342 int i;
Takashi Iwai95c09092009-04-14 16:15:29 +02004343 for (i = 0; i < spec->jacks.used; i++, jacks++) {
4344 if (jacks->jack)
4345 snd_device_free(codec->bus->card, jacks->jack);
4346 }
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004347 }
4348 snd_array_free(&spec->jacks);
Takashi Iwaie4973e12008-11-18 09:32:42 +01004349#endif
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004350}
4351
Takashi Iwai603c4012008-07-30 15:01:44 +02004352static void stac92xx_free_kctls(struct hda_codec *codec)
4353{
4354 struct sigmatel_spec *spec = codec->spec;
4355
4356 if (spec->kctls.list) {
4357 struct snd_kcontrol_new *kctl = spec->kctls.list;
4358 int i;
4359 for (i = 0; i < spec->kctls.used; i++)
4360 kfree(kctl[i].name);
4361 }
4362 snd_array_free(&spec->kctls);
4363}
4364
Matt2f2f4252005-04-13 14:45:30 +02004365static void stac92xx_free(struct hda_codec *codec)
4366{
Mattc7d4b2f2005-06-27 14:59:41 +02004367 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004368
4369 if (! spec)
4370 return;
4371
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004372 stac92xx_free_jacks(codec);
4373 snd_array_free(&spec->events);
Richard Fish11b44bb2006-08-23 18:31:34 +02004374
Mattc7d4b2f2005-06-27 14:59:41 +02004375 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004376 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02004377}
4378
Matt4e550962005-07-04 17:51:39 +02004379static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4380 unsigned int flag)
4381{
Takashi Iwai8ce841982009-01-22 16:59:20 +01004382 unsigned int old_ctl, pin_ctl;
4383
4384 pin_ctl = snd_hda_codec_read(codec, nid,
Matt4e550962005-07-04 17:51:39 +02004385 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02004386
Takashi Iwaif9acba42007-05-29 18:01:06 +02004387 if (pin_ctl & AC_PINCTL_IN_EN) {
4388 /*
4389 * we need to check the current set-up direction of
4390 * shared input pins since they can be switched via
4391 * "xxx as Output" mixer switch
4392 */
4393 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004394 if (nid == spec->line_switch || nid == spec->mic_switch)
Takashi Iwaif9acba42007-05-29 18:01:06 +02004395 return;
4396 }
4397
Takashi Iwai8ce841982009-01-22 16:59:20 +01004398 old_ctl = pin_ctl;
Steve Longerbeam7b043892007-05-03 20:50:03 +02004399 /* if setting pin direction bits, clear the current
4400 direction bits first */
4401 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4402 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4403
Takashi Iwai8ce841982009-01-22 16:59:20 +01004404 pin_ctl |= flag;
4405 if (old_ctl != pin_ctl)
4406 snd_hda_codec_write_cache(codec, nid, 0,
4407 AC_VERB_SET_PIN_WIDGET_CONTROL,
4408 pin_ctl);
Matt4e550962005-07-04 17:51:39 +02004409}
4410
4411static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4412 unsigned int flag)
4413{
4414 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4415 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai8ce841982009-01-22 16:59:20 +01004416 if (pin_ctl & flag)
4417 snd_hda_codec_write_cache(codec, nid, 0,
4418 AC_VERB_SET_PIN_WIDGET_CONTROL,
4419 pin_ctl & ~flag);
Matt4e550962005-07-04 17:51:39 +02004420}
4421
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004422static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02004423{
4424 if (!nid)
4425 return 0;
4426 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004427 & (1 << 31))
4428 return 1;
Takashi Iwai314634b2006-09-21 11:56:18 +02004429 return 0;
4430}
4431
Takashi Iwaid7a89432008-11-12 09:48:04 +01004432/* return non-zero if the hp-pin of the given array index isn't
4433 * a jack-detection target
4434 */
4435static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4436{
4437 struct auto_pin_cfg *cfg = &spec->autocfg;
4438
4439 /* ignore sensing of shared line and mic jacks */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004440 if (cfg->hp_pins[i] == spec->line_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004441 return 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004442 if (cfg->hp_pins[i] == spec->mic_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004443 return 1;
4444 /* ignore if the pin is set as line-out */
4445 if (cfg->hp_pins[i] == spec->hp_switch)
4446 return 1;
4447 return 0;
4448}
4449
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004450static void stac92xx_hp_detect(struct hda_codec *codec)
Matt4e550962005-07-04 17:51:39 +02004451{
4452 struct sigmatel_spec *spec = codec->spec;
4453 struct auto_pin_cfg *cfg = &spec->autocfg;
4454 int i, presence;
4455
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004456 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004457 if (spec->gpio_mute)
4458 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4459 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4460
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004461 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004462 if (presence)
4463 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01004464 if (no_hp_sensing(spec, i))
4465 continue;
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004466 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4467 if (presence) {
4468 unsigned int pinctl;
4469 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4470 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4471 if (pinctl & AC_PINCTL_IN_EN)
4472 presence = 0; /* mic- or line-input */
4473 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004474 }
Matt4e550962005-07-04 17:51:39 +02004475
4476 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004477 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004478 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004479 stac92xx_reset_pinctl(codec, spec->hp_switch,
4480 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004481 for (i = 0; i < cfg->line_outs; i++)
4482 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4483 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004484 for (i = 0; i < cfg->speaker_outs; i++)
4485 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4486 AC_PINCTL_OUT_EN);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004487 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004488 stac_gpio_set(codec, spec->gpio_mask,
4489 spec->gpio_dir, spec->gpio_data &
4490 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02004491 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004492 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004493 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004494 stac92xx_set_pinctl(codec, spec->hp_switch,
4495 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004496 for (i = 0; i < cfg->line_outs; i++)
4497 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4498 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004499 for (i = 0; i < cfg->speaker_outs; i++)
4500 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4501 AC_PINCTL_OUT_EN);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004502 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004503 stac_gpio_set(codec, spec->gpio_mask,
4504 spec->gpio_dir, spec->gpio_data |
4505 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02004506 }
Takashi Iwaid7a89432008-11-12 09:48:04 +01004507 /* toggle hp outs */
4508 for (i = 0; i < cfg->hp_outs; i++) {
4509 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4510 if (no_hp_sensing(spec, i))
4511 continue;
4512 if (presence)
4513 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004514#if 0 /* FIXME */
4515/* Resetting the pinctl like below may lead to (a sort of) regressions
4516 * on some devices since they use the HP pin actually for line/speaker
4517 * outs although the default pin config shows a different pin (that is
4518 * wrong and useless).
4519 *
4520 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4521 * But, disabling the code below just works around it, and I'm too tired of
4522 * bug reports with such devices...
4523 */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004524 else
4525 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004526#endif /* FIXME */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004527 }
Matt4e550962005-07-04 17:51:39 +02004528}
4529
Takashi Iwaif73d3582008-11-25 08:21:51 +01004530static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4531 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004532{
4533 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004534 unsigned int idx, val;
4535
4536 for (idx = 0; idx < spec->num_pwrs; idx++) {
4537 if (spec->pwr_nids[idx] == nid)
4538 break;
4539 }
4540 if (idx >= spec->num_pwrs)
4541 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004542
4543 /* several codecs have two power down bits */
4544 if (spec->pwr_mapping)
4545 idx = spec->pwr_mapping[idx];
4546 else
4547 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004548
Takashi Iwaif73d3582008-11-25 08:21:51 +01004549 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4550 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004551 val &= ~idx;
4552 else
4553 val |= idx;
4554
4555 /* power down unused output ports */
4556 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004557}
4558
Takashi Iwaif73d3582008-11-25 08:21:51 +01004559static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4560{
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004561 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
Takashi Iwaif73d3582008-11-25 08:21:51 +01004562}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004563
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004564static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4565{
4566 struct sigmatel_spec *spec = codec->spec;
4567 struct sigmatel_jack *jacks = spec->jacks.list;
4568
4569 if (jacks) {
4570 int i;
4571 for (i = 0; i < spec->jacks.used; i++) {
4572 if (jacks->nid == nid) {
4573 unsigned int pin_ctl =
4574 snd_hda_codec_read(codec, nid,
4575 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4576 0x00);
4577 int type = jacks->type;
4578 if (type == (SND_JACK_LINEOUT
4579 | SND_JACK_HEADPHONE))
4580 type = (pin_ctl & AC_PINCTL_HP_EN)
4581 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4582 snd_jack_report(jacks->jack,
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004583 get_pin_presence(codec, nid)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004584 ? type : 0);
4585 }
4586 jacks++;
4587 }
4588 }
4589}
Matt2f2f4252005-04-13 14:45:30 +02004590
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004591static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
4592 unsigned char type)
4593{
4594 struct sigmatel_event *event = stac_get_event(codec, nid, type);
4595 if (!event)
4596 return;
4597 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4598}
4599
Takashi Iwai314634b2006-09-21 11:56:18 +02004600static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4601{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004602 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004603 struct sigmatel_event *event;
4604 int tag, data;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004605
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004606 tag = (res >> 26) & 0x7f;
4607 event = stac_get_event_from_tag(codec, tag);
4608 if (!event)
4609 return;
4610
4611 switch (event->type) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004612 case STAC_HP_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004613 stac92xx_hp_detect(codec);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004614 /* fallthru */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004615 case STAC_INSERT_EVENT:
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004616 case STAC_PWR_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004617 if (spec->num_pwrs > 0)
4618 stac92xx_pin_sense(codec, event->nid);
4619 stac92xx_report_jack(codec, event->nid);
Matthew Ranostayfd60cc82009-04-06 09:30:46 -04004620
4621 switch (codec->subsystem_id) {
4622 case 0x103c308f:
4623 if (event->nid == 0xb) {
4624 int pin = AC_PINCTL_IN_EN;
4625
4626 if (get_pin_presence(codec, 0xa)
4627 && get_pin_presence(codec, 0xb))
4628 pin |= AC_PINCTL_VREF_80;
4629 if (!get_pin_presence(codec, 0xb))
4630 pin |= AC_PINCTL_VREF_80;
4631
4632 /* toggle VREF state based on mic + hp pin
4633 * status
4634 */
4635 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
4636 }
4637 }
Matthew Ranostay72474be2008-10-09 09:32:17 -04004638 break;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004639 case STAC_VREF_EVENT:
4640 data = snd_hda_codec_read(codec, codec->afg, 0,
4641 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004642 /* toggle VREF state based on GPIOx status */
4643 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004644 !!(data & (1 << event->data)));
Matthew Ranostay72474be2008-10-09 09:32:17 -04004645 break;
Takashi Iwai314634b2006-09-21 11:56:18 +02004646 }
4647}
4648
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004649#ifdef CONFIG_PROC_FS
4650static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4651 struct hda_codec *codec, hda_nid_t nid)
4652{
4653 if (nid == codec->afg)
4654 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4655 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4656}
4657
4658static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4659 struct hda_codec *codec,
4660 unsigned int verb)
4661{
4662 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4663 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4664}
4665
4666/* stac92hd71bxx, stac92hd73xx */
4667static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4668 struct hda_codec *codec, hda_nid_t nid)
4669{
4670 stac92hd_proc_hook(buffer, codec, nid);
4671 if (nid == codec->afg)
4672 analog_loop_proc_hook(buffer, codec, 0xfa0);
4673}
4674
4675static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4676 struct hda_codec *codec, hda_nid_t nid)
4677{
4678 if (nid == codec->afg)
4679 analog_loop_proc_hook(buffer, codec, 0xfe0);
4680}
4681
4682static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4683 struct hda_codec *codec, hda_nid_t nid)
4684{
4685 if (nid == codec->afg)
4686 analog_loop_proc_hook(buffer, codec, 0xfeb);
4687}
4688#else
4689#define stac92hd_proc_hook NULL
4690#define stac92hd7x_proc_hook NULL
4691#define stac9205_proc_hook NULL
4692#define stac927x_proc_hook NULL
4693#endif
4694
Takashi Iwaicb53c622007-08-10 17:21:45 +02004695#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004696static int stac92xx_resume(struct hda_codec *codec)
4697{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004698 struct sigmatel_spec *spec = codec->spec;
4699
Takashi Iwai2c885872008-11-18 09:36:55 +01004700 stac92xx_init(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004701 snd_hda_codec_resume_amp(codec);
4702 snd_hda_codec_resume_cache(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01004703 /* fake event to set up pins again to override cached values */
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004704 if (spec->hp_detect)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004705 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4706 STAC_HP_EVENT);
Mattff6fdc32005-06-27 15:06:52 +02004707 return 0;
4708}
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004709
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004710/*
James Gardiner514bf542009-05-03 04:00:44 -04004711 * using power check for controlling mute led of HP notebooks
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004712 * check for mute state only on Speakers (nid = 0x10)
4713 *
4714 * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise
4715 * the LED is NOT working properly !
James Gardiner514bf542009-05-03 04:00:44 -04004716 *
4717 * Changed name to reflect that it now works for any designated
4718 * model, not just HP HDX.
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004719 */
4720
4721#ifdef CONFIG_SND_HDA_POWER_SAVE
James Gardiner514bf542009-05-03 04:00:44 -04004722static int stac92xx_hp_check_power_status(struct hda_codec *codec,
Takashi Iwai6fce61a2009-03-10 07:48:57 +01004723 hda_nid_t nid)
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004724{
4725 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai6fce61a2009-03-10 07:48:57 +01004726
4727 if (nid == 0x10) {
4728 if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004729 HDA_AMP_MUTE)
Takashi Iwai86d190e2009-05-26 15:18:58 +02004730 spec->gpio_data &= ~spec->gpio_led; /* orange */
Takashi Iwaiba84bfc2009-05-30 08:59:03 +02004731 else
4732 spec->gpio_data |= spec->gpio_led; /* white */
Takashi Iwai6fce61a2009-03-10 07:48:57 +01004733
4734 stac_gpio_set(codec, spec->gpio_mask,
4735 spec->gpio_dir,
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004736 spec->gpio_data);
4737 }
4738
4739 return 0;
4740}
4741#endif
4742
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004743static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4744{
4745 struct sigmatel_spec *spec = codec->spec;
4746 if (spec->eapd_mask)
4747 stac_gpio_set(codec, spec->gpio_mask,
4748 spec->gpio_dir, spec->gpio_data &
4749 ~spec->eapd_mask);
4750 return 0;
4751}
Mattff6fdc32005-06-27 15:06:52 +02004752#endif
4753
Matt2f2f4252005-04-13 14:45:30 +02004754static struct hda_codec_ops stac92xx_patch_ops = {
4755 .build_controls = stac92xx_build_controls,
4756 .build_pcms = stac92xx_build_pcms,
4757 .init = stac92xx_init,
4758 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02004759 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004760#ifdef SND_HDA_NEEDS_RESUME
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004761 .suspend = stac92xx_suspend,
Mattff6fdc32005-06-27 15:06:52 +02004762 .resume = stac92xx_resume,
4763#endif
Matt2f2f4252005-04-13 14:45:30 +02004764};
4765
4766static int patch_stac9200(struct hda_codec *codec)
4767{
4768 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004769 int err;
Matt2f2f4252005-04-13 14:45:30 +02004770
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004771 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004772 if (spec == NULL)
4773 return -ENOMEM;
4774
4775 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004776 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004777 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004778 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4779 stac9200_models,
4780 stac9200_cfg_tbl);
Takashi Iwai330ee992009-02-20 14:33:36 +01004781 if (spec->board_config < 0)
Richard Fish11b44bb2006-08-23 18:31:34 +02004782 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01004783 else
4784 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004785 stac9200_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02004786
4787 spec->multiout.max_channels = 2;
4788 spec->multiout.num_dacs = 1;
4789 spec->multiout.dac_nids = stac9200_dac_nids;
4790 spec->adc_nids = stac9200_adc_nids;
4791 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02004792 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02004793 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004794 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004795 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004796
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02004797 if (spec->board_config == STAC_9200_M4 ||
4798 spec->board_config == STAC_9200_M4_2 ||
Tobin Davisbf277782008-02-03 20:31:47 +01004799 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02004800 spec->init = stac9200_eapd_init;
4801 else
4802 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004803 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004804
Takashi Iwai117f2572008-03-18 09:53:23 +01004805 if (spec->board_config == STAC_9200_PANASONIC) {
4806 spec->gpio_mask = spec->gpio_dir = 0x09;
4807 spec->gpio_data = 0x00;
4808 }
4809
Mattc7d4b2f2005-06-27 14:59:41 +02004810 err = stac9200_parse_auto_config(codec);
4811 if (err < 0) {
4812 stac92xx_free(codec);
4813 return err;
4814 }
Matt2f2f4252005-04-13 14:45:30 +02004815
Takashi Iwai2acc9dc2009-01-09 16:57:14 +01004816 /* CF-74 has no headphone detection, and the driver should *NOT*
4817 * do detection and HP/speaker toggle because the hardware does it.
4818 */
4819 if (spec->board_config == STAC_9200_PANASONIC)
4820 spec->hp_detect = 0;
4821
Matt2f2f4252005-04-13 14:45:30 +02004822 codec->patch_ops = stac92xx_patch_ops;
4823
4824 return 0;
4825}
4826
Tobin Davis8e21c342007-01-08 11:04:17 +01004827static int patch_stac925x(struct hda_codec *codec)
4828{
4829 struct sigmatel_spec *spec;
4830 int err;
4831
4832 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4833 if (spec == NULL)
4834 return -ENOMEM;
4835
4836 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004837 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01004838 spec->pin_nids = stac925x_pin_nids;
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02004839
4840 /* Check first for codec ID */
4841 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
4842 STAC_925x_MODELS,
4843 stac925x_models,
4844 stac925x_codec_id_cfg_tbl);
4845
4846 /* Now checks for PCI ID, if codec ID is not found */
4847 if (spec->board_config < 0)
4848 spec->board_config = snd_hda_check_board_config(codec,
4849 STAC_925x_MODELS,
Tobin Davis8e21c342007-01-08 11:04:17 +01004850 stac925x_models,
4851 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004852 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01004853 if (spec->board_config < 0)
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02004854 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
Tobin Davis2c11f952007-05-17 09:36:34 +02004855 "using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01004856 else
4857 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004858 stac925x_brd_tbl[spec->board_config]);
Tobin Davis8e21c342007-01-08 11:04:17 +01004859
4860 spec->multiout.max_channels = 2;
4861 spec->multiout.num_dacs = 1;
4862 spec->multiout.dac_nids = stac925x_dac_nids;
4863 spec->adc_nids = stac925x_adc_nids;
4864 spec->mux_nids = stac925x_mux_nids;
4865 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004866 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004867 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02004868 switch (codec->vendor_id) {
4869 case 0x83847632: /* STAC9202 */
4870 case 0x83847633: /* STAC9202D */
4871 case 0x83847636: /* STAC9251 */
4872 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02004873 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02004874 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004875 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4876 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02004877 break;
4878 default:
4879 spec->num_dmics = 0;
4880 break;
4881 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004882
4883 spec->init = stac925x_core_init;
4884 spec->mixer = stac925x_mixer;
4885
4886 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004887 if (!err) {
4888 if (spec->board_config < 0) {
4889 printk(KERN_WARNING "hda_codec: No auto-config is "
4890 "available, default to model=ref\n");
4891 spec->board_config = STAC_925x_REF;
4892 goto again;
4893 }
4894 err = -EINVAL;
4895 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004896 if (err < 0) {
4897 stac92xx_free(codec);
4898 return err;
4899 }
4900
4901 codec->patch_ops = stac92xx_patch_ops;
4902
4903 return 0;
4904}
4905
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004906static struct hda_input_mux stac92hd73xx_dmux = {
4907 .num_items = 4,
4908 .items = {
4909 { "Analog Inputs", 0x0b },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004910 { "Digital Mic 1", 0x09 },
4911 { "Digital Mic 2", 0x0a },
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004912 { "CD", 0x08 },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004913 }
4914};
4915
4916static int patch_stac92hd73xx(struct hda_codec *codec)
4917{
4918 struct sigmatel_spec *spec;
4919 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4920 int err = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004921 int num_dacs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004922
4923 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4924 if (spec == NULL)
4925 return -ENOMEM;
4926
4927 codec->spec = spec;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02004928 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004929 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4930 spec->pin_nids = stac92hd73xx_pin_nids;
4931 spec->board_config = snd_hda_check_board_config(codec,
4932 STAC_92HD73XX_MODELS,
4933 stac92hd73xx_models,
4934 stac92hd73xx_cfg_tbl);
4935again:
Takashi Iwai330ee992009-02-20 14:33:36 +01004936 if (spec->board_config < 0)
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004937 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4938 " STAC92HD73XX, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01004939 else
4940 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004941 stac92hd73xx_brd_tbl[spec->board_config]);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004942
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004943 num_dacs = snd_hda_get_connections(codec, 0x0a,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004944 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4945
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004946 if (num_dacs < 3 || num_dacs > 5) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004947 printk(KERN_WARNING "hda_codec: Could not determine "
4948 "number of channels defaulting to DAC count\n");
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004949 num_dacs = STAC92HD73_DAC_COUNT;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004950 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004951 switch (num_dacs) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004952 case 0x3: /* 6 Channel */
4953 spec->mixer = stac92hd73xx_6ch_mixer;
4954 spec->init = stac92hd73xx_6ch_core_init;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01004955 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004956 break;
4957 case 0x4: /* 8 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004958 spec->mixer = stac92hd73xx_8ch_mixer;
4959 spec->init = stac92hd73xx_8ch_core_init;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01004960 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004961 break;
4962 case 0x5: /* 10 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004963 spec->mixer = stac92hd73xx_10ch_mixer;
4964 spec->init = stac92hd73xx_10ch_core_init;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01004965 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
4966 break;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004967 }
4968 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004969
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004970 spec->aloopback_mask = 0x01;
4971 spec->aloopback_shift = 8;
4972
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004973 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004974 spec->mux_nids = stac92hd73xx_mux_nids;
4975 spec->adc_nids = stac92hd73xx_adc_nids;
4976 spec->dmic_nids = stac92hd73xx_dmic_nids;
4977 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004978 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostay89385032008-09-11 09:49:39 -04004979 spec->amp_nids = stac92hd73xx_amp_nids;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004980 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004981
4982 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4983 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01004984 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004985 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4986 sizeof(stac92hd73xx_dmux));
4987
Matthew Ranostaya7662642008-02-21 07:51:14 +01004988 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004989 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004990 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004991 /* fallthru */
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004992 case STAC_DELL_M6_AMIC:
4993 case STAC_DELL_M6_DMIC:
4994 case STAC_DELL_M6_BOTH:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004995 spec->num_smuxes = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004996 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4997 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004998 spec->eapd_switch = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004999 spec->num_amps = 1;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005000
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005001 if (spec->board_config != STAC_DELL_EQ)
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005002 spec->init = dell_m6_core_init;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005003 switch (spec->board_config) {
5004 case STAC_DELL_M6_AMIC: /* Analog Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01005005 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005006 spec->num_dmics = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005007 spec->private_dimux.num_items = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01005008 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005009 case STAC_DELL_M6_DMIC: /* Digital Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01005010 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005011 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005012 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01005013 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005014 case STAC_DELL_M6_BOTH: /* Both */
Takashi Iwai330ee992009-02-20 14:33:36 +01005015 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5016 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005017 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005018 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01005019 break;
5020 }
5021 break;
5022 default:
5023 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005024 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005025 spec->eapd_switch = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01005026 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005027 if (spec->board_config > STAC_92HD73XX_REF) {
5028 /* GPIO0 High = Enable EAPD */
5029 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5030 spec->gpio_data = 0x01;
5031 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005032 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostaya7662642008-02-21 07:51:14 +01005033
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005034 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
5035 spec->pwr_nids = stac92hd73xx_pwr_nids;
5036
Matthew Ranostayd9737752008-09-07 12:03:41 +02005037 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005038
5039 if (!err) {
5040 if (spec->board_config < 0) {
5041 printk(KERN_WARNING "hda_codec: No auto-config is "
5042 "available, default to model=ref\n");
5043 spec->board_config = STAC_92HD73XX_REF;
5044 goto again;
5045 }
5046 err = -EINVAL;
5047 }
5048
5049 if (err < 0) {
5050 stac92xx_free(codec);
5051 return err;
5052 }
5053
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01005054 if (spec->board_config == STAC_92HD73XX_NO_JD)
5055 spec->hp_detect = 0;
5056
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005057 codec->patch_ops = stac92xx_patch_ops;
5058
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005059 codec->proc_widget_hook = stac92hd7x_proc_hook;
5060
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005061 return 0;
5062}
5063
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005064static struct hda_input_mux stac92hd83xxx_dmux = {
5065 .num_items = 3,
5066 .items = {
5067 { "Analog Inputs", 0x03 },
5068 { "Digital Mic 1", 0x04 },
5069 { "Digital Mic 2", 0x05 },
5070 }
5071};
5072
5073static int patch_stac92hd83xxx(struct hda_codec *codec)
5074{
5075 struct sigmatel_spec *spec;
Matthew Ranostay65557f32009-01-20 16:50:25 -05005076 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005077 int err;
Matthew Ranostay65557f32009-01-20 16:50:25 -05005078 int num_dacs;
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05005079 hda_nid_t nid;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005080
5081 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5082 if (spec == NULL)
5083 return -ENOMEM;
5084
5085 codec->spec = spec;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005086 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005087 spec->mono_nid = 0x19;
5088 spec->digbeep_nid = 0x21;
5089 spec->dmic_nids = stac92hd83xxx_dmic_nids;
5090 spec->dmux_nids = stac92hd83xxx_dmux_nids;
5091 spec->adc_nids = stac92hd83xxx_adc_nids;
5092 spec->pwr_nids = stac92hd83xxx_pwr_nids;
Matthew Ranostayc15c5062009-01-13 13:30:07 -05005093 spec->amp_nids = stac92hd83xxx_amp_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005094 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
5095 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005096 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005097
5098 spec->init = stac92hd83xxx_core_init;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005099 spec->mixer = stac92hd83xxx_mixer;
5100 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
5101 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
5102 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
Matthew Ranostayc15c5062009-01-13 13:30:07 -05005103 spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005104 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
5105 spec->dinput_mux = &stac92hd83xxx_dmux;
5106 spec->pin_nids = stac92hd83xxx_pin_nids;
5107 spec->board_config = snd_hda_check_board_config(codec,
5108 STAC_92HD83XXX_MODELS,
5109 stac92hd83xxx_models,
5110 stac92hd83xxx_cfg_tbl);
5111again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005112 if (spec->board_config < 0)
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005113 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
5114 " STAC92HD83XXX, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01005115 else
5116 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005117 stac92hd83xxx_brd_tbl[spec->board_config]);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005118
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05005119 switch (codec->vendor_id) {
5120 case 0x111d7604:
5121 case 0x111d7605:
Matthew Ranostayff2e7332009-04-01 14:49:48 -04005122 case 0x111d76d5:
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05005123 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
5124 break;
5125 spec->num_pwrs = 0;
5126 break;
5127 }
5128
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005129 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
5130 if (!err) {
5131 if (spec->board_config < 0) {
5132 printk(KERN_WARNING "hda_codec: No auto-config is "
5133 "available, default to model=ref\n");
5134 spec->board_config = STAC_92HD83XXX_REF;
5135 goto again;
5136 }
5137 err = -EINVAL;
5138 }
5139
5140 if (err < 0) {
5141 stac92xx_free(codec);
5142 return err;
5143 }
5144
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05005145 switch (spec->board_config) {
5146 case STAC_DELL_S14:
5147 nid = 0xf;
5148 break;
5149 default:
5150 nid = 0xe;
5151 break;
5152 }
5153
5154 num_dacs = snd_hda_get_connections(codec, nid,
5155 conn, STAC92HD83_DAC_COUNT + 1) - 1;
5156
5157 /* set port X to select the last DAC
5158 */
5159 snd_hda_codec_write_cache(codec, nid, 0,
5160 AC_VERB_SET_CONNECT_SEL, num_dacs);
5161
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005162 codec->patch_ops = stac92xx_patch_ops;
5163
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005164 codec->proc_widget_hook = stac92hd_proc_hook;
5165
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005166 return 0;
5167}
5168
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005169static struct hda_input_mux stac92hd71bxx_dmux_nomixer = {
5170 .num_items = 3,
5171 .items = {
5172 { "Analog Inputs", 0x00 },
5173 { "Digital Mic 1", 0x02 },
5174 { "Digital Mic 2", 0x03 },
5175 }
5176};
5177
5178static struct hda_input_mux stac92hd71bxx_dmux_amixer = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005179 .num_items = 4,
5180 .items = {
5181 { "Analog Inputs", 0x00 },
5182 { "Mixer", 0x01 },
5183 { "Digital Mic 1", 0x02 },
5184 { "Digital Mic 2", 0x03 },
5185 }
5186};
5187
Takashi Iwai330ee992009-02-20 14:33:36 +01005188/* get the pin connection (fixed, none, etc) */
5189static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
5190{
5191 struct sigmatel_spec *spec = codec->spec;
5192 unsigned int cfg;
5193
5194 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
5195 return get_defcfg_connect(cfg);
5196}
5197
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005198static int stac92hd71bxx_connected_ports(struct hda_codec *codec,
5199 hda_nid_t *nids, int num_nids)
5200{
5201 struct sigmatel_spec *spec = codec->spec;
5202 int idx, num;
5203 unsigned int def_conf;
5204
5205 for (num = 0; num < num_nids; num++) {
5206 for (idx = 0; idx < spec->num_pins; idx++)
5207 if (spec->pin_nids[idx] == nids[num])
5208 break;
5209 if (idx >= spec->num_pins)
5210 break;
Takashi Iwai330ee992009-02-20 14:33:36 +01005211 def_conf = stac_get_defcfg_connect(codec, idx);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005212 if (def_conf == AC_JACK_PORT_NONE)
5213 break;
5214 }
5215 return num;
5216}
5217
5218static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
5219 hda_nid_t dig0pin)
5220{
5221 struct sigmatel_spec *spec = codec->spec;
5222 int idx;
5223
5224 for (idx = 0; idx < spec->num_pins; idx++)
5225 if (spec->pin_nids[idx] == dig0pin)
5226 break;
5227 if ((idx + 2) >= spec->num_pins)
5228 return 0;
5229
5230 /* dig1pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01005231 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005232 return 2;
5233
5234 /* dig0pin + dig2pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01005235 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005236 return 2;
Takashi Iwai330ee992009-02-20 14:33:36 +01005237 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005238 return 1;
5239 else
5240 return 0;
5241}
5242
Matthew Ranostaye035b842007-11-06 11:53:55 +01005243static int patch_stac92hd71bxx(struct hda_codec *codec)
5244{
5245 struct sigmatel_spec *spec;
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005246 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005247 int err = 0;
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005248 unsigned int ndmic_nids = 0;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005249
5250 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5251 if (spec == NULL)
5252 return -ENOMEM;
5253
5254 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005255 codec->patch_ops = stac92xx_patch_ops;
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05005256 spec->num_pins = STAC92HD71BXX_NUM_PINS;
5257 switch (codec->vendor_id) {
5258 case 0x111d76b6:
5259 case 0x111d76b7:
5260 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
5261 break;
5262 case 0x111d7603:
5263 case 0x111d7608:
5264 /* On 92HD75Bx 0x27 isn't a pin nid */
5265 spec->num_pins--;
5266 /* fallthrough */
5267 default:
5268 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
5269 }
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005270 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005271 spec->board_config = snd_hda_check_board_config(codec,
5272 STAC_92HD71BXX_MODELS,
5273 stac92hd71bxx_models,
5274 stac92hd71bxx_cfg_tbl);
5275again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005276 if (spec->board_config < 0)
Matthew Ranostaye035b842007-11-06 11:53:55 +01005277 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
5278 " STAC92HD71BXX, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01005279 else
5280 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005281 stac92hd71bxx_brd_tbl[spec->board_config]);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005282
Takashi Iwai41c3b642008-11-18 10:45:15 +01005283 if (spec->board_config > STAC_92HD71BXX_REF) {
5284 /* GPIO0 = EAPD */
5285 spec->gpio_mask = 0x01;
5286 spec->gpio_dir = 0x01;
5287 spec->gpio_data = 0x01;
5288 }
5289
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005290 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5291 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5292
Matthew Ranostay541eee82007-12-14 12:08:04 +01005293 switch (codec->vendor_id) {
5294 case 0x111d76b6: /* 4 Port without Analog Mixer */
5295 case 0x111d76b7:
Herton Ronaldo Krzesinski23c7b522009-02-08 19:51:28 -02005296 unmute_init++;
5297 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005298 case 0x111d76b4: /* 6 Port without Analog Mixer */
5299 case 0x111d76b5:
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005300 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_nomixer,
5301 sizeof(stac92hd71bxx_dmux_nomixer));
Matthew Ranostay541eee82007-12-14 12:08:04 +01005302 spec->mixer = stac92hd71bxx_mixer;
5303 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005304 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005305 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5306 stac92hd71bxx_dmic_nids,
5307 STAC92HD71BXX_NUM_DMICS);
5308 if (spec->num_dmics) {
5309 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5310 spec->dinput_mux = &spec->private_dimux;
5311 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
5312 }
Matthew Ranostay541eee82007-12-14 12:08:04 +01005313 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005314 case 0x111d7608: /* 5 Port with Analog Mixer */
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005315 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
5316 sizeof(stac92hd71bxx_dmux_amixer));
5317 spec->private_dimux.num_items--;
Takashi Iwai8e5f2622008-11-15 19:28:54 +01005318 switch (spec->board_config) {
5319 case STAC_HP_M4:
Matthew Ranostay72474be2008-10-09 09:32:17 -04005320 /* Enable VREF power saving on GPIO1 detect */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005321 err = stac_add_event(spec, codec->afg,
5322 STAC_VREF_EVENT, 0x02);
5323 if (err < 0)
5324 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005325 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay72474be2008-10-09 09:32:17 -04005326 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
5327 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005328 AC_VERB_SET_UNSOLICITED_ENABLE,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005329 AC_USRSP_EN | err);
Matthew Ranostay72474be2008-10-09 09:32:17 -04005330 spec->gpio_mask |= 0x02;
5331 break;
5332 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005333 if ((codec->revision_id & 0xf) == 0 ||
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005334 (codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005335 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005336
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005337 /* no output amps */
5338 spec->num_pwrs = 0;
5339 spec->mixer = stac92hd71bxx_analog_mixer;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005340 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005341
5342 /* disable VSW */
5343 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005344 unmute_init++;
Takashi Iwai330ee992009-02-20 14:33:36 +01005345 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5346 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005347 stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0;
5348 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5349 stac92hd71bxx_dmic_nids,
5350 STAC92HD71BXX_NUM_DMICS - 1);
5351 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5352 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 2;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005353 break;
5354 case 0x111d7603: /* 6 Port with Analog Mixer */
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005355 if ((codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005356 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005357
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005358 /* no output amps */
5359 spec->num_pwrs = 0;
5360 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005361 default:
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005362 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
5363 sizeof(stac92hd71bxx_dmux_amixer));
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005364 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005365 spec->mixer = stac92hd71bxx_analog_mixer;
5366 spec->init = stac92hd71bxx_analog_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005367 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005368 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5369 stac92hd71bxx_dmic_nids,
5370 STAC92HD71BXX_NUM_DMICS);
5371 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5372 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005373 }
5374
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005375 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5376 snd_hda_sequence_write_cache(codec, unmute_init);
5377
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005378 spec->aloopback_ctl = stac92hd71bxx_loopback;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005379 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005380 spec->aloopback_shift = 0;
5381
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005382 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005383 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005384 spec->mux_nids = stac92hd71bxx_mux_nids;
5385 spec->adc_nids = stac92hd71bxx_adc_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005386 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005387 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005388
5389 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5390 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005391 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005392
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005393 switch (spec->board_config) {
5394 case STAC_HP_M4:
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005395 /* enable internal microphone */
Takashi Iwai330ee992009-02-20 14:33:36 +01005396 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
Matthew Ranostayb9aea712008-10-09 08:37:28 -04005397 stac92xx_auto_set_pinctl(codec, 0x0e,
5398 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05005399 /* fallthru */
5400 case STAC_DELL_M4_2:
5401 spec->num_dmics = 0;
5402 spec->num_smuxes = 0;
5403 spec->num_dmuxes = 0;
5404 break;
5405 case STAC_DELL_M4_1:
5406 case STAC_DELL_M4_3:
5407 spec->num_dmics = 1;
5408 spec->num_smuxes = 0;
Takashi Iwaiea18aa42009-02-27 17:36:33 +01005409 spec->num_dmuxes = 1;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005410 break;
James Gardiner514bf542009-05-03 04:00:44 -04005411 case STAC_HP_DV4_1222NR:
5412 spec->num_dmics = 1;
5413 /* I don't know if it needs 1 or 2 smuxes - will wait for
5414 * bug reports to fix if needed
5415 */
5416 spec->num_smuxes = 1;
5417 spec->num_dmuxes = 1;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005418 spec->gpio_led = 0x01;
James Gardiner514bf542009-05-03 04:00:44 -04005419 /* fallthrough */
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005420 case STAC_HP_DV5:
Takashi Iwai330ee992009-02-20 14:33:36 +01005421 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005422 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
5423 break;
Christoph Plattnerae6241f2009-03-08 23:19:05 +01005424 case STAC_HP_HDX:
5425 spec->num_dmics = 1;
5426 spec->num_dmuxes = 1;
5427 spec->num_smuxes = 1;
Christoph Plattner443e26d2009-03-10 00:05:56 +01005428 /* orange/white mute led on GPIO3, orange=0, white=1 */
Takashi Iwai86d190e2009-05-26 15:18:58 +02005429 spec->gpio_led = 0x08;
5430 break;
5431 }
Christoph Plattner443e26d2009-03-10 00:05:56 +01005432
Takashi Iwai86d190e2009-05-26 15:18:58 +02005433#ifdef CONFIG_SND_HDA_POWER_SAVE
5434 if (spec->gpio_led) {
5435 spec->gpio_mask |= spec->gpio_led;
5436 spec->gpio_dir |= spec->gpio_led;
5437 spec->gpio_data |= spec->gpio_led;
Christoph Plattner443e26d2009-03-10 00:05:56 +01005438 /* register check_power_status callback. */
Takashi Iwai6fce61a2009-03-10 07:48:57 +01005439 codec->patch_ops.check_power_status =
Takashi Iwai86d190e2009-05-26 15:18:58 +02005440 stac92xx_hp_check_power_status;
5441 }
Christoph Plattner443e26d2009-03-10 00:05:56 +01005442#endif
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005443
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005444 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005445 if (spec->dinput_mux)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005446 spec->private_dimux.num_items += spec->num_dmics - ndmic_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005447
Herton Ronaldo Krzesinski29d4ab42009-02-04 11:37:27 -05005448 err = stac92xx_parse_auto_config(codec, 0x21, 0);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005449 if (!err) {
5450 if (spec->board_config < 0) {
5451 printk(KERN_WARNING "hda_codec: No auto-config is "
5452 "available, default to model=ref\n");
5453 spec->board_config = STAC_92HD71BXX_REF;
5454 goto again;
5455 }
5456 err = -EINVAL;
5457 }
5458
5459 if (err < 0) {
5460 stac92xx_free(codec);
5461 return err;
5462 }
5463
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005464 codec->proc_widget_hook = stac92hd7x_proc_hook;
5465
Matthew Ranostaye035b842007-11-06 11:53:55 +01005466 return 0;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005467}
Matthew Ranostaye035b842007-11-06 11:53:55 +01005468
Matt2f2f4252005-04-13 14:45:30 +02005469static int patch_stac922x(struct hda_codec *codec)
5470{
5471 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005472 int err;
Matt2f2f4252005-04-13 14:45:30 +02005473
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005474 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02005475 if (spec == NULL)
5476 return -ENOMEM;
5477
5478 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005479 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005480 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005481 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5482 stac922x_models,
5483 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08005484 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005485 spec->gpio_mask = spec->gpio_dir = 0x03;
5486 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005487 /* Intel Macs have all same PCI SSID, so we need to check
5488 * codec SSID to distinguish the exact models
5489 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005490 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005491 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005492
5493 case 0x106b0800:
5494 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02005495 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005496 case 0x106b0600:
5497 case 0x106b0700:
5498 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005499 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005500 case 0x106b0e00:
5501 case 0x106b0f00:
5502 case 0x106b1600:
5503 case 0x106b1700:
5504 case 0x106b0200:
5505 case 0x106b1e00:
5506 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005507 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005508 case 0x106b1a00:
5509 case 0x00000100:
5510 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02005511 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005512 case 0x106b0a00:
5513 case 0x106b2200:
5514 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02005515 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08005516 default:
5517 spec->board_config = STAC_INTEL_MAC_V3;
5518 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005519 }
5520 }
5521
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005522 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005523 if (spec->board_config < 0)
Richard Fish11b44bb2006-08-23 18:31:34 +02005524 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
5525 "using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01005526 else
5527 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005528 stac922x_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02005529
Matt2f2f4252005-04-13 14:45:30 +02005530 spec->adc_nids = stac922x_adc_nids;
5531 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005532 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005533 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005534 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005535 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02005536
5537 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02005538 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02005539
5540 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02005541
Matt Porter3cc08dc2006-01-23 15:27:49 +01005542 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005543 if (!err) {
5544 if (spec->board_config < 0) {
5545 printk(KERN_WARNING "hda_codec: No auto-config is "
5546 "available, default to model=ref\n");
5547 spec->board_config = STAC_D945_REF;
5548 goto again;
5549 }
5550 err = -EINVAL;
5551 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005552 if (err < 0) {
5553 stac92xx_free(codec);
5554 return err;
5555 }
5556
5557 codec->patch_ops = stac92xx_patch_ops;
5558
Takashi Iwai807a46362007-05-29 19:01:37 +02005559 /* Fix Mux capture level; max to 2 */
5560 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
5561 (0 << AC_AMPCAP_OFFSET_SHIFT) |
5562 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5563 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5564 (0 << AC_AMPCAP_MUTE_SHIFT));
5565
Matt Porter3cc08dc2006-01-23 15:27:49 +01005566 return 0;
5567}
5568
5569static int patch_stac927x(struct hda_codec *codec)
5570{
5571 struct sigmatel_spec *spec;
5572 int err;
5573
5574 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5575 if (spec == NULL)
5576 return -ENOMEM;
5577
5578 codec->spec = spec;
Matthew Ranostay45c1d852009-02-04 17:49:41 -05005579 codec->slave_dig_outs = stac927x_slave_dig_outs;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005580 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005581 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005582 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5583 stac927x_models,
5584 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005585 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005586 if (spec->board_config < 0)
Herton Ronaldo Krzesinskic98041f2009-02-11 20:33:15 -02005587 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
5588 "STAC927x, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01005589 else
5590 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005591 stac927x_brd_tbl[spec->board_config]);
Matt Porter3cc08dc2006-01-23 15:27:49 +01005592
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005593 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005594 spec->adc_nids = stac927x_adc_nids;
5595 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
5596 spec->mux_nids = stac927x_mux_nids;
5597 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005598 spec->smux_nids = stac927x_smux_nids;
5599 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04005600 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005601 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005602 spec->multiout.dac_nids = spec->dac_nids;
5603
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005604 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02005605 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005606 case STAC_D965_5ST:
5607 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005608 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005609 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005610 spec->num_dmics = 0;
5611
Tobin Davis93ed1502006-09-01 21:03:12 +02005612 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005613 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005614 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005615 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02005616 switch (codec->subsystem_id) {
5617 case 0x10280209:
5618 case 0x1028022e:
5619 /* correct the device field to SPDIF out */
Takashi Iwai330ee992009-02-20 14:33:36 +01005620 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
Matthew Ranostay780c8be2008-04-14 13:32:27 +02005621 break;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005622 }
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01005623 /* configure the analog microphone on some laptops */
Takashi Iwai330ee992009-02-20 14:33:36 +01005624 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01005625 /* correct the front output jack as a hp out */
Takashi Iwai330ee992009-02-20 14:33:36 +01005626 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01005627 /* correct the front input jack as a mic */
Takashi Iwai330ee992009-02-20 14:33:36 +01005628 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01005629 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005630 case STAC_DELL_3ST:
5631 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005632 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005633 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005634 spec->dmic_nids = stac927x_dmic_nids;
5635 spec->num_dmics = STAC927X_NUM_DMICS;
5636
Tobin Davis93ed1502006-09-01 21:03:12 +02005637 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005638 spec->mixer = stac927x_mixer;
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;
5642 default:
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005643 if (spec->board_config > STAC_D965_REF) {
5644 /* GPIO0 High = Enable EAPD */
5645 spec->eapd_mask = spec->gpio_mask = 0x01;
5646 spec->gpio_dir = spec->gpio_data = 0x01;
5647 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005648 spec->num_dmics = 0;
5649
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005650 spec->init = stac927x_core_init;
5651 spec->mixer = stac927x_mixer;
5652 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005653
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005654 spec->num_pwrs = 0;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005655 spec->aloopback_ctl = stac927x_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005656 spec->aloopback_mask = 0x40;
5657 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005658 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005659
Matt Porter3cc08dc2006-01-23 15:27:49 +01005660 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005661 if (!err) {
5662 if (spec->board_config < 0) {
5663 printk(KERN_WARNING "hda_codec: No auto-config is "
5664 "available, default to model=ref\n");
5665 spec->board_config = STAC_D965_REF;
5666 goto again;
5667 }
5668 err = -EINVAL;
5669 }
Mattc7d4b2f2005-06-27 14:59:41 +02005670 if (err < 0) {
5671 stac92xx_free(codec);
5672 return err;
5673 }
Matt2f2f4252005-04-13 14:45:30 +02005674
5675 codec->patch_ops = stac92xx_patch_ops;
5676
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005677 codec->proc_widget_hook = stac927x_proc_hook;
5678
Takashi Iwai52987652008-01-16 16:09:47 +01005679 /*
5680 * !!FIXME!!
5681 * The STAC927x seem to require fairly long delays for certain
5682 * command sequences. With too short delays (even if the answer
5683 * is set to RIRB properly), it results in the silence output
5684 * on some hardwares like Dell.
5685 *
5686 * The below flag enables the longer delay (see get_response
5687 * in hda_intel.c).
5688 */
5689 codec->bus->needs_damn_long_delay = 1;
5690
Takashi Iwaie28d8322008-12-17 13:48:29 +01005691 /* no jack detecion for ref-no-jd model */
5692 if (spec->board_config == STAC_D965_REF_NO_JD)
5693 spec->hp_detect = 0;
5694
Matt2f2f4252005-04-13 14:45:30 +02005695 return 0;
5696}
5697
Matt Porterf3302a52006-07-31 12:49:34 +02005698static int patch_stac9205(struct hda_codec *codec)
5699{
5700 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02005701 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02005702
5703 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5704 if (spec == NULL)
5705 return -ENOMEM;
5706
5707 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005708 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005709 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005710 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
5711 stac9205_models,
5712 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005713 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005714 if (spec->board_config < 0)
Richard Fish11b44bb2006-08-23 18:31:34 +02005715 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01005716 else
5717 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005718 stac9205_brd_tbl[spec->board_config]);
Matt Porterf3302a52006-07-31 12:49:34 +02005719
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005720 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02005721 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005722 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02005723 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005724 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005725 spec->smux_nids = stac9205_smux_nids;
5726 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005727 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02005728 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005729 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005730 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005731 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02005732
5733 spec->init = stac9205_core_init;
5734 spec->mixer = stac9205_mixer;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005735 spec->aloopback_ctl = stac9205_loopback;
Matt Porterf3302a52006-07-31 12:49:34 +02005736
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005737 spec->aloopback_mask = 0x40;
5738 spec->aloopback_shift = 0;
Takashi Iwaid9a42682009-01-22 17:40:18 +01005739 /* Turn on/off EAPD per HP plugging */
5740 if (spec->board_config != STAC_9205_EAPD)
5741 spec->eapd_switch = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02005742 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02005743
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005744 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005745 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02005746 /* Enable SPDIF in/out */
Takashi Iwai330ee992009-02-20 14:33:36 +01005747 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
5748 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01005749
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005750 /* Enable unsol response for GPIO4/Dock HP connection */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005751 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
5752 if (err < 0)
5753 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005754 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005755 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
5756 snd_hda_codec_write_cache(codec, codec->afg, 0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005757 AC_VERB_SET_UNSOLICITED_ENABLE,
5758 AC_USRSP_EN | err);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005759
5760 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005761 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005762 spec->gpio_mask = 0x1b;
5763 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01005764 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005765 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02005766 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005767 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005768 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005769 case STAC_9205_REF:
5770 /* SPDIF-In enabled */
5771 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005772 default:
5773 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005774 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005775 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005776 break;
5777 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02005778
Matt Porterf3302a52006-07-31 12:49:34 +02005779 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005780 if (!err) {
5781 if (spec->board_config < 0) {
5782 printk(KERN_WARNING "hda_codec: No auto-config is "
5783 "available, default to model=ref\n");
5784 spec->board_config = STAC_9205_REF;
5785 goto again;
5786 }
5787 err = -EINVAL;
5788 }
Matt Porterf3302a52006-07-31 12:49:34 +02005789 if (err < 0) {
5790 stac92xx_free(codec);
5791 return err;
5792 }
5793
5794 codec->patch_ops = stac92xx_patch_ops;
5795
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005796 codec->proc_widget_hook = stac9205_proc_hook;
5797
Matt Porterf3302a52006-07-31 12:49:34 +02005798 return 0;
5799}
5800
Matt2f2f4252005-04-13 14:45:30 +02005801/*
Guillaume Munch6d859062006-08-22 17:15:47 +02005802 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01005803 */
5804
Takashi Iwai1e137f92009-01-21 07:41:22 +01005805static struct hda_verb stac9872_core_init[] = {
Takashi Iwai1624cb92007-07-05 13:10:51 +02005806 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005807 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5808 {}
5809};
5810
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005811static struct snd_kcontrol_new stac9872_mixer[] = {
5812 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5813 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005814 { } /* end */
5815};
5816
5817static 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 Iwai307282c2009-03-12 18:17:58 +01005830static unsigned int stac9872_vaio_pin_configs[9] = {
5831 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
5832 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
5833 0x90a7013e
5834};
5835
5836static const char *stac9872_models[STAC_9872_MODELS] = {
5837 [STAC_9872_AUTO] = "auto",
5838 [STAC_9872_VAIO] = "vaio",
5839};
5840
5841static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
5842 [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
5843};
5844
5845static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5846 {} /* terminator */
5847};
5848
Guillaume Munch6d859062006-08-22 17:15:47 +02005849static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01005850{
5851 struct sigmatel_spec *spec;
Takashi Iwai1e137f92009-01-21 07:41:22 +01005852 int err;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005853
Takashi Iwaidb064e52006-03-16 16:04:58 +01005854 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5855 if (spec == NULL)
5856 return -ENOMEM;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005857 codec->spec = spec;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005858
5859 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5860 stac9872_models,
5861 stac9872_cfg_tbl);
Takashi Iwai307282c2009-03-12 18:17:58 +01005862 if (spec->board_config < 0)
5863 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9872, "
5864 "using BIOS defaults\n");
5865 else
5866 stac92xx_set_config_regs(codec,
5867 stac9872_brd_tbl[spec->board_config]);
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005868
Takashi Iwai1e137f92009-01-21 07:41:22 +01005869 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
5870 spec->pin_nids = stac9872_pin_nids;
5871 spec->multiout.dac_nids = spec->dac_nids;
5872 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
5873 spec->adc_nids = stac9872_adc_nids;
5874 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
5875 spec->mux_nids = stac9872_mux_nids;
5876 spec->mixer = stac9872_mixer;
5877 spec->init = stac9872_core_init;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005878
Takashi Iwai1e137f92009-01-21 07:41:22 +01005879 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
5880 if (err < 0) {
5881 stac92xx_free(codec);
5882 return -EINVAL;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005883 }
Takashi Iwai1e137f92009-01-21 07:41:22 +01005884 spec->input_mux = &spec->private_imux;
5885 codec->patch_ops = stac92xx_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005886 return 0;
5887}
5888
5889
5890/*
Matt2f2f4252005-04-13 14:45:30 +02005891 * patch entries
5892 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +01005893static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
Matt2f2f4252005-04-13 14:45:30 +02005894 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5895 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5896 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5897 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5898 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5899 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5900 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02005901 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5902 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5903 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5904 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5905 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5906 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01005907 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5908 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5909 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5910 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5911 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5912 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5913 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5914 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5915 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5916 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01005917 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5918 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5919 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5920 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5921 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5922 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02005923 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5924 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02005925 /* The following does not take into account .id=0x83847661 when subsys =
5926 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5927 * currently not fully supported.
5928 */
5929 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5930 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5931 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02005932 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5933 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5934 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5935 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5936 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5937 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5938 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5939 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005940 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005941 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5942 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayff2e7332009-04-01 14:49:48 -04005943 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005944 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01005945 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5946 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005947 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01005948 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5949 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5950 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5951 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5952 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5953 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5954 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5955 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02005956 {} /* terminator */
5957};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01005958
5959MODULE_ALIAS("snd-hda-codec-id:8384*");
5960MODULE_ALIAS("snd-hda-codec-id:111d*");
5961
5962MODULE_LICENSE("GPL");
5963MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
5964
5965static struct hda_codec_preset_list sigmatel_list = {
5966 .preset = snd_hda_preset_sigmatel,
5967 .owner = THIS_MODULE,
5968};
5969
5970static int __init patch_sigmatel_init(void)
5971{
5972 return snd_hda_add_codec_preset(&sigmatel_list);
5973}
5974
5975static void __exit patch_sigmatel_exit(void)
5976{
5977 snd_hda_delete_codec_preset(&sigmatel_list);
5978}
5979
5980module_init(patch_sigmatel_init)
5981module_exit(patch_sigmatel_exit)