blob: c2d4abee3b0963089fdfdddba4bad970cafb4a58 [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 {
46 STAC_REF,
Tobin Davisbf277782008-02-03 20:31:47 +010047 STAC_9200_OQO,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020048 STAC_9200_DELL_D21,
49 STAC_9200_DELL_D22,
50 STAC_9200_DELL_D23,
51 STAC_9200_DELL_M21,
52 STAC_9200_DELL_M22,
53 STAC_9200_DELL_M23,
54 STAC_9200_DELL_M24,
55 STAC_9200_DELL_M25,
56 STAC_9200_DELL_M26,
57 STAC_9200_DELL_M27,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +020058 STAC_9200_M4,
59 STAC_9200_M4_2,
Takashi Iwai117f2572008-03-18 09:53:23 +010060 STAC_9200_PANASONIC,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010061 STAC_9200_MODELS
62};
63
64enum {
65 STAC_9205_REF,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020066 STAC_9205_DELL_M42,
Tobin Davisae0a8ed2007-08-13 15:50:29 +020067 STAC_9205_DELL_M43,
68 STAC_9205_DELL_M44,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010069 STAC_9205_MODELS
70};
71
72enum {
Takashi Iwai9e43f0d2008-12-17 14:51:01 +010073 STAC_92HD73XX_NO_JD, /* no jack-detection */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010074 STAC_92HD73XX_REF,
Takashi Iwai661cd8f2008-11-25 15:18:29 +010075 STAC_DELL_M6_AMIC,
76 STAC_DELL_M6_DMIC,
77 STAC_DELL_M6_BOTH,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -050078 STAC_DELL_EQ,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010079 STAC_92HD73XX_MODELS
80};
81
82enum {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020083 STAC_92HD83XXX_REF,
84 STAC_92HD83XXX_MODELS
85};
86
87enum {
Matthew Ranostaye035b842007-11-06 11:53:55 +010088 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010089 STAC_DELL_M4_1,
90 STAC_DELL_M4_2,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -050091 STAC_DELL_M4_3,
Matthew Ranostay6a14f582008-09-12 12:02:30 -040092 STAC_HP_M4,
Takashi Iwai1b0652e2009-01-14 08:27:35 +010093 STAC_HP_DV5,
Matthew Ranostaye035b842007-11-06 11:53:55 +010094 STAC_92HD71BXX_MODELS
95};
96
97enum {
Tobin Davis8e21c342007-01-08 11:04:17 +010098 STAC_925x_REF,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +020099 STAC_M1,
100 STAC_M1_2,
101 STAC_M2,
Tobin Davis8e21c342007-01-08 11:04:17 +0100102 STAC_M2_2,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200103 STAC_M3,
104 STAC_M5,
105 STAC_M6,
Tobin Davis8e21c342007-01-08 11:04:17 +0100106 STAC_925x_MODELS
107};
108
109enum {
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100110 STAC_D945_REF,
111 STAC_D945GTP3,
112 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200113 STAC_INTEL_MAC_V1,
114 STAC_INTEL_MAC_V2,
115 STAC_INTEL_MAC_V3,
116 STAC_INTEL_MAC_V4,
117 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800118 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
119 * is given, one of the above models will be
120 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200121 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100122 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100123 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100124 STAC_MACBOOK_PRO_V1,
125 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200126 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200127 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300128 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200129 STAC_922X_DELL_D81,
130 STAC_922X_DELL_D82,
131 STAC_922X_DELL_M81,
132 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100133 STAC_922X_MODELS
134};
135
136enum {
Takashi Iwaie28d8322008-12-17 13:48:29 +0100137 STAC_D965_REF_NO_JD, /* no jack-detection */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100138 STAC_D965_REF,
139 STAC_D965_3ST,
140 STAC_D965_5ST,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200141 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100142 STAC_DELL_BIOS,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100143 STAC_927X_MODELS
144};
Matt Porter403d1942005-11-29 15:00:51 +0100145
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400146struct sigmatel_event {
147 hda_nid_t nid;
Takashi Iwaic6e4c662008-11-25 11:58:19 +0100148 unsigned char type;
149 unsigned char tag;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400150 int data;
151};
152
153struct sigmatel_jack {
154 hda_nid_t nid;
155 int type;
156 struct snd_jack *jack;
157};
158
Matt2f2f4252005-04-13 14:45:30 +0200159struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100160 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200161 unsigned int num_mixers;
162
Matt Porter403d1942005-11-29 15:00:51 +0100163 int board_config;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -0500164 unsigned int eapd_switch: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200165 unsigned int surr_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100166 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100167 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400168 unsigned int spdif_mute: 1;
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100169 unsigned int check_volume_offset:1;
Mattc7d4b2f2005-06-27 14:59:41 +0200170
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100171 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200172 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100173 unsigned int gpio_mask;
174 unsigned int gpio_dir;
175 unsigned int gpio_data;
176 unsigned int gpio_mute;
177
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200178 /* stream */
179 unsigned int stream_delay;
180
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100181 /* analog loopback */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100182 unsigned char aloopback_mask;
183 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200184
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100185 /* power management */
186 unsigned int num_pwrs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200187 unsigned int *pwr_mapping;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100188 hda_nid_t *pwr_nids;
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100189 hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100190
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400191 /* jack detection */
192 struct snd_array jacks;
193
194 /* events */
195 struct snd_array events;
196
Matt2f2f4252005-04-13 14:45:30 +0200197 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100198 struct hda_input_mux *mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400199 struct hda_input_mux *amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100200 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200201 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100202 hda_nid_t dac_nids[5];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100203 hda_nid_t hp_dacs[5];
204 hda_nid_t speaker_dacs[5];
Matt2f2f4252005-04-13 14:45:30 +0200205
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100206 int volume_offset;
207
Matt2f2f4252005-04-13 14:45:30 +0200208 /* capture */
209 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200210 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200211 hda_nid_t *mux_nids;
212 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200213 hda_nid_t *dmic_nids;
214 unsigned int num_dmics;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100215 hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100216 unsigned int num_dmuxes;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200217 hda_nid_t *smux_nids;
218 unsigned int num_smuxes;
Matthew Ranostay65973632008-09-16 10:39:37 -0400219 const char **spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200220
Mattdabbed62005-06-14 10:19:34 +0200221 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100222 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200223 hda_nid_t anabeep_nid;
224 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200225
Matt2f2f4252005-04-13 14:45:30 +0200226 /* pin widgets */
227 hda_nid_t *pin_nids;
228 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200229 unsigned int *pin_configs;
Matt2f2f4252005-04-13 14:45:30 +0200230
231 /* codec specific stuff */
232 struct hda_verb *init;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100233 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200234
235 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200236 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100237 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200238 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100239 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200240 struct hda_input_mux *sinput_mux;
241 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400242 unsigned int cur_amux;
243 hda_nid_t *amp_nids;
244 unsigned int num_amps;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200245 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200246
Matt Porter403d1942005-11-29 15:00:51 +0100247 /* i/o switches */
248 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200249 unsigned int clfe_swap;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100250 hda_nid_t line_switch; /* shared line-in for input and output */
251 hda_nid_t mic_switch; /* shared mic-in for input and output */
252 hda_nid_t hp_switch; /* NID of HP as line-out */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200253 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200254
Mattc7d4b2f2005-06-27 14:59:41 +0200255 struct hda_pcm pcm_rec[2]; /* PCM information */
256
257 /* dynamic controls and input_mux */
258 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200259 struct snd_array kctls;
Matt Porter8b657272006-10-26 17:12:59 +0200260 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200261 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200262 struct hda_input_mux private_smux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400263 struct hda_input_mux private_amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100264 struct hda_input_mux private_mono_mux;
Matt2f2f4252005-04-13 14:45:30 +0200265};
266
267static hda_nid_t stac9200_adc_nids[1] = {
268 0x03,
269};
270
271static hda_nid_t stac9200_mux_nids[1] = {
272 0x0c,
273};
274
275static hda_nid_t stac9200_dac_nids[1] = {
276 0x02,
277};
278
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100279static hda_nid_t stac92hd73xx_pwr_nids[8] = {
280 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
281 0x0f, 0x10, 0x11
282};
283
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400284static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
285 0x26, 0,
286};
287
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100288static hda_nid_t stac92hd73xx_adc_nids[2] = {
289 0x1a, 0x1b
290};
291
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400292#define DELL_M6_AMP 2
293static hda_nid_t stac92hd73xx_amp_nids[3] = {
294 0x0b, 0x0c, 0x0e
Matthew Ranostay89385032008-09-11 09:49:39 -0400295};
296
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100297#define STAC92HD73XX_NUM_DMICS 2
298static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
299 0x13, 0x14, 0
300};
301
302#define STAC92HD73_DAC_COUNT 5
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100303
304static hda_nid_t stac92hd73xx_mux_nids[4] = {
305 0x28, 0x29, 0x2a, 0x2b,
306};
307
308static hda_nid_t stac92hd73xx_dmux_nids[2] = {
309 0x20, 0x21,
310};
311
Matthew Ranostayd9737752008-09-07 12:03:41 +0200312static hda_nid_t stac92hd73xx_smux_nids[2] = {
313 0x22, 0x23,
314};
315
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200316#define STAC92HD83XXX_NUM_DMICS 2
317static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
318 0x11, 0x12, 0
319};
320
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200321#define STAC92HD83_DAC_COUNT 3
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200322
323static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
324 0x17, 0x18,
325};
326
327static hda_nid_t stac92hd83xxx_adc_nids[2] = {
328 0x15, 0x16,
329};
330
331static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
332 0xa, 0xb, 0xd, 0xe,
333};
334
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400335static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
336 0x1e, 0,
337};
338
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200339static unsigned int stac92hd83xxx_pwr_mapping[4] = {
Matthew Ranostay989738c2009-01-17 18:47:27 -0500340 0x03, 0x0c, 0x20, 0x80,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200341};
342
Takashi Iwai9248f262009-01-14 09:40:25 +0100343static hda_nid_t stac92hd83xxx_amp_nids[1] = {
Matthew Ranostayc15c5062009-01-13 13:30:07 -0500344 0xc,
345};
346
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100347static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
348 0x0a, 0x0d, 0x0f
349};
350
Matthew Ranostaye035b842007-11-06 11:53:55 +0100351static hda_nid_t stac92hd71bxx_adc_nids[2] = {
352 0x12, 0x13,
353};
354
355static hda_nid_t stac92hd71bxx_mux_nids[2] = {
356 0x1a, 0x1b
357};
358
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400359static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
360 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100361};
362
Matthew Ranostayd9737752008-09-07 12:03:41 +0200363static hda_nid_t stac92hd71bxx_smux_nids[2] = {
364 0x24, 0x25,
365};
366
Matthew Ranostaye035b842007-11-06 11:53:55 +0100367#define STAC92HD71BXX_NUM_DMICS 2
368static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
369 0x18, 0x19, 0
370};
371
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400372static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
373 0x22, 0
374};
375
Tobin Davis8e21c342007-01-08 11:04:17 +0100376static hda_nid_t stac925x_adc_nids[1] = {
377 0x03,
378};
379
380static hda_nid_t stac925x_mux_nids[1] = {
381 0x0f,
382};
383
384static hda_nid_t stac925x_dac_nids[1] = {
385 0x02,
386};
387
Takashi Iwaif6e98522007-10-16 14:27:04 +0200388#define STAC925X_NUM_DMICS 1
389static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
390 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200391};
392
Takashi Iwai1697055e2007-12-18 18:05:52 +0100393static hda_nid_t stac925x_dmux_nids[1] = {
394 0x14,
395};
396
Matt2f2f4252005-04-13 14:45:30 +0200397static hda_nid_t stac922x_adc_nids[2] = {
398 0x06, 0x07,
399};
400
401static hda_nid_t stac922x_mux_nids[2] = {
402 0x12, 0x13,
403};
404
Matt Porter3cc08dc2006-01-23 15:27:49 +0100405static hda_nid_t stac927x_adc_nids[3] = {
406 0x07, 0x08, 0x09
407};
408
409static hda_nid_t stac927x_mux_nids[3] = {
410 0x15, 0x16, 0x17
411};
412
Matthew Ranostayd9737752008-09-07 12:03:41 +0200413static hda_nid_t stac927x_smux_nids[1] = {
414 0x21,
415};
416
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100417static hda_nid_t stac927x_dac_nids[6] = {
418 0x02, 0x03, 0x04, 0x05, 0x06, 0
419};
420
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100421static hda_nid_t stac927x_dmux_nids[1] = {
422 0x1b,
423};
424
Matthew Ranostay7f168592007-10-18 17:38:17 +0200425#define STAC927X_NUM_DMICS 2
426static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
427 0x13, 0x14, 0
428};
429
Matthew Ranostay65973632008-09-16 10:39:37 -0400430static const char *stac927x_spdif_labels[5] = {
431 "Digital Playback", "ADAT", "Analog Mux 1",
432 "Analog Mux 2", "Analog Mux 3"
433};
434
Matt Porterf3302a52006-07-31 12:49:34 +0200435static hda_nid_t stac9205_adc_nids[2] = {
436 0x12, 0x13
437};
438
439static hda_nid_t stac9205_mux_nids[2] = {
440 0x19, 0x1a
441};
442
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100443static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100444 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100445};
446
Matthew Ranostayd9737752008-09-07 12:03:41 +0200447static hda_nid_t stac9205_smux_nids[1] = {
448 0x21,
449};
450
Takashi Iwaif6e98522007-10-16 14:27:04 +0200451#define STAC9205_NUM_DMICS 2
452static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
453 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200454};
455
Mattc7d4b2f2005-06-27 14:59:41 +0200456static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200457 0x08, 0x09, 0x0d, 0x0e,
458 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200459};
460
Tobin Davis8e21c342007-01-08 11:04:17 +0100461static hda_nid_t stac925x_pin_nids[8] = {
462 0x07, 0x08, 0x0a, 0x0b,
463 0x0c, 0x0d, 0x10, 0x11,
464};
465
Matt2f2f4252005-04-13 14:45:30 +0200466static hda_nid_t stac922x_pin_nids[10] = {
467 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
468 0x0f, 0x10, 0x11, 0x15, 0x1b,
469};
470
Matthew Ranostaya7662642008-02-21 07:51:14 +0100471static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100472 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
473 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200474 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100475};
476
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200477static hda_nid_t stac92hd83xxx_pin_nids[14] = {
478 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
479 0x0f, 0x10, 0x11, 0x12, 0x13,
480 0x1d, 0x1e, 0x1f, 0x20
481};
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400482static hda_nid_t stac92hd71bxx_pin_nids[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100483 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
484 0x0f, 0x14, 0x18, 0x19, 0x1e,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400485 0x1f,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100486};
487
Matt Porter3cc08dc2006-01-23 15:27:49 +0100488static hda_nid_t stac927x_pin_nids[14] = {
489 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
490 0x0f, 0x10, 0x11, 0x12, 0x13,
491 0x14, 0x21, 0x22, 0x23,
492};
493
Matt Porterf3302a52006-07-31 12:49:34 +0200494static hda_nid_t stac9205_pin_nids[12] = {
495 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
496 0x0f, 0x14, 0x16, 0x17, 0x18,
497 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200498};
499
Matthew Ranostay89385032008-09-11 09:49:39 -0400500#define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
501
502static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
503 struct snd_ctl_elem_value *ucontrol)
504{
505 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
506 struct sigmatel_spec *spec = codec->spec;
507 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
508
509 kcontrol->private_value ^= get_amp_nid(kcontrol);
510 kcontrol->private_value |= nid;
511
512 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
513}
514
515static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
516 struct snd_ctl_elem_value *ucontrol)
517{
518 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
519 struct sigmatel_spec *spec = codec->spec;
520 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
521
522 kcontrol->private_value ^= get_amp_nid(kcontrol);
523 kcontrol->private_value |= nid;
524
525 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
526}
527
Matt Porter8b657272006-10-26 17:12:59 +0200528static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
529 struct snd_ctl_elem_info *uinfo)
530{
531 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
532 struct sigmatel_spec *spec = codec->spec;
533 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
534}
535
536static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
537 struct snd_ctl_elem_value *ucontrol)
538{
539 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
540 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100541 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200542
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100543 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200544 return 0;
545}
546
547static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
548 struct snd_ctl_elem_value *ucontrol)
549{
550 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
551 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100552 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200553
554 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100555 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200556}
557
Matthew Ranostayd9737752008-09-07 12:03:41 +0200558static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
559 struct snd_ctl_elem_info *uinfo)
560{
561 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
562 struct sigmatel_spec *spec = codec->spec;
563 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
564}
565
566static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
567 struct snd_ctl_elem_value *ucontrol)
568{
569 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
570 struct sigmatel_spec *spec = codec->spec;
571 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
572
573 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
574 return 0;
575}
576
577static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
578 struct snd_ctl_elem_value *ucontrol)
579{
580 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
581 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400582 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200583 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400584 int err, val;
585 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200586
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400587 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200588 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400589 if (err < 0)
590 return err;
591
592 if (spec->spdif_mute) {
593 if (smux_idx == 0)
594 nid = spec->multiout.dig_out_nid;
595 else
596 nid = codec->slave_dig_outs[smux_idx - 1];
597 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100598 val = HDA_AMP_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400599 else
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100600 val = 0;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400601 /* un/mute SPDIF out */
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100602 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
603 HDA_AMP_MUTE, val);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400604 }
605 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200606}
607
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100608static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200609{
610 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
611 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200612 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200613}
614
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100615static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200616{
617 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
618 struct sigmatel_spec *spec = codec->spec;
619 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
620
621 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
622 return 0;
623}
624
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100625static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200626{
627 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
628 struct sigmatel_spec *spec = codec->spec;
629 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
630
Mattc7d4b2f2005-06-27 14:59:41 +0200631 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200632 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
633}
634
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100635static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
636 struct snd_ctl_elem_info *uinfo)
637{
638 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
639 struct sigmatel_spec *spec = codec->spec;
640 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
641}
642
643static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
644 struct snd_ctl_elem_value *ucontrol)
645{
646 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
647 struct sigmatel_spec *spec = codec->spec;
648
649 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
650 return 0;
651}
652
653static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
654 struct snd_ctl_elem_value *ucontrol)
655{
656 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
657 struct sigmatel_spec *spec = codec->spec;
658
659 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
660 spec->mono_nid, &spec->cur_mmux);
661}
662
Matthew Ranostay89385032008-09-11 09:49:39 -0400663static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
664 struct snd_ctl_elem_info *uinfo)
665{
666 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
667 struct sigmatel_spec *spec = codec->spec;
668 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
669}
670
671static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
672 struct snd_ctl_elem_value *ucontrol)
673{
674 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
675 struct sigmatel_spec *spec = codec->spec;
676
677 ucontrol->value.enumerated.item[0] = spec->cur_amux;
678 return 0;
679}
680
681static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
682 struct snd_ctl_elem_value *ucontrol)
683{
684 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
685 struct sigmatel_spec *spec = codec->spec;
686 struct snd_kcontrol *ctl =
687 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
688 if (!ctl)
689 return -EINVAL;
690
691 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
692 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
693
694 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
695 0, &spec->cur_amux);
696}
697
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200698#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
699
700static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
701 struct snd_ctl_elem_value *ucontrol)
702{
703 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100704 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200705 struct sigmatel_spec *spec = codec->spec;
706
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100707 ucontrol->value.integer.value[0] = !!(spec->aloopback &
708 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200709 return 0;
710}
711
712static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
713 struct snd_ctl_elem_value *ucontrol)
714{
715 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
716 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100717 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200718 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100719 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200720
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100721 idx_val = spec->aloopback_mask << idx;
722 if (ucontrol->value.integer.value[0])
723 val = spec->aloopback | idx_val;
724 else
725 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100726 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200727 return 0;
728
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100729 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200730
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100731 /* Only return the bits defined by the shift value of the
732 * first two bytes of the mask
733 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200734 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100735 kcontrol->private_value & 0xFFFF, 0x0);
736 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200737
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100738 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200739 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100740 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200741 } else {
742 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100743 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200744 }
745
746 snd_hda_codec_write_cache(codec, codec->afg, 0,
747 kcontrol->private_value >> 16, dac_mode);
748
749 return 1;
750}
751
Mattc7d4b2f2005-06-27 14:59:41 +0200752static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200753 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200754 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200755 {}
756};
757
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200758static struct hda_verb stac9200_eapd_init[] = {
759 /* set dac0mux for dac converter */
760 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
761 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
762 {}
763};
764
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100765static struct hda_verb stac92hd73xx_6ch_core_init[] = {
766 /* set master volume and direct control */
767 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100768 /* setup adcs to point to mixer */
769 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
770 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100771 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
772 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
773 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
774 /* setup import muxs */
775 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
776 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
777 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
778 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
779 {}
780};
781
Matthew Ranostayd654a662008-03-14 08:46:51 +0100782static struct hda_verb dell_eq_core_init[] = {
783 /* set master volume to max value without distortion
784 * and direct control */
785 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100786 /* setup adcs to point to mixer */
787 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
788 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
789 /* setup import muxs */
790 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
791 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
792 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
793 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
794 {}
795};
796
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100797static struct hda_verb dell_m6_core_init[] = {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -0500798 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100799 /* setup adcs to point to mixer */
800 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
801 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
802 /* setup import muxs */
803 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
804 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
805 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
806 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
807 {}
808};
809
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100810static struct hda_verb stac92hd73xx_8ch_core_init[] = {
811 /* set master volume and direct control */
812 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100813 /* setup adcs to point to mixer */
814 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
815 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100816 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
817 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
818 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
819 /* setup import muxs */
820 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
821 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
822 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
823 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
824 {}
825};
826
827static struct hda_verb stac92hd73xx_10ch_core_init[] = {
828 /* set master volume and direct control */
829 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100830 /* dac3 is connected to import3 mux */
831 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100832 /* setup adcs to point to mixer */
833 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
834 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100835 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
836 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
837 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
838 /* setup import muxs */
839 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
840 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
841 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
842 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
843 {}
844};
845
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200846static struct hda_verb stac92hd83xxx_core_init[] = {
847 /* start of config #1 */
848 { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3},
849
850 /* start of config #2 */
851 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
852 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
853 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
854
855 /* power state controls amps */
856 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200857 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200858};
859
Matthew Ranostaye035b842007-11-06 11:53:55 +0100860static struct hda_verb stac92hd71bxx_core_init[] = {
861 /* set master volume and direct control */
862 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100863 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
864 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
865 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
866 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200867 {}
Matthew Ranostay541eee82007-12-14 12:08:04 +0100868};
869
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400870#define HD_DISABLE_PORTF 2
Matthew Ranostay541eee82007-12-14 12:08:04 +0100871static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200872 /* start of config #1 */
873
874 /* connect port 0f to audio mixer */
875 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200876 /* unmute right and left channels for node 0x0f */
877 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
878 /* start of config #2 */
879
Matthew Ranostay541eee82007-12-14 12:08:04 +0100880 /* set master volume and direct control */
881 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200882 /* unmute right and left channels for nodes 0x0a, 0xd */
Matthew Ranostaye035b842007-11-06 11:53:55 +0100883 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
884 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100885 {}
886};
887
Tobin Davis8e21c342007-01-08 11:04:17 +0100888static struct hda_verb stac925x_core_init[] = {
889 /* set dac0mux for dac converter */
890 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaic9280d62009-01-15 17:31:00 +0100891 /* mute the master volume */
892 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Tobin Davis8e21c342007-01-08 11:04:17 +0100893 {}
894};
895
Mattc7d4b2f2005-06-27 14:59:41 +0200896static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200897 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200898 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200899 {}
900};
901
Tobin Davis93ed1502006-09-01 21:03:12 +0200902static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200903 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200904 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200905 /* unmute node 0x1b */
906 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
907 /* select node 0x03 as DAC */
908 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
909 {}
910};
911
Matt Porter3cc08dc2006-01-23 15:27:49 +0100912static struct hda_verb stac927x_core_init[] = {
913 /* set master volume and direct control */
914 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200915 /* enable analog pc beep path */
916 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100917 {}
918};
919
Matt Porterf3302a52006-07-31 12:49:34 +0200920static struct hda_verb stac9205_core_init[] = {
921 /* set master volume and direct control */
922 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200923 /* enable analog pc beep path */
924 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200925 {}
926};
927
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100928#define STAC_MONO_MUX \
929 { \
930 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
931 .name = "Mono Mux", \
932 .count = 1, \
933 .info = stac92xx_mono_mux_enum_info, \
934 .get = stac92xx_mono_mux_enum_get, \
935 .put = stac92xx_mono_mux_enum_put, \
936 }
937
Matthew Ranostay89385032008-09-11 09:49:39 -0400938#define STAC_AMP_MUX \
939 { \
940 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
941 .name = "Amp Selector Capture Switch", \
942 .count = 1, \
943 .info = stac92xx_amp_mux_enum_info, \
944 .get = stac92xx_amp_mux_enum_get, \
945 .put = stac92xx_amp_mux_enum_put, \
946 }
947
948#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
949 { \
950 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
951 .name = xname, \
952 .index = 0, \
953 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
954 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
955 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
956 .info = stac92xx_amp_volume_info, \
957 .get = stac92xx_amp_volume_get, \
958 .put = stac92xx_amp_volume_put, \
959 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
960 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
961 }
962
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200963#define STAC_INPUT_SOURCE(cnt) \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200964 { \
965 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
966 .name = "Input Source", \
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200967 .count = cnt, \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200968 .info = stac92xx_mux_enum_info, \
969 .get = stac92xx_mux_enum_get, \
970 .put = stac92xx_mux_enum_put, \
971 }
972
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100973#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200974 { \
975 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
976 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100977 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200978 .info = stac92xx_aloopback_info, \
979 .get = stac92xx_aloopback_get, \
980 .put = stac92xx_aloopback_put, \
981 .private_value = verb_read | (verb_write << 16), \
982 }
983
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100984static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200985 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
986 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200987 STAC_INPUT_SOURCE(1),
Matt2f2f4252005-04-13 14:45:30 +0200988 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
989 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200990 { } /* end */
991};
992
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400993#define DELL_M6_MIXER 6
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100994static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400995 /* start of config #1 */
996 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
997 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
998
999 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1000 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1001
1002 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1003 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1004
1005 /* start of config #2 */
1006 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1007 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1008
1009 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1010 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1011
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001012 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1013
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001014 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1015 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1016
1017 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1018 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1019
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001020 { } /* end */
1021};
1022
1023static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001024 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1025
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001026 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1027 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1028
1029 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1030 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1031
1032 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1033 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1034
1035 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1036 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1037
1038 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1039 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1040
1041 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1042 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1043
1044 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1045 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1046 { } /* end */
1047};
1048
1049static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001050 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1051
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001052 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1053 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1054
1055 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1056 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1057
1058 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1059 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1060
1061 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1062 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1063
1064 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1065 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1066
1067 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1068 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1069
1070 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1071 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1072 { } /* end */
1073};
1074
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001075
1076static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1077 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1078 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1079
1080 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1081 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1082
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001083 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT),
1084 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001085
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001086 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT),
1087 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001088
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001089 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT),
1090 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001091
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001092 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT),
1093 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001094
1095 /*
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001096 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT),
1097 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001098 */
1099 { } /* end */
1100};
1101
Matthew Ranostay541eee82007-12-14 12:08:04 +01001102static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001103 STAC_INPUT_SOURCE(2),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001104 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001105
Matthew Ranostay9b359472007-11-07 13:03:12 +01001106 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1107 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay9b359472007-11-07 13:03:12 +01001108
1109 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1110 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001111 /* analog pc-beep replaced with digital beep support */
1112 /*
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001113 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1114 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001115 */
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001116
Matthew Ranostay687cb982008-10-11 13:52:43 -04001117 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1118 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001119
Matthew Ranostay687cb982008-10-11 13:52:43 -04001120 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1121 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001122
1123 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1124 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1125
1126 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1127 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001128 { } /* end */
1129};
1130
Matthew Ranostay541eee82007-12-14 12:08:04 +01001131static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +01001132 STAC_INPUT_SOURCE(2),
1133 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1134
Matthew Ranostay541eee82007-12-14 12:08:04 +01001135 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1136 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001137
1138 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1139 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001140 { } /* end */
1141};
1142
Tobin Davis8e21c342007-01-08 11:04:17 +01001143static struct snd_kcontrol_new stac925x_mixer[] = {
Takashi Iwaic9280d62009-01-15 17:31:00 +01001144 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
1145 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001146 STAC_INPUT_SOURCE(1),
Tobin Davis8e21c342007-01-08 11:04:17 +01001147 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +02001148 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001149 { } /* end */
1150};
1151
Takashi Iwaid1d985f2006-11-23 19:27:12 +01001152static struct snd_kcontrol_new stac9205_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001153 STAC_INPUT_SOURCE(2),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001154 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001155
1156 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1157 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001158
1159 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1160 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001161 { } /* end */
1162};
1163
1164/* This needs to be generated dynamically based on sequence */
1165static struct snd_kcontrol_new stac922x_mixer[] = {
1166 STAC_INPUT_SOURCE(2),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001167 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1168 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001169
1170 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1171 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001172 { } /* end */
1173};
1174
1175
1176static struct snd_kcontrol_new stac927x_mixer[] = {
1177 STAC_INPUT_SOURCE(3),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001178 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001179
1180 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1181 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001182
1183 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1184 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001185
1186 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1187 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
Matt Porterf3302a52006-07-31 12:49:34 +02001188 { } /* end */
1189};
1190
Takashi Iwai1697055e2007-12-18 18:05:52 +01001191static struct snd_kcontrol_new stac_dmux_mixer = {
1192 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1193 .name = "Digital Input Source",
1194 /* count set later */
1195 .info = stac92xx_dmux_enum_info,
1196 .get = stac92xx_dmux_enum_get,
1197 .put = stac92xx_dmux_enum_put,
1198};
1199
Matthew Ranostayd9737752008-09-07 12:03:41 +02001200static struct snd_kcontrol_new stac_smux_mixer = {
1201 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001202 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001203 /* count set later */
1204 .info = stac92xx_smux_enum_info,
1205 .get = stac92xx_smux_enum_get,
1206 .put = stac92xx_smux_enum_put,
1207};
1208
Takashi Iwai2134ea42008-01-10 16:53:55 +01001209static const char *slave_vols[] = {
1210 "Front Playback Volume",
1211 "Surround Playback Volume",
1212 "Center Playback Volume",
1213 "LFE Playback Volume",
1214 "Side Playback Volume",
1215 "Headphone Playback Volume",
1216 "Headphone Playback Volume",
1217 "Speaker Playback Volume",
1218 "External Speaker Playback Volume",
1219 "Speaker2 Playback Volume",
1220 NULL
1221};
1222
1223static const char *slave_sws[] = {
1224 "Front Playback Switch",
1225 "Surround Playback Switch",
1226 "Center Playback Switch",
1227 "LFE Playback Switch",
1228 "Side Playback Switch",
1229 "Headphone Playback Switch",
1230 "Headphone Playback Switch",
1231 "Speaker Playback Switch",
1232 "External Speaker Playback Switch",
1233 "Speaker2 Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001234 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001235 NULL
1236};
1237
Takashi Iwai603c4012008-07-30 15:01:44 +02001238static void stac92xx_free_kctls(struct hda_codec *codec);
Takashi Iwaie4973e12008-11-18 09:32:42 +01001239static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
Takashi Iwai603c4012008-07-30 15:01:44 +02001240
Matt2f2f4252005-04-13 14:45:30 +02001241static int stac92xx_build_controls(struct hda_codec *codec)
1242{
1243 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaie4973e12008-11-18 09:32:42 +01001244 struct auto_pin_cfg *cfg = &spec->autocfg;
1245 hda_nid_t nid;
Matt2f2f4252005-04-13 14:45:30 +02001246 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001247 int i;
Matt2f2f4252005-04-13 14:45:30 +02001248
1249 err = snd_hda_add_new_ctls(codec, spec->mixer);
1250 if (err < 0)
1251 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001252
1253 for (i = 0; i < spec->num_mixers; i++) {
1254 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1255 if (err < 0)
1256 return err;
1257 }
Takashi Iwai1697055e2007-12-18 18:05:52 +01001258 if (spec->num_dmuxes > 0) {
1259 stac_dmux_mixer.count = spec->num_dmuxes;
Takashi Iwaid13bd412008-07-30 15:01:45 +02001260 err = snd_hda_ctl_add(codec,
Takashi Iwai1697055e2007-12-18 18:05:52 +01001261 snd_ctl_new1(&stac_dmux_mixer, codec));
1262 if (err < 0)
1263 return err;
1264 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001265 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001266 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1267 struct hda_input_mux *smux = &spec->private_smux;
1268 /* check for mute support on SPDIF out */
1269 if (wcaps & AC_WCAP_OUT_AMP) {
1270 smux->items[smux->num_items].label = "Off";
1271 smux->items[smux->num_items].index = 0;
1272 smux->num_items++;
1273 spec->spdif_mute = 1;
1274 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001275 stac_smux_mixer.count = spec->num_smuxes;
Takashi Iwai4f2d23e2008-12-19 10:14:13 +01001276 err = snd_hda_ctl_add(codec,
Matthew Ranostayd9737752008-09-07 12:03:41 +02001277 snd_ctl_new1(&stac_smux_mixer, codec));
1278 if (err < 0)
1279 return err;
1280 }
Mattc7d4b2f2005-06-27 14:59:41 +02001281
Mattdabbed62005-06-14 10:19:34 +02001282 if (spec->multiout.dig_out_nid) {
1283 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1284 if (err < 0)
1285 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001286 err = snd_hda_create_spdif_share_sw(codec,
1287 &spec->multiout);
1288 if (err < 0)
1289 return err;
1290 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001291 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001292 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001293 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1294 if (err < 0)
1295 return err;
1296 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001297
1298 /* if we have no master control, let's create it */
1299 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001300 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001301 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001302 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai7c7767e2009-01-20 15:28:38 +01001303 /* correct volume offset */
1304 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
Takashi Iwai2134ea42008-01-10 16:53:55 +01001305 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001306 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001307 if (err < 0)
1308 return err;
1309 }
1310 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1311 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1312 NULL, slave_sws);
1313 if (err < 0)
1314 return err;
1315 }
1316
Takashi Iwai603c4012008-07-30 15:01:44 +02001317 stac92xx_free_kctls(codec); /* no longer needed */
Takashi Iwaie4973e12008-11-18 09:32:42 +01001318
1319 /* create jack input elements */
1320 if (spec->hp_detect) {
1321 for (i = 0; i < cfg->hp_outs; i++) {
1322 int type = SND_JACK_HEADPHONE;
1323 nid = cfg->hp_pins[i];
1324 /* jack detection */
1325 if (cfg->hp_outs == i)
1326 type |= SND_JACK_LINEOUT;
1327 err = stac92xx_add_jack(codec, nid, type);
1328 if (err < 0)
1329 return err;
1330 }
1331 }
1332 for (i = 0; i < cfg->line_outs; i++) {
1333 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1334 SND_JACK_LINEOUT);
1335 if (err < 0)
1336 return err;
1337 }
1338 for (i = 0; i < AUTO_PIN_LAST; i++) {
1339 nid = cfg->input_pins[i];
1340 if (nid) {
1341 err = stac92xx_add_jack(codec, nid,
1342 SND_JACK_MICROPHONE);
1343 if (err < 0)
1344 return err;
1345 }
1346 }
1347
Mattdabbed62005-06-14 10:19:34 +02001348 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001349}
1350
Matt Porter403d1942005-11-29 15:00:51 +01001351static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001352 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001353 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1354};
1355
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001356static unsigned int gateway9200_m4_pin_configs[8] = {
1357 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1358 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1359};
1360static unsigned int gateway9200_m4_2_pin_configs[8] = {
1361 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1362 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1363};
1364
1365/*
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001366 STAC 9200 pin configs for
1367 102801A8
1368 102801DE
1369 102801E8
1370*/
1371static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001372 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1373 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001374};
1375
1376/*
1377 STAC 9200 pin configs for
1378 102801C0
1379 102801C1
1380*/
1381static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001382 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1383 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001384};
1385
1386/*
1387 STAC 9200 pin configs for
1388 102801C4 (Dell Dimension E310)
1389 102801C5
1390 102801C7
1391 102801D9
1392 102801DA
1393 102801E3
1394*/
1395static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001396 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1397 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001398};
1399
1400
1401/*
1402 STAC 9200-32 pin configs for
1403 102801B5 (Dell Inspiron 630m)
1404 102801D8 (Dell Inspiron 640m)
1405*/
1406static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001407 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1408 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001409};
1410
1411/*
1412 STAC 9200-32 pin configs for
1413 102801C2 (Dell Latitude D620)
1414 102801C8
1415 102801CC (Dell Latitude D820)
1416 102801D4
1417 102801D6
1418*/
1419static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001420 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1421 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001422};
1423
1424/*
1425 STAC 9200-32 pin configs for
1426 102801CE (Dell XPS M1710)
1427 102801CF (Dell Precision M90)
1428*/
1429static unsigned int dell9200_m23_pin_configs[8] = {
1430 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1431 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1432};
1433
1434/*
1435 STAC 9200-32 pin configs for
1436 102801C9
1437 102801CA
1438 102801CB (Dell Latitude 120L)
1439 102801D3
1440*/
1441static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001442 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1443 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001444};
1445
1446/*
1447 STAC 9200-32 pin configs for
1448 102801BD (Dell Inspiron E1505n)
1449 102801EE
1450 102801EF
1451*/
1452static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001453 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1454 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001455};
1456
1457/*
1458 STAC 9200-32 pin configs for
1459 102801F5 (Dell Inspiron 1501)
1460 102801F6
1461*/
1462static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001463 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1464 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001465};
1466
1467/*
1468 STAC 9200-32
1469 102801CD (Dell Inspiron E1705/9400)
1470*/
1471static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001472 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1473 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001474};
1475
Tobin Davisbf277782008-02-03 20:31:47 +01001476static unsigned int oqo9200_pin_configs[8] = {
1477 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1478 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1479};
1480
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001481
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001482static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1483 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001484 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001485 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1486 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1487 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1488 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1489 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1490 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1491 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1492 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1493 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1494 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001495 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1496 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001497 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001498};
1499
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001500static const char *stac9200_models[STAC_9200_MODELS] = {
1501 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001502 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001503 [STAC_9200_DELL_D21] = "dell-d21",
1504 [STAC_9200_DELL_D22] = "dell-d22",
1505 [STAC_9200_DELL_D23] = "dell-d23",
1506 [STAC_9200_DELL_M21] = "dell-m21",
1507 [STAC_9200_DELL_M22] = "dell-m22",
1508 [STAC_9200_DELL_M23] = "dell-m23",
1509 [STAC_9200_DELL_M24] = "dell-m24",
1510 [STAC_9200_DELL_M25] = "dell-m25",
1511 [STAC_9200_DELL_M26] = "dell-m26",
1512 [STAC_9200_DELL_M27] = "dell-m27",
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001513 [STAC_9200_M4] = "gateway-m4",
1514 [STAC_9200_M4_2] = "gateway-m4-2",
Takashi Iwai117f2572008-03-18 09:53:23 +01001515 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001516};
1517
1518static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1519 /* SigmaTel reference board */
1520 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1521 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001522 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001523 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1524 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001525 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001526 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1527 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1528 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1529 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1530 "unknown Dell", STAC_9200_DELL_D22),
1531 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1532 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001533 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001534 "Dell Latitude D620", STAC_9200_DELL_M22),
1535 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1536 "unknown Dell", STAC_9200_DELL_D23),
1537 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1538 "unknown Dell", STAC_9200_DELL_D23),
1539 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1540 "unknown Dell", STAC_9200_DELL_M22),
1541 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1542 "unknown Dell", STAC_9200_DELL_M24),
1543 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1544 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001545 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001546 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001547 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001548 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001549 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001550 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001551 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001552 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001553 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001554 "Dell Precision M90", STAC_9200_DELL_M23),
1555 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1556 "unknown Dell", STAC_9200_DELL_M22),
1557 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1558 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001559 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001560 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001561 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001562 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1563 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1564 "unknown Dell", STAC_9200_DELL_D23),
1565 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1566 "unknown Dell", STAC_9200_DELL_D23),
1567 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1568 "unknown Dell", STAC_9200_DELL_D21),
1569 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1570 "unknown Dell", STAC_9200_DELL_D23),
1571 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1572 "unknown Dell", STAC_9200_DELL_D21),
1573 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1574 "unknown Dell", STAC_9200_DELL_M25),
1575 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1576 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001577 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001578 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1579 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1580 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001581 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001582 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001583 /* Gateway machines needs EAPD to be set on resume */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001584 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1585 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1586 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
Tobin Davisbf277782008-02-03 20:31:47 +01001587 /* OQO Mobile */
1588 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001589 {} /* terminator */
1590};
1591
Tobin Davis8e21c342007-01-08 11:04:17 +01001592static unsigned int ref925x_pin_configs[8] = {
1593 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001594 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001595};
1596
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001597static unsigned int stac925xM1_pin_configs[8] = {
1598 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1599 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001600};
1601
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001602static unsigned int stac925xM1_2_pin_configs[8] = {
1603 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1604 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1605};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001606
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001607static unsigned int stac925xM2_pin_configs[8] = {
1608 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1609 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis2c11f952007-05-17 09:36:34 +02001610};
1611
Tobin Davis8e21c342007-01-08 11:04:17 +01001612static unsigned int stac925xM2_2_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001613 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1614 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1615};
1616
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001617static unsigned int stac925xM3_pin_configs[8] = {
1618 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1619 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1620};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001621
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001622static unsigned int stac925xM5_pin_configs[8] = {
1623 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1624 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1625};
1626
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001627static unsigned int stac925xM6_pin_configs[8] = {
1628 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1629 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
Tobin Davis8e21c342007-01-08 11:04:17 +01001630};
1631
1632static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1633 [STAC_REF] = ref925x_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001634 [STAC_M1] = stac925xM1_pin_configs,
1635 [STAC_M1_2] = stac925xM1_2_pin_configs,
1636 [STAC_M2] = stac925xM2_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001637 [STAC_M2_2] = stac925xM2_2_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001638 [STAC_M3] = stac925xM3_pin_configs,
1639 [STAC_M5] = stac925xM5_pin_configs,
1640 [STAC_M6] = stac925xM6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001641};
1642
1643static const char *stac925x_models[STAC_925x_MODELS] = {
1644 [STAC_REF] = "ref",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001645 [STAC_M1] = "m1",
1646 [STAC_M1_2] = "m1-2",
1647 [STAC_M2] = "m2",
Tobin Davis8e21c342007-01-08 11:04:17 +01001648 [STAC_M2_2] = "m2-2",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001649 [STAC_M3] = "m3",
1650 [STAC_M5] = "m5",
1651 [STAC_M6] = "m6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001652};
1653
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001654static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001655 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1656 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1657 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1658 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001659 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001660 /* Not sure about the brand name for those */
1661 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1662 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1663 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1664 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001665 {} /* terminator */
Tobin Davis8e21c342007-01-08 11:04:17 +01001666};
1667
1668static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1669 /* SigmaTel reference board */
1670 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001671 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001672
1673 /* Default table for unknown ID */
1674 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1675
Tobin Davis8e21c342007-01-08 11:04:17 +01001676 {} /* terminator */
1677};
1678
Matthew Ranostaya7662642008-02-21 07:51:14 +01001679static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001680 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1681 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1682 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001683 0x01452050,
1684};
1685
1686static unsigned int dell_m6_pin_configs[13] = {
1687 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001688 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001689 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1690 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001691};
1692
1693static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001694 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001695 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1696 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1697 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001698 [STAC_DELL_EQ] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001699};
1700
1701static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01001702 [STAC_92HD73XX_NO_JD] = "no-jd",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001703 [STAC_92HD73XX_REF] = "ref",
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001704 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1705 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1706 [STAC_DELL_M6_BOTH] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001707 [STAC_DELL_EQ] = "dell-eq",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001708};
1709
1710static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1711 /* SigmaTel reference board */
1712 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001713 "DFI LanParty", STAC_92HD73XX_REF),
1714 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001715 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001716 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001717 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001718 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001719 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001720 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001721 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001722 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001723 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001724 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001725 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001726 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001727 "unknown Dell", STAC_DELL_M6_DMIC),
1728 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1729 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01001730 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001731 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Joerg Schirottkefa620e92008-12-19 08:13:49 +01001732 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1733 "Dell Studio 17", STAC_DELL_M6_DMIC),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001734 {} /* terminator */
1735};
1736
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001737static unsigned int ref92hd83xxx_pin_configs[14] = {
1738 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1739 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1740 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1741 0x01451160, 0x98560170,
1742};
1743
1744static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1745 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1746};
1747
1748static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1749 [STAC_92HD83XXX_REF] = "ref",
1750};
1751
1752static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1753 /* SigmaTel reference board */
1754 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Takashi Iwaif9d088b2009-01-13 11:54:49 +01001755 "DFI LanParty", STAC_92HD83XXX_REF),
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -02001756 {} /* terminator */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001757};
1758
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001759static unsigned int ref92hd71bxx_pin_configs[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001760 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001761 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001762 0x90a000f0, 0x01452050, 0x01452050,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001763};
1764
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001765static unsigned int dell_m4_1_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001766 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001767 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001768 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001769};
1770
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001771static unsigned int dell_m4_2_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001772 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1773 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001774 0x40f000f0, 0x044413b0, 0x044413b0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001775};
1776
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001777static unsigned int dell_m4_3_pin_configs[11] = {
1778 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1779 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1780 0x40f000f0, 0x044413b0, 0x044413b0,
1781};
1782
Matthew Ranostaye035b842007-11-06 11:53:55 +01001783static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1784 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001785 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1786 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001787 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001788 [STAC_HP_M4] = NULL,
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001789 [STAC_HP_DV5] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001790};
1791
1792static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1793 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001794 [STAC_DELL_M4_1] = "dell-m4-1",
1795 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001796 [STAC_DELL_M4_3] = "dell-m4-3",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001797 [STAC_HP_M4] = "hp-m4",
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001798 [STAC_HP_DV5] = "hp-dv5",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001799};
1800
1801static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1802 /* SigmaTel reference board */
1803 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1804 "DFI LanParty", STAC_92HD71BXX_REF),
Takashi Iwai80bf2722008-11-18 10:48:41 +01001805 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f2,
1806 "HP dv5", STAC_HP_M4),
1807 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4,
1808 "HP dv7", STAC_HP_M4),
Takashi Iwai69dfaef2008-12-20 16:57:50 +01001809 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fc,
1810 "HP dv7", STAC_HP_M4),
Giuseppe Bilottadafb70c2009-01-13 08:58:49 -05001811 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3603,
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001812 "HP dv5", STAC_HP_DV5),
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001813 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1814 "unknown HP", STAC_HP_M4),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001815 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1816 "unknown Dell", STAC_DELL_M4_1),
1817 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1818 "unknown Dell", STAC_DELL_M4_1),
1819 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1820 "unknown Dell", STAC_DELL_M4_1),
1821 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1822 "unknown Dell", STAC_DELL_M4_1),
1823 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1824 "unknown Dell", STAC_DELL_M4_1),
1825 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1826 "unknown Dell", STAC_DELL_M4_1),
1827 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1828 "unknown Dell", STAC_DELL_M4_1),
1829 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1830 "unknown Dell", STAC_DELL_M4_2),
1831 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1832 "unknown Dell", STAC_DELL_M4_2),
1833 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1834 "unknown Dell", STAC_DELL_M4_2),
1835 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1836 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001837 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1838 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001839 {} /* terminator */
1840};
1841
Matt Porter403d1942005-11-29 15:00:51 +01001842static unsigned int ref922x_pin_configs[10] = {
1843 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1844 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001845 0x40000100, 0x40000100,
1846};
1847
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001848/*
1849 STAC 922X pin configs for
1850 102801A7
1851 102801AB
1852 102801A9
1853 102801D1
1854 102801D2
1855*/
1856static unsigned int dell_922x_d81_pin_configs[10] = {
1857 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1858 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1859 0x01813122, 0x400001f2,
1860};
1861
1862/*
1863 STAC 922X pin configs for
1864 102801AC
1865 102801D0
1866*/
1867static unsigned int dell_922x_d82_pin_configs[10] = {
1868 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1869 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1870 0x01813122, 0x400001f1,
1871};
1872
1873/*
1874 STAC 922X pin configs for
1875 102801BF
1876*/
1877static unsigned int dell_922x_m81_pin_configs[10] = {
1878 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1879 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1880 0x40C003f1, 0x405003f0,
1881};
1882
1883/*
1884 STAC 9221 A1 pin configs for
1885 102801D7 (Dell XPS M1210)
1886*/
1887static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001888 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1889 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001890 0x508003f3, 0x405003f4,
1891};
1892
Matt Porter403d1942005-11-29 15:00:51 +01001893static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001894 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001895 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1896 0x02a19120, 0x40000100,
1897};
1898
1899static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001900 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1901 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001902 0x02a19320, 0x40000100,
1903};
1904
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001905static unsigned int intel_mac_v1_pin_configs[10] = {
1906 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1907 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001908 0x400000fc, 0x400000fb,
1909};
1910
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001911static unsigned int intel_mac_v2_pin_configs[10] = {
1912 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1913 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001914 0x400000fc, 0x400000fb,
1915};
1916
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001917static unsigned int intel_mac_v3_pin_configs[10] = {
1918 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1919 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1920 0x400000fc, 0x400000fb,
1921};
1922
1923static unsigned int intel_mac_v4_pin_configs[10] = {
1924 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1925 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1926 0x400000fc, 0x400000fb,
1927};
1928
1929static unsigned int intel_mac_v5_pin_configs[10] = {
1930 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1931 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1932 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001933};
1934
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001935static unsigned int ecs202_pin_configs[10] = {
1936 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1937 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1938 0x9037012e, 0x40e000f2,
1939};
Takashi Iwai76c08822007-06-19 12:17:42 +02001940
Takashi Iwai19039bd2006-06-28 15:52:16 +02001941static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001942 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001943 [STAC_D945GTP3] = d945gtp3_pin_configs,
1944 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001945 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1946 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1947 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1948 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1949 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001950 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001951 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001952 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1953 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1954 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1955 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1956 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1957 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001958 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001959 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1960 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1961 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1962 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001963};
1964
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001965static const char *stac922x_models[STAC_922X_MODELS] = {
1966 [STAC_D945_REF] = "ref",
1967 [STAC_D945GTP5] = "5stack",
1968 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001969 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1970 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1971 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1972 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1973 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001974 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001975 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001976 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001977 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001978 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1979 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001980 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001981 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001982 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001983 [STAC_922X_DELL_D81] = "dell-d81",
1984 [STAC_922X_DELL_D82] = "dell-d82",
1985 [STAC_922X_DELL_M81] = "dell-m81",
1986 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001987};
1988
1989static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1990 /* SigmaTel reference board */
1991 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1992 "DFI LanParty", STAC_D945_REF),
1993 /* Intel 945G based systems */
1994 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1995 "Intel D945G", STAC_D945GTP3),
1996 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1997 "Intel D945G", STAC_D945GTP3),
1998 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1999 "Intel D945G", STAC_D945GTP3),
2000 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2001 "Intel D945G", STAC_D945GTP3),
2002 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2003 "Intel D945G", STAC_D945GTP3),
2004 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2005 "Intel D945G", STAC_D945GTP3),
2006 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2007 "Intel D945G", STAC_D945GTP3),
2008 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2009 "Intel D945G", STAC_D945GTP3),
2010 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2011 "Intel D945G", STAC_D945GTP3),
2012 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2013 "Intel D945G", STAC_D945GTP3),
2014 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2015 "Intel D945G", STAC_D945GTP3),
2016 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2017 "Intel D945G", STAC_D945GTP3),
2018 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2019 "Intel D945G", STAC_D945GTP3),
2020 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2021 "Intel D945G", STAC_D945GTP3),
2022 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2023 "Intel D945G", STAC_D945GTP3),
2024 /* Intel D945G 5-stack systems */
2025 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2026 "Intel D945G", STAC_D945GTP5),
2027 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2028 "Intel D945G", STAC_D945GTP5),
2029 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2030 "Intel D945G", STAC_D945GTP5),
2031 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2032 "Intel D945G", STAC_D945GTP5),
2033 /* Intel 945P based systems */
2034 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2035 "Intel D945P", STAC_D945GTP3),
2036 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2037 "Intel D945P", STAC_D945GTP3),
2038 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2039 "Intel D945P", STAC_D945GTP3),
2040 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2041 "Intel D945P", STAC_D945GTP3),
2042 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2043 "Intel D945P", STAC_D945GTP3),
2044 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2045 "Intel D945P", STAC_D945GTP5),
2046 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08002047 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002048 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08002049 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002050 /* Dell systems */
2051 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2052 "unknown Dell", STAC_922X_DELL_D81),
2053 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2054 "unknown Dell", STAC_922X_DELL_D81),
2055 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2056 "unknown Dell", STAC_922X_DELL_D81),
2057 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2058 "unknown Dell", STAC_922X_DELL_D82),
2059 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2060 "unknown Dell", STAC_922X_DELL_M81),
2061 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2062 "unknown Dell", STAC_922X_DELL_D82),
2063 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2064 "unknown Dell", STAC_922X_DELL_D81),
2065 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2066 "unknown Dell", STAC_922X_DELL_D81),
2067 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2068 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002069 /* ECS/PC Chips boards */
2070 SND_PCI_QUIRK(0x1019, 0x2144,
2071 "ECS/PC chips", STAC_ECS_202),
2072 SND_PCI_QUIRK(0x1019, 0x2608,
2073 "ECS/PC chips", STAC_ECS_202),
2074 SND_PCI_QUIRK(0x1019, 0x2633,
2075 "ECS/PC chips P17G/1333", STAC_ECS_202),
2076 SND_PCI_QUIRK(0x1019, 0x2811,
2077 "ECS/PC chips", STAC_ECS_202),
2078 SND_PCI_QUIRK(0x1019, 0x2812,
2079 "ECS/PC chips", STAC_ECS_202),
2080 SND_PCI_QUIRK(0x1019, 0x2813,
2081 "ECS/PC chips", STAC_ECS_202),
2082 SND_PCI_QUIRK(0x1019, 0x2814,
2083 "ECS/PC chips", STAC_ECS_202),
2084 SND_PCI_QUIRK(0x1019, 0x2815,
2085 "ECS/PC chips", STAC_ECS_202),
2086 SND_PCI_QUIRK(0x1019, 0x2816,
2087 "ECS/PC chips", STAC_ECS_202),
2088 SND_PCI_QUIRK(0x1019, 0x2817,
2089 "ECS/PC chips", STAC_ECS_202),
2090 SND_PCI_QUIRK(0x1019, 0x2818,
2091 "ECS/PC chips", STAC_ECS_202),
2092 SND_PCI_QUIRK(0x1019, 0x2819,
2093 "ECS/PC chips", STAC_ECS_202),
2094 SND_PCI_QUIRK(0x1019, 0x2820,
2095 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01002096 {} /* terminator */
2097};
2098
Matt Porter3cc08dc2006-01-23 15:27:49 +01002099static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002100 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2101 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2102 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2103 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002104};
2105
Tobin Davis93ed1502006-09-01 21:03:12 +02002106static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002107 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2108 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2109 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2110 0x40000100, 0x40000100
2111};
2112
Tobin Davis93ed1502006-09-01 21:03:12 +02002113static unsigned int d965_5st_pin_configs[14] = {
2114 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2115 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2116 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2117 0x40000100, 0x40000100
2118};
2119
Tobin Davis4ff076e2007-08-07 11:48:12 +02002120static unsigned int dell_3st_pin_configs[14] = {
2121 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2122 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002123 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002124 0x40c003fc, 0x40000100
2125};
2126
Tobin Davis93ed1502006-09-01 21:03:12 +02002127static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002128 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002129 [STAC_D965_REF] = ref927x_pin_configs,
2130 [STAC_D965_3ST] = d965_3st_pin_configs,
2131 [STAC_D965_5ST] = d965_5st_pin_configs,
2132 [STAC_DELL_3ST] = dell_3st_pin_configs,
2133 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002134};
2135
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002136static const char *stac927x_models[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002137 [STAC_D965_REF_NO_JD] = "ref-no-jd",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002138 [STAC_D965_REF] = "ref",
2139 [STAC_D965_3ST] = "3stack",
2140 [STAC_D965_5ST] = "5stack",
2141 [STAC_DELL_3ST] = "dell-3stack",
2142 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002143};
2144
2145static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2146 /* SigmaTel reference board */
2147 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2148 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002149 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002150 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2151 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002152 /* 965 based 3 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002153 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
2154 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
2155 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
2156 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
2157 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
2158 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
2159 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
2160 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
2161 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
2162 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
2163 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
2164 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
2165 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
2166 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
2167 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
2168 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002169 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002170 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002171 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002172 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2173 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002174 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002175 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2176 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002177 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02002178 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002179 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2180 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2181 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2182 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002183 /* 965 based 5 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002184 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2185 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2186 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2187 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2188 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2189 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2190 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2191 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2192 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002193 {} /* terminator */
2194};
2195
Matt Porterf3302a52006-07-31 12:49:34 +02002196static unsigned int ref9205_pin_configs[12] = {
2197 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002198 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002199 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002200};
2201
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002202/*
2203 STAC 9205 pin configs for
2204 102801F1
2205 102801F2
2206 102801FC
2207 102801FD
2208 10280204
2209 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002210 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002211*/
2212static unsigned int dell_9205_m42_pin_configs[12] = {
2213 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2214 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2215 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2216};
2217
2218/*
2219 STAC 9205 pin configs for
2220 102801F9
2221 102801FA
2222 102801FE
2223 102801FF (Dell Precision M4300)
2224 10280206
2225 10280200
2226 10280201
2227*/
2228static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002229 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2230 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2231 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2232};
2233
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002234static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002235 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2236 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2237 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2238};
2239
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002240static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002241 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002242 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2243 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2244 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Matt Porterf3302a52006-07-31 12:49:34 +02002245};
2246
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002247static const char *stac9205_models[STAC_9205_MODELS] = {
2248 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002249 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002250 [STAC_9205_DELL_M43] = "dell-m43",
2251 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002252};
2253
2254static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2255 /* SigmaTel reference board */
2256 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2257 "DFI LanParty", STAC_9205_REF),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002258 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2259 "unknown Dell", STAC_9205_DELL_M42),
2260 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2261 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002262 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002263 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002264 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2265 "Dell Precision", STAC_9205_DELL_M43),
2266 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2267 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002268 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2269 "unknown Dell", STAC_9205_DELL_M42),
2270 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2271 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002272 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2273 "Dell Precision", STAC_9205_DELL_M43),
2274 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002275 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002276 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2277 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002278 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2279 "Dell Precision", STAC_9205_DELL_M43),
2280 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2281 "Dell Precision", STAC_9205_DELL_M43),
2282 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2283 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002284 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2285 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002286 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2287 "Dell Vostro 1500", STAC_9205_DELL_M42),
Matt Porterf3302a52006-07-31 12:49:34 +02002288 {} /* terminator */
2289};
2290
Richard Fish11b44bb2006-08-23 18:31:34 +02002291static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2292{
2293 int i;
2294 struct sigmatel_spec *spec = codec->spec;
2295
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002296 kfree(spec->pin_configs);
2297 spec->pin_configs = kcalloc(spec->num_pins, sizeof(*spec->pin_configs),
2298 GFP_KERNEL);
2299 if (!spec->pin_configs)
2300 return -ENOMEM;
Richard Fish11b44bb2006-08-23 18:31:34 +02002301
2302 for (i = 0; i < spec->num_pins; i++) {
2303 hda_nid_t nid = spec->pin_nids[i];
2304 unsigned int pin_cfg;
2305
2306 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2307 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2308 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2309 nid, pin_cfg);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002310 spec->pin_configs[i] = pin_cfg;
Richard Fish11b44bb2006-08-23 18:31:34 +02002311 }
2312
2313 return 0;
2314}
2315
Matthew Ranostay87d48362007-07-17 11:52:24 +02002316static void stac92xx_set_config_reg(struct hda_codec *codec,
2317 hda_nid_t pin_nid, unsigned int pin_config)
2318{
2319 int i;
2320 snd_hda_codec_write(codec, pin_nid, 0,
2321 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2322 pin_config & 0x000000ff);
2323 snd_hda_codec_write(codec, pin_nid, 0,
2324 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2325 (pin_config & 0x0000ff00) >> 8);
2326 snd_hda_codec_write(codec, pin_nid, 0,
2327 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2328 (pin_config & 0x00ff0000) >> 16);
2329 snd_hda_codec_write(codec, pin_nid, 0,
2330 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2331 pin_config >> 24);
2332 i = snd_hda_codec_read(codec, pin_nid, 0,
2333 AC_VERB_GET_CONFIG_DEFAULT,
2334 0x00);
2335 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2336 pin_nid, i);
2337}
2338
Matt2f2f4252005-04-13 14:45:30 +02002339static void stac92xx_set_config_regs(struct hda_codec *codec)
2340{
2341 int i;
2342 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002343
Matthew Ranostay87d48362007-07-17 11:52:24 +02002344 if (!spec->pin_configs)
2345 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002346
Matthew Ranostay87d48362007-07-17 11:52:24 +02002347 for (i = 0; i < spec->num_pins; i++)
2348 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2349 spec->pin_configs[i]);
Matt2f2f4252005-04-13 14:45:30 +02002350}
Matt2f2f4252005-04-13 14:45:30 +02002351
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002352static int stac_save_pin_cfgs(struct hda_codec *codec, unsigned int *pins)
2353{
2354 struct sigmatel_spec *spec = codec->spec;
2355
2356 if (!pins)
2357 return stac92xx_save_bios_config_regs(codec);
2358
2359 kfree(spec->pin_configs);
2360 spec->pin_configs = kmemdup(pins,
2361 spec->num_pins * sizeof(*pins),
2362 GFP_KERNEL);
2363 if (!spec->pin_configs)
2364 return -ENOMEM;
2365
2366 stac92xx_set_config_regs(codec);
2367 return 0;
2368}
2369
2370static void stac_change_pin_config(struct hda_codec *codec, hda_nid_t nid,
2371 unsigned int cfg)
2372{
2373 struct sigmatel_spec *spec = codec->spec;
2374 int i;
2375
2376 for (i = 0; i < spec->num_pins; i++) {
2377 if (spec->pin_nids[i] == nid) {
2378 spec->pin_configs[i] = cfg;
2379 stac92xx_set_config_reg(codec, nid, cfg);
2380 break;
2381 }
2382 }
2383}
2384
Matt2f2f4252005-04-13 14:45:30 +02002385/*
2386 * Analog playback callbacks
2387 */
2388static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2389 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002390 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002391{
2392 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002393 if (spec->stream_delay)
2394 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002395 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2396 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002397}
2398
2399static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2400 struct hda_codec *codec,
2401 unsigned int stream_tag,
2402 unsigned int format,
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;
Matt Porter403d1942005-11-29 15:00:51 +01002406 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002407}
2408
2409static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2410 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002411 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002412{
2413 struct sigmatel_spec *spec = codec->spec;
2414 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2415}
2416
2417/*
Mattdabbed62005-06-14 10:19:34 +02002418 * Digital playback callbacks
2419 */
2420static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2421 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002422 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002423{
2424 struct sigmatel_spec *spec = codec->spec;
2425 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2426}
2427
2428static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2429 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002430 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002431{
2432 struct sigmatel_spec *spec = codec->spec;
2433 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2434}
2435
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002436static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2437 struct hda_codec *codec,
2438 unsigned int stream_tag,
2439 unsigned int format,
2440 struct snd_pcm_substream *substream)
2441{
2442 struct sigmatel_spec *spec = codec->spec;
2443 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2444 stream_tag, format, substream);
2445}
2446
Mattdabbed62005-06-14 10:19:34 +02002447
2448/*
Matt2f2f4252005-04-13 14:45:30 +02002449 * Analog capture callbacks
2450 */
2451static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2452 struct hda_codec *codec,
2453 unsigned int stream_tag,
2454 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002455 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002456{
2457 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002458 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002459
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002460 if (spec->powerdown_adcs) {
2461 msleep(40);
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002462 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002463 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2464 }
2465 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002466 return 0;
2467}
2468
2469static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2470 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002471 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002472{
2473 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002474 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002475
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002476 snd_hda_codec_cleanup_stream(codec, nid);
2477 if (spec->powerdown_adcs)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002478 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002479 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002480 return 0;
2481}
2482
Mattdabbed62005-06-14 10:19:34 +02002483static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2484 .substreams = 1,
2485 .channels_min = 2,
2486 .channels_max = 2,
2487 /* NID is set in stac92xx_build_pcms */
2488 .ops = {
2489 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002490 .close = stac92xx_dig_playback_pcm_close,
2491 .prepare = stac92xx_dig_playback_pcm_prepare
Mattdabbed62005-06-14 10:19:34 +02002492 },
2493};
2494
2495static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2496 .substreams = 1,
2497 .channels_min = 2,
2498 .channels_max = 2,
2499 /* NID is set in stac92xx_build_pcms */
2500};
2501
Matt2f2f4252005-04-13 14:45:30 +02002502static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2503 .substreams = 1,
2504 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002505 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002506 .nid = 0x02, /* NID to query formats and rates */
2507 .ops = {
2508 .open = stac92xx_playback_pcm_open,
2509 .prepare = stac92xx_playback_pcm_prepare,
2510 .cleanup = stac92xx_playback_pcm_cleanup
2511 },
2512};
2513
Matt Porter3cc08dc2006-01-23 15:27:49 +01002514static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2515 .substreams = 1,
2516 .channels_min = 2,
2517 .channels_max = 2,
2518 .nid = 0x06, /* NID to query formats and rates */
2519 .ops = {
2520 .open = stac92xx_playback_pcm_open,
2521 .prepare = stac92xx_playback_pcm_prepare,
2522 .cleanup = stac92xx_playback_pcm_cleanup
2523 },
2524};
2525
Matt2f2f4252005-04-13 14:45:30 +02002526static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002527 .channels_min = 2,
2528 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002529 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002530 .ops = {
2531 .prepare = stac92xx_capture_pcm_prepare,
2532 .cleanup = stac92xx_capture_pcm_cleanup
2533 },
2534};
2535
2536static int stac92xx_build_pcms(struct hda_codec *codec)
2537{
2538 struct sigmatel_spec *spec = codec->spec;
2539 struct hda_pcm *info = spec->pcm_rec;
2540
2541 codec->num_pcms = 1;
2542 codec->pcm_info = info;
2543
Mattc7d4b2f2005-06-27 14:59:41 +02002544 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002545 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Matt2f2f4252005-04-13 14:45:30 +02002546 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002547 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002548 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002549
2550 if (spec->alt_switch) {
2551 codec->num_pcms++;
2552 info++;
2553 info->name = "STAC92xx Analog Alt";
2554 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2555 }
Matt2f2f4252005-04-13 14:45:30 +02002556
Mattdabbed62005-06-14 10:19:34 +02002557 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2558 codec->num_pcms++;
2559 info++;
2560 info->name = "STAC92xx Digital";
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002561 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Mattdabbed62005-06-14 10:19:34 +02002562 if (spec->multiout.dig_out_nid) {
2563 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2564 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2565 }
2566 if (spec->dig_in_nid) {
2567 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2568 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2569 }
2570 }
2571
Matt2f2f4252005-04-13 14:45:30 +02002572 return 0;
2573}
2574
Takashi Iwaic960a032006-03-23 17:06:28 +01002575static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2576{
2577 unsigned int pincap = snd_hda_param_read(codec, nid,
2578 AC_PAR_PIN_CAP);
2579 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2580 if (pincap & AC_PINCAP_VREF_100)
2581 return AC_PINCTL_VREF_100;
2582 if (pincap & AC_PINCAP_VREF_80)
2583 return AC_PINCTL_VREF_80;
2584 if (pincap & AC_PINCAP_VREF_50)
2585 return AC_PINCTL_VREF_50;
2586 if (pincap & AC_PINCAP_VREF_GRD)
2587 return AC_PINCTL_VREF_GRD;
2588 return 0;
2589}
2590
Matt Porter403d1942005-11-29 15:00:51 +01002591static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2592
2593{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002594 snd_hda_codec_write_cache(codec, nid, 0,
2595 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002596}
2597
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002598#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2599
2600static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2601 struct snd_ctl_elem_value *ucontrol)
2602{
2603 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2604 struct sigmatel_spec *spec = codec->spec;
2605
Takashi Iwaid7a89432008-11-12 09:48:04 +01002606 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002607 return 0;
2608}
2609
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002610static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
2611 unsigned char type);
2612
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002613static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2614 struct snd_ctl_elem_value *ucontrol)
2615{
2616 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2617 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002618 int nid = kcontrol->private_value;
2619
2620 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002621
2622 /* check to be sure that the ports are upto date with
2623 * switch changes
2624 */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002625 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002626
2627 return 1;
2628}
2629
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002630#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002631
2632static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2633{
2634 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2635 struct sigmatel_spec *spec = codec->spec;
2636 int io_idx = kcontrol-> private_value & 0xff;
2637
2638 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2639 return 0;
2640}
2641
2642static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2643{
2644 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2645 struct sigmatel_spec *spec = codec->spec;
2646 hda_nid_t nid = kcontrol->private_value >> 8;
2647 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002648 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002649
2650 spec->io_switch[io_idx] = val;
2651
2652 if (val)
2653 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002654 else {
2655 unsigned int pinctl = AC_PINCTL_IN_EN;
2656 if (io_idx) /* set VREF for mic */
2657 pinctl |= stac92xx_get_vref(codec, nid);
2658 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2659 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002660
2661 /* check the auto-mute again: we need to mute/unmute the speaker
2662 * appropriately according to the pin direction
2663 */
2664 if (spec->hp_detect)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002665 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
Jiang Zhe40c1d302007-11-12 13:05:16 +01002666
Matt Porter403d1942005-11-29 15:00:51 +01002667 return 1;
2668}
2669
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002670#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2671
2672static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2673 struct snd_ctl_elem_value *ucontrol)
2674{
2675 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2676 struct sigmatel_spec *spec = codec->spec;
2677
2678 ucontrol->value.integer.value[0] = spec->clfe_swap;
2679 return 0;
2680}
2681
2682static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2683 struct snd_ctl_elem_value *ucontrol)
2684{
2685 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2686 struct sigmatel_spec *spec = codec->spec;
2687 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002688 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002689
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002690 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002691 return 0;
2692
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002693 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002694
2695 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2696 spec->clfe_swap ? 0x4 : 0x0);
2697
2698 return 1;
2699}
2700
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002701#define STAC_CODEC_HP_SWITCH(xname) \
2702 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2703 .name = xname, \
2704 .index = 0, \
2705 .info = stac92xx_hp_switch_info, \
2706 .get = stac92xx_hp_switch_get, \
2707 .put = stac92xx_hp_switch_put, \
2708 }
2709
Matt Porter403d1942005-11-29 15:00:51 +01002710#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2711 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2712 .name = xname, \
2713 .index = 0, \
2714 .info = stac92xx_io_switch_info, \
2715 .get = stac92xx_io_switch_get, \
2716 .put = stac92xx_io_switch_put, \
2717 .private_value = xpval, \
2718 }
2719
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002720#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2721 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2722 .name = xname, \
2723 .index = 0, \
2724 .info = stac92xx_clfe_switch_info, \
2725 .get = stac92xx_clfe_switch_get, \
2726 .put = stac92xx_clfe_switch_put, \
2727 .private_value = xpval, \
2728 }
Matt Porter403d1942005-11-29 15:00:51 +01002729
Mattc7d4b2f2005-06-27 14:59:41 +02002730enum {
2731 STAC_CTL_WIDGET_VOL,
2732 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002733 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002734 STAC_CTL_WIDGET_AMP_MUX,
2735 STAC_CTL_WIDGET_AMP_VOL,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002736 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002737 STAC_CTL_WIDGET_IO_SWITCH,
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002738 STAC_CTL_WIDGET_CLFE_SWITCH
Mattc7d4b2f2005-06-27 14:59:41 +02002739};
2740
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002741static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002742 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2743 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002744 STAC_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002745 STAC_AMP_MUX,
2746 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002747 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002748 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002749 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002750};
2751
2752/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002753static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2754 struct snd_kcontrol_new *ktemp,
2755 int idx, const char *name,
2756 unsigned long val)
Mattc7d4b2f2005-06-27 14:59:41 +02002757{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002758 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002759
Takashi Iwai603c4012008-07-30 15:01:44 +02002760 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2761 knew = snd_array_new(&spec->kctls);
2762 if (!knew)
2763 return -ENOMEM;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002764 *knew = *ktemp;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002765 knew->index = idx;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002766 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002767 if (!knew->name)
Mattc7d4b2f2005-06-27 14:59:41 +02002768 return -ENOMEM;
2769 knew->private_value = val;
Mattc7d4b2f2005-06-27 14:59:41 +02002770 return 0;
2771}
2772
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002773static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2774 int type, int idx, const char *name,
2775 unsigned long val)
2776{
2777 return stac92xx_add_control_temp(spec,
2778 &stac92xx_control_templates[type],
2779 idx, name, val);
2780}
2781
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002782
2783/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002784static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2785 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002786{
2787 return stac92xx_add_control_idx(spec, type, 0, name, val);
2788}
2789
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002790/* check whether the line-input can be used as line-out */
2791static hda_nid_t check_line_out_switch(struct hda_codec *codec)
Matt Porter403d1942005-11-29 15:00:51 +01002792{
2793 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002794 struct auto_pin_cfg *cfg = &spec->autocfg;
2795 hda_nid_t nid;
2796 unsigned int pincap;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002797
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002798 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2799 return 0;
2800 nid = cfg->input_pins[AUTO_PIN_LINE];
2801 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
2802 if (pincap & AC_PINCAP_OUT)
2803 return nid;
Matt Porter403d1942005-11-29 15:00:51 +01002804 return 0;
2805}
2806
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002807/* check whether the mic-input can be used as line-out */
2808static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2809{
2810 struct sigmatel_spec *spec = codec->spec;
2811 struct auto_pin_cfg *cfg = &spec->autocfg;
2812 unsigned int def_conf, pincap;
2813 unsigned int mic_pin;
2814
2815 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2816 return 0;
2817 mic_pin = AUTO_PIN_MIC;
2818 for (;;) {
2819 hda_nid_t nid = cfg->input_pins[mic_pin];
2820 def_conf = snd_hda_codec_read(codec, nid, 0,
2821 AC_VERB_GET_CONFIG_DEFAULT, 0);
2822 /* some laptops have an internal analog microphone
2823 * which can't be used as a output */
2824 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2825 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
2826 if (pincap & AC_PINCAP_OUT)
2827 return nid;
2828 }
2829 if (mic_pin == AUTO_PIN_MIC)
2830 mic_pin = AUTO_PIN_FRONT_MIC;
2831 else
2832 break;
2833 }
2834 return 0;
2835}
Steve Longerbeam7b043892007-05-03 20:50:03 +02002836
2837static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2838{
2839 int i;
2840
2841 for (i = 0; i < spec->multiout.num_dacs; i++) {
2842 if (spec->multiout.dac_nids[i] == nid)
2843 return 1;
2844 }
2845
2846 return 0;
2847}
2848
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002849static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2850{
2851 int i;
2852 if (is_in_dac_nids(spec, nid))
2853 return 1;
2854 for (i = 0; i < spec->autocfg.hp_outs; i++)
2855 if (spec->hp_dacs[i] == nid)
2856 return 1;
2857 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2858 if (spec->speaker_dacs[i] == nid)
2859 return 1;
2860 return 0;
2861}
2862
2863static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2864{
2865 struct sigmatel_spec *spec = codec->spec;
2866 int j, conn_len;
2867 hda_nid_t conn[HDA_MAX_CONNECTIONS];
2868 unsigned int wcaps, wtype;
2869
2870 conn_len = snd_hda_get_connections(codec, nid, conn,
2871 HDA_MAX_CONNECTIONS);
2872 for (j = 0; j < conn_len; j++) {
2873 wcaps = snd_hda_param_read(codec, conn[j],
2874 AC_PAR_AUDIO_WIDGET_CAP);
2875 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2876 /* we check only analog outputs */
2877 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2878 continue;
2879 /* if this route has a free DAC, assign it */
2880 if (!check_all_dac_nids(spec, conn[j])) {
2881 if (conn_len > 1) {
2882 /* select this DAC in the pin's input mux */
2883 snd_hda_codec_write_cache(codec, nid, 0,
2884 AC_VERB_SET_CONNECT_SEL, j);
2885 }
2886 return conn[j];
2887 }
2888 }
2889 return 0;
2890}
2891
2892static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2893static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2894
Matt Porter3cc08dc2006-01-23 15:27:49 +01002895/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02002896 * Fill in the dac_nids table from the parsed pin configuration
2897 * This function only works when every pin in line_out_pins[]
2898 * contains atleast one DAC in its connection list. Some 92xx
2899 * codecs are not connected directly to a DAC, such as the 9200
2900 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002901 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002902static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02002903{
2904 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002905 struct auto_pin_cfg *cfg = &spec->autocfg;
2906 int i;
2907 hda_nid_t nid, dac;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002908
Mattc7d4b2f2005-06-27 14:59:41 +02002909 for (i = 0; i < cfg->line_outs; i++) {
2910 nid = cfg->line_out_pins[i];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002911 dac = get_unassigned_dac(codec, nid);
2912 if (!dac) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002913 if (spec->multiout.num_dacs > 0) {
2914 /* we have already working output pins,
2915 * so let's drop the broken ones again
2916 */
2917 cfg->line_outs = spec->multiout.num_dacs;
2918 break;
2919 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002920 /* error out, no available DAC found */
2921 snd_printk(KERN_ERR
2922 "%s: No available DAC for pin 0x%x\n",
2923 __func__, nid);
2924 return -ENODEV;
2925 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002926 add_spec_dacs(spec, dac);
2927 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002928
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002929 /* add line-in as output */
2930 nid = check_line_out_switch(codec);
2931 if (nid) {
2932 dac = get_unassigned_dac(codec, nid);
2933 if (dac) {
2934 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
2935 nid, cfg->line_outs);
2936 cfg->line_out_pins[cfg->line_outs] = nid;
2937 cfg->line_outs++;
2938 spec->line_switch = nid;
2939 add_spec_dacs(spec, dac);
2940 }
2941 }
2942 /* add mic as output */
2943 nid = check_mic_out_switch(codec);
2944 if (nid) {
2945 dac = get_unassigned_dac(codec, nid);
2946 if (dac) {
2947 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
2948 nid, cfg->line_outs);
2949 cfg->line_out_pins[cfg->line_outs] = nid;
2950 cfg->line_outs++;
2951 spec->mic_switch = nid;
2952 add_spec_dacs(spec, dac);
Steve Longerbeam7b043892007-05-03 20:50:03 +02002953 }
Mattc7d4b2f2005-06-27 14:59:41 +02002954 }
2955
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002956 for (i = 0; i < cfg->hp_outs; i++) {
2957 nid = cfg->hp_pins[i];
2958 dac = get_unassigned_dac(codec, nid);
2959 if (dac) {
2960 if (!spec->multiout.hp_nid)
2961 spec->multiout.hp_nid = dac;
2962 else
2963 add_spec_extra_dacs(spec, dac);
2964 }
2965 spec->hp_dacs[i] = dac;
2966 }
2967
2968 for (i = 0; i < cfg->speaker_outs; i++) {
2969 nid = cfg->speaker_pins[i];
2970 dac = get_unassigned_dac(codec, nid);
2971 if (dac)
2972 add_spec_extra_dacs(spec, dac);
2973 spec->speaker_dacs[i] = dac;
2974 }
2975
2976 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
Steve Longerbeam7b043892007-05-03 20:50:03 +02002977 spec->multiout.num_dacs,
2978 spec->multiout.dac_nids[0],
2979 spec->multiout.dac_nids[1],
2980 spec->multiout.dac_nids[2],
2981 spec->multiout.dac_nids[3],
2982 spec->multiout.dac_nids[4]);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002983
Mattc7d4b2f2005-06-27 14:59:41 +02002984 return 0;
2985}
2986
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002987/* create volume control/switch for the given prefx type */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01002988static int create_controls(struct hda_codec *codec, const char *pfx,
2989 hda_nid_t nid, int chs)
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002990{
Takashi Iwai7c7767e2009-01-20 15:28:38 +01002991 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002992 char name[32];
2993 int err;
2994
Takashi Iwai7c7767e2009-01-20 15:28:38 +01002995 if (!spec->check_volume_offset) {
2996 unsigned int caps, step, nums, db_scale;
2997 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
2998 step = (caps & AC_AMPCAP_STEP_SIZE) >>
2999 AC_AMPCAP_STEP_SIZE_SHIFT;
3000 step = (step + 1) * 25; /* in .01dB unit */
3001 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3002 AC_AMPCAP_NUM_STEPS_SHIFT;
3003 db_scale = nums * step;
3004 /* if dB scale is over -64dB, and finer enough,
3005 * let's reduce it to half
3006 */
3007 if (db_scale > 6400 && nums >= 0x1f)
3008 spec->volume_offset = nums / 2;
3009 spec->check_volume_offset = 1;
3010 }
3011
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003012 sprintf(name, "%s Playback Volume", pfx);
3013 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003014 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3015 spec->volume_offset));
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003016 if (err < 0)
3017 return err;
3018 sprintf(name, "%s Playback Switch", pfx);
3019 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
3020 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3021 if (err < 0)
3022 return err;
3023 return 0;
3024}
3025
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003026static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3027{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003028 if (spec->multiout.num_dacs > 4) {
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003029 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3030 return 1;
3031 } else {
3032 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
3033 spec->multiout.num_dacs++;
3034 }
3035 return 0;
3036}
3037
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003038static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003039{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003040 int i;
3041 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3042 if (!spec->multiout.extra_out_nid[i]) {
3043 spec->multiout.extra_out_nid[i] = nid;
3044 return 0;
3045 }
3046 }
3047 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3048 return 1;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003049}
3050
Takashi Iwai76624532008-12-19 10:09:47 +01003051static int is_unique_dac(struct sigmatel_spec *spec, hda_nid_t nid)
3052{
3053 int i;
3054
3055 if (spec->autocfg.line_outs != 1)
3056 return 0;
3057 if (spec->multiout.hp_nid == nid)
3058 return 0;
3059 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++)
3060 if (spec->multiout.extra_out_nid[i] == nid)
3061 return 0;
3062 return 1;
3063}
3064
Mattc7d4b2f2005-06-27 14:59:41 +02003065/* add playback controls from the parsed DAC table */
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003066static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
Takashi Iwai19039bd2006-06-28 15:52:16 +02003067 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003068{
Takashi Iwai76624532008-12-19 10:09:47 +01003069 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003070 static const char *chname[4] = {
3071 "Front", "Surround", NULL /*CLFE*/, "Side"
3072 };
Matthew Ranostayd21995e2008-10-13 13:22:45 -04003073 hda_nid_t nid = 0;
Takashi Iwai91589232008-12-19 15:59:40 +01003074 int i, err;
3075 unsigned int wid_caps;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003076
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003077 for (i = 0; i < cfg->line_outs && spec->multiout.dac_nids[i]; i++) {
Mattc7d4b2f2005-06-27 14:59:41 +02003078 nid = spec->multiout.dac_nids[i];
Mattc7d4b2f2005-06-27 14:59:41 +02003079 if (i == 2) {
3080 /* Center/LFE */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003081 err = create_controls(codec, "Center", nid, 1);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003082 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003083 return err;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003084 err = create_controls(codec, "LFE", nid, 2);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003085 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003086 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003087
3088 wid_caps = get_wcaps(codec, nid);
3089
3090 if (wid_caps & AC_WCAP_LR_SWAP) {
3091 err = stac92xx_add_control(spec,
3092 STAC_CTL_WIDGET_CLFE_SWITCH,
3093 "Swap Center/LFE Playback Switch", nid);
3094
3095 if (err < 0)
3096 return err;
3097 }
3098
Mattc7d4b2f2005-06-27 14:59:41 +02003099 } else {
Takashi Iwai76624532008-12-19 10:09:47 +01003100 const char *name = chname[i];
3101 /* if it's a single DAC, assign a better name */
3102 if (!i && is_unique_dac(spec, nid)) {
3103 switch (cfg->line_out_type) {
3104 case AUTO_PIN_HP_OUT:
3105 name = "Headphone";
3106 break;
3107 case AUTO_PIN_SPEAKER_OUT:
3108 name = "Speaker";
3109 break;
3110 }
3111 }
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003112 err = create_controls(codec, name, nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003113 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003114 return err;
3115 }
3116 }
3117
Takashi Iwaia9cb5c92008-11-24 07:51:11 +01003118 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003119 err = stac92xx_add_control(spec,
3120 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01003121 "Headphone as Line Out Switch",
3122 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003123 if (err < 0)
3124 return err;
3125 }
3126
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003127 if (spec->line_switch) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003128 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
3129 "Line In as Output Switch",
3130 spec->line_switch << 8);
3131 if (err < 0)
3132 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003133 }
Matt Porter403d1942005-11-29 15:00:51 +01003134
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003135 if (spec->mic_switch) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003136 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
3137 "Mic as Output Switch",
3138 (spec->mic_switch << 8) | 1);
3139 if (err < 0)
3140 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003141 }
Matt Porter403d1942005-11-29 15:00:51 +01003142
Mattc7d4b2f2005-06-27 14:59:41 +02003143 return 0;
3144}
3145
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003146/* add playback controls for Speaker and HP outputs */
3147static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3148 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003149{
3150 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003151 hda_nid_t nid;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003152 int i, err, nums;
Mattc7d4b2f2005-06-27 14:59:41 +02003153
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003154 nums = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003155 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003156 static const char *pfxs[] = {
3157 "Headphone", "Headphone2", "Headphone3",
3158 };
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003159 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
3160 if (wid_caps & AC_WCAP_UNSOL_CAP)
3161 spec->hp_detect = 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003162 if (nums >= ARRAY_SIZE(pfxs))
Mattc7d4b2f2005-06-27 14:59:41 +02003163 continue;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003164 nid = spec->hp_dacs[i];
3165 if (!nid)
3166 continue;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003167 err = create_controls(codec, pfxs[nums++], nid, 3);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003168 if (err < 0)
3169 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003170 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003171 nums = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003172 for (i = 0; i < cfg->speaker_outs; i++) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003173 static const char *pfxs[] = {
3174 "Speaker", "External Speaker", "Speaker2",
3175 };
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003176 if (nums >= ARRAY_SIZE(pfxs))
3177 continue;
3178 nid = spec->speaker_dacs[i];
3179 if (!nid)
3180 continue;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003181 err = create_controls(codec, pfxs[nums++], nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003182 if (err < 0)
3183 return err;
3184 }
Mattc7d4b2f2005-06-27 14:59:41 +02003185 return 0;
3186}
3187
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003188/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003189static const char *stac92xx_mono_labels[4] = {
3190 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003191};
3192
3193/* create mono mux for mono out on capable codecs */
3194static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3195{
3196 struct sigmatel_spec *spec = codec->spec;
3197 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3198 int i, num_cons;
3199 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3200
3201 num_cons = snd_hda_get_connections(codec,
3202 spec->mono_nid,
3203 con_lst,
3204 HDA_MAX_NUM_INPUTS);
3205 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3206 return -EINVAL;
3207
3208 for (i = 0; i < num_cons; i++) {
3209 mono_mux->items[mono_mux->num_items].label =
3210 stac92xx_mono_labels[i];
3211 mono_mux->items[mono_mux->num_items].index = i;
3212 mono_mux->num_items++;
3213 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003214
3215 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3216 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003217}
3218
Matthew Ranostay89385032008-09-11 09:49:39 -04003219/* labels for amp mux outputs */
3220static const char *stac92xx_amp_labels[3] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04003221 "Front Microphone", "Microphone", "Line In",
Matthew Ranostay89385032008-09-11 09:49:39 -04003222};
3223
3224/* create amp out controls mux on capable codecs */
3225static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3226{
3227 struct sigmatel_spec *spec = codec->spec;
3228 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3229 int i, err;
3230
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003231 for (i = 0; i < spec->num_amps; i++) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003232 amp_mux->items[amp_mux->num_items].label =
3233 stac92xx_amp_labels[i];
3234 amp_mux->items[amp_mux->num_items].index = i;
3235 amp_mux->num_items++;
3236 }
3237
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003238 if (spec->num_amps > 1) {
3239 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3240 "Amp Selector Capture Switch", 0);
3241 if (err < 0)
3242 return err;
3243 }
Matthew Ranostay89385032008-09-11 09:49:39 -04003244 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3245 "Amp Capture Volume",
3246 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3247}
3248
3249
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003250/* create PC beep volume controls */
3251static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3252 hda_nid_t nid)
3253{
3254 struct sigmatel_spec *spec = codec->spec;
3255 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3256 int err;
3257
3258 /* check for mute support for the the amp */
3259 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3260 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3261 "PC Beep Playback Switch",
3262 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3263 if (err < 0)
3264 return err;
3265 }
3266
3267 /* check to see if there is volume support for the amp */
3268 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3269 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3270 "PC Beep Playback Volume",
3271 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3272 if (err < 0)
3273 return err;
3274 }
3275 return 0;
3276}
3277
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003278#ifdef CONFIG_SND_HDA_INPUT_BEEP
3279#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3280
3281static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3282 struct snd_ctl_elem_value *ucontrol)
3283{
3284 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3285 ucontrol->value.integer.value[0] = codec->beep->enabled;
3286 return 0;
3287}
3288
3289static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3290 struct snd_ctl_elem_value *ucontrol)
3291{
3292 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3293 int enabled = !!ucontrol->value.integer.value[0];
3294 if (codec->beep->enabled != enabled) {
3295 codec->beep->enabled = enabled;
3296 return 1;
3297 }
3298 return 0;
3299}
3300
3301static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3302 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3303 .info = stac92xx_dig_beep_switch_info,
3304 .get = stac92xx_dig_beep_switch_get,
3305 .put = stac92xx_dig_beep_switch_put,
3306};
3307
3308static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3309{
3310 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3311 0, "PC Beep Playback Switch", 0);
3312}
3313#endif
3314
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003315static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3316{
3317 struct sigmatel_spec *spec = codec->spec;
3318 int wcaps, nid, i, err = 0;
3319
3320 for (i = 0; i < spec->num_muxes; i++) {
3321 nid = spec->mux_nids[i];
3322 wcaps = get_wcaps(codec, nid);
3323
3324 if (wcaps & AC_WCAP_OUT_AMP) {
3325 err = stac92xx_add_control_idx(spec,
3326 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3327 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3328 if (err < 0)
3329 return err;
3330 }
3331 }
3332 return 0;
3333};
3334
Matthew Ranostayd9737752008-09-07 12:03:41 +02003335static const char *stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003336 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003337};
3338
3339static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3340{
3341 struct sigmatel_spec *spec = codec->spec;
3342 struct hda_input_mux *spdif_mux = &spec->private_smux;
Matthew Ranostay65973632008-09-16 10:39:37 -04003343 const char **labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003344 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003345 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003346
3347 num_cons = snd_hda_get_connections(codec,
3348 spec->smux_nids[0],
3349 con_lst,
3350 HDA_MAX_NUM_INPUTS);
Matthew Ranostay65973632008-09-16 10:39:37 -04003351 if (!num_cons)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003352 return -EINVAL;
3353
Matthew Ranostay65973632008-09-16 10:39:37 -04003354 if (!labels)
3355 labels = stac92xx_spdif_labels;
3356
Matthew Ranostayd9737752008-09-07 12:03:41 +02003357 for (i = 0; i < num_cons; i++) {
Matthew Ranostay65973632008-09-16 10:39:37 -04003358 spdif_mux->items[spdif_mux->num_items].label = labels[i];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003359 spdif_mux->items[spdif_mux->num_items].index = i;
3360 spdif_mux->num_items++;
3361 }
3362
3363 return 0;
3364}
3365
Matt Porter8b657272006-10-26 17:12:59 +02003366/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003367static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003368 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3369 "Digital Mic 3", "Digital Mic 4"
3370};
3371
3372/* create playback/capture controls for input pins on dmic capable codecs */
3373static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3374 const struct auto_pin_cfg *cfg)
3375{
3376 struct sigmatel_spec *spec = codec->spec;
3377 struct hda_input_mux *dimux = &spec->private_dimux;
3378 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003379 int err, i, j;
3380 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02003381
3382 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3383 dimux->items[dimux->num_items].index = 0;
3384 dimux->num_items++;
3385
3386 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003387 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003388 int index;
3389 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003390 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02003391 unsigned int def_conf;
3392
3393 def_conf = snd_hda_codec_read(codec,
3394 spec->dmic_nids[i],
3395 0,
3396 AC_VERB_GET_CONFIG_DEFAULT,
3397 0);
3398 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3399 continue;
3400
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003401 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02003402 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003403 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02003404 con_lst,
3405 HDA_MAX_NUM_INPUTS);
3406 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003407 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02003408 index = j;
3409 goto found;
3410 }
3411 continue;
3412found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003413 wcaps = get_wcaps(codec, nid) &
3414 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003415
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003416 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003417 sprintf(name, "%s Capture Volume",
3418 stac92xx_dmic_labels[dimux->num_items]);
3419
3420 err = stac92xx_add_control(spec,
3421 STAC_CTL_WIDGET_VOL,
3422 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003423 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3424 (wcaps & AC_WCAP_OUT_AMP) ?
3425 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003426 if (err < 0)
3427 return err;
3428 }
3429
Matt Porter8b657272006-10-26 17:12:59 +02003430 dimux->items[dimux->num_items].label =
3431 stac92xx_dmic_labels[dimux->num_items];
3432 dimux->items[dimux->num_items].index = index;
3433 dimux->num_items++;
3434 }
3435
3436 return 0;
3437}
3438
Mattc7d4b2f2005-06-27 14:59:41 +02003439/* create playback/capture controls for input pins */
3440static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3441{
3442 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003443 struct hda_input_mux *imux = &spec->private_imux;
3444 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3445 int i, j, k;
3446
3447 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003448 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02003449
Takashi Iwai314634b2006-09-21 11:56:18 +02003450 if (!cfg->input_pins[i])
3451 continue;
3452 index = -1;
3453 for (j = 0; j < spec->num_muxes; j++) {
3454 int num_cons;
3455 num_cons = snd_hda_get_connections(codec,
3456 spec->mux_nids[j],
3457 con_lst,
3458 HDA_MAX_NUM_INPUTS);
3459 for (k = 0; k < num_cons; k++)
3460 if (con_lst[k] == cfg->input_pins[i]) {
3461 index = k;
3462 goto found;
3463 }
Mattc7d4b2f2005-06-27 14:59:41 +02003464 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003465 continue;
3466 found:
3467 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3468 imux->items[imux->num_items].index = index;
3469 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003470 }
3471
Steve Longerbeam7b043892007-05-03 20:50:03 +02003472 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003473 /*
3474 * Set the current input for the muxes.
3475 * The STAC9221 has two input muxes with identical source
3476 * NID lists. Hopefully this won't get confused.
3477 */
3478 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003479 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3480 AC_VERB_SET_CONNECT_SEL,
3481 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003482 }
3483 }
3484
Mattc7d4b2f2005-06-27 14:59:41 +02003485 return 0;
3486}
3487
Mattc7d4b2f2005-06-27 14:59:41 +02003488static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3489{
3490 struct sigmatel_spec *spec = codec->spec;
3491 int i;
3492
3493 for (i = 0; i < spec->autocfg.line_outs; i++) {
3494 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3495 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3496 }
3497}
3498
3499static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3500{
3501 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003502 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003503
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003504 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3505 hda_nid_t pin;
3506 pin = spec->autocfg.hp_pins[i];
3507 if (pin) /* connect to front */
3508 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3509 }
3510 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3511 hda_nid_t pin;
3512 pin = spec->autocfg.speaker_pins[i];
3513 if (pin) /* connect to front */
3514 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3515 }
Mattc7d4b2f2005-06-27 14:59:41 +02003516}
3517
Matt Porter3cc08dc2006-01-23 15:27:49 +01003518static 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 +02003519{
3520 struct sigmatel_spec *spec = codec->spec;
3521 int err;
3522
Matt Porter8b657272006-10-26 17:12:59 +02003523 if ((err = snd_hda_parse_pin_def_config(codec,
3524 &spec->autocfg,
3525 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003526 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003527 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003528 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003529
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003530 /* If we have no real line-out pin and multiple hp-outs, HPs should
3531 * be set up as multi-channel outputs.
3532 */
3533 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3534 spec->autocfg.hp_outs > 1) {
3535 /* Copy hp_outs to line_outs, backup line_outs in
3536 * speaker_outs so that the following routines can handle
3537 * HP pins as primary outputs.
3538 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003539 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003540 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3541 sizeof(spec->autocfg.line_out_pins));
3542 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3543 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3544 sizeof(spec->autocfg.hp_pins));
3545 spec->autocfg.line_outs = spec->autocfg.hp_outs;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003546 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3547 spec->autocfg.hp_outs = 0;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003548 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003549 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003550 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3551 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003552 u32 caps = query_amp_caps(codec,
3553 spec->autocfg.mono_out_pin, dir);
3554 hda_nid_t conn_list[1];
3555
3556 /* get the mixer node and then the mono mux if it exists */
3557 if (snd_hda_get_connections(codec,
3558 spec->autocfg.mono_out_pin, conn_list, 1) &&
3559 snd_hda_get_connections(codec, conn_list[0],
3560 conn_list, 1)) {
3561
3562 int wcaps = get_wcaps(codec, conn_list[0]);
3563 int wid_type = (wcaps & AC_WCAP_TYPE)
3564 >> AC_WCAP_TYPE_SHIFT;
3565 /* LR swap check, some stac925x have a mux that
3566 * changes the DACs output path instead of the
3567 * mono-mux path.
3568 */
3569 if (wid_type == AC_WID_AUD_SEL &&
3570 !(wcaps & AC_WCAP_LR_SWAP))
3571 spec->mono_nid = conn_list[0];
3572 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003573 if (dir) {
3574 hda_nid_t nid = spec->autocfg.mono_out_pin;
3575
3576 /* most mono outs have a least a mute/unmute switch */
3577 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3578 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3579 "Mono Playback Switch",
3580 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003581 if (err < 0)
3582 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003583 /* check for volume support for the amp */
3584 if ((caps & AC_AMPCAP_NUM_STEPS)
3585 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3586 err = stac92xx_add_control(spec,
3587 STAC_CTL_WIDGET_VOL,
3588 "Mono Playback Volume",
3589 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3590 if (err < 0)
3591 return err;
3592 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003593 }
3594
3595 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3596 AC_PINCTL_OUT_EN);
3597 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003598
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003599 if (!spec->multiout.num_dacs) {
3600 err = stac92xx_auto_fill_dac_nids(codec);
3601 if (err < 0)
Takashi Iwai19039bd2006-06-28 15:52:16 +02003602 return err;
Takashi Iwaic9280d62009-01-15 17:31:00 +01003603 err = stac92xx_auto_create_multi_out_ctls(codec,
3604 &spec->autocfg);
3605 if (err < 0)
3606 return err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003607 }
Mattc7d4b2f2005-06-27 14:59:41 +02003608
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003609 /* setup analog beep controls */
3610 if (spec->anabeep_nid > 0) {
3611 err = stac92xx_auto_create_beep_ctls(codec,
3612 spec->anabeep_nid);
3613 if (err < 0)
3614 return err;
3615 }
3616
3617 /* setup digital beep controls and input device */
3618#ifdef CONFIG_SND_HDA_INPUT_BEEP
3619 if (spec->digbeep_nid > 0) {
3620 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003621 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003622
3623 err = stac92xx_auto_create_beep_ctls(codec, nid);
3624 if (err < 0)
3625 return err;
3626 err = snd_hda_attach_beep_device(codec, nid);
3627 if (err < 0)
3628 return err;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003629 /* if no beep switch is available, make its own one */
3630 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3631 if (codec->beep &&
3632 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3633 err = stac92xx_beep_switch_ctl(codec);
3634 if (err < 0)
3635 return err;
3636 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003637 }
3638#endif
3639
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003640 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3641
3642 if (err < 0)
3643 return err;
3644
3645 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3646
3647 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003648 return err;
3649
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003650 if (spec->mono_nid > 0) {
3651 err = stac92xx_auto_create_mono_output_ctls(codec);
3652 if (err < 0)
3653 return err;
3654 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003655 if (spec->num_amps > 0) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003656 err = stac92xx_auto_create_amp_output_ctls(codec);
3657 if (err < 0)
3658 return err;
3659 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003660 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003661 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3662 &spec->autocfg)) < 0)
3663 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003664 if (spec->num_muxes > 0) {
3665 err = stac92xx_auto_create_mux_input_ctls(codec);
3666 if (err < 0)
3667 return err;
3668 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003669 if (spec->num_smuxes > 0) {
3670 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3671 if (err < 0)
3672 return err;
3673 }
Matt Porter8b657272006-10-26 17:12:59 +02003674
Mattc7d4b2f2005-06-27 14:59:41 +02003675 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003676 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003677 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003678
Takashi Iwai82bc9552006-03-21 11:24:42 +01003679 if (spec->autocfg.dig_out_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003680 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003681 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003682 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003683
Takashi Iwai603c4012008-07-30 15:01:44 +02003684 if (spec->kctls.list)
3685 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003686
3687 spec->input_mux = &spec->private_imux;
Matthew Ranostayf8ccbf62008-12-20 17:36:28 -05003688 if (!spec->dinput_mux)
3689 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003690 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003691 spec->mono_mux = &spec->private_mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -04003692 spec->amp_mux = &spec->private_amp_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003693 return 1;
3694}
3695
Takashi Iwai82bc9552006-03-21 11:24:42 +01003696/* add playback controls for HP output */
3697static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3698 struct auto_pin_cfg *cfg)
3699{
3700 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003701 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003702 unsigned int wid_caps;
3703
3704 if (! pin)
3705 return 0;
3706
3707 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003708 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003709 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003710
3711 return 0;
3712}
3713
Richard Fish160ea0d2006-09-06 13:58:25 +02003714/* add playback controls for LFE output */
3715static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3716 struct auto_pin_cfg *cfg)
3717{
3718 struct sigmatel_spec *spec = codec->spec;
3719 int err;
3720 hda_nid_t lfe_pin = 0x0;
3721 int i;
3722
3723 /*
3724 * search speaker outs and line outs for a mono speaker pin
3725 * with an amp. If one is found, add LFE controls
3726 * for it.
3727 */
3728 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3729 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003730 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003731 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3732 if (wcaps == AC_WCAP_OUT_AMP)
3733 /* found a mono speaker with an amp, must be lfe */
3734 lfe_pin = pin;
3735 }
3736
3737 /* if speaker_outs is 0, then speakers may be in line_outs */
3738 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3739 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3740 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003741 unsigned int defcfg;
Harvey Harrison8b551782008-02-29 11:56:48 +01003742 defcfg = snd_hda_codec_read(codec, pin, 0,
Richard Fish160ea0d2006-09-06 13:58:25 +02003743 AC_VERB_GET_CONFIG_DEFAULT,
3744 0x00);
Harvey Harrison8b551782008-02-29 11:56:48 +01003745 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003746 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003747 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3748 if (wcaps == AC_WCAP_OUT_AMP)
3749 /* found a mono speaker with an amp,
3750 must be lfe */
3751 lfe_pin = pin;
3752 }
3753 }
3754 }
3755
3756 if (lfe_pin) {
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003757 err = create_controls(codec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003758 if (err < 0)
3759 return err;
3760 }
3761
3762 return 0;
3763}
3764
Mattc7d4b2f2005-06-27 14:59:41 +02003765static int stac9200_parse_auto_config(struct hda_codec *codec)
3766{
3767 struct sigmatel_spec *spec = codec->spec;
3768 int err;
3769
Kailang Yangdf694da2005-12-05 19:42:22 +01003770 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003771 return err;
3772
3773 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3774 return err;
3775
Takashi Iwai82bc9552006-03-21 11:24:42 +01003776 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3777 return err;
3778
Richard Fish160ea0d2006-09-06 13:58:25 +02003779 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3780 return err;
3781
Takashi Iwai355a0ec2008-11-11 16:46:19 +01003782 if (spec->num_muxes > 0) {
3783 err = stac92xx_auto_create_mux_input_ctls(codec);
3784 if (err < 0)
3785 return err;
3786 }
3787
Takashi Iwai82bc9552006-03-21 11:24:42 +01003788 if (spec->autocfg.dig_out_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003789 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003790 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003791 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003792
Takashi Iwai603c4012008-07-30 15:01:44 +02003793 if (spec->kctls.list)
3794 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003795
3796 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003797 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003798
3799 return 1;
3800}
3801
Sam Revitch62fe78e2006-05-10 15:09:17 +02003802/*
3803 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3804 * funky external mute control using GPIO pins.
3805 */
3806
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003807static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003808 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003809{
3810 unsigned int gpiostate, gpiomask, gpiodir;
3811
3812 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3813 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003814 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003815
3816 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3817 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003818 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003819
3820 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3821 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003822 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003823
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003824 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003825 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3826
3827 snd_hda_codec_write(codec, codec->afg, 0,
3828 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003829 snd_hda_codec_read(codec, codec->afg, 0,
3830 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003831
3832 msleep(1);
3833
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003834 snd_hda_codec_read(codec, codec->afg, 0,
3835 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003836}
3837
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003838static int stac92xx_add_jack(struct hda_codec *codec,
3839 hda_nid_t nid, int type)
3840{
Takashi Iwaie4973e12008-11-18 09:32:42 +01003841#ifdef CONFIG_SND_JACK
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003842 struct sigmatel_spec *spec = codec->spec;
3843 struct sigmatel_jack *jack;
3844 int def_conf = snd_hda_codec_read(codec, nid,
3845 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
3846 int connectivity = get_defcfg_connect(def_conf);
3847 char name[32];
3848
3849 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
3850 return 0;
3851
3852 snd_array_init(&spec->jacks, sizeof(*jack), 32);
3853 jack = snd_array_new(&spec->jacks);
3854 if (!jack)
3855 return -ENOMEM;
3856 jack->nid = nid;
3857 jack->type = type;
3858
3859 sprintf(name, "%s at %s %s Jack",
3860 snd_hda_get_jack_type(def_conf),
3861 snd_hda_get_jack_connectivity(def_conf),
3862 snd_hda_get_jack_location(def_conf));
3863
3864 return snd_jack_new(codec->bus->card, name, type, &jack->jack);
Takashi Iwaie4973e12008-11-18 09:32:42 +01003865#else
3866 return 0;
3867#endif
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003868}
3869
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003870static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
3871 unsigned char type, int data)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003872{
3873 struct sigmatel_event *event;
3874
3875 snd_array_init(&spec->events, sizeof(*event), 32);
3876 event = snd_array_new(&spec->events);
3877 if (!event)
3878 return -ENOMEM;
3879 event->nid = nid;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003880 event->type = type;
3881 event->tag = spec->events.used;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003882 event->data = data;
3883
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003884 return event->tag;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003885}
3886
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003887static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
3888 hda_nid_t nid, unsigned char type)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003889{
3890 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003891 struct sigmatel_event *event = spec->events.list;
3892 int i;
3893
3894 for (i = 0; i < spec->events.used; i++, event++) {
3895 if (event->nid == nid && event->type == type)
3896 return event;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003897 }
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003898 return NULL;
3899}
3900
3901static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
3902 unsigned char tag)
3903{
3904 struct sigmatel_spec *spec = codec->spec;
3905 struct sigmatel_event *event = spec->events.list;
3906 int i;
3907
3908 for (i = 0; i < spec->events.used; i++, event++) {
3909 if (event->tag == tag)
3910 return event;
3911 }
3912 return NULL;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003913}
3914
Takashi Iwai314634b2006-09-21 11:56:18 +02003915static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003916 unsigned int type)
Takashi Iwai314634b2006-09-21 11:56:18 +02003917{
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003918 struct sigmatel_event *event;
3919 int tag;
3920
3921 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
3922 return;
3923 event = stac_get_event(codec, nid, type);
3924 if (event)
3925 tag = event->tag;
3926 else
3927 tag = stac_add_event(codec->spec, nid, type, 0);
3928 if (tag < 0)
3929 return;
3930 snd_hda_codec_write_cache(codec, nid, 0,
3931 AC_VERB_SET_UNSOLICITED_ENABLE,
3932 AC_USRSP_EN | tag);
Takashi Iwai314634b2006-09-21 11:56:18 +02003933}
3934
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003935static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3936{
3937 int i;
3938 for (i = 0; i < cfg->hp_outs; i++)
3939 if (cfg->hp_pins[i] == nid)
3940 return 1; /* nid is a HP-Out */
3941
3942 return 0; /* nid is not a HP-Out */
3943};
3944
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003945static void stac92xx_power_down(struct hda_codec *codec)
3946{
3947 struct sigmatel_spec *spec = codec->spec;
3948
3949 /* power down inactive DACs */
3950 hda_nid_t *dac;
3951 for (dac = spec->dac_list; *dac; dac++)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003952 if (!check_all_dac_nids(spec, *dac))
Takashi Iwai8c2f7672008-12-01 11:54:35 +01003953 snd_hda_codec_write(codec, *dac, 0,
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003954 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3955}
3956
Takashi Iwaif73d3582008-11-25 08:21:51 +01003957static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
3958 int enable);
3959
Mattc7d4b2f2005-06-27 14:59:41 +02003960static int stac92xx_init(struct hda_codec *codec)
3961{
3962 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003963 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01003964 unsigned int gpio;
Takashi Iwaie4973e12008-11-18 09:32:42 +01003965 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003966
Mattc7d4b2f2005-06-27 14:59:41 +02003967 snd_hda_sequence_write(codec, spec->init);
3968
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003969 /* power down adcs initially */
3970 if (spec->powerdown_adcs)
3971 for (i = 0; i < spec->num_adcs; i++)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01003972 snd_hda_codec_write(codec,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003973 spec->adc_nids[i], 0,
3974 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01003975
3976 /* set up GPIO */
3977 gpio = spec->gpio_data;
3978 /* turn on EAPD statically when spec->eapd_switch isn't set.
3979 * otherwise, unsol event will turn it on/off dynamically
3980 */
3981 if (!spec->eapd_switch)
3982 gpio |= spec->eapd_mask;
3983 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
3984
Takashi Iwai82bc9552006-03-21 11:24:42 +01003985 /* set up pins */
3986 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02003987 /* Enable unsolicited responses on the HP widget */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003988 for (i = 0; i < cfg->hp_outs; i++) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003989 hda_nid_t nid = cfg->hp_pins[i];
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003990 enable_pin_detect(codec, nid, STAC_HP_EVENT);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003991 }
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01003992 /* force to enable the first line-out; the others are set up
3993 * in unsol_event
3994 */
3995 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003996 AC_PINCTL_OUT_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003997 /* fake event to set up pins */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003998 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
3999 STAC_HP_EVENT);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004000 } else {
4001 stac92xx_auto_init_multi_out(codec);
4002 stac92xx_auto_init_hp_out(codec);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004003 for (i = 0; i < cfg->hp_outs; i++)
4004 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004005 }
4006 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01004007 hda_nid_t nid = cfg->input_pins[i];
4008 if (nid) {
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004009 unsigned int pinctl, conf;
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004010 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
4011 /* for mic pins, force to initialize */
4012 pinctl = stac92xx_get_vref(codec, nid);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004013 pinctl |= AC_PINCTL_IN_EN;
4014 stac92xx_auto_set_pinctl(codec, nid, pinctl);
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004015 } else {
4016 pinctl = snd_hda_codec_read(codec, nid, 0,
4017 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4018 /* if PINCTL already set then skip */
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004019 if (!(pinctl & AC_PINCTL_IN_EN)) {
4020 pinctl |= AC_PINCTL_IN_EN;
4021 stac92xx_auto_set_pinctl(codec, nid,
4022 pinctl);
4023 }
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004024 }
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004025 conf = snd_hda_codec_read(codec, nid, 0,
4026 AC_VERB_GET_CONFIG_DEFAULT, 0);
4027 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4028 enable_pin_detect(codec, nid,
4029 STAC_INSERT_EVENT);
4030 stac_issue_unsol_event(codec, nid,
4031 STAC_INSERT_EVENT);
4032 }
Takashi Iwaic960a032006-03-23 17:06:28 +01004033 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01004034 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004035 for (i = 0; i < spec->num_dmics; i++)
4036 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4037 AC_PINCTL_IN_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004038 if (cfg->dig_out_pin)
4039 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
4040 AC_PINCTL_OUT_EN);
4041 if (cfg->dig_in_pin)
4042 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4043 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004044 for (i = 0; i < spec->num_pwrs; i++) {
4045 hda_nid_t nid = spec->pwr_nids[i];
4046 int pinctl, def_conf;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004047
Takashi Iwaieb632122008-12-19 16:39:48 +01004048 /* power on when no jack detection is available */
4049 if (!spec->hp_detect) {
4050 stac_toggle_power_map(codec, nid, 1);
4051 continue;
4052 }
4053
4054 if (is_nid_hp_pin(cfg, nid))
Takashi Iwaif73d3582008-11-25 08:21:51 +01004055 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004056
Takashi Iwaif73d3582008-11-25 08:21:51 +01004057 pinctl = snd_hda_codec_read(codec, nid, 0,
4058 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4059 /* outputs are only ports capable of power management
4060 * any attempts on powering down a input port cause the
4061 * referenced VREF to act quirky.
4062 */
Takashi Iwaieb632122008-12-19 16:39:48 +01004063 if (pinctl & AC_PINCTL_IN_EN) {
4064 stac_toggle_power_map(codec, nid, 1);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004065 continue;
Takashi Iwaieb632122008-12-19 16:39:48 +01004066 }
Takashi Iwaif73d3582008-11-25 08:21:51 +01004067 def_conf = snd_hda_codec_read(codec, nid, 0,
4068 AC_VERB_GET_CONFIG_DEFAULT, 0);
4069 def_conf = get_defcfg_connect(def_conf);
4070 /* skip any ports that don't have jacks since presence
4071 * detection is useless */
4072 if (def_conf != AC_JACK_PORT_COMPLEX) {
4073 if (def_conf != AC_JACK_PORT_NONE)
4074 stac_toggle_power_map(codec, nid, 1);
4075 continue;
4076 }
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004077 if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) {
4078 enable_pin_detect(codec, nid, STAC_PWR_EVENT);
4079 stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT);
4080 }
Takashi Iwaif73d3582008-11-25 08:21:51 +01004081 }
4082 if (spec->dac_list)
4083 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02004084 return 0;
4085}
4086
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004087static void stac92xx_free_jacks(struct hda_codec *codec)
4088{
Takashi Iwaie4973e12008-11-18 09:32:42 +01004089#ifdef CONFIG_SND_JACK
Takashi Iwaib94d35392008-11-21 09:08:06 +01004090 /* free jack instances manually when clearing/reconfiguring */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004091 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaib94d35392008-11-21 09:08:06 +01004092 if (!codec->bus->shutdown && spec->jacks.list) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004093 struct sigmatel_jack *jacks = spec->jacks.list;
4094 int i;
4095 for (i = 0; i < spec->jacks.used; i++)
4096 snd_device_free(codec->bus->card, &jacks[i].jack);
4097 }
4098 snd_array_free(&spec->jacks);
Takashi Iwaie4973e12008-11-18 09:32:42 +01004099#endif
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004100}
4101
Takashi Iwai603c4012008-07-30 15:01:44 +02004102static void stac92xx_free_kctls(struct hda_codec *codec)
4103{
4104 struct sigmatel_spec *spec = codec->spec;
4105
4106 if (spec->kctls.list) {
4107 struct snd_kcontrol_new *kctl = spec->kctls.list;
4108 int i;
4109 for (i = 0; i < spec->kctls.used; i++)
4110 kfree(kctl[i].name);
4111 }
4112 snd_array_free(&spec->kctls);
4113}
4114
Matt2f2f4252005-04-13 14:45:30 +02004115static void stac92xx_free(struct hda_codec *codec)
4116{
Mattc7d4b2f2005-06-27 14:59:41 +02004117 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004118
4119 if (! spec)
4120 return;
4121
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004122 kfree(spec->pin_configs);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004123 stac92xx_free_jacks(codec);
4124 snd_array_free(&spec->events);
Richard Fish11b44bb2006-08-23 18:31:34 +02004125
Mattc7d4b2f2005-06-27 14:59:41 +02004126 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004127 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02004128}
4129
Matt4e550962005-07-04 17:51:39 +02004130static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4131 unsigned int flag)
4132{
4133 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4134 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02004135
Takashi Iwaif9acba42007-05-29 18:01:06 +02004136 if (pin_ctl & AC_PINCTL_IN_EN) {
4137 /*
4138 * we need to check the current set-up direction of
4139 * shared input pins since they can be switched via
4140 * "xxx as Output" mixer switch
4141 */
4142 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004143 if (nid == spec->line_switch || nid == spec->mic_switch)
Takashi Iwaif9acba42007-05-29 18:01:06 +02004144 return;
4145 }
4146
Steve Longerbeam7b043892007-05-03 20:50:03 +02004147 /* if setting pin direction bits, clear the current
4148 direction bits first */
4149 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4150 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4151
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004152 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02004153 AC_VERB_SET_PIN_WIDGET_CONTROL,
4154 pin_ctl | flag);
4155}
4156
4157static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4158 unsigned int flag)
4159{
4160 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4161 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004162 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02004163 AC_VERB_SET_PIN_WIDGET_CONTROL,
4164 pin_ctl & ~flag);
4165}
4166
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004167static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02004168{
4169 if (!nid)
4170 return 0;
4171 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004172 & (1 << 31))
4173 return 1;
Takashi Iwai314634b2006-09-21 11:56:18 +02004174 return 0;
4175}
4176
Takashi Iwaid7a89432008-11-12 09:48:04 +01004177/* return non-zero if the hp-pin of the given array index isn't
4178 * a jack-detection target
4179 */
4180static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4181{
4182 struct auto_pin_cfg *cfg = &spec->autocfg;
4183
4184 /* ignore sensing of shared line and mic jacks */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004185 if (cfg->hp_pins[i] == spec->line_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004186 return 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004187 if (cfg->hp_pins[i] == spec->mic_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004188 return 1;
4189 /* ignore if the pin is set as line-out */
4190 if (cfg->hp_pins[i] == spec->hp_switch)
4191 return 1;
4192 return 0;
4193}
4194
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004195static void stac92xx_hp_detect(struct hda_codec *codec)
Matt4e550962005-07-04 17:51:39 +02004196{
4197 struct sigmatel_spec *spec = codec->spec;
4198 struct auto_pin_cfg *cfg = &spec->autocfg;
4199 int i, presence;
4200
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004201 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004202 if (spec->gpio_mute)
4203 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4204 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4205
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004206 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004207 if (presence)
4208 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01004209 if (no_hp_sensing(spec, i))
4210 continue;
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004211 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4212 if (presence) {
4213 unsigned int pinctl;
4214 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4215 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4216 if (pinctl & AC_PINCTL_IN_EN)
4217 presence = 0; /* mic- or line-input */
4218 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004219 }
Matt4e550962005-07-04 17:51:39 +02004220
4221 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004222 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004223 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004224 stac92xx_reset_pinctl(codec, spec->hp_switch,
4225 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004226 for (i = 0; i < cfg->line_outs; i++)
4227 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4228 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004229 for (i = 0; i < cfg->speaker_outs; i++)
4230 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4231 AC_PINCTL_OUT_EN);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004232 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004233 stac_gpio_set(codec, spec->gpio_mask,
4234 spec->gpio_dir, spec->gpio_data &
4235 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02004236 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004237 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004238 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004239 stac92xx_set_pinctl(codec, spec->hp_switch,
4240 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004241 for (i = 0; i < cfg->line_outs; i++)
4242 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4243 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004244 for (i = 0; i < cfg->speaker_outs; i++)
4245 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4246 AC_PINCTL_OUT_EN);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004247 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004248 stac_gpio_set(codec, spec->gpio_mask,
4249 spec->gpio_dir, spec->gpio_data |
4250 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02004251 }
Takashi Iwaid7a89432008-11-12 09:48:04 +01004252 /* toggle hp outs */
4253 for (i = 0; i < cfg->hp_outs; i++) {
4254 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4255 if (no_hp_sensing(spec, i))
4256 continue;
4257 if (presence)
4258 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004259#if 0 /* FIXME */
4260/* Resetting the pinctl like below may lead to (a sort of) regressions
4261 * on some devices since they use the HP pin actually for line/speaker
4262 * outs although the default pin config shows a different pin (that is
4263 * wrong and useless).
4264 *
4265 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4266 * But, disabling the code below just works around it, and I'm too tired of
4267 * bug reports with such devices...
4268 */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004269 else
4270 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004271#endif /* FIXME */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004272 }
Matt4e550962005-07-04 17:51:39 +02004273}
4274
Takashi Iwaif73d3582008-11-25 08:21:51 +01004275static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4276 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004277{
4278 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004279 unsigned int idx, val;
4280
4281 for (idx = 0; idx < spec->num_pwrs; idx++) {
4282 if (spec->pwr_nids[idx] == nid)
4283 break;
4284 }
4285 if (idx >= spec->num_pwrs)
4286 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004287
4288 /* several codecs have two power down bits */
4289 if (spec->pwr_mapping)
4290 idx = spec->pwr_mapping[idx];
4291 else
4292 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004293
Takashi Iwaif73d3582008-11-25 08:21:51 +01004294 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4295 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004296 val &= ~idx;
4297 else
4298 val |= idx;
4299
4300 /* power down unused output ports */
4301 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004302}
4303
Takashi Iwaif73d3582008-11-25 08:21:51 +01004304static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4305{
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004306 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
Takashi Iwaif73d3582008-11-25 08:21:51 +01004307}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004308
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004309static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4310{
4311 struct sigmatel_spec *spec = codec->spec;
4312 struct sigmatel_jack *jacks = spec->jacks.list;
4313
4314 if (jacks) {
4315 int i;
4316 for (i = 0; i < spec->jacks.used; i++) {
4317 if (jacks->nid == nid) {
4318 unsigned int pin_ctl =
4319 snd_hda_codec_read(codec, nid,
4320 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4321 0x00);
4322 int type = jacks->type;
4323 if (type == (SND_JACK_LINEOUT
4324 | SND_JACK_HEADPHONE))
4325 type = (pin_ctl & AC_PINCTL_HP_EN)
4326 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4327 snd_jack_report(jacks->jack,
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004328 get_pin_presence(codec, nid)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004329 ? type : 0);
4330 }
4331 jacks++;
4332 }
4333 }
4334}
Matt2f2f4252005-04-13 14:45:30 +02004335
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004336static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
4337 unsigned char type)
4338{
4339 struct sigmatel_event *event = stac_get_event(codec, nid, type);
4340 if (!event)
4341 return;
4342 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4343}
4344
Takashi Iwai314634b2006-09-21 11:56:18 +02004345static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4346{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004347 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004348 struct sigmatel_event *event;
4349 int tag, data;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004350
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004351 tag = (res >> 26) & 0x7f;
4352 event = stac_get_event_from_tag(codec, tag);
4353 if (!event)
4354 return;
4355
4356 switch (event->type) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004357 case STAC_HP_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004358 stac92xx_hp_detect(codec);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004359 /* fallthru */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004360 case STAC_INSERT_EVENT:
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004361 case STAC_PWR_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004362 if (spec->num_pwrs > 0)
4363 stac92xx_pin_sense(codec, event->nid);
4364 stac92xx_report_jack(codec, event->nid);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004365 break;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004366 case STAC_VREF_EVENT:
4367 data = snd_hda_codec_read(codec, codec->afg, 0,
4368 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004369 /* toggle VREF state based on GPIOx status */
4370 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004371 !!(data & (1 << event->data)));
Matthew Ranostay72474be2008-10-09 09:32:17 -04004372 break;
Takashi Iwai314634b2006-09-21 11:56:18 +02004373 }
4374}
4375
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004376#ifdef CONFIG_PROC_FS
4377static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4378 struct hda_codec *codec, hda_nid_t nid)
4379{
4380 if (nid == codec->afg)
4381 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4382 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4383}
4384
4385static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4386 struct hda_codec *codec,
4387 unsigned int verb)
4388{
4389 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4390 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4391}
4392
4393/* stac92hd71bxx, stac92hd73xx */
4394static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4395 struct hda_codec *codec, hda_nid_t nid)
4396{
4397 stac92hd_proc_hook(buffer, codec, nid);
4398 if (nid == codec->afg)
4399 analog_loop_proc_hook(buffer, codec, 0xfa0);
4400}
4401
4402static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4403 struct hda_codec *codec, hda_nid_t nid)
4404{
4405 if (nid == codec->afg)
4406 analog_loop_proc_hook(buffer, codec, 0xfe0);
4407}
4408
4409static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4410 struct hda_codec *codec, hda_nid_t nid)
4411{
4412 if (nid == codec->afg)
4413 analog_loop_proc_hook(buffer, codec, 0xfeb);
4414}
4415#else
4416#define stac92hd_proc_hook NULL
4417#define stac92hd7x_proc_hook NULL
4418#define stac9205_proc_hook NULL
4419#define stac927x_proc_hook NULL
4420#endif
4421
Takashi Iwaicb53c622007-08-10 17:21:45 +02004422#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004423static int stac92xx_resume(struct hda_codec *codec)
4424{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004425 struct sigmatel_spec *spec = codec->spec;
4426
Richard Fish11b44bb2006-08-23 18:31:34 +02004427 stac92xx_set_config_regs(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01004428 stac92xx_init(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004429 snd_hda_codec_resume_amp(codec);
4430 snd_hda_codec_resume_cache(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01004431 /* fake event to set up pins again to override cached values */
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004432 if (spec->hp_detect)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004433 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4434 STAC_HP_EVENT);
Mattff6fdc32005-06-27 15:06:52 +02004435 return 0;
4436}
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004437
4438static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4439{
4440 struct sigmatel_spec *spec = codec->spec;
4441 if (spec->eapd_mask)
4442 stac_gpio_set(codec, spec->gpio_mask,
4443 spec->gpio_dir, spec->gpio_data &
4444 ~spec->eapd_mask);
4445 return 0;
4446}
Mattff6fdc32005-06-27 15:06:52 +02004447#endif
4448
Matt2f2f4252005-04-13 14:45:30 +02004449static struct hda_codec_ops stac92xx_patch_ops = {
4450 .build_controls = stac92xx_build_controls,
4451 .build_pcms = stac92xx_build_pcms,
4452 .init = stac92xx_init,
4453 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02004454 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004455#ifdef SND_HDA_NEEDS_RESUME
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004456 .suspend = stac92xx_suspend,
Mattff6fdc32005-06-27 15:06:52 +02004457 .resume = stac92xx_resume,
4458#endif
Matt2f2f4252005-04-13 14:45:30 +02004459};
4460
4461static int patch_stac9200(struct hda_codec *codec)
4462{
4463 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004464 int err;
Matt2f2f4252005-04-13 14:45:30 +02004465
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004466 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004467 if (spec == NULL)
4468 return -ENOMEM;
4469
4470 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004471 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004472 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004473 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4474 stac9200_models,
4475 stac9200_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02004476 if (spec->board_config < 0) {
4477 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
4478 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004479 } else
4480 err = stac_save_pin_cfgs(codec,
4481 stac9200_brd_tbl[spec->board_config]);
4482 if (err < 0) {
4483 stac92xx_free(codec);
4484 return err;
Matt Porter403d1942005-11-29 15:00:51 +01004485 }
Matt2f2f4252005-04-13 14:45:30 +02004486
4487 spec->multiout.max_channels = 2;
4488 spec->multiout.num_dacs = 1;
4489 spec->multiout.dac_nids = stac9200_dac_nids;
4490 spec->adc_nids = stac9200_adc_nids;
4491 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02004492 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02004493 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004494 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004495 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004496
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02004497 if (spec->board_config == STAC_9200_M4 ||
4498 spec->board_config == STAC_9200_M4_2 ||
Tobin Davisbf277782008-02-03 20:31:47 +01004499 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02004500 spec->init = stac9200_eapd_init;
4501 else
4502 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004503 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004504
Takashi Iwai117f2572008-03-18 09:53:23 +01004505 if (spec->board_config == STAC_9200_PANASONIC) {
4506 spec->gpio_mask = spec->gpio_dir = 0x09;
4507 spec->gpio_data = 0x00;
4508 }
4509
Mattc7d4b2f2005-06-27 14:59:41 +02004510 err = stac9200_parse_auto_config(codec);
4511 if (err < 0) {
4512 stac92xx_free(codec);
4513 return err;
4514 }
Matt2f2f4252005-04-13 14:45:30 +02004515
Takashi Iwai2acc9dc2009-01-09 16:57:14 +01004516 /* CF-74 has no headphone detection, and the driver should *NOT*
4517 * do detection and HP/speaker toggle because the hardware does it.
4518 */
4519 if (spec->board_config == STAC_9200_PANASONIC)
4520 spec->hp_detect = 0;
4521
Matt2f2f4252005-04-13 14:45:30 +02004522 codec->patch_ops = stac92xx_patch_ops;
4523
4524 return 0;
4525}
4526
Tobin Davis8e21c342007-01-08 11:04:17 +01004527static int patch_stac925x(struct hda_codec *codec)
4528{
4529 struct sigmatel_spec *spec;
4530 int err;
4531
4532 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4533 if (spec == NULL)
4534 return -ENOMEM;
4535
4536 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004537 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01004538 spec->pin_nids = stac925x_pin_nids;
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02004539
4540 /* Check first for codec ID */
4541 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
4542 STAC_925x_MODELS,
4543 stac925x_models,
4544 stac925x_codec_id_cfg_tbl);
4545
4546 /* Now checks for PCI ID, if codec ID is not found */
4547 if (spec->board_config < 0)
4548 spec->board_config = snd_hda_check_board_config(codec,
4549 STAC_925x_MODELS,
Tobin Davis8e21c342007-01-08 11:04:17 +01004550 stac925x_models,
4551 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004552 again:
Tobin Davis8e21c342007-01-08 11:04:17 +01004553 if (spec->board_config < 0) {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02004554 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
Tobin Davis2c11f952007-05-17 09:36:34 +02004555 "using BIOS defaults\n");
Tobin Davis8e21c342007-01-08 11:04:17 +01004556 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004557 } else
4558 err = stac_save_pin_cfgs(codec,
4559 stac925x_brd_tbl[spec->board_config]);
4560 if (err < 0) {
4561 stac92xx_free(codec);
4562 return err;
Tobin Davis8e21c342007-01-08 11:04:17 +01004563 }
4564
4565 spec->multiout.max_channels = 2;
4566 spec->multiout.num_dacs = 1;
4567 spec->multiout.dac_nids = stac925x_dac_nids;
4568 spec->adc_nids = stac925x_adc_nids;
4569 spec->mux_nids = stac925x_mux_nids;
4570 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004571 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004572 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02004573 switch (codec->vendor_id) {
4574 case 0x83847632: /* STAC9202 */
4575 case 0x83847633: /* STAC9202D */
4576 case 0x83847636: /* STAC9251 */
4577 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02004578 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02004579 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004580 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4581 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02004582 break;
4583 default:
4584 spec->num_dmics = 0;
4585 break;
4586 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004587
4588 spec->init = stac925x_core_init;
4589 spec->mixer = stac925x_mixer;
4590
4591 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004592 if (!err) {
4593 if (spec->board_config < 0) {
4594 printk(KERN_WARNING "hda_codec: No auto-config is "
4595 "available, default to model=ref\n");
4596 spec->board_config = STAC_925x_REF;
4597 goto again;
4598 }
4599 err = -EINVAL;
4600 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004601 if (err < 0) {
4602 stac92xx_free(codec);
4603 return err;
4604 }
4605
4606 codec->patch_ops = stac92xx_patch_ops;
4607
4608 return 0;
4609}
4610
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004611static struct hda_input_mux stac92hd73xx_dmux = {
4612 .num_items = 4,
4613 .items = {
4614 { "Analog Inputs", 0x0b },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004615 { "Digital Mic 1", 0x09 },
4616 { "Digital Mic 2", 0x0a },
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004617 { "CD", 0x08 },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004618 }
4619};
4620
4621static int patch_stac92hd73xx(struct hda_codec *codec)
4622{
4623 struct sigmatel_spec *spec;
4624 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4625 int err = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004626 int num_dacs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004627
4628 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4629 if (spec == NULL)
4630 return -ENOMEM;
4631
4632 codec->spec = spec;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02004633 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004634 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4635 spec->pin_nids = stac92hd73xx_pin_nids;
4636 spec->board_config = snd_hda_check_board_config(codec,
4637 STAC_92HD73XX_MODELS,
4638 stac92hd73xx_models,
4639 stac92hd73xx_cfg_tbl);
4640again:
4641 if (spec->board_config < 0) {
4642 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4643 " STAC92HD73XX, using BIOS defaults\n");
4644 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004645 } else
4646 err = stac_save_pin_cfgs(codec,
4647 stac92hd73xx_brd_tbl[spec->board_config]);
4648 if (err < 0) {
4649 stac92xx_free(codec);
4650 return err;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004651 }
4652
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004653 num_dacs = snd_hda_get_connections(codec, 0x0a,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004654 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4655
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004656 if (num_dacs < 3 || num_dacs > 5) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004657 printk(KERN_WARNING "hda_codec: Could not determine "
4658 "number of channels defaulting to DAC count\n");
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004659 num_dacs = STAC92HD73_DAC_COUNT;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004660 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004661 switch (num_dacs) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004662 case 0x3: /* 6 Channel */
4663 spec->mixer = stac92hd73xx_6ch_mixer;
4664 spec->init = stac92hd73xx_6ch_core_init;
4665 break;
4666 case 0x4: /* 8 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004667 spec->mixer = stac92hd73xx_8ch_mixer;
4668 spec->init = stac92hd73xx_8ch_core_init;
4669 break;
4670 case 0x5: /* 10 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004671 spec->mixer = stac92hd73xx_10ch_mixer;
4672 spec->init = stac92hd73xx_10ch_core_init;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004673 }
4674 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004675
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004676 spec->aloopback_mask = 0x01;
4677 spec->aloopback_shift = 8;
4678
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004679 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004680 spec->mux_nids = stac92hd73xx_mux_nids;
4681 spec->adc_nids = stac92hd73xx_adc_nids;
4682 spec->dmic_nids = stac92hd73xx_dmic_nids;
4683 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004684 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostay89385032008-09-11 09:49:39 -04004685 spec->amp_nids = stac92hd73xx_amp_nids;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004686 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004687
4688 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4689 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01004690 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004691 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4692 sizeof(stac92hd73xx_dmux));
4693
Matthew Ranostaya7662642008-02-21 07:51:14 +01004694 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004695 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004696 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004697 /* fallthru */
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004698 case STAC_DELL_M6_AMIC:
4699 case STAC_DELL_M6_DMIC:
4700 case STAC_DELL_M6_BOTH:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004701 spec->num_smuxes = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004702 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4703 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004704 spec->eapd_switch = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004705 spec->num_amps = 1;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004706
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004707 if (spec->board_config != STAC_DELL_EQ)
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004708 spec->init = dell_m6_core_init;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004709 switch (spec->board_config) {
4710 case STAC_DELL_M6_AMIC: /* Analog Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004711 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4712 spec->num_dmics = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004713 spec->private_dimux.num_items = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004714 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004715 case STAC_DELL_M6_DMIC: /* Digital Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004716 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4717 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004718 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004719 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004720 case STAC_DELL_M6_BOTH: /* Both */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004721 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4722 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4723 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004724 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004725 break;
4726 }
4727 break;
4728 default:
4729 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004730 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004731 spec->eapd_switch = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004732 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004733 if (spec->board_config > STAC_92HD73XX_REF) {
4734 /* GPIO0 High = Enable EAPD */
4735 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4736 spec->gpio_data = 0x01;
4737 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004738 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004739
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004740 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4741 spec->pwr_nids = stac92hd73xx_pwr_nids;
4742
Matthew Ranostayd9737752008-09-07 12:03:41 +02004743 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004744
4745 if (!err) {
4746 if (spec->board_config < 0) {
4747 printk(KERN_WARNING "hda_codec: No auto-config is "
4748 "available, default to model=ref\n");
4749 spec->board_config = STAC_92HD73XX_REF;
4750 goto again;
4751 }
4752 err = -EINVAL;
4753 }
4754
4755 if (err < 0) {
4756 stac92xx_free(codec);
4757 return err;
4758 }
4759
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01004760 if (spec->board_config == STAC_92HD73XX_NO_JD)
4761 spec->hp_detect = 0;
4762
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004763 codec->patch_ops = stac92xx_patch_ops;
4764
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004765 codec->proc_widget_hook = stac92hd7x_proc_hook;
4766
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004767 return 0;
4768}
4769
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004770static struct hda_input_mux stac92hd83xxx_dmux = {
4771 .num_items = 3,
4772 .items = {
4773 { "Analog Inputs", 0x03 },
4774 { "Digital Mic 1", 0x04 },
4775 { "Digital Mic 2", 0x05 },
4776 }
4777};
4778
4779static int patch_stac92hd83xxx(struct hda_codec *codec)
4780{
4781 struct sigmatel_spec *spec;
4782 int err;
4783
4784 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4785 if (spec == NULL)
4786 return -ENOMEM;
4787
4788 codec->spec = spec;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004789 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004790 spec->mono_nid = 0x19;
4791 spec->digbeep_nid = 0x21;
4792 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4793 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4794 spec->adc_nids = stac92hd83xxx_adc_nids;
4795 spec->pwr_nids = stac92hd83xxx_pwr_nids;
Matthew Ranostayc15c5062009-01-13 13:30:07 -05004796 spec->amp_nids = stac92hd83xxx_amp_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004797 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4798 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004799 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004800
4801 spec->init = stac92hd83xxx_core_init;
4802 switch (codec->vendor_id) {
4803 case 0x111d7605:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004804 break;
4805 default:
4806 spec->num_pwrs--;
4807 spec->init++; /* switch to config #2 */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004808 }
4809
4810 spec->mixer = stac92hd83xxx_mixer;
4811 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4812 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4813 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
Matthew Ranostayc15c5062009-01-13 13:30:07 -05004814 spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004815 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4816 spec->dinput_mux = &stac92hd83xxx_dmux;
4817 spec->pin_nids = stac92hd83xxx_pin_nids;
4818 spec->board_config = snd_hda_check_board_config(codec,
4819 STAC_92HD83XXX_MODELS,
4820 stac92hd83xxx_models,
4821 stac92hd83xxx_cfg_tbl);
4822again:
4823 if (spec->board_config < 0) {
4824 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4825 " STAC92HD83XXX, using BIOS defaults\n");
4826 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004827 } else
4828 err = stac_save_pin_cfgs(codec,
4829 stac92hd83xxx_brd_tbl[spec->board_config]);
4830 if (err < 0) {
4831 stac92xx_free(codec);
4832 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004833 }
4834
4835 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4836 if (!err) {
4837 if (spec->board_config < 0) {
4838 printk(KERN_WARNING "hda_codec: No auto-config is "
4839 "available, default to model=ref\n");
4840 spec->board_config = STAC_92HD83XXX_REF;
4841 goto again;
4842 }
4843 err = -EINVAL;
4844 }
4845
4846 if (err < 0) {
4847 stac92xx_free(codec);
4848 return err;
4849 }
4850
4851 codec->patch_ops = stac92xx_patch_ops;
4852
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004853 codec->proc_widget_hook = stac92hd_proc_hook;
4854
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004855 return 0;
4856}
4857
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004858static struct hda_input_mux stac92hd71bxx_dmux = {
4859 .num_items = 4,
4860 .items = {
4861 { "Analog Inputs", 0x00 },
4862 { "Mixer", 0x01 },
4863 { "Digital Mic 1", 0x02 },
4864 { "Digital Mic 2", 0x03 },
4865 }
4866};
4867
Matthew Ranostaye035b842007-11-06 11:53:55 +01004868static int patch_stac92hd71bxx(struct hda_codec *codec)
4869{
4870 struct sigmatel_spec *spec;
4871 int err = 0;
4872
4873 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4874 if (spec == NULL)
4875 return -ENOMEM;
4876
4877 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004878 codec->patch_ops = stac92xx_patch_ops;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004879 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004880 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004881 spec->pin_nids = stac92hd71bxx_pin_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004882 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux,
4883 sizeof(stac92hd71bxx_dmux));
Matthew Ranostaye035b842007-11-06 11:53:55 +01004884 spec->board_config = snd_hda_check_board_config(codec,
4885 STAC_92HD71BXX_MODELS,
4886 stac92hd71bxx_models,
4887 stac92hd71bxx_cfg_tbl);
4888again:
4889 if (spec->board_config < 0) {
4890 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4891 " STAC92HD71BXX, using BIOS defaults\n");
4892 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004893 } else
4894 err = stac_save_pin_cfgs(codec,
4895 stac92hd71bxx_brd_tbl[spec->board_config]);
4896 if (err < 0) {
4897 stac92xx_free(codec);
4898 return err;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004899 }
4900
Takashi Iwai41c3b642008-11-18 10:45:15 +01004901 if (spec->board_config > STAC_92HD71BXX_REF) {
4902 /* GPIO0 = EAPD */
4903 spec->gpio_mask = 0x01;
4904 spec->gpio_dir = 0x01;
4905 spec->gpio_data = 0x01;
4906 }
4907
Matthew Ranostay541eee82007-12-14 12:08:04 +01004908 switch (codec->vendor_id) {
4909 case 0x111d76b6: /* 4 Port without Analog Mixer */
4910 case 0x111d76b7:
4911 case 0x111d76b4: /* 6 Port without Analog Mixer */
4912 case 0x111d76b5:
4913 spec->mixer = stac92hd71bxx_mixer;
4914 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004915 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004916 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004917 case 0x111d7608: /* 5 Port with Analog Mixer */
Takashi Iwai8e5f2622008-11-15 19:28:54 +01004918 switch (spec->board_config) {
4919 case STAC_HP_M4:
Matthew Ranostay72474be2008-10-09 09:32:17 -04004920 /* Enable VREF power saving on GPIO1 detect */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004921 err = stac_add_event(spec, codec->afg,
4922 STAC_VREF_EVENT, 0x02);
4923 if (err < 0)
4924 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01004925 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay72474be2008-10-09 09:32:17 -04004926 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
4927 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004928 AC_VERB_SET_UNSOLICITED_ENABLE,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004929 AC_USRSP_EN | err);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004930 spec->gpio_mask |= 0x02;
4931 break;
4932 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004933 if ((codec->revision_id & 0xf) == 0 ||
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004934 (codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004935 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004936
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004937 /* no output amps */
4938 spec->num_pwrs = 0;
4939 spec->mixer = stac92hd71bxx_analog_mixer;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004940 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004941
4942 /* disable VSW */
4943 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004944 stac_change_pin_config(codec, 0xf, 0x40f000f0);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004945 break;
4946 case 0x111d7603: /* 6 Port with Analog Mixer */
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004947 if ((codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004948 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004949
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004950 /* no output amps */
4951 spec->num_pwrs = 0;
4952 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01004953 default:
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004954 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004955 spec->mixer = stac92hd71bxx_analog_mixer;
4956 spec->init = stac92hd71bxx_analog_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004957 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004958 }
4959
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004960 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004961 spec->aloopback_shift = 0;
4962
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004963 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004964 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004965 spec->mux_nids = stac92hd71bxx_mux_nids;
4966 spec->adc_nids = stac92hd71bxx_adc_nids;
4967 spec->dmic_nids = stac92hd71bxx_dmic_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004968 spec->dmux_nids = stac92hd71bxx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004969 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004970 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004971
4972 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
4973 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004974
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004975 switch (spec->board_config) {
4976 case STAC_HP_M4:
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004977 /* enable internal microphone */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004978 stac_change_pin_config(codec, 0x0e, 0x01813040);
Matthew Ranostayb9aea712008-10-09 08:37:28 -04004979 stac92xx_auto_set_pinctl(codec, 0x0e,
4980 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05004981 /* fallthru */
4982 case STAC_DELL_M4_2:
4983 spec->num_dmics = 0;
4984 spec->num_smuxes = 0;
4985 spec->num_dmuxes = 0;
4986 break;
4987 case STAC_DELL_M4_1:
4988 case STAC_DELL_M4_3:
4989 spec->num_dmics = 1;
4990 spec->num_smuxes = 0;
4991 spec->num_dmuxes = 0;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004992 break;
4993 default:
4994 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
4995 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
4996 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4997 };
4998
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004999 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005000 if (spec->dinput_mux)
5001 spec->private_dimux.num_items +=
5002 spec->num_dmics -
5003 (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005004
5005 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
5006 if (!err) {
5007 if (spec->board_config < 0) {
5008 printk(KERN_WARNING "hda_codec: No auto-config is "
5009 "available, default to model=ref\n");
5010 spec->board_config = STAC_92HD71BXX_REF;
5011 goto again;
5012 }
5013 err = -EINVAL;
5014 }
5015
5016 if (err < 0) {
5017 stac92xx_free(codec);
5018 return err;
5019 }
5020
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005021 codec->proc_widget_hook = stac92hd7x_proc_hook;
5022
Matthew Ranostaye035b842007-11-06 11:53:55 +01005023 return 0;
5024};
5025
Matt2f2f4252005-04-13 14:45:30 +02005026static int patch_stac922x(struct hda_codec *codec)
5027{
5028 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005029 int err;
Matt2f2f4252005-04-13 14:45:30 +02005030
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005031 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02005032 if (spec == NULL)
5033 return -ENOMEM;
5034
5035 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005036 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005037 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005038 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5039 stac922x_models,
5040 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08005041 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005042 spec->gpio_mask = spec->gpio_dir = 0x03;
5043 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005044 /* Intel Macs have all same PCI SSID, so we need to check
5045 * codec SSID to distinguish the exact models
5046 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005047 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005048 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005049
5050 case 0x106b0800:
5051 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02005052 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005053 case 0x106b0600:
5054 case 0x106b0700:
5055 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005056 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005057 case 0x106b0e00:
5058 case 0x106b0f00:
5059 case 0x106b1600:
5060 case 0x106b1700:
5061 case 0x106b0200:
5062 case 0x106b1e00:
5063 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005064 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005065 case 0x106b1a00:
5066 case 0x00000100:
5067 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02005068 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005069 case 0x106b0a00:
5070 case 0x106b2200:
5071 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02005072 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08005073 default:
5074 spec->board_config = STAC_INTEL_MAC_V3;
5075 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005076 }
5077 }
5078
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005079 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02005080 if (spec->board_config < 0) {
5081 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
5082 "using BIOS defaults\n");
5083 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005084 } else
5085 err = stac_save_pin_cfgs(codec,
5086 stac922x_brd_tbl[spec->board_config]);
5087 if (err < 0) {
5088 stac92xx_free(codec);
5089 return err;
Matt Porter403d1942005-11-29 15:00:51 +01005090 }
Matt2f2f4252005-04-13 14:45:30 +02005091
Matt2f2f4252005-04-13 14:45:30 +02005092 spec->adc_nids = stac922x_adc_nids;
5093 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005094 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005095 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005096 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005097 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02005098
5099 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02005100 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02005101
5102 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02005103
Matt Porter3cc08dc2006-01-23 15:27:49 +01005104 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005105 if (!err) {
5106 if (spec->board_config < 0) {
5107 printk(KERN_WARNING "hda_codec: No auto-config is "
5108 "available, default to model=ref\n");
5109 spec->board_config = STAC_D945_REF;
5110 goto again;
5111 }
5112 err = -EINVAL;
5113 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005114 if (err < 0) {
5115 stac92xx_free(codec);
5116 return err;
5117 }
5118
5119 codec->patch_ops = stac92xx_patch_ops;
5120
Takashi Iwai807a46362007-05-29 19:01:37 +02005121 /* Fix Mux capture level; max to 2 */
5122 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
5123 (0 << AC_AMPCAP_OFFSET_SHIFT) |
5124 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5125 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5126 (0 << AC_AMPCAP_MUTE_SHIFT));
5127
Matt Porter3cc08dc2006-01-23 15:27:49 +01005128 return 0;
5129}
5130
5131static int patch_stac927x(struct hda_codec *codec)
5132{
5133 struct sigmatel_spec *spec;
5134 int err;
5135
5136 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5137 if (spec == NULL)
5138 return -ENOMEM;
5139
5140 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005141 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005142 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005143 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5144 stac927x_models,
5145 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005146 again:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005147 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
5148 if (spec->board_config < 0)
5149 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
5150 "STAC927x, using BIOS defaults\n");
Richard Fish11b44bb2006-08-23 18:31:34 +02005151 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005152 } else
5153 err = stac_save_pin_cfgs(codec,
5154 stac927x_brd_tbl[spec->board_config]);
5155 if (err < 0) {
5156 stac92xx_free(codec);
5157 return err;
Matt Porter3cc08dc2006-01-23 15:27:49 +01005158 }
5159
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005160 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005161 spec->adc_nids = stac927x_adc_nids;
5162 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
5163 spec->mux_nids = stac927x_mux_nids;
5164 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005165 spec->smux_nids = stac927x_smux_nids;
5166 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04005167 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005168 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005169 spec->multiout.dac_nids = spec->dac_nids;
5170
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005171 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02005172 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005173 case STAC_D965_5ST:
5174 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005175 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005176 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005177 spec->num_dmics = 0;
5178
Tobin Davis93ed1502006-09-01 21:03:12 +02005179 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005180 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005181 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005182 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02005183 switch (codec->subsystem_id) {
5184 case 0x10280209:
5185 case 0x1028022e:
5186 /* correct the device field to SPDIF out */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005187 stac_change_pin_config(codec, 0x21, 0x01442070);
Matthew Ranostay780c8be2008-04-14 13:32:27 +02005188 break;
5189 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01005190 /* configure the analog microphone on some laptops */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005191 stac_change_pin_config(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01005192 /* correct the front output jack as a hp out */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005193 stac_change_pin_config(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01005194 /* correct the front input jack as a mic */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005195 stac_change_pin_config(codec, 0x0e, 0x02a79130);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01005196 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005197 case STAC_DELL_3ST:
5198 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005199 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005200 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005201 spec->dmic_nids = stac927x_dmic_nids;
5202 spec->num_dmics = STAC927X_NUM_DMICS;
5203
Tobin Davis93ed1502006-09-01 21:03:12 +02005204 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005205 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005206 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005207 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005208 break;
5209 default:
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005210 if (spec->board_config > STAC_D965_REF) {
5211 /* GPIO0 High = Enable EAPD */
5212 spec->eapd_mask = spec->gpio_mask = 0x01;
5213 spec->gpio_dir = spec->gpio_data = 0x01;
5214 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005215 spec->num_dmics = 0;
5216
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005217 spec->init = stac927x_core_init;
5218 spec->mixer = stac927x_mixer;
5219 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005220
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005221 spec->num_pwrs = 0;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005222 spec->aloopback_mask = 0x40;
5223 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005224 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005225
Matt Porter3cc08dc2006-01-23 15:27:49 +01005226 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005227 if (!err) {
5228 if (spec->board_config < 0) {
5229 printk(KERN_WARNING "hda_codec: No auto-config is "
5230 "available, default to model=ref\n");
5231 spec->board_config = STAC_D965_REF;
5232 goto again;
5233 }
5234 err = -EINVAL;
5235 }
Mattc7d4b2f2005-06-27 14:59:41 +02005236 if (err < 0) {
5237 stac92xx_free(codec);
5238 return err;
5239 }
Matt2f2f4252005-04-13 14:45:30 +02005240
5241 codec->patch_ops = stac92xx_patch_ops;
5242
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005243 codec->proc_widget_hook = stac927x_proc_hook;
5244
Takashi Iwai52987652008-01-16 16:09:47 +01005245 /*
5246 * !!FIXME!!
5247 * The STAC927x seem to require fairly long delays for certain
5248 * command sequences. With too short delays (even if the answer
5249 * is set to RIRB properly), it results in the silence output
5250 * on some hardwares like Dell.
5251 *
5252 * The below flag enables the longer delay (see get_response
5253 * in hda_intel.c).
5254 */
5255 codec->bus->needs_damn_long_delay = 1;
5256
Takashi Iwaie28d8322008-12-17 13:48:29 +01005257 /* no jack detecion for ref-no-jd model */
5258 if (spec->board_config == STAC_D965_REF_NO_JD)
5259 spec->hp_detect = 0;
5260
Matt2f2f4252005-04-13 14:45:30 +02005261 return 0;
5262}
5263
Matt Porterf3302a52006-07-31 12:49:34 +02005264static int patch_stac9205(struct hda_codec *codec)
5265{
5266 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02005267 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02005268
5269 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5270 if (spec == NULL)
5271 return -ENOMEM;
5272
5273 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005274 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005275 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005276 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
5277 stac9205_models,
5278 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005279 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02005280 if (spec->board_config < 0) {
5281 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
5282 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005283 } else
5284 err = stac_save_pin_cfgs(codec,
5285 stac9205_brd_tbl[spec->board_config]);
5286 if (err < 0) {
5287 stac92xx_free(codec);
5288 return err;
Matt Porterf3302a52006-07-31 12:49:34 +02005289 }
5290
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005291 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02005292 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005293 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02005294 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005295 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005296 spec->smux_nids = stac9205_smux_nids;
5297 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005298 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02005299 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005300 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005301 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005302 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02005303
5304 spec->init = stac9205_core_init;
5305 spec->mixer = stac9205_mixer;
5306
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005307 spec->aloopback_mask = 0x40;
5308 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005309 spec->eapd_switch = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02005310 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02005311
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005312 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005313 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02005314 /* Enable SPDIF in/out */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005315 stac_change_pin_config(codec, 0x1f, 0x01441030);
5316 stac_change_pin_config(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01005317
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005318 /* Enable unsol response for GPIO4/Dock HP connection */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005319 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
5320 if (err < 0)
5321 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005322 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005323 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
5324 snd_hda_codec_write_cache(codec, codec->afg, 0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005325 AC_VERB_SET_UNSOLICITED_ENABLE,
5326 AC_USRSP_EN | err);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005327
5328 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005329 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005330 spec->gpio_mask = 0x1b;
5331 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01005332 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005333 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02005334 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005335 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005336 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005337 case STAC_9205_REF:
5338 /* SPDIF-In enabled */
5339 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005340 default:
5341 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005342 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005343 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005344 break;
5345 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02005346
Matt Porterf3302a52006-07-31 12:49:34 +02005347 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005348 if (!err) {
5349 if (spec->board_config < 0) {
5350 printk(KERN_WARNING "hda_codec: No auto-config is "
5351 "available, default to model=ref\n");
5352 spec->board_config = STAC_9205_REF;
5353 goto again;
5354 }
5355 err = -EINVAL;
5356 }
Matt Porterf3302a52006-07-31 12:49:34 +02005357 if (err < 0) {
5358 stac92xx_free(codec);
5359 return err;
5360 }
5361
5362 codec->patch_ops = stac92xx_patch_ops;
5363
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005364 codec->proc_widget_hook = stac9205_proc_hook;
5365
Matt Porterf3302a52006-07-31 12:49:34 +02005366 return 0;
5367}
5368
Matt2f2f4252005-04-13 14:45:30 +02005369/*
Guillaume Munch6d859062006-08-22 17:15:47 +02005370 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01005371 */
5372
Guillaume Munch99ccc562006-08-16 19:35:12 +02005373/* static config for Sony VAIO FE550G and Sony VAIO AR */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005374static hda_nid_t vaio_dacs[] = { 0x2 };
5375#define VAIO_HP_DAC 0x5
5376static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
5377static hda_nid_t vaio_mux_nids[] = { 0x15 };
5378
5379static struct hda_input_mux vaio_mux = {
Takashi Iwaia3a2f422007-10-11 11:21:21 +02005380 .num_items = 3,
Takashi Iwaidb064e52006-03-16 16:04:58 +01005381 .items = {
Takashi Iwaid7737812006-04-25 13:05:43 +02005382 /* { "HP", 0x0 }, */
Takashi Iwai1624cb92007-07-05 13:10:51 +02005383 { "Mic Jack", 0x1 },
5384 { "Internal Mic", 0x2 },
Takashi Iwaidb064e52006-03-16 16:04:58 +01005385 { "PCM", 0x3 },
5386 }
5387};
5388
5389static struct hda_verb vaio_init[] = {
5390 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005391 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
Takashi Iwaidb064e52006-03-16 16:04:58 +01005392 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5393 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5394 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5395 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02005396 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005397 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5398 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5399 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5400 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5401 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5402 {}
5403};
5404
Guillaume Munch6d859062006-08-22 17:15:47 +02005405static struct hda_verb vaio_ar_init[] = {
5406 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
5407 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5408 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5409 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5410/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
5411 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02005412 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Guillaume Munch6d859062006-08-22 17:15:47 +02005413 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5414 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5415/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
5416 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5417 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5418 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5419 {}
5420};
5421
Takashi Iwaidb064e52006-03-16 16:04:58 +01005422static struct snd_kcontrol_new vaio_mixer[] = {
Takashi Iwai127e82e2008-11-14 14:03:33 +01005423 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x02, 0, HDA_OUTPUT),
5424 HDA_CODEC_MUTE("Headphone Playback Switch", 0x02, 0, HDA_OUTPUT),
5425 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x05, 0, HDA_OUTPUT),
5426 HDA_CODEC_MUTE("Speaker Playback Switch", 0x05, 0, HDA_OUTPUT),
Takashi Iwaidb064e52006-03-16 16:04:58 +01005427 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5428 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5429 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5430 {
5431 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5432 .name = "Capture Source",
5433 .count = 1,
5434 .info = stac92xx_mux_enum_info,
5435 .get = stac92xx_mux_enum_get,
5436 .put = stac92xx_mux_enum_put,
5437 },
5438 {}
5439};
5440
Guillaume Munch6d859062006-08-22 17:15:47 +02005441static struct snd_kcontrol_new vaio_ar_mixer[] = {
Takashi Iwai127e82e2008-11-14 14:03:33 +01005442 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x02, 0, HDA_OUTPUT),
5443 HDA_CODEC_MUTE("Headphone Playback Switch", 0x02, 0, HDA_OUTPUT),
5444 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x05, 0, HDA_OUTPUT),
5445 HDA_CODEC_MUTE("Speaker Playback Switch", 0x05, 0, HDA_OUTPUT),
Guillaume Munch6d859062006-08-22 17:15:47 +02005446 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5447 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5448 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5449 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
5450 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
5451 {
5452 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5453 .name = "Capture Source",
5454 .count = 1,
5455 .info = stac92xx_mux_enum_info,
5456 .get = stac92xx_mux_enum_get,
5457 .put = stac92xx_mux_enum_put,
5458 },
5459 {}
5460};
5461
5462static struct hda_codec_ops stac9872_patch_ops = {
Takashi Iwaidb064e52006-03-16 16:04:58 +01005463 .build_controls = stac92xx_build_controls,
5464 .build_pcms = stac92xx_build_pcms,
5465 .init = stac92xx_init,
5466 .free = stac92xx_free,
Takashi Iwaicb53c622007-08-10 17:21:45 +02005467#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaidb064e52006-03-16 16:04:58 +01005468 .resume = stac92xx_resume,
5469#endif
5470};
5471
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005472static int stac9872_vaio_init(struct hda_codec *codec)
5473{
5474 int err;
5475
5476 err = stac92xx_init(codec);
5477 if (err < 0)
5478 return err;
5479 if (codec->patch_ops.unsol_event)
5480 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
5481 return 0;
5482}
5483
5484static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
5485{
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01005486 if (get_pin_presence(codec, 0x0a)) {
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005487 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5488 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5489 } else {
5490 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5491 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5492 }
5493}
5494
5495static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
5496{
5497 switch (res >> 26) {
5498 case STAC_HP_EVENT:
5499 stac9872_vaio_hp_detect(codec, res);
5500 break;
5501 }
5502}
5503
5504static struct hda_codec_ops stac9872_vaio_patch_ops = {
5505 .build_controls = stac92xx_build_controls,
5506 .build_pcms = stac92xx_build_pcms,
5507 .init = stac9872_vaio_init,
5508 .free = stac92xx_free,
5509 .unsol_event = stac9872_vaio_unsol_event,
5510#ifdef CONFIG_PM
5511 .resume = stac92xx_resume,
5512#endif
5513};
5514
Guillaume Munch6d859062006-08-22 17:15:47 +02005515enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
5516 CXD9872RD_VAIO,
5517 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
5518 STAC9872AK_VAIO,
5519 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
5520 STAC9872K_VAIO,
5521 /* AR Series. id=0x83847664 and subsys=104D1300 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005522 CXD9872AKD_VAIO,
5523 STAC_9872_MODELS,
5524};
Takashi Iwaidb064e52006-03-16 16:04:58 +01005525
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005526static const char *stac9872_models[STAC_9872_MODELS] = {
5527 [CXD9872RD_VAIO] = "vaio",
5528 [CXD9872AKD_VAIO] = "vaio-ar",
5529};
5530
5531static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5532 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
5533 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
5534 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
Tobin Davis68e22542007-03-12 11:36:39 +01005535 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
Takashi Iwaidb064e52006-03-16 16:04:58 +01005536 {}
5537};
5538
Guillaume Munch6d859062006-08-22 17:15:47 +02005539static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01005540{
5541 struct sigmatel_spec *spec;
5542 int board_config;
5543
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005544 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5545 stac9872_models,
5546 stac9872_cfg_tbl);
Takashi Iwaidb064e52006-03-16 16:04:58 +01005547 if (board_config < 0)
5548 /* unknown config, let generic-parser do its job... */
5549 return snd_hda_parse_generic_codec(codec);
5550
5551 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5552 if (spec == NULL)
5553 return -ENOMEM;
5554
5555 codec->spec = spec;
5556 switch (board_config) {
Guillaume Munch6d859062006-08-22 17:15:47 +02005557 case CXD9872RD_VAIO:
5558 case STAC9872AK_VAIO:
5559 case STAC9872K_VAIO:
Takashi Iwaidb064e52006-03-16 16:04:58 +01005560 spec->mixer = vaio_mixer;
5561 spec->init = vaio_init;
5562 spec->multiout.max_channels = 2;
5563 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5564 spec->multiout.dac_nids = vaio_dacs;
5565 spec->multiout.hp_nid = VAIO_HP_DAC;
5566 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5567 spec->adc_nids = vaio_adcs;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005568 spec->num_pwrs = 0;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005569 spec->input_mux = &vaio_mux;
5570 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005571 codec->patch_ops = stac9872_vaio_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005572 break;
Guillaume Munch6d859062006-08-22 17:15:47 +02005573
5574 case CXD9872AKD_VAIO:
5575 spec->mixer = vaio_ar_mixer;
5576 spec->init = vaio_ar_init;
5577 spec->multiout.max_channels = 2;
5578 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5579 spec->multiout.dac_nids = vaio_dacs;
5580 spec->multiout.hp_nid = VAIO_HP_DAC;
5581 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005582 spec->num_pwrs = 0;
Guillaume Munch6d859062006-08-22 17:15:47 +02005583 spec->adc_nids = vaio_adcs;
5584 spec->input_mux = &vaio_mux;
5585 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005586 codec->patch_ops = stac9872_patch_ops;
Guillaume Munch6d859062006-08-22 17:15:47 +02005587 break;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005588 }
5589
Takashi Iwaidb064e52006-03-16 16:04:58 +01005590 return 0;
5591}
5592
5593
5594/*
Matt2f2f4252005-04-13 14:45:30 +02005595 * patch entries
5596 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +01005597static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
Matt2f2f4252005-04-13 14:45:30 +02005598 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5599 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5600 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5601 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5602 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5603 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5604 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02005605 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5606 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5607 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5608 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5609 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5610 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01005611 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5612 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5613 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5614 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5615 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5616 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5617 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5618 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5619 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5620 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01005621 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5622 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5623 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5624 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5625 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5626 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02005627 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5628 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02005629 /* The following does not take into account .id=0x83847661 when subsys =
5630 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5631 * currently not fully supported.
5632 */
5633 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5634 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5635 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02005636 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5637 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5638 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5639 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5640 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5641 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5642 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5643 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005644 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005645 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5646 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005647 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01005648 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5649 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005650 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01005651 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5652 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5653 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5654 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5655 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5656 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5657 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5658 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02005659 {} /* terminator */
5660};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01005661
5662MODULE_ALIAS("snd-hda-codec-id:8384*");
5663MODULE_ALIAS("snd-hda-codec-id:111d*");
5664
5665MODULE_LICENSE("GPL");
5666MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
5667
5668static struct hda_codec_preset_list sigmatel_list = {
5669 .preset = snd_hda_preset_sigmatel,
5670 .owner = THIS_MODULE,
5671};
5672
5673static int __init patch_sigmatel_init(void)
5674{
5675 return snd_hda_add_codec_preset(&sigmatel_list);
5676}
5677
5678static void __exit patch_sigmatel_exit(void)
5679{
5680 snd_hda_delete_codec_preset(&sigmatel_list);
5681}
5682
5683module_init(patch_sigmatel_init)
5684module_exit(patch_sigmatel_exit)