blob: 89ff916a0ed19619149dcb4381b952df6cfb8334 [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,
Matthew Ranostaye035b842007-11-06 11:53:55 +010093 STAC_92HD71BXX_MODELS
94};
95
96enum {
Tobin Davis8e21c342007-01-08 11:04:17 +010097 STAC_925x_REF,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +020098 STAC_M1,
99 STAC_M1_2,
100 STAC_M2,
Tobin Davis8e21c342007-01-08 11:04:17 +0100101 STAC_M2_2,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200102 STAC_M3,
103 STAC_M5,
104 STAC_M6,
Tobin Davis8e21c342007-01-08 11:04:17 +0100105 STAC_925x_MODELS
106};
107
108enum {
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100109 STAC_D945_REF,
110 STAC_D945GTP3,
111 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200112 STAC_INTEL_MAC_V1,
113 STAC_INTEL_MAC_V2,
114 STAC_INTEL_MAC_V3,
115 STAC_INTEL_MAC_V4,
116 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800117 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
118 * is given, one of the above models will be
119 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200120 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100121 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100122 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100123 STAC_MACBOOK_PRO_V1,
124 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200125 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200126 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300127 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200128 STAC_922X_DELL_D81,
129 STAC_922X_DELL_D82,
130 STAC_922X_DELL_M81,
131 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100132 STAC_922X_MODELS
133};
134
135enum {
Takashi Iwaie28d8322008-12-17 13:48:29 +0100136 STAC_D965_REF_NO_JD, /* no jack-detection */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100137 STAC_D965_REF,
138 STAC_D965_3ST,
139 STAC_D965_5ST,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200140 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100141 STAC_DELL_BIOS,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100142 STAC_927X_MODELS
143};
Matt Porter403d1942005-11-29 15:00:51 +0100144
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400145struct sigmatel_event {
146 hda_nid_t nid;
Takashi Iwaic6e4c662008-11-25 11:58:19 +0100147 unsigned char type;
148 unsigned char tag;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400149 int data;
150};
151
152struct sigmatel_jack {
153 hda_nid_t nid;
154 int type;
155 struct snd_jack *jack;
156};
157
Matt2f2f4252005-04-13 14:45:30 +0200158struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100159 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200160 unsigned int num_mixers;
161
Matt Porter403d1942005-11-29 15:00:51 +0100162 int board_config;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -0500163 unsigned int eapd_switch: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200164 unsigned int surr_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100165 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100166 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400167 unsigned int spdif_mute: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200168
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100169 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200170 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100171 unsigned int gpio_mask;
172 unsigned int gpio_dir;
173 unsigned int gpio_data;
174 unsigned int gpio_mute;
175
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200176 /* stream */
177 unsigned int stream_delay;
178
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100179 /* analog loopback */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100180 unsigned char aloopback_mask;
181 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200182
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100183 /* power management */
184 unsigned int num_pwrs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200185 unsigned int *pwr_mapping;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100186 hda_nid_t *pwr_nids;
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100187 hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100188
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400189 /* jack detection */
190 struct snd_array jacks;
191
192 /* events */
193 struct snd_array events;
194
Matt2f2f4252005-04-13 14:45:30 +0200195 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100196 struct hda_input_mux *mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400197 struct hda_input_mux *amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100198 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200199 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100200 hda_nid_t dac_nids[5];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100201 hda_nid_t hp_dacs[5];
202 hda_nid_t speaker_dacs[5];
Matt2f2f4252005-04-13 14:45:30 +0200203
204 /* capture */
205 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200206 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200207 hda_nid_t *mux_nids;
208 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200209 hda_nid_t *dmic_nids;
210 unsigned int num_dmics;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100211 hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100212 unsigned int num_dmuxes;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200213 hda_nid_t *smux_nids;
214 unsigned int num_smuxes;
Matthew Ranostay65973632008-09-16 10:39:37 -0400215 const char **spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200216
Mattdabbed62005-06-14 10:19:34 +0200217 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100218 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200219 hda_nid_t anabeep_nid;
220 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200221
Matt2f2f4252005-04-13 14:45:30 +0200222 /* pin widgets */
223 hda_nid_t *pin_nids;
224 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200225 unsigned int *pin_configs;
Matt2f2f4252005-04-13 14:45:30 +0200226
227 /* codec specific stuff */
228 struct hda_verb *init;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100229 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200230
231 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200232 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100233 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200234 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100235 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200236 struct hda_input_mux *sinput_mux;
237 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400238 unsigned int cur_amux;
239 hda_nid_t *amp_nids;
240 unsigned int num_amps;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200241 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200242
Matt Porter403d1942005-11-29 15:00:51 +0100243 /* i/o switches */
244 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200245 unsigned int clfe_swap;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100246 hda_nid_t line_switch; /* shared line-in for input and output */
247 hda_nid_t mic_switch; /* shared mic-in for input and output */
248 hda_nid_t hp_switch; /* NID of HP as line-out */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200249 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200250
Mattc7d4b2f2005-06-27 14:59:41 +0200251 struct hda_pcm pcm_rec[2]; /* PCM information */
252
253 /* dynamic controls and input_mux */
254 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200255 struct snd_array kctls;
Matt Porter8b657272006-10-26 17:12:59 +0200256 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200257 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200258 struct hda_input_mux private_smux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400259 struct hda_input_mux private_amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100260 struct hda_input_mux private_mono_mux;
Matt2f2f4252005-04-13 14:45:30 +0200261};
262
263static hda_nid_t stac9200_adc_nids[1] = {
264 0x03,
265};
266
267static hda_nid_t stac9200_mux_nids[1] = {
268 0x0c,
269};
270
271static hda_nid_t stac9200_dac_nids[1] = {
272 0x02,
273};
274
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100275static hda_nid_t stac92hd73xx_pwr_nids[8] = {
276 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
277 0x0f, 0x10, 0x11
278};
279
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400280static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
281 0x26, 0,
282};
283
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100284static hda_nid_t stac92hd73xx_adc_nids[2] = {
285 0x1a, 0x1b
286};
287
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400288#define DELL_M6_AMP 2
289static hda_nid_t stac92hd73xx_amp_nids[3] = {
290 0x0b, 0x0c, 0x0e
Matthew Ranostay89385032008-09-11 09:49:39 -0400291};
292
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100293#define STAC92HD73XX_NUM_DMICS 2
294static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
295 0x13, 0x14, 0
296};
297
298#define STAC92HD73_DAC_COUNT 5
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100299
300static hda_nid_t stac92hd73xx_mux_nids[4] = {
301 0x28, 0x29, 0x2a, 0x2b,
302};
303
304static hda_nid_t stac92hd73xx_dmux_nids[2] = {
305 0x20, 0x21,
306};
307
Matthew Ranostayd9737752008-09-07 12:03:41 +0200308static hda_nid_t stac92hd73xx_smux_nids[2] = {
309 0x22, 0x23,
310};
311
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200312#define STAC92HD83XXX_NUM_DMICS 2
313static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
314 0x11, 0x12, 0
315};
316
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200317#define STAC92HD83_DAC_COUNT 3
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200318
319static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
320 0x17, 0x18,
321};
322
323static hda_nid_t stac92hd83xxx_adc_nids[2] = {
324 0x15, 0x16,
325};
326
327static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
328 0xa, 0xb, 0xd, 0xe,
329};
330
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400331static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
332 0x1e, 0,
333};
334
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200335static unsigned int stac92hd83xxx_pwr_mapping[4] = {
336 0x03, 0x0c, 0x10, 0x40,
337};
338
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100339static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
340 0x0a, 0x0d, 0x0f
341};
342
Matthew Ranostaye035b842007-11-06 11:53:55 +0100343static hda_nid_t stac92hd71bxx_adc_nids[2] = {
344 0x12, 0x13,
345};
346
347static hda_nid_t stac92hd71bxx_mux_nids[2] = {
348 0x1a, 0x1b
349};
350
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400351static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
352 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100353};
354
Matthew Ranostayd9737752008-09-07 12:03:41 +0200355static hda_nid_t stac92hd71bxx_smux_nids[2] = {
356 0x24, 0x25,
357};
358
Matthew Ranostaye035b842007-11-06 11:53:55 +0100359#define STAC92HD71BXX_NUM_DMICS 2
360static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
361 0x18, 0x19, 0
362};
363
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400364static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
365 0x22, 0
366};
367
Tobin Davis8e21c342007-01-08 11:04:17 +0100368static hda_nid_t stac925x_adc_nids[1] = {
369 0x03,
370};
371
372static hda_nid_t stac925x_mux_nids[1] = {
373 0x0f,
374};
375
376static hda_nid_t stac925x_dac_nids[1] = {
377 0x02,
378};
379
Takashi Iwaif6e98522007-10-16 14:27:04 +0200380#define STAC925X_NUM_DMICS 1
381static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
382 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200383};
384
Takashi Iwai1697055e2007-12-18 18:05:52 +0100385static hda_nid_t stac925x_dmux_nids[1] = {
386 0x14,
387};
388
Matt2f2f4252005-04-13 14:45:30 +0200389static hda_nid_t stac922x_adc_nids[2] = {
390 0x06, 0x07,
391};
392
393static hda_nid_t stac922x_mux_nids[2] = {
394 0x12, 0x13,
395};
396
Matt Porter3cc08dc2006-01-23 15:27:49 +0100397static hda_nid_t stac927x_adc_nids[3] = {
398 0x07, 0x08, 0x09
399};
400
401static hda_nid_t stac927x_mux_nids[3] = {
402 0x15, 0x16, 0x17
403};
404
Matthew Ranostayd9737752008-09-07 12:03:41 +0200405static hda_nid_t stac927x_smux_nids[1] = {
406 0x21,
407};
408
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100409static hda_nid_t stac927x_dac_nids[6] = {
410 0x02, 0x03, 0x04, 0x05, 0x06, 0
411};
412
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100413static hda_nid_t stac927x_dmux_nids[1] = {
414 0x1b,
415};
416
Matthew Ranostay7f168592007-10-18 17:38:17 +0200417#define STAC927X_NUM_DMICS 2
418static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
419 0x13, 0x14, 0
420};
421
Matthew Ranostay65973632008-09-16 10:39:37 -0400422static const char *stac927x_spdif_labels[5] = {
423 "Digital Playback", "ADAT", "Analog Mux 1",
424 "Analog Mux 2", "Analog Mux 3"
425};
426
Matt Porterf3302a52006-07-31 12:49:34 +0200427static hda_nid_t stac9205_adc_nids[2] = {
428 0x12, 0x13
429};
430
431static hda_nid_t stac9205_mux_nids[2] = {
432 0x19, 0x1a
433};
434
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100435static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100436 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100437};
438
Matthew Ranostayd9737752008-09-07 12:03:41 +0200439static hda_nid_t stac9205_smux_nids[1] = {
440 0x21,
441};
442
Takashi Iwaif6e98522007-10-16 14:27:04 +0200443#define STAC9205_NUM_DMICS 2
444static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
445 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200446};
447
Mattc7d4b2f2005-06-27 14:59:41 +0200448static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200449 0x08, 0x09, 0x0d, 0x0e,
450 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200451};
452
Tobin Davis8e21c342007-01-08 11:04:17 +0100453static hda_nid_t stac925x_pin_nids[8] = {
454 0x07, 0x08, 0x0a, 0x0b,
455 0x0c, 0x0d, 0x10, 0x11,
456};
457
Matt2f2f4252005-04-13 14:45:30 +0200458static hda_nid_t stac922x_pin_nids[10] = {
459 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
460 0x0f, 0x10, 0x11, 0x15, 0x1b,
461};
462
Matthew Ranostaya7662642008-02-21 07:51:14 +0100463static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100464 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
465 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200466 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100467};
468
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200469static hda_nid_t stac92hd83xxx_pin_nids[14] = {
470 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
471 0x0f, 0x10, 0x11, 0x12, 0x13,
472 0x1d, 0x1e, 0x1f, 0x20
473};
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400474static hda_nid_t stac92hd71bxx_pin_nids[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100475 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
476 0x0f, 0x14, 0x18, 0x19, 0x1e,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400477 0x1f,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100478};
479
Matt Porter3cc08dc2006-01-23 15:27:49 +0100480static hda_nid_t stac927x_pin_nids[14] = {
481 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
482 0x0f, 0x10, 0x11, 0x12, 0x13,
483 0x14, 0x21, 0x22, 0x23,
484};
485
Matt Porterf3302a52006-07-31 12:49:34 +0200486static hda_nid_t stac9205_pin_nids[12] = {
487 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
488 0x0f, 0x14, 0x16, 0x17, 0x18,
489 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200490};
491
Matthew Ranostay89385032008-09-11 09:49:39 -0400492#define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
493
494static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
495 struct snd_ctl_elem_value *ucontrol)
496{
497 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
498 struct sigmatel_spec *spec = codec->spec;
499 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
500
501 kcontrol->private_value ^= get_amp_nid(kcontrol);
502 kcontrol->private_value |= nid;
503
504 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
505}
506
507static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
508 struct snd_ctl_elem_value *ucontrol)
509{
510 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
511 struct sigmatel_spec *spec = codec->spec;
512 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
513
514 kcontrol->private_value ^= get_amp_nid(kcontrol);
515 kcontrol->private_value |= nid;
516
517 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
518}
519
Matt Porter8b657272006-10-26 17:12:59 +0200520static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
521 struct snd_ctl_elem_info *uinfo)
522{
523 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
524 struct sigmatel_spec *spec = codec->spec;
525 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
526}
527
528static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
529 struct snd_ctl_elem_value *ucontrol)
530{
531 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
532 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100533 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200534
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100535 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200536 return 0;
537}
538
539static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
540 struct snd_ctl_elem_value *ucontrol)
541{
542 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
543 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100544 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200545
546 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100547 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200548}
549
Matthew Ranostayd9737752008-09-07 12:03:41 +0200550static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
551 struct snd_ctl_elem_info *uinfo)
552{
553 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
554 struct sigmatel_spec *spec = codec->spec;
555 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
556}
557
558static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
559 struct snd_ctl_elem_value *ucontrol)
560{
561 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
562 struct sigmatel_spec *spec = codec->spec;
563 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
564
565 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
566 return 0;
567}
568
569static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
570 struct snd_ctl_elem_value *ucontrol)
571{
572 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
573 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400574 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200575 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400576 int err, val;
577 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200578
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400579 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200580 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400581 if (err < 0)
582 return err;
583
584 if (spec->spdif_mute) {
585 if (smux_idx == 0)
586 nid = spec->multiout.dig_out_nid;
587 else
588 nid = codec->slave_dig_outs[smux_idx - 1];
589 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100590 val = HDA_AMP_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400591 else
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100592 val = 0;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400593 /* un/mute SPDIF out */
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100594 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
595 HDA_AMP_MUTE, val);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400596 }
597 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200598}
599
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100600static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200601{
602 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
603 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200604 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200605}
606
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100607static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200608{
609 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
610 struct sigmatel_spec *spec = codec->spec;
611 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
612
613 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
614 return 0;
615}
616
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100617static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200618{
619 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
620 struct sigmatel_spec *spec = codec->spec;
621 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
622
Mattc7d4b2f2005-06-27 14:59:41 +0200623 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200624 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
625}
626
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100627static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
628 struct snd_ctl_elem_info *uinfo)
629{
630 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
631 struct sigmatel_spec *spec = codec->spec;
632 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
633}
634
635static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
636 struct snd_ctl_elem_value *ucontrol)
637{
638 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
639 struct sigmatel_spec *spec = codec->spec;
640
641 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
642 return 0;
643}
644
645static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
646 struct snd_ctl_elem_value *ucontrol)
647{
648 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
649 struct sigmatel_spec *spec = codec->spec;
650
651 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
652 spec->mono_nid, &spec->cur_mmux);
653}
654
Matthew Ranostay89385032008-09-11 09:49:39 -0400655static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
656 struct snd_ctl_elem_info *uinfo)
657{
658 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
659 struct sigmatel_spec *spec = codec->spec;
660 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
661}
662
663static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
664 struct snd_ctl_elem_value *ucontrol)
665{
666 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
667 struct sigmatel_spec *spec = codec->spec;
668
669 ucontrol->value.enumerated.item[0] = spec->cur_amux;
670 return 0;
671}
672
673static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
674 struct snd_ctl_elem_value *ucontrol)
675{
676 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
677 struct sigmatel_spec *spec = codec->spec;
678 struct snd_kcontrol *ctl =
679 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
680 if (!ctl)
681 return -EINVAL;
682
683 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
684 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
685
686 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
687 0, &spec->cur_amux);
688}
689
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200690#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
691
692static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
693 struct snd_ctl_elem_value *ucontrol)
694{
695 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100696 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200697 struct sigmatel_spec *spec = codec->spec;
698
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100699 ucontrol->value.integer.value[0] = !!(spec->aloopback &
700 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200701 return 0;
702}
703
704static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
705 struct snd_ctl_elem_value *ucontrol)
706{
707 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
708 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100709 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200710 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100711 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200712
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100713 idx_val = spec->aloopback_mask << idx;
714 if (ucontrol->value.integer.value[0])
715 val = spec->aloopback | idx_val;
716 else
717 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100718 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200719 return 0;
720
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100721 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200722
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100723 /* Only return the bits defined by the shift value of the
724 * first two bytes of the mask
725 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200726 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100727 kcontrol->private_value & 0xFFFF, 0x0);
728 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200729
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100730 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200731 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100732 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200733 } else {
734 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100735 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200736 }
737
738 snd_hda_codec_write_cache(codec, codec->afg, 0,
739 kcontrol->private_value >> 16, dac_mode);
740
741 return 1;
742}
743
Mattc7d4b2f2005-06-27 14:59:41 +0200744static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200745 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200746 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200747 {}
748};
749
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200750static struct hda_verb stac9200_eapd_init[] = {
751 /* set dac0mux for dac converter */
752 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
753 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
754 {}
755};
756
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100757static struct hda_verb stac92hd73xx_6ch_core_init[] = {
758 /* set master volume and direct control */
759 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100760 /* setup adcs to point to mixer */
761 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
762 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100763 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
764 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
765 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
766 /* setup import muxs */
767 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
768 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
769 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
770 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
771 {}
772};
773
Matthew Ranostayd654a662008-03-14 08:46:51 +0100774static struct hda_verb dell_eq_core_init[] = {
775 /* set master volume to max value without distortion
776 * and direct control */
777 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100778 /* setup adcs to point to mixer */
779 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
780 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
781 /* setup import muxs */
782 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
783 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
784 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
785 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
786 {}
787};
788
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100789static struct hda_verb dell_m6_core_init[] = {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -0500790 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100791 /* setup adcs to point to mixer */
792 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
793 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
794 /* setup import muxs */
795 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
796 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
797 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
798 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
799 {}
800};
801
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100802static struct hda_verb stac92hd73xx_8ch_core_init[] = {
803 /* set master volume and direct control */
804 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100805 /* setup adcs to point to mixer */
806 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
807 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100808 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
809 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
810 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
811 /* setup import muxs */
812 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
813 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
814 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
815 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
816 {}
817};
818
819static struct hda_verb stac92hd73xx_10ch_core_init[] = {
820 /* set master volume and direct control */
821 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100822 /* dac3 is connected to import3 mux */
823 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100824 /* setup adcs to point to mixer */
825 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
826 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100827 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
828 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
829 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
830 /* setup import muxs */
831 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
832 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
833 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
834 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
835 {}
836};
837
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200838static struct hda_verb stac92hd83xxx_core_init[] = {
839 /* start of config #1 */
840 { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3},
841
842 /* start of config #2 */
843 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
844 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
845 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
846
847 /* power state controls amps */
848 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200849 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200850};
851
Matthew Ranostaye035b842007-11-06 11:53:55 +0100852static struct hda_verb stac92hd71bxx_core_init[] = {
853 /* set master volume and direct control */
854 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100855 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
856 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
857 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
858 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200859 {}
Matthew Ranostay541eee82007-12-14 12:08:04 +0100860};
861
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400862#define HD_DISABLE_PORTF 2
Matthew Ranostay541eee82007-12-14 12:08:04 +0100863static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200864 /* start of config #1 */
865
866 /* connect port 0f to audio mixer */
867 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200868 /* unmute right and left channels for node 0x0f */
869 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
870 /* start of config #2 */
871
Matthew Ranostay541eee82007-12-14 12:08:04 +0100872 /* set master volume and direct control */
873 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200874 /* unmute right and left channels for nodes 0x0a, 0xd */
Matthew Ranostaye035b842007-11-06 11:53:55 +0100875 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
876 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100877 {}
878};
879
Tobin Davis8e21c342007-01-08 11:04:17 +0100880static struct hda_verb stac925x_core_init[] = {
881 /* set dac0mux for dac converter */
882 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
883 {}
884};
885
Mattc7d4b2f2005-06-27 14:59:41 +0200886static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200887 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200888 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200889 {}
890};
891
Tobin Davis93ed1502006-09-01 21:03:12 +0200892static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200893 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200894 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200895 /* unmute node 0x1b */
896 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
897 /* select node 0x03 as DAC */
898 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
899 {}
900};
901
Matt Porter3cc08dc2006-01-23 15:27:49 +0100902static struct hda_verb stac927x_core_init[] = {
903 /* set master volume and direct control */
904 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200905 /* enable analog pc beep path */
906 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100907 {}
908};
909
Matt Porterf3302a52006-07-31 12:49:34 +0200910static struct hda_verb stac9205_core_init[] = {
911 /* set master volume and direct control */
912 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200913 /* enable analog pc beep path */
914 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200915 {}
916};
917
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100918#define STAC_MONO_MUX \
919 { \
920 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
921 .name = "Mono Mux", \
922 .count = 1, \
923 .info = stac92xx_mono_mux_enum_info, \
924 .get = stac92xx_mono_mux_enum_get, \
925 .put = stac92xx_mono_mux_enum_put, \
926 }
927
Matthew Ranostay89385032008-09-11 09:49:39 -0400928#define STAC_AMP_MUX \
929 { \
930 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
931 .name = "Amp Selector Capture Switch", \
932 .count = 1, \
933 .info = stac92xx_amp_mux_enum_info, \
934 .get = stac92xx_amp_mux_enum_get, \
935 .put = stac92xx_amp_mux_enum_put, \
936 }
937
938#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
939 { \
940 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
941 .name = xname, \
942 .index = 0, \
943 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
944 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
945 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
946 .info = stac92xx_amp_volume_info, \
947 .get = stac92xx_amp_volume_get, \
948 .put = stac92xx_amp_volume_put, \
949 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
950 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
951 }
952
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200953#define STAC_INPUT_SOURCE(cnt) \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200954 { \
955 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
956 .name = "Input Source", \
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200957 .count = cnt, \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200958 .info = stac92xx_mux_enum_info, \
959 .get = stac92xx_mux_enum_get, \
960 .put = stac92xx_mux_enum_put, \
961 }
962
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100963#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200964 { \
965 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
966 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100967 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200968 .info = stac92xx_aloopback_info, \
969 .get = stac92xx_aloopback_get, \
970 .put = stac92xx_aloopback_put, \
971 .private_value = verb_read | (verb_write << 16), \
972 }
973
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100974static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200975 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
976 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200977 STAC_INPUT_SOURCE(1),
Matt2f2f4252005-04-13 14:45:30 +0200978 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
979 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200980 { } /* end */
981};
982
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400983#define DELL_M6_MIXER 6
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100984static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400985 /* start of config #1 */
986 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
987 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
988
989 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
990 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
991
992 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
993 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
994
995 /* start of config #2 */
996 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
997 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
998
999 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1000 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1001
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001002 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1003
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001004 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1005 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1006
1007 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1008 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1009
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001010 { } /* end */
1011};
1012
1013static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001014 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1015
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001016 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1017 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1018
1019 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1020 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1021
1022 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1023 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1024
1025 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1026 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1027
1028 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1029 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1030
1031 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1032 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1033
1034 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1035 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1036 { } /* end */
1037};
1038
1039static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001040 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1041
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001042 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1043 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1044
1045 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1046 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1047
1048 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1049 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1050
1051 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1052 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1053
1054 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1055 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1056
1057 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1058 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1059
1060 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1061 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1062 { } /* end */
1063};
1064
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001065
1066static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1067 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1068 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1069
1070 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1071 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1072
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001073 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT),
1074 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001075
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001076 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT),
1077 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001078
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001079 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT),
1080 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001081
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001082 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT),
1083 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001084
1085 /*
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001086 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT),
1087 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001088 */
1089 { } /* end */
1090};
1091
Matthew Ranostay541eee82007-12-14 12:08:04 +01001092static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001093 STAC_INPUT_SOURCE(2),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001094 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001095
Matthew Ranostay9b359472007-11-07 13:03:12 +01001096 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1097 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay9b359472007-11-07 13:03:12 +01001098
1099 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1100 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001101 /* analog pc-beep replaced with digital beep support */
1102 /*
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001103 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1104 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001105 */
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001106
Matthew Ranostay687cb982008-10-11 13:52:43 -04001107 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1108 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001109
Matthew Ranostay687cb982008-10-11 13:52:43 -04001110 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1111 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001112
1113 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1114 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1115
1116 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1117 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001118 { } /* end */
1119};
1120
Matthew Ranostay541eee82007-12-14 12:08:04 +01001121static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +01001122 STAC_INPUT_SOURCE(2),
1123 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1124
Matthew Ranostay541eee82007-12-14 12:08:04 +01001125 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1126 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001127
1128 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1129 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001130 { } /* end */
1131};
1132
Tobin Davis8e21c342007-01-08 11:04:17 +01001133static struct snd_kcontrol_new stac925x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001134 STAC_INPUT_SOURCE(1),
Tobin Davis8e21c342007-01-08 11:04:17 +01001135 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +02001136 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001137 { } /* end */
1138};
1139
Takashi Iwaid1d985f2006-11-23 19:27:12 +01001140static struct snd_kcontrol_new stac9205_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001141 STAC_INPUT_SOURCE(2),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001142 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001143
1144 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1145 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001146
1147 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1148 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001149 { } /* end */
1150};
1151
1152/* This needs to be generated dynamically based on sequence */
1153static struct snd_kcontrol_new stac922x_mixer[] = {
1154 STAC_INPUT_SOURCE(2),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001155 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1156 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001157
1158 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1159 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001160 { } /* end */
1161};
1162
1163
1164static struct snd_kcontrol_new stac927x_mixer[] = {
1165 STAC_INPUT_SOURCE(3),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001166 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001167
1168 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1169 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001170
1171 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1172 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001173
1174 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1175 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
Matt Porterf3302a52006-07-31 12:49:34 +02001176 { } /* end */
1177};
1178
Takashi Iwai1697055e2007-12-18 18:05:52 +01001179static struct snd_kcontrol_new stac_dmux_mixer = {
1180 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1181 .name = "Digital Input Source",
1182 /* count set later */
1183 .info = stac92xx_dmux_enum_info,
1184 .get = stac92xx_dmux_enum_get,
1185 .put = stac92xx_dmux_enum_put,
1186};
1187
Matthew Ranostayd9737752008-09-07 12:03:41 +02001188static struct snd_kcontrol_new stac_smux_mixer = {
1189 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001190 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001191 /* count set later */
1192 .info = stac92xx_smux_enum_info,
1193 .get = stac92xx_smux_enum_get,
1194 .put = stac92xx_smux_enum_put,
1195};
1196
Takashi Iwai2134ea42008-01-10 16:53:55 +01001197static const char *slave_vols[] = {
1198 "Front Playback Volume",
1199 "Surround Playback Volume",
1200 "Center Playback Volume",
1201 "LFE Playback Volume",
1202 "Side Playback Volume",
1203 "Headphone Playback Volume",
1204 "Headphone Playback Volume",
1205 "Speaker Playback Volume",
1206 "External Speaker Playback Volume",
1207 "Speaker2 Playback Volume",
1208 NULL
1209};
1210
1211static const char *slave_sws[] = {
1212 "Front Playback Switch",
1213 "Surround Playback Switch",
1214 "Center Playback Switch",
1215 "LFE Playback Switch",
1216 "Side Playback Switch",
1217 "Headphone Playback Switch",
1218 "Headphone Playback Switch",
1219 "Speaker Playback Switch",
1220 "External Speaker Playback Switch",
1221 "Speaker2 Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001222 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001223 NULL
1224};
1225
Takashi Iwai603c4012008-07-30 15:01:44 +02001226static void stac92xx_free_kctls(struct hda_codec *codec);
Takashi Iwaie4973e12008-11-18 09:32:42 +01001227static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
Takashi Iwai603c4012008-07-30 15:01:44 +02001228
Matt2f2f4252005-04-13 14:45:30 +02001229static int stac92xx_build_controls(struct hda_codec *codec)
1230{
1231 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaie4973e12008-11-18 09:32:42 +01001232 struct auto_pin_cfg *cfg = &spec->autocfg;
1233 hda_nid_t nid;
Matt2f2f4252005-04-13 14:45:30 +02001234 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001235 int i;
Matt2f2f4252005-04-13 14:45:30 +02001236
1237 err = snd_hda_add_new_ctls(codec, spec->mixer);
1238 if (err < 0)
1239 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001240
1241 for (i = 0; i < spec->num_mixers; i++) {
1242 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1243 if (err < 0)
1244 return err;
1245 }
Takashi Iwai1697055e2007-12-18 18:05:52 +01001246 if (spec->num_dmuxes > 0) {
1247 stac_dmux_mixer.count = spec->num_dmuxes;
Takashi Iwaid13bd412008-07-30 15:01:45 +02001248 err = snd_hda_ctl_add(codec,
Takashi Iwai1697055e2007-12-18 18:05:52 +01001249 snd_ctl_new1(&stac_dmux_mixer, codec));
1250 if (err < 0)
1251 return err;
1252 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001253 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001254 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1255 struct hda_input_mux *smux = &spec->private_smux;
1256 /* check for mute support on SPDIF out */
1257 if (wcaps & AC_WCAP_OUT_AMP) {
1258 smux->items[smux->num_items].label = "Off";
1259 smux->items[smux->num_items].index = 0;
1260 smux->num_items++;
1261 spec->spdif_mute = 1;
1262 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001263 stac_smux_mixer.count = spec->num_smuxes;
Takashi Iwai4f2d23e2008-12-19 10:14:13 +01001264 err = snd_hda_ctl_add(codec,
Matthew Ranostayd9737752008-09-07 12:03:41 +02001265 snd_ctl_new1(&stac_smux_mixer, codec));
1266 if (err < 0)
1267 return err;
1268 }
Mattc7d4b2f2005-06-27 14:59:41 +02001269
Mattdabbed62005-06-14 10:19:34 +02001270 if (spec->multiout.dig_out_nid) {
1271 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1272 if (err < 0)
1273 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001274 err = snd_hda_create_spdif_share_sw(codec,
1275 &spec->multiout);
1276 if (err < 0)
1277 return err;
1278 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001279 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001280 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001281 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1282 if (err < 0)
1283 return err;
1284 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001285
1286 /* if we have no master control, let's create it */
1287 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001288 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001289 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001290 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001291 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001292 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001293 if (err < 0)
1294 return err;
1295 }
1296 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1297 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1298 NULL, slave_sws);
1299 if (err < 0)
1300 return err;
1301 }
1302
Takashi Iwai603c4012008-07-30 15:01:44 +02001303 stac92xx_free_kctls(codec); /* no longer needed */
Takashi Iwaie4973e12008-11-18 09:32:42 +01001304
1305 /* create jack input elements */
1306 if (spec->hp_detect) {
1307 for (i = 0; i < cfg->hp_outs; i++) {
1308 int type = SND_JACK_HEADPHONE;
1309 nid = cfg->hp_pins[i];
1310 /* jack detection */
1311 if (cfg->hp_outs == i)
1312 type |= SND_JACK_LINEOUT;
1313 err = stac92xx_add_jack(codec, nid, type);
1314 if (err < 0)
1315 return err;
1316 }
1317 }
1318 for (i = 0; i < cfg->line_outs; i++) {
1319 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1320 SND_JACK_LINEOUT);
1321 if (err < 0)
1322 return err;
1323 }
1324 for (i = 0; i < AUTO_PIN_LAST; i++) {
1325 nid = cfg->input_pins[i];
1326 if (nid) {
1327 err = stac92xx_add_jack(codec, nid,
1328 SND_JACK_MICROPHONE);
1329 if (err < 0)
1330 return err;
1331 }
1332 }
1333
Mattdabbed62005-06-14 10:19:34 +02001334 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001335}
1336
Matt Porter403d1942005-11-29 15:00:51 +01001337static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001338 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001339 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1340};
1341
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001342static unsigned int gateway9200_m4_pin_configs[8] = {
1343 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1344 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1345};
1346static unsigned int gateway9200_m4_2_pin_configs[8] = {
1347 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1348 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1349};
1350
1351/*
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001352 STAC 9200 pin configs for
1353 102801A8
1354 102801DE
1355 102801E8
1356*/
1357static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001358 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1359 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001360};
1361
1362/*
1363 STAC 9200 pin configs for
1364 102801C0
1365 102801C1
1366*/
1367static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001368 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1369 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001370};
1371
1372/*
1373 STAC 9200 pin configs for
1374 102801C4 (Dell Dimension E310)
1375 102801C5
1376 102801C7
1377 102801D9
1378 102801DA
1379 102801E3
1380*/
1381static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001382 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1383 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001384};
1385
1386
1387/*
1388 STAC 9200-32 pin configs for
1389 102801B5 (Dell Inspiron 630m)
1390 102801D8 (Dell Inspiron 640m)
1391*/
1392static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001393 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1394 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001395};
1396
1397/*
1398 STAC 9200-32 pin configs for
1399 102801C2 (Dell Latitude D620)
1400 102801C8
1401 102801CC (Dell Latitude D820)
1402 102801D4
1403 102801D6
1404*/
1405static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001406 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1407 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001408};
1409
1410/*
1411 STAC 9200-32 pin configs for
1412 102801CE (Dell XPS M1710)
1413 102801CF (Dell Precision M90)
1414*/
1415static unsigned int dell9200_m23_pin_configs[8] = {
1416 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1417 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1418};
1419
1420/*
1421 STAC 9200-32 pin configs for
1422 102801C9
1423 102801CA
1424 102801CB (Dell Latitude 120L)
1425 102801D3
1426*/
1427static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001428 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1429 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001430};
1431
1432/*
1433 STAC 9200-32 pin configs for
1434 102801BD (Dell Inspiron E1505n)
1435 102801EE
1436 102801EF
1437*/
1438static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001439 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1440 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001441};
1442
1443/*
1444 STAC 9200-32 pin configs for
1445 102801F5 (Dell Inspiron 1501)
1446 102801F6
1447*/
1448static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001449 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1450 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001451};
1452
1453/*
1454 STAC 9200-32
1455 102801CD (Dell Inspiron E1705/9400)
1456*/
1457static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001458 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1459 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001460};
1461
Tobin Davisbf277782008-02-03 20:31:47 +01001462static unsigned int oqo9200_pin_configs[8] = {
1463 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1464 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1465};
1466
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001467
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001468static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1469 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001470 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001471 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1472 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1473 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1474 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1475 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1476 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1477 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1478 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1479 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1480 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001481 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1482 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001483 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001484};
1485
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001486static const char *stac9200_models[STAC_9200_MODELS] = {
1487 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001488 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001489 [STAC_9200_DELL_D21] = "dell-d21",
1490 [STAC_9200_DELL_D22] = "dell-d22",
1491 [STAC_9200_DELL_D23] = "dell-d23",
1492 [STAC_9200_DELL_M21] = "dell-m21",
1493 [STAC_9200_DELL_M22] = "dell-m22",
1494 [STAC_9200_DELL_M23] = "dell-m23",
1495 [STAC_9200_DELL_M24] = "dell-m24",
1496 [STAC_9200_DELL_M25] = "dell-m25",
1497 [STAC_9200_DELL_M26] = "dell-m26",
1498 [STAC_9200_DELL_M27] = "dell-m27",
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001499 [STAC_9200_M4] = "gateway-m4",
1500 [STAC_9200_M4_2] = "gateway-m4-2",
Takashi Iwai117f2572008-03-18 09:53:23 +01001501 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001502};
1503
1504static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1505 /* SigmaTel reference board */
1506 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1507 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001508 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001509 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1510 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001511 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001512 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1513 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1514 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1515 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1516 "unknown Dell", STAC_9200_DELL_D22),
1517 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1518 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001519 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001520 "Dell Latitude D620", STAC_9200_DELL_M22),
1521 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1522 "unknown Dell", STAC_9200_DELL_D23),
1523 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1524 "unknown Dell", STAC_9200_DELL_D23),
1525 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1526 "unknown Dell", STAC_9200_DELL_M22),
1527 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1528 "unknown Dell", STAC_9200_DELL_M24),
1529 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1530 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001531 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001532 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001533 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001534 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001535 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001536 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001537 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001538 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001539 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001540 "Dell Precision M90", STAC_9200_DELL_M23),
1541 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1542 "unknown Dell", STAC_9200_DELL_M22),
1543 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1544 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001545 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001546 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001547 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001548 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1549 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1550 "unknown Dell", STAC_9200_DELL_D23),
1551 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1552 "unknown Dell", STAC_9200_DELL_D23),
1553 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1554 "unknown Dell", STAC_9200_DELL_D21),
1555 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1556 "unknown Dell", STAC_9200_DELL_D23),
1557 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1558 "unknown Dell", STAC_9200_DELL_D21),
1559 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1560 "unknown Dell", STAC_9200_DELL_M25),
1561 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1562 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001563 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001564 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1565 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1566 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001567 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001568 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001569 /* Gateway machines needs EAPD to be set on resume */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001570 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1571 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1572 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
Tobin Davisbf277782008-02-03 20:31:47 +01001573 /* OQO Mobile */
1574 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001575 {} /* terminator */
1576};
1577
Tobin Davis8e21c342007-01-08 11:04:17 +01001578static unsigned int ref925x_pin_configs[8] = {
1579 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001580 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001581};
1582
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001583static unsigned int stac925xM1_pin_configs[8] = {
1584 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1585 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001586};
1587
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001588static unsigned int stac925xM1_2_pin_configs[8] = {
1589 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1590 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1591};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001592
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001593static unsigned int stac925xM2_pin_configs[8] = {
1594 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1595 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis2c11f952007-05-17 09:36:34 +02001596};
1597
Tobin Davis8e21c342007-01-08 11:04:17 +01001598static unsigned int stac925xM2_2_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001599 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1600 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1601};
1602
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001603static unsigned int stac925xM3_pin_configs[8] = {
1604 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1605 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1606};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001607
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001608static unsigned int stac925xM5_pin_configs[8] = {
1609 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1610 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1611};
1612
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001613static unsigned int stac925xM6_pin_configs[8] = {
1614 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1615 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
Tobin Davis8e21c342007-01-08 11:04:17 +01001616};
1617
1618static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1619 [STAC_REF] = ref925x_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001620 [STAC_M1] = stac925xM1_pin_configs,
1621 [STAC_M1_2] = stac925xM1_2_pin_configs,
1622 [STAC_M2] = stac925xM2_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001623 [STAC_M2_2] = stac925xM2_2_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001624 [STAC_M3] = stac925xM3_pin_configs,
1625 [STAC_M5] = stac925xM5_pin_configs,
1626 [STAC_M6] = stac925xM6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001627};
1628
1629static const char *stac925x_models[STAC_925x_MODELS] = {
1630 [STAC_REF] = "ref",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001631 [STAC_M1] = "m1",
1632 [STAC_M1_2] = "m1-2",
1633 [STAC_M2] = "m2",
Tobin Davis8e21c342007-01-08 11:04:17 +01001634 [STAC_M2_2] = "m2-2",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001635 [STAC_M3] = "m3",
1636 [STAC_M5] = "m5",
1637 [STAC_M6] = "m6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001638};
1639
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001640static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001641 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1642 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1643 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1644 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001645 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001646 /* Not sure about the brand name for those */
1647 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1648 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1649 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1650 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001651 {} /* terminator */
Tobin Davis8e21c342007-01-08 11:04:17 +01001652};
1653
1654static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1655 /* SigmaTel reference board */
1656 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001657 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001658
1659 /* Default table for unknown ID */
1660 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1661
Tobin Davis8e21c342007-01-08 11:04:17 +01001662 {} /* terminator */
1663};
1664
Matthew Ranostaya7662642008-02-21 07:51:14 +01001665static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001666 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1667 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1668 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001669 0x01452050,
1670};
1671
1672static unsigned int dell_m6_pin_configs[13] = {
1673 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001674 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001675 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1676 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001677};
1678
1679static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001680 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001681 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1682 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1683 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001684 [STAC_DELL_EQ] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001685};
1686
1687static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01001688 [STAC_92HD73XX_NO_JD] = "no-jd",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001689 [STAC_92HD73XX_REF] = "ref",
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001690 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1691 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1692 [STAC_DELL_M6_BOTH] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001693 [STAC_DELL_EQ] = "dell-eq",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001694};
1695
1696static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1697 /* SigmaTel reference board */
1698 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001699 "DFI LanParty", STAC_92HD73XX_REF),
1700 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001701 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001702 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001703 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001704 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001705 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001706 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001707 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001708 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001709 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001710 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001711 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001712 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001713 "unknown Dell", STAC_DELL_M6_DMIC),
1714 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1715 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01001716 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001717 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Joerg Schirottkefa620e92008-12-19 08:13:49 +01001718 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1719 "Dell Studio 17", STAC_DELL_M6_DMIC),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001720 {} /* terminator */
1721};
1722
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001723static unsigned int ref92hd83xxx_pin_configs[14] = {
1724 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1725 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1726 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1727 0x01451160, 0x98560170,
1728};
1729
1730static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1731 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1732};
1733
1734static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1735 [STAC_92HD83XXX_REF] = "ref",
1736};
1737
1738static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1739 /* SigmaTel reference board */
1740 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Takashi Iwaif9d088b2009-01-13 11:54:49 +01001741 "DFI LanParty", STAC_92HD83XXX_REF),
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -02001742 {} /* terminator */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001743};
1744
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001745static unsigned int ref92hd71bxx_pin_configs[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001746 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001747 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001748 0x90a000f0, 0x01452050, 0x01452050,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001749};
1750
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001751static unsigned int dell_m4_1_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001752 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001753 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001754 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001755};
1756
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001757static unsigned int dell_m4_2_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001758 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1759 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001760 0x40f000f0, 0x044413b0, 0x044413b0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001761};
1762
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001763static unsigned int dell_m4_3_pin_configs[11] = {
1764 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1765 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1766 0x40f000f0, 0x044413b0, 0x044413b0,
1767};
1768
Matthew Ranostaye035b842007-11-06 11:53:55 +01001769static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1770 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001771 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1772 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001773 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001774 [STAC_HP_M4] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001775};
1776
1777static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1778 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001779 [STAC_DELL_M4_1] = "dell-m4-1",
1780 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001781 [STAC_DELL_M4_3] = "dell-m4-3",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001782 [STAC_HP_M4] = "hp-m4",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001783};
1784
1785static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1786 /* SigmaTel reference board */
1787 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1788 "DFI LanParty", STAC_92HD71BXX_REF),
Takashi Iwai80bf2722008-11-18 10:48:41 +01001789 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f2,
1790 "HP dv5", STAC_HP_M4),
1791 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4,
1792 "HP dv7", STAC_HP_M4),
Takashi Iwai69dfaef2008-12-20 16:57:50 +01001793 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fc,
1794 "HP dv7", STAC_HP_M4),
Giuseppe Bilottadafb70c2009-01-13 08:58:49 -05001795 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3603,
1796 "HP dv5", STAC_HP_M4),
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001797 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1798 "unknown HP", STAC_HP_M4),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001799 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1800 "unknown Dell", STAC_DELL_M4_1),
1801 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1802 "unknown Dell", STAC_DELL_M4_1),
1803 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1804 "unknown Dell", STAC_DELL_M4_1),
1805 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1806 "unknown Dell", STAC_DELL_M4_1),
1807 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1808 "unknown Dell", STAC_DELL_M4_1),
1809 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1810 "unknown Dell", STAC_DELL_M4_1),
1811 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1812 "unknown Dell", STAC_DELL_M4_1),
1813 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1814 "unknown Dell", STAC_DELL_M4_2),
1815 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1816 "unknown Dell", STAC_DELL_M4_2),
1817 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1818 "unknown Dell", STAC_DELL_M4_2),
1819 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1820 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001821 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1822 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001823 {} /* terminator */
1824};
1825
Matt Porter403d1942005-11-29 15:00:51 +01001826static unsigned int ref922x_pin_configs[10] = {
1827 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1828 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001829 0x40000100, 0x40000100,
1830};
1831
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001832/*
1833 STAC 922X pin configs for
1834 102801A7
1835 102801AB
1836 102801A9
1837 102801D1
1838 102801D2
1839*/
1840static unsigned int dell_922x_d81_pin_configs[10] = {
1841 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1842 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1843 0x01813122, 0x400001f2,
1844};
1845
1846/*
1847 STAC 922X pin configs for
1848 102801AC
1849 102801D0
1850*/
1851static unsigned int dell_922x_d82_pin_configs[10] = {
1852 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1853 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1854 0x01813122, 0x400001f1,
1855};
1856
1857/*
1858 STAC 922X pin configs for
1859 102801BF
1860*/
1861static unsigned int dell_922x_m81_pin_configs[10] = {
1862 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1863 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1864 0x40C003f1, 0x405003f0,
1865};
1866
1867/*
1868 STAC 9221 A1 pin configs for
1869 102801D7 (Dell XPS M1210)
1870*/
1871static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001872 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1873 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001874 0x508003f3, 0x405003f4,
1875};
1876
Matt Porter403d1942005-11-29 15:00:51 +01001877static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001878 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001879 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1880 0x02a19120, 0x40000100,
1881};
1882
1883static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001884 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1885 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001886 0x02a19320, 0x40000100,
1887};
1888
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001889static unsigned int intel_mac_v1_pin_configs[10] = {
1890 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1891 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001892 0x400000fc, 0x400000fb,
1893};
1894
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001895static unsigned int intel_mac_v2_pin_configs[10] = {
1896 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1897 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001898 0x400000fc, 0x400000fb,
1899};
1900
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001901static unsigned int intel_mac_v3_pin_configs[10] = {
1902 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1903 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1904 0x400000fc, 0x400000fb,
1905};
1906
1907static unsigned int intel_mac_v4_pin_configs[10] = {
1908 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1909 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1910 0x400000fc, 0x400000fb,
1911};
1912
1913static unsigned int intel_mac_v5_pin_configs[10] = {
1914 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1915 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1916 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001917};
1918
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001919static unsigned int ecs202_pin_configs[10] = {
1920 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1921 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1922 0x9037012e, 0x40e000f2,
1923};
Takashi Iwai76c08822007-06-19 12:17:42 +02001924
Takashi Iwai19039bd2006-06-28 15:52:16 +02001925static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001926 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001927 [STAC_D945GTP3] = d945gtp3_pin_configs,
1928 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001929 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1930 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1931 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1932 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1933 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001934 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001935 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001936 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1937 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1938 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1939 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1940 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1941 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001942 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001943 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1944 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1945 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1946 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001947};
1948
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001949static const char *stac922x_models[STAC_922X_MODELS] = {
1950 [STAC_D945_REF] = "ref",
1951 [STAC_D945GTP5] = "5stack",
1952 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001953 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1954 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1955 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1956 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1957 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001958 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001959 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001960 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001961 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001962 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1963 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001964 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001965 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001966 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001967 [STAC_922X_DELL_D81] = "dell-d81",
1968 [STAC_922X_DELL_D82] = "dell-d82",
1969 [STAC_922X_DELL_M81] = "dell-m81",
1970 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001971};
1972
1973static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1974 /* SigmaTel reference board */
1975 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1976 "DFI LanParty", STAC_D945_REF),
1977 /* Intel 945G based systems */
1978 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1979 "Intel D945G", STAC_D945GTP3),
1980 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1981 "Intel D945G", STAC_D945GTP3),
1982 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1983 "Intel D945G", STAC_D945GTP3),
1984 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1985 "Intel D945G", STAC_D945GTP3),
1986 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1987 "Intel D945G", STAC_D945GTP3),
1988 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1989 "Intel D945G", STAC_D945GTP3),
1990 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1991 "Intel D945G", STAC_D945GTP3),
1992 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1993 "Intel D945G", STAC_D945GTP3),
1994 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1995 "Intel D945G", STAC_D945GTP3),
1996 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1997 "Intel D945G", STAC_D945GTP3),
1998 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1999 "Intel D945G", STAC_D945GTP3),
2000 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2001 "Intel D945G", STAC_D945GTP3),
2002 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2003 "Intel D945G", STAC_D945GTP3),
2004 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2005 "Intel D945G", STAC_D945GTP3),
2006 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2007 "Intel D945G", STAC_D945GTP3),
2008 /* Intel D945G 5-stack systems */
2009 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2010 "Intel D945G", STAC_D945GTP5),
2011 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2012 "Intel D945G", STAC_D945GTP5),
2013 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2014 "Intel D945G", STAC_D945GTP5),
2015 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2016 "Intel D945G", STAC_D945GTP5),
2017 /* Intel 945P based systems */
2018 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2019 "Intel D945P", STAC_D945GTP3),
2020 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2021 "Intel D945P", STAC_D945GTP3),
2022 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2023 "Intel D945P", STAC_D945GTP3),
2024 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2025 "Intel D945P", STAC_D945GTP3),
2026 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2027 "Intel D945P", STAC_D945GTP3),
2028 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2029 "Intel D945P", STAC_D945GTP5),
2030 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08002031 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002032 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08002033 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002034 /* Dell systems */
2035 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2036 "unknown Dell", STAC_922X_DELL_D81),
2037 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2038 "unknown Dell", STAC_922X_DELL_D81),
2039 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2040 "unknown Dell", STAC_922X_DELL_D81),
2041 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2042 "unknown Dell", STAC_922X_DELL_D82),
2043 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2044 "unknown Dell", STAC_922X_DELL_M81),
2045 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2046 "unknown Dell", STAC_922X_DELL_D82),
2047 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2048 "unknown Dell", STAC_922X_DELL_D81),
2049 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2050 "unknown Dell", STAC_922X_DELL_D81),
2051 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2052 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002053 /* ECS/PC Chips boards */
2054 SND_PCI_QUIRK(0x1019, 0x2144,
2055 "ECS/PC chips", STAC_ECS_202),
2056 SND_PCI_QUIRK(0x1019, 0x2608,
2057 "ECS/PC chips", STAC_ECS_202),
2058 SND_PCI_QUIRK(0x1019, 0x2633,
2059 "ECS/PC chips P17G/1333", STAC_ECS_202),
2060 SND_PCI_QUIRK(0x1019, 0x2811,
2061 "ECS/PC chips", STAC_ECS_202),
2062 SND_PCI_QUIRK(0x1019, 0x2812,
2063 "ECS/PC chips", STAC_ECS_202),
2064 SND_PCI_QUIRK(0x1019, 0x2813,
2065 "ECS/PC chips", STAC_ECS_202),
2066 SND_PCI_QUIRK(0x1019, 0x2814,
2067 "ECS/PC chips", STAC_ECS_202),
2068 SND_PCI_QUIRK(0x1019, 0x2815,
2069 "ECS/PC chips", STAC_ECS_202),
2070 SND_PCI_QUIRK(0x1019, 0x2816,
2071 "ECS/PC chips", STAC_ECS_202),
2072 SND_PCI_QUIRK(0x1019, 0x2817,
2073 "ECS/PC chips", STAC_ECS_202),
2074 SND_PCI_QUIRK(0x1019, 0x2818,
2075 "ECS/PC chips", STAC_ECS_202),
2076 SND_PCI_QUIRK(0x1019, 0x2819,
2077 "ECS/PC chips", STAC_ECS_202),
2078 SND_PCI_QUIRK(0x1019, 0x2820,
2079 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01002080 {} /* terminator */
2081};
2082
Matt Porter3cc08dc2006-01-23 15:27:49 +01002083static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002084 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2085 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2086 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2087 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002088};
2089
Tobin Davis93ed1502006-09-01 21:03:12 +02002090static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002091 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2092 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2093 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2094 0x40000100, 0x40000100
2095};
2096
Tobin Davis93ed1502006-09-01 21:03:12 +02002097static unsigned int d965_5st_pin_configs[14] = {
2098 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2099 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2100 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2101 0x40000100, 0x40000100
2102};
2103
Tobin Davis4ff076e2007-08-07 11:48:12 +02002104static unsigned int dell_3st_pin_configs[14] = {
2105 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2106 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002107 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002108 0x40c003fc, 0x40000100
2109};
2110
Tobin Davis93ed1502006-09-01 21:03:12 +02002111static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002112 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002113 [STAC_D965_REF] = ref927x_pin_configs,
2114 [STAC_D965_3ST] = d965_3st_pin_configs,
2115 [STAC_D965_5ST] = d965_5st_pin_configs,
2116 [STAC_DELL_3ST] = dell_3st_pin_configs,
2117 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002118};
2119
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002120static const char *stac927x_models[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002121 [STAC_D965_REF_NO_JD] = "ref-no-jd",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002122 [STAC_D965_REF] = "ref",
2123 [STAC_D965_3ST] = "3stack",
2124 [STAC_D965_5ST] = "5stack",
2125 [STAC_DELL_3ST] = "dell-3stack",
2126 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002127};
2128
2129static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2130 /* SigmaTel reference board */
2131 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2132 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002133 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002134 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2135 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002136 /* 965 based 3 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002137 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
2138 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
2139 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
2140 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
2141 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
2142 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
2143 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
2144 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
2145 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
2146 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
2147 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
2148 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
2149 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
2150 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
2151 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
2152 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002153 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002154 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002155 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002156 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2157 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002158 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002159 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2160 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002161 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02002162 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002163 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2164 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2165 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2166 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002167 /* 965 based 5 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002168 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2169 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2170 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2171 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2172 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2173 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2174 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2175 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2176 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002177 {} /* terminator */
2178};
2179
Matt Porterf3302a52006-07-31 12:49:34 +02002180static unsigned int ref9205_pin_configs[12] = {
2181 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002182 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002183 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002184};
2185
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002186/*
2187 STAC 9205 pin configs for
2188 102801F1
2189 102801F2
2190 102801FC
2191 102801FD
2192 10280204
2193 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002194 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002195*/
2196static unsigned int dell_9205_m42_pin_configs[12] = {
2197 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2198 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2199 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2200};
2201
2202/*
2203 STAC 9205 pin configs for
2204 102801F9
2205 102801FA
2206 102801FE
2207 102801FF (Dell Precision M4300)
2208 10280206
2209 10280200
2210 10280201
2211*/
2212static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002213 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2214 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2215 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2216};
2217
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002218static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002219 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2220 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2221 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2222};
2223
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002224static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002225 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002226 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2227 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2228 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Matt Porterf3302a52006-07-31 12:49:34 +02002229};
2230
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002231static const char *stac9205_models[STAC_9205_MODELS] = {
2232 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002233 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002234 [STAC_9205_DELL_M43] = "dell-m43",
2235 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002236};
2237
2238static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2239 /* SigmaTel reference board */
2240 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2241 "DFI LanParty", STAC_9205_REF),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002242 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2243 "unknown Dell", STAC_9205_DELL_M42),
2244 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2245 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002246 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002247 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002248 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2249 "Dell Precision", STAC_9205_DELL_M43),
2250 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2251 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002252 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2253 "unknown Dell", STAC_9205_DELL_M42),
2254 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2255 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002256 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2257 "Dell Precision", STAC_9205_DELL_M43),
2258 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002259 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002260 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2261 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002262 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2263 "Dell Precision", STAC_9205_DELL_M43),
2264 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2265 "Dell Precision", STAC_9205_DELL_M43),
2266 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2267 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002268 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2269 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002270 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2271 "Dell Vostro 1500", STAC_9205_DELL_M42),
Matt Porterf3302a52006-07-31 12:49:34 +02002272 {} /* terminator */
2273};
2274
Richard Fish11b44bb2006-08-23 18:31:34 +02002275static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2276{
2277 int i;
2278 struct sigmatel_spec *spec = codec->spec;
2279
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002280 kfree(spec->pin_configs);
2281 spec->pin_configs = kcalloc(spec->num_pins, sizeof(*spec->pin_configs),
2282 GFP_KERNEL);
2283 if (!spec->pin_configs)
2284 return -ENOMEM;
Richard Fish11b44bb2006-08-23 18:31:34 +02002285
2286 for (i = 0; i < spec->num_pins; i++) {
2287 hda_nid_t nid = spec->pin_nids[i];
2288 unsigned int pin_cfg;
2289
2290 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2291 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2292 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2293 nid, pin_cfg);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002294 spec->pin_configs[i] = pin_cfg;
Richard Fish11b44bb2006-08-23 18:31:34 +02002295 }
2296
2297 return 0;
2298}
2299
Matthew Ranostay87d48362007-07-17 11:52:24 +02002300static void stac92xx_set_config_reg(struct hda_codec *codec,
2301 hda_nid_t pin_nid, unsigned int pin_config)
2302{
2303 int i;
2304 snd_hda_codec_write(codec, pin_nid, 0,
2305 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2306 pin_config & 0x000000ff);
2307 snd_hda_codec_write(codec, pin_nid, 0,
2308 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2309 (pin_config & 0x0000ff00) >> 8);
2310 snd_hda_codec_write(codec, pin_nid, 0,
2311 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2312 (pin_config & 0x00ff0000) >> 16);
2313 snd_hda_codec_write(codec, pin_nid, 0,
2314 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2315 pin_config >> 24);
2316 i = snd_hda_codec_read(codec, pin_nid, 0,
2317 AC_VERB_GET_CONFIG_DEFAULT,
2318 0x00);
2319 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2320 pin_nid, i);
2321}
2322
Matt2f2f4252005-04-13 14:45:30 +02002323static void stac92xx_set_config_regs(struct hda_codec *codec)
2324{
2325 int i;
2326 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002327
Matthew Ranostay87d48362007-07-17 11:52:24 +02002328 if (!spec->pin_configs)
2329 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002330
Matthew Ranostay87d48362007-07-17 11:52:24 +02002331 for (i = 0; i < spec->num_pins; i++)
2332 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2333 spec->pin_configs[i]);
Matt2f2f4252005-04-13 14:45:30 +02002334}
Matt2f2f4252005-04-13 14:45:30 +02002335
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002336static int stac_save_pin_cfgs(struct hda_codec *codec, unsigned int *pins)
2337{
2338 struct sigmatel_spec *spec = codec->spec;
2339
2340 if (!pins)
2341 return stac92xx_save_bios_config_regs(codec);
2342
2343 kfree(spec->pin_configs);
2344 spec->pin_configs = kmemdup(pins,
2345 spec->num_pins * sizeof(*pins),
2346 GFP_KERNEL);
2347 if (!spec->pin_configs)
2348 return -ENOMEM;
2349
2350 stac92xx_set_config_regs(codec);
2351 return 0;
2352}
2353
2354static void stac_change_pin_config(struct hda_codec *codec, hda_nid_t nid,
2355 unsigned int cfg)
2356{
2357 struct sigmatel_spec *spec = codec->spec;
2358 int i;
2359
2360 for (i = 0; i < spec->num_pins; i++) {
2361 if (spec->pin_nids[i] == nid) {
2362 spec->pin_configs[i] = cfg;
2363 stac92xx_set_config_reg(codec, nid, cfg);
2364 break;
2365 }
2366 }
2367}
2368
Matt2f2f4252005-04-13 14:45:30 +02002369/*
2370 * Analog playback callbacks
2371 */
2372static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2373 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002374 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002375{
2376 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002377 if (spec->stream_delay)
2378 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002379 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2380 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002381}
2382
2383static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2384 struct hda_codec *codec,
2385 unsigned int stream_tag,
2386 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002387 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002388{
2389 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002390 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002391}
2392
2393static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2394 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002395 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002396{
2397 struct sigmatel_spec *spec = codec->spec;
2398 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2399}
2400
2401/*
Mattdabbed62005-06-14 10:19:34 +02002402 * Digital playback callbacks
2403 */
2404static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2405 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002406 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002407{
2408 struct sigmatel_spec *spec = codec->spec;
2409 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2410}
2411
2412static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2413 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002414 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002415{
2416 struct sigmatel_spec *spec = codec->spec;
2417 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2418}
2419
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002420static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2421 struct hda_codec *codec,
2422 unsigned int stream_tag,
2423 unsigned int format,
2424 struct snd_pcm_substream *substream)
2425{
2426 struct sigmatel_spec *spec = codec->spec;
2427 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2428 stream_tag, format, substream);
2429}
2430
Mattdabbed62005-06-14 10:19:34 +02002431
2432/*
Matt2f2f4252005-04-13 14:45:30 +02002433 * Analog capture callbacks
2434 */
2435static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2436 struct hda_codec *codec,
2437 unsigned int stream_tag,
2438 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002439 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002440{
2441 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002442 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002443
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002444 if (spec->powerdown_adcs) {
2445 msleep(40);
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002446 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002447 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2448 }
2449 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002450 return 0;
2451}
2452
2453static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2454 struct hda_codec *codec,
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 snd_hda_codec_cleanup_stream(codec, nid);
2461 if (spec->powerdown_adcs)
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_D3);
Matt2f2f4252005-04-13 14:45:30 +02002464 return 0;
2465}
2466
Mattdabbed62005-06-14 10:19:34 +02002467static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2468 .substreams = 1,
2469 .channels_min = 2,
2470 .channels_max = 2,
2471 /* NID is set in stac92xx_build_pcms */
2472 .ops = {
2473 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002474 .close = stac92xx_dig_playback_pcm_close,
2475 .prepare = stac92xx_dig_playback_pcm_prepare
Mattdabbed62005-06-14 10:19:34 +02002476 },
2477};
2478
2479static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2480 .substreams = 1,
2481 .channels_min = 2,
2482 .channels_max = 2,
2483 /* NID is set in stac92xx_build_pcms */
2484};
2485
Matt2f2f4252005-04-13 14:45:30 +02002486static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2487 .substreams = 1,
2488 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002489 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002490 .nid = 0x02, /* NID to query formats and rates */
2491 .ops = {
2492 .open = stac92xx_playback_pcm_open,
2493 .prepare = stac92xx_playback_pcm_prepare,
2494 .cleanup = stac92xx_playback_pcm_cleanup
2495 },
2496};
2497
Matt Porter3cc08dc2006-01-23 15:27:49 +01002498static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2499 .substreams = 1,
2500 .channels_min = 2,
2501 .channels_max = 2,
2502 .nid = 0x06, /* NID to query formats and rates */
2503 .ops = {
2504 .open = stac92xx_playback_pcm_open,
2505 .prepare = stac92xx_playback_pcm_prepare,
2506 .cleanup = stac92xx_playback_pcm_cleanup
2507 },
2508};
2509
Matt2f2f4252005-04-13 14:45:30 +02002510static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002511 .channels_min = 2,
2512 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002513 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002514 .ops = {
2515 .prepare = stac92xx_capture_pcm_prepare,
2516 .cleanup = stac92xx_capture_pcm_cleanup
2517 },
2518};
2519
2520static int stac92xx_build_pcms(struct hda_codec *codec)
2521{
2522 struct sigmatel_spec *spec = codec->spec;
2523 struct hda_pcm *info = spec->pcm_rec;
2524
2525 codec->num_pcms = 1;
2526 codec->pcm_info = info;
2527
Mattc7d4b2f2005-06-27 14:59:41 +02002528 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002529 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Matt2f2f4252005-04-13 14:45:30 +02002530 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002531 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002532 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002533
2534 if (spec->alt_switch) {
2535 codec->num_pcms++;
2536 info++;
2537 info->name = "STAC92xx Analog Alt";
2538 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2539 }
Matt2f2f4252005-04-13 14:45:30 +02002540
Mattdabbed62005-06-14 10:19:34 +02002541 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2542 codec->num_pcms++;
2543 info++;
2544 info->name = "STAC92xx Digital";
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002545 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Mattdabbed62005-06-14 10:19:34 +02002546 if (spec->multiout.dig_out_nid) {
2547 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2548 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2549 }
2550 if (spec->dig_in_nid) {
2551 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2552 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2553 }
2554 }
2555
Matt2f2f4252005-04-13 14:45:30 +02002556 return 0;
2557}
2558
Takashi Iwaic960a032006-03-23 17:06:28 +01002559static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2560{
2561 unsigned int pincap = snd_hda_param_read(codec, nid,
2562 AC_PAR_PIN_CAP);
2563 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2564 if (pincap & AC_PINCAP_VREF_100)
2565 return AC_PINCTL_VREF_100;
2566 if (pincap & AC_PINCAP_VREF_80)
2567 return AC_PINCTL_VREF_80;
2568 if (pincap & AC_PINCAP_VREF_50)
2569 return AC_PINCTL_VREF_50;
2570 if (pincap & AC_PINCAP_VREF_GRD)
2571 return AC_PINCTL_VREF_GRD;
2572 return 0;
2573}
2574
Matt Porter403d1942005-11-29 15:00:51 +01002575static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2576
2577{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002578 snd_hda_codec_write_cache(codec, nid, 0,
2579 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002580}
2581
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002582#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2583
2584static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2585 struct snd_ctl_elem_value *ucontrol)
2586{
2587 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2588 struct sigmatel_spec *spec = codec->spec;
2589
Takashi Iwaid7a89432008-11-12 09:48:04 +01002590 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002591 return 0;
2592}
2593
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002594static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
2595 unsigned char type);
2596
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002597static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2598 struct snd_ctl_elem_value *ucontrol)
2599{
2600 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2601 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002602 int nid = kcontrol->private_value;
2603
2604 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002605
2606 /* check to be sure that the ports are upto date with
2607 * switch changes
2608 */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002609 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002610
2611 return 1;
2612}
2613
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002614#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002615
2616static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2617{
2618 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2619 struct sigmatel_spec *spec = codec->spec;
2620 int io_idx = kcontrol-> private_value & 0xff;
2621
2622 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2623 return 0;
2624}
2625
2626static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2627{
2628 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2629 struct sigmatel_spec *spec = codec->spec;
2630 hda_nid_t nid = kcontrol->private_value >> 8;
2631 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002632 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002633
2634 spec->io_switch[io_idx] = val;
2635
2636 if (val)
2637 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002638 else {
2639 unsigned int pinctl = AC_PINCTL_IN_EN;
2640 if (io_idx) /* set VREF for mic */
2641 pinctl |= stac92xx_get_vref(codec, nid);
2642 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2643 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002644
2645 /* check the auto-mute again: we need to mute/unmute the speaker
2646 * appropriately according to the pin direction
2647 */
2648 if (spec->hp_detect)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002649 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
Jiang Zhe40c1d302007-11-12 13:05:16 +01002650
Matt Porter403d1942005-11-29 15:00:51 +01002651 return 1;
2652}
2653
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002654#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2655
2656static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2657 struct snd_ctl_elem_value *ucontrol)
2658{
2659 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2660 struct sigmatel_spec *spec = codec->spec;
2661
2662 ucontrol->value.integer.value[0] = spec->clfe_swap;
2663 return 0;
2664}
2665
2666static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2667 struct snd_ctl_elem_value *ucontrol)
2668{
2669 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2670 struct sigmatel_spec *spec = codec->spec;
2671 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002672 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002673
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002674 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002675 return 0;
2676
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002677 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002678
2679 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2680 spec->clfe_swap ? 0x4 : 0x0);
2681
2682 return 1;
2683}
2684
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002685#define STAC_CODEC_HP_SWITCH(xname) \
2686 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2687 .name = xname, \
2688 .index = 0, \
2689 .info = stac92xx_hp_switch_info, \
2690 .get = stac92xx_hp_switch_get, \
2691 .put = stac92xx_hp_switch_put, \
2692 }
2693
Matt Porter403d1942005-11-29 15:00:51 +01002694#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2695 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2696 .name = xname, \
2697 .index = 0, \
2698 .info = stac92xx_io_switch_info, \
2699 .get = stac92xx_io_switch_get, \
2700 .put = stac92xx_io_switch_put, \
2701 .private_value = xpval, \
2702 }
2703
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002704#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2705 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2706 .name = xname, \
2707 .index = 0, \
2708 .info = stac92xx_clfe_switch_info, \
2709 .get = stac92xx_clfe_switch_get, \
2710 .put = stac92xx_clfe_switch_put, \
2711 .private_value = xpval, \
2712 }
Matt Porter403d1942005-11-29 15:00:51 +01002713
Mattc7d4b2f2005-06-27 14:59:41 +02002714enum {
2715 STAC_CTL_WIDGET_VOL,
2716 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002717 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002718 STAC_CTL_WIDGET_AMP_MUX,
2719 STAC_CTL_WIDGET_AMP_VOL,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002720 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002721 STAC_CTL_WIDGET_IO_SWITCH,
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002722 STAC_CTL_WIDGET_CLFE_SWITCH
Mattc7d4b2f2005-06-27 14:59:41 +02002723};
2724
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002725static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002726 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2727 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002728 STAC_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002729 STAC_AMP_MUX,
2730 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002731 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002732 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002733 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002734};
2735
2736/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002737static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2738 struct snd_kcontrol_new *ktemp,
2739 int idx, const char *name,
2740 unsigned long val)
Mattc7d4b2f2005-06-27 14:59:41 +02002741{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002742 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002743
Takashi Iwai603c4012008-07-30 15:01:44 +02002744 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2745 knew = snd_array_new(&spec->kctls);
2746 if (!knew)
2747 return -ENOMEM;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002748 *knew = *ktemp;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002749 knew->index = idx;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002750 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002751 if (!knew->name)
Mattc7d4b2f2005-06-27 14:59:41 +02002752 return -ENOMEM;
2753 knew->private_value = val;
Mattc7d4b2f2005-06-27 14:59:41 +02002754 return 0;
2755}
2756
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002757static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2758 int type, int idx, const char *name,
2759 unsigned long val)
2760{
2761 return stac92xx_add_control_temp(spec,
2762 &stac92xx_control_templates[type],
2763 idx, name, val);
2764}
2765
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002766
2767/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002768static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2769 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002770{
2771 return stac92xx_add_control_idx(spec, type, 0, name, val);
2772}
2773
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002774/* check whether the line-input can be used as line-out */
2775static hda_nid_t check_line_out_switch(struct hda_codec *codec)
Matt Porter403d1942005-11-29 15:00:51 +01002776{
2777 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002778 struct auto_pin_cfg *cfg = &spec->autocfg;
2779 hda_nid_t nid;
2780 unsigned int pincap;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002781
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002782 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2783 return 0;
2784 nid = cfg->input_pins[AUTO_PIN_LINE];
2785 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
2786 if (pincap & AC_PINCAP_OUT)
2787 return nid;
Matt Porter403d1942005-11-29 15:00:51 +01002788 return 0;
2789}
2790
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002791/* check whether the mic-input can be used as line-out */
2792static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2793{
2794 struct sigmatel_spec *spec = codec->spec;
2795 struct auto_pin_cfg *cfg = &spec->autocfg;
2796 unsigned int def_conf, pincap;
2797 unsigned int mic_pin;
2798
2799 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2800 return 0;
2801 mic_pin = AUTO_PIN_MIC;
2802 for (;;) {
2803 hda_nid_t nid = cfg->input_pins[mic_pin];
2804 def_conf = snd_hda_codec_read(codec, nid, 0,
2805 AC_VERB_GET_CONFIG_DEFAULT, 0);
2806 /* some laptops have an internal analog microphone
2807 * which can't be used as a output */
2808 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2809 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
2810 if (pincap & AC_PINCAP_OUT)
2811 return nid;
2812 }
2813 if (mic_pin == AUTO_PIN_MIC)
2814 mic_pin = AUTO_PIN_FRONT_MIC;
2815 else
2816 break;
2817 }
2818 return 0;
2819}
Steve Longerbeam7b043892007-05-03 20:50:03 +02002820
2821static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2822{
2823 int i;
2824
2825 for (i = 0; i < spec->multiout.num_dacs; i++) {
2826 if (spec->multiout.dac_nids[i] == nid)
2827 return 1;
2828 }
2829
2830 return 0;
2831}
2832
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002833static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2834{
2835 int i;
2836 if (is_in_dac_nids(spec, nid))
2837 return 1;
2838 for (i = 0; i < spec->autocfg.hp_outs; i++)
2839 if (spec->hp_dacs[i] == nid)
2840 return 1;
2841 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2842 if (spec->speaker_dacs[i] == nid)
2843 return 1;
2844 return 0;
2845}
2846
2847static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2848{
2849 struct sigmatel_spec *spec = codec->spec;
2850 int j, conn_len;
2851 hda_nid_t conn[HDA_MAX_CONNECTIONS];
2852 unsigned int wcaps, wtype;
2853
2854 conn_len = snd_hda_get_connections(codec, nid, conn,
2855 HDA_MAX_CONNECTIONS);
2856 for (j = 0; j < conn_len; j++) {
2857 wcaps = snd_hda_param_read(codec, conn[j],
2858 AC_PAR_AUDIO_WIDGET_CAP);
2859 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2860 /* we check only analog outputs */
2861 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2862 continue;
2863 /* if this route has a free DAC, assign it */
2864 if (!check_all_dac_nids(spec, conn[j])) {
2865 if (conn_len > 1) {
2866 /* select this DAC in the pin's input mux */
2867 snd_hda_codec_write_cache(codec, nid, 0,
2868 AC_VERB_SET_CONNECT_SEL, j);
2869 }
2870 return conn[j];
2871 }
2872 }
2873 return 0;
2874}
2875
2876static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2877static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2878
Matt Porter3cc08dc2006-01-23 15:27:49 +01002879/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02002880 * Fill in the dac_nids table from the parsed pin configuration
2881 * This function only works when every pin in line_out_pins[]
2882 * contains atleast one DAC in its connection list. Some 92xx
2883 * codecs are not connected directly to a DAC, such as the 9200
2884 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002885 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002886static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02002887{
2888 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002889 struct auto_pin_cfg *cfg = &spec->autocfg;
2890 int i;
2891 hda_nid_t nid, dac;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002892
Mattc7d4b2f2005-06-27 14:59:41 +02002893 for (i = 0; i < cfg->line_outs; i++) {
2894 nid = cfg->line_out_pins[i];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002895 dac = get_unassigned_dac(codec, nid);
2896 if (!dac) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002897 if (spec->multiout.num_dacs > 0) {
2898 /* we have already working output pins,
2899 * so let's drop the broken ones again
2900 */
2901 cfg->line_outs = spec->multiout.num_dacs;
2902 break;
2903 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002904 /* error out, no available DAC found */
2905 snd_printk(KERN_ERR
2906 "%s: No available DAC for pin 0x%x\n",
2907 __func__, nid);
2908 return -ENODEV;
2909 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002910 add_spec_dacs(spec, dac);
2911 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002912
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002913 /* add line-in as output */
2914 nid = check_line_out_switch(codec);
2915 if (nid) {
2916 dac = get_unassigned_dac(codec, nid);
2917 if (dac) {
2918 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
2919 nid, cfg->line_outs);
2920 cfg->line_out_pins[cfg->line_outs] = nid;
2921 cfg->line_outs++;
2922 spec->line_switch = nid;
2923 add_spec_dacs(spec, dac);
2924 }
2925 }
2926 /* add mic as output */
2927 nid = check_mic_out_switch(codec);
2928 if (nid) {
2929 dac = get_unassigned_dac(codec, nid);
2930 if (dac) {
2931 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
2932 nid, cfg->line_outs);
2933 cfg->line_out_pins[cfg->line_outs] = nid;
2934 cfg->line_outs++;
2935 spec->mic_switch = nid;
2936 add_spec_dacs(spec, dac);
Steve Longerbeam7b043892007-05-03 20:50:03 +02002937 }
Mattc7d4b2f2005-06-27 14:59:41 +02002938 }
2939
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002940 for (i = 0; i < cfg->hp_outs; i++) {
2941 nid = cfg->hp_pins[i];
2942 dac = get_unassigned_dac(codec, nid);
2943 if (dac) {
2944 if (!spec->multiout.hp_nid)
2945 spec->multiout.hp_nid = dac;
2946 else
2947 add_spec_extra_dacs(spec, dac);
2948 }
2949 spec->hp_dacs[i] = dac;
2950 }
2951
2952 for (i = 0; i < cfg->speaker_outs; i++) {
2953 nid = cfg->speaker_pins[i];
2954 dac = get_unassigned_dac(codec, nid);
2955 if (dac)
2956 add_spec_extra_dacs(spec, dac);
2957 spec->speaker_dacs[i] = dac;
2958 }
2959
2960 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
Steve Longerbeam7b043892007-05-03 20:50:03 +02002961 spec->multiout.num_dacs,
2962 spec->multiout.dac_nids[0],
2963 spec->multiout.dac_nids[1],
2964 spec->multiout.dac_nids[2],
2965 spec->multiout.dac_nids[3],
2966 spec->multiout.dac_nids[4]);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002967
Mattc7d4b2f2005-06-27 14:59:41 +02002968 return 0;
2969}
2970
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002971/* create volume control/switch for the given prefx type */
2972static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2973{
2974 char name[32];
2975 int err;
2976
2977 sprintf(name, "%s Playback Volume", pfx);
2978 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2979 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2980 if (err < 0)
2981 return err;
2982 sprintf(name, "%s Playback Switch", pfx);
2983 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2984 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2985 if (err < 0)
2986 return err;
2987 return 0;
2988}
2989
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002990static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2991{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002992 if (spec->multiout.num_dacs > 4) {
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002993 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2994 return 1;
2995 } else {
2996 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2997 spec->multiout.num_dacs++;
2998 }
2999 return 0;
3000}
3001
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003002static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003003{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003004 int i;
3005 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3006 if (!spec->multiout.extra_out_nid[i]) {
3007 spec->multiout.extra_out_nid[i] = nid;
3008 return 0;
3009 }
3010 }
3011 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3012 return 1;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003013}
3014
Takashi Iwai76624532008-12-19 10:09:47 +01003015static int is_unique_dac(struct sigmatel_spec *spec, hda_nid_t nid)
3016{
3017 int i;
3018
3019 if (spec->autocfg.line_outs != 1)
3020 return 0;
3021 if (spec->multiout.hp_nid == nid)
3022 return 0;
3023 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++)
3024 if (spec->multiout.extra_out_nid[i] == nid)
3025 return 0;
3026 return 1;
3027}
3028
Mattc7d4b2f2005-06-27 14:59:41 +02003029/* add playback controls from the parsed DAC table */
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003030static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
Takashi Iwai19039bd2006-06-28 15:52:16 +02003031 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003032{
Takashi Iwai76624532008-12-19 10:09:47 +01003033 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003034 static const char *chname[4] = {
3035 "Front", "Surround", NULL /*CLFE*/, "Side"
3036 };
Matthew Ranostayd21995e2008-10-13 13:22:45 -04003037 hda_nid_t nid = 0;
Takashi Iwai91589232008-12-19 15:59:40 +01003038 int i, err;
3039 unsigned int wid_caps;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003040
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003041 for (i = 0; i < cfg->line_outs && spec->multiout.dac_nids[i]; i++) {
Mattc7d4b2f2005-06-27 14:59:41 +02003042 nid = spec->multiout.dac_nids[i];
Mattc7d4b2f2005-06-27 14:59:41 +02003043 if (i == 2) {
3044 /* Center/LFE */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003045 err = create_controls(spec, "Center", nid, 1);
3046 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003047 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003048 err = create_controls(spec, "LFE", nid, 2);
3049 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003050 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003051
3052 wid_caps = get_wcaps(codec, nid);
3053
3054 if (wid_caps & AC_WCAP_LR_SWAP) {
3055 err = stac92xx_add_control(spec,
3056 STAC_CTL_WIDGET_CLFE_SWITCH,
3057 "Swap Center/LFE Playback Switch", nid);
3058
3059 if (err < 0)
3060 return err;
3061 }
3062
Mattc7d4b2f2005-06-27 14:59:41 +02003063 } else {
Takashi Iwai76624532008-12-19 10:09:47 +01003064 const char *name = chname[i];
3065 /* if it's a single DAC, assign a better name */
3066 if (!i && is_unique_dac(spec, nid)) {
3067 switch (cfg->line_out_type) {
3068 case AUTO_PIN_HP_OUT:
3069 name = "Headphone";
3070 break;
3071 case AUTO_PIN_SPEAKER_OUT:
3072 name = "Speaker";
3073 break;
3074 }
3075 }
3076 err = create_controls(spec, name, nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003077 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003078 return err;
3079 }
3080 }
3081
Takashi Iwaia9cb5c92008-11-24 07:51:11 +01003082 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003083 err = stac92xx_add_control(spec,
3084 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01003085 "Headphone as Line Out Switch",
3086 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003087 if (err < 0)
3088 return err;
3089 }
3090
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003091 if (spec->line_switch) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003092 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
3093 "Line In as Output Switch",
3094 spec->line_switch << 8);
3095 if (err < 0)
3096 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003097 }
Matt Porter403d1942005-11-29 15:00:51 +01003098
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003099 if (spec->mic_switch) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003100 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
3101 "Mic as Output Switch",
3102 (spec->mic_switch << 8) | 1);
3103 if (err < 0)
3104 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003105 }
Matt Porter403d1942005-11-29 15:00:51 +01003106
Mattc7d4b2f2005-06-27 14:59:41 +02003107 return 0;
3108}
3109
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003110/* add playback controls for Speaker and HP outputs */
3111static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3112 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003113{
3114 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003115 hda_nid_t nid;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003116 int i, err, nums;
Mattc7d4b2f2005-06-27 14:59:41 +02003117
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003118 nums = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003119 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003120 static const char *pfxs[] = {
3121 "Headphone", "Headphone2", "Headphone3",
3122 };
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003123 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
3124 if (wid_caps & AC_WCAP_UNSOL_CAP)
3125 spec->hp_detect = 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003126 if (nums >= ARRAY_SIZE(pfxs))
Mattc7d4b2f2005-06-27 14:59:41 +02003127 continue;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003128 nid = spec->hp_dacs[i];
3129 if (!nid)
3130 continue;
3131 err = create_controls(spec, pfxs[nums++], nid, 3);
3132 if (err < 0)
3133 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003134 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003135 nums = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003136 for (i = 0; i < cfg->speaker_outs; i++) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003137 static const char *pfxs[] = {
3138 "Speaker", "External Speaker", "Speaker2",
3139 };
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003140 if (nums >= ARRAY_SIZE(pfxs))
3141 continue;
3142 nid = spec->speaker_dacs[i];
3143 if (!nid)
3144 continue;
3145 err = create_controls(spec, pfxs[nums++], nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003146 if (err < 0)
3147 return err;
3148 }
Mattc7d4b2f2005-06-27 14:59:41 +02003149 return 0;
3150}
3151
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003152/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003153static const char *stac92xx_mono_labels[4] = {
3154 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003155};
3156
3157/* create mono mux for mono out on capable codecs */
3158static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3159{
3160 struct sigmatel_spec *spec = codec->spec;
3161 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3162 int i, num_cons;
3163 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3164
3165 num_cons = snd_hda_get_connections(codec,
3166 spec->mono_nid,
3167 con_lst,
3168 HDA_MAX_NUM_INPUTS);
3169 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3170 return -EINVAL;
3171
3172 for (i = 0; i < num_cons; i++) {
3173 mono_mux->items[mono_mux->num_items].label =
3174 stac92xx_mono_labels[i];
3175 mono_mux->items[mono_mux->num_items].index = i;
3176 mono_mux->num_items++;
3177 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003178
3179 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3180 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003181}
3182
Matthew Ranostay89385032008-09-11 09:49:39 -04003183/* labels for amp mux outputs */
3184static const char *stac92xx_amp_labels[3] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04003185 "Front Microphone", "Microphone", "Line In",
Matthew Ranostay89385032008-09-11 09:49:39 -04003186};
3187
3188/* create amp out controls mux on capable codecs */
3189static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3190{
3191 struct sigmatel_spec *spec = codec->spec;
3192 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3193 int i, err;
3194
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003195 for (i = 0; i < spec->num_amps; i++) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003196 amp_mux->items[amp_mux->num_items].label =
3197 stac92xx_amp_labels[i];
3198 amp_mux->items[amp_mux->num_items].index = i;
3199 amp_mux->num_items++;
3200 }
3201
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003202 if (spec->num_amps > 1) {
3203 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3204 "Amp Selector Capture Switch", 0);
3205 if (err < 0)
3206 return err;
3207 }
Matthew Ranostay89385032008-09-11 09:49:39 -04003208 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3209 "Amp Capture Volume",
3210 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3211}
3212
3213
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003214/* create PC beep volume controls */
3215static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3216 hda_nid_t nid)
3217{
3218 struct sigmatel_spec *spec = codec->spec;
3219 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3220 int err;
3221
3222 /* check for mute support for the the amp */
3223 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3224 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3225 "PC Beep Playback Switch",
3226 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3227 if (err < 0)
3228 return err;
3229 }
3230
3231 /* check to see if there is volume support for the amp */
3232 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3233 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3234 "PC Beep Playback Volume",
3235 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3236 if (err < 0)
3237 return err;
3238 }
3239 return 0;
3240}
3241
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003242#ifdef CONFIG_SND_HDA_INPUT_BEEP
3243#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3244
3245static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3246 struct snd_ctl_elem_value *ucontrol)
3247{
3248 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3249 ucontrol->value.integer.value[0] = codec->beep->enabled;
3250 return 0;
3251}
3252
3253static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3254 struct snd_ctl_elem_value *ucontrol)
3255{
3256 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3257 int enabled = !!ucontrol->value.integer.value[0];
3258 if (codec->beep->enabled != enabled) {
3259 codec->beep->enabled = enabled;
3260 return 1;
3261 }
3262 return 0;
3263}
3264
3265static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3266 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3267 .info = stac92xx_dig_beep_switch_info,
3268 .get = stac92xx_dig_beep_switch_get,
3269 .put = stac92xx_dig_beep_switch_put,
3270};
3271
3272static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3273{
3274 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3275 0, "PC Beep Playback Switch", 0);
3276}
3277#endif
3278
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003279static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3280{
3281 struct sigmatel_spec *spec = codec->spec;
3282 int wcaps, nid, i, err = 0;
3283
3284 for (i = 0; i < spec->num_muxes; i++) {
3285 nid = spec->mux_nids[i];
3286 wcaps = get_wcaps(codec, nid);
3287
3288 if (wcaps & AC_WCAP_OUT_AMP) {
3289 err = stac92xx_add_control_idx(spec,
3290 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3291 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3292 if (err < 0)
3293 return err;
3294 }
3295 }
3296 return 0;
3297};
3298
Matthew Ranostayd9737752008-09-07 12:03:41 +02003299static const char *stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003300 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003301};
3302
3303static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3304{
3305 struct sigmatel_spec *spec = codec->spec;
3306 struct hda_input_mux *spdif_mux = &spec->private_smux;
Matthew Ranostay65973632008-09-16 10:39:37 -04003307 const char **labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003308 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003309 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003310
3311 num_cons = snd_hda_get_connections(codec,
3312 spec->smux_nids[0],
3313 con_lst,
3314 HDA_MAX_NUM_INPUTS);
Matthew Ranostay65973632008-09-16 10:39:37 -04003315 if (!num_cons)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003316 return -EINVAL;
3317
Matthew Ranostay65973632008-09-16 10:39:37 -04003318 if (!labels)
3319 labels = stac92xx_spdif_labels;
3320
Matthew Ranostayd9737752008-09-07 12:03:41 +02003321 for (i = 0; i < num_cons; i++) {
Matthew Ranostay65973632008-09-16 10:39:37 -04003322 spdif_mux->items[spdif_mux->num_items].label = labels[i];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003323 spdif_mux->items[spdif_mux->num_items].index = i;
3324 spdif_mux->num_items++;
3325 }
3326
3327 return 0;
3328}
3329
Matt Porter8b657272006-10-26 17:12:59 +02003330/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003331static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003332 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3333 "Digital Mic 3", "Digital Mic 4"
3334};
3335
3336/* create playback/capture controls for input pins on dmic capable codecs */
3337static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3338 const struct auto_pin_cfg *cfg)
3339{
3340 struct sigmatel_spec *spec = codec->spec;
3341 struct hda_input_mux *dimux = &spec->private_dimux;
3342 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003343 int err, i, j;
3344 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02003345
3346 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3347 dimux->items[dimux->num_items].index = 0;
3348 dimux->num_items++;
3349
3350 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003351 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003352 int index;
3353 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003354 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02003355 unsigned int def_conf;
3356
3357 def_conf = snd_hda_codec_read(codec,
3358 spec->dmic_nids[i],
3359 0,
3360 AC_VERB_GET_CONFIG_DEFAULT,
3361 0);
3362 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3363 continue;
3364
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003365 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02003366 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003367 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02003368 con_lst,
3369 HDA_MAX_NUM_INPUTS);
3370 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003371 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02003372 index = j;
3373 goto found;
3374 }
3375 continue;
3376found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003377 wcaps = get_wcaps(codec, nid) &
3378 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003379
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003380 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003381 sprintf(name, "%s Capture Volume",
3382 stac92xx_dmic_labels[dimux->num_items]);
3383
3384 err = stac92xx_add_control(spec,
3385 STAC_CTL_WIDGET_VOL,
3386 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003387 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3388 (wcaps & AC_WCAP_OUT_AMP) ?
3389 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003390 if (err < 0)
3391 return err;
3392 }
3393
Matt Porter8b657272006-10-26 17:12:59 +02003394 dimux->items[dimux->num_items].label =
3395 stac92xx_dmic_labels[dimux->num_items];
3396 dimux->items[dimux->num_items].index = index;
3397 dimux->num_items++;
3398 }
3399
3400 return 0;
3401}
3402
Mattc7d4b2f2005-06-27 14:59:41 +02003403/* create playback/capture controls for input pins */
3404static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3405{
3406 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003407 struct hda_input_mux *imux = &spec->private_imux;
3408 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3409 int i, j, k;
3410
3411 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003412 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02003413
Takashi Iwai314634b2006-09-21 11:56:18 +02003414 if (!cfg->input_pins[i])
3415 continue;
3416 index = -1;
3417 for (j = 0; j < spec->num_muxes; j++) {
3418 int num_cons;
3419 num_cons = snd_hda_get_connections(codec,
3420 spec->mux_nids[j],
3421 con_lst,
3422 HDA_MAX_NUM_INPUTS);
3423 for (k = 0; k < num_cons; k++)
3424 if (con_lst[k] == cfg->input_pins[i]) {
3425 index = k;
3426 goto found;
3427 }
Mattc7d4b2f2005-06-27 14:59:41 +02003428 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003429 continue;
3430 found:
3431 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3432 imux->items[imux->num_items].index = index;
3433 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003434 }
3435
Steve Longerbeam7b043892007-05-03 20:50:03 +02003436 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003437 /*
3438 * Set the current input for the muxes.
3439 * The STAC9221 has two input muxes with identical source
3440 * NID lists. Hopefully this won't get confused.
3441 */
3442 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003443 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3444 AC_VERB_SET_CONNECT_SEL,
3445 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003446 }
3447 }
3448
Mattc7d4b2f2005-06-27 14:59:41 +02003449 return 0;
3450}
3451
Mattc7d4b2f2005-06-27 14:59:41 +02003452static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3453{
3454 struct sigmatel_spec *spec = codec->spec;
3455 int i;
3456
3457 for (i = 0; i < spec->autocfg.line_outs; i++) {
3458 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3459 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3460 }
3461}
3462
3463static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3464{
3465 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003466 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003467
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003468 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3469 hda_nid_t pin;
3470 pin = spec->autocfg.hp_pins[i];
3471 if (pin) /* connect to front */
3472 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3473 }
3474 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3475 hda_nid_t pin;
3476 pin = spec->autocfg.speaker_pins[i];
3477 if (pin) /* connect to front */
3478 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3479 }
Mattc7d4b2f2005-06-27 14:59:41 +02003480}
3481
Matt Porter3cc08dc2006-01-23 15:27:49 +01003482static 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 +02003483{
3484 struct sigmatel_spec *spec = codec->spec;
3485 int err;
3486
Matt Porter8b657272006-10-26 17:12:59 +02003487 if ((err = snd_hda_parse_pin_def_config(codec,
3488 &spec->autocfg,
3489 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003490 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003491 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003492 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003493
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003494 /* If we have no real line-out pin and multiple hp-outs, HPs should
3495 * be set up as multi-channel outputs.
3496 */
3497 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3498 spec->autocfg.hp_outs > 1) {
3499 /* Copy hp_outs to line_outs, backup line_outs in
3500 * speaker_outs so that the following routines can handle
3501 * HP pins as primary outputs.
3502 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003503 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003504 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3505 sizeof(spec->autocfg.line_out_pins));
3506 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3507 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3508 sizeof(spec->autocfg.hp_pins));
3509 spec->autocfg.line_outs = spec->autocfg.hp_outs;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003510 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3511 spec->autocfg.hp_outs = 0;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003512 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003513 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003514 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3515 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003516 u32 caps = query_amp_caps(codec,
3517 spec->autocfg.mono_out_pin, dir);
3518 hda_nid_t conn_list[1];
3519
3520 /* get the mixer node and then the mono mux if it exists */
3521 if (snd_hda_get_connections(codec,
3522 spec->autocfg.mono_out_pin, conn_list, 1) &&
3523 snd_hda_get_connections(codec, conn_list[0],
3524 conn_list, 1)) {
3525
3526 int wcaps = get_wcaps(codec, conn_list[0]);
3527 int wid_type = (wcaps & AC_WCAP_TYPE)
3528 >> AC_WCAP_TYPE_SHIFT;
3529 /* LR swap check, some stac925x have a mux that
3530 * changes the DACs output path instead of the
3531 * mono-mux path.
3532 */
3533 if (wid_type == AC_WID_AUD_SEL &&
3534 !(wcaps & AC_WCAP_LR_SWAP))
3535 spec->mono_nid = conn_list[0];
3536 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003537 if (dir) {
3538 hda_nid_t nid = spec->autocfg.mono_out_pin;
3539
3540 /* most mono outs have a least a mute/unmute switch */
3541 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3542 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3543 "Mono Playback Switch",
3544 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003545 if (err < 0)
3546 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003547 /* check for volume support for the amp */
3548 if ((caps & AC_AMPCAP_NUM_STEPS)
3549 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3550 err = stac92xx_add_control(spec,
3551 STAC_CTL_WIDGET_VOL,
3552 "Mono Playback Volume",
3553 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3554 if (err < 0)
3555 return err;
3556 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003557 }
3558
3559 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3560 AC_PINCTL_OUT_EN);
3561 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003562
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003563 if (!spec->multiout.num_dacs) {
3564 err = stac92xx_auto_fill_dac_nids(codec);
3565 if (err < 0)
Takashi Iwai19039bd2006-06-28 15:52:16 +02003566 return err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003567 }
Mattc7d4b2f2005-06-27 14:59:41 +02003568
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003569 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
3570
3571 if (err < 0)
3572 return err;
3573
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003574 /* setup analog beep controls */
3575 if (spec->anabeep_nid > 0) {
3576 err = stac92xx_auto_create_beep_ctls(codec,
3577 spec->anabeep_nid);
3578 if (err < 0)
3579 return err;
3580 }
3581
3582 /* setup digital beep controls and input device */
3583#ifdef CONFIG_SND_HDA_INPUT_BEEP
3584 if (spec->digbeep_nid > 0) {
3585 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003586 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003587
3588 err = stac92xx_auto_create_beep_ctls(codec, nid);
3589 if (err < 0)
3590 return err;
3591 err = snd_hda_attach_beep_device(codec, nid);
3592 if (err < 0)
3593 return err;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003594 /* if no beep switch is available, make its own one */
3595 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3596 if (codec->beep &&
3597 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3598 err = stac92xx_beep_switch_ctl(codec);
3599 if (err < 0)
3600 return err;
3601 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003602 }
3603#endif
3604
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003605 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3606
3607 if (err < 0)
3608 return err;
3609
3610 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3611
3612 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003613 return err;
3614
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003615 if (spec->mono_nid > 0) {
3616 err = stac92xx_auto_create_mono_output_ctls(codec);
3617 if (err < 0)
3618 return err;
3619 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003620 if (spec->num_amps > 0) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003621 err = stac92xx_auto_create_amp_output_ctls(codec);
3622 if (err < 0)
3623 return err;
3624 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003625 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003626 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3627 &spec->autocfg)) < 0)
3628 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003629 if (spec->num_muxes > 0) {
3630 err = stac92xx_auto_create_mux_input_ctls(codec);
3631 if (err < 0)
3632 return err;
3633 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003634 if (spec->num_smuxes > 0) {
3635 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3636 if (err < 0)
3637 return err;
3638 }
Matt Porter8b657272006-10-26 17:12:59 +02003639
Mattc7d4b2f2005-06-27 14:59:41 +02003640 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003641 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003642 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003643
Takashi Iwai82bc9552006-03-21 11:24:42 +01003644 if (spec->autocfg.dig_out_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003645 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003646 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003647 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003648
Takashi Iwai603c4012008-07-30 15:01:44 +02003649 if (spec->kctls.list)
3650 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003651
3652 spec->input_mux = &spec->private_imux;
Matthew Ranostayf8ccbf62008-12-20 17:36:28 -05003653 if (!spec->dinput_mux)
3654 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003655 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003656 spec->mono_mux = &spec->private_mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -04003657 spec->amp_mux = &spec->private_amp_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003658 return 1;
3659}
3660
Takashi Iwai82bc9552006-03-21 11:24:42 +01003661/* add playback controls for HP output */
3662static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3663 struct auto_pin_cfg *cfg)
3664{
3665 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003666 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003667 unsigned int wid_caps;
3668
3669 if (! pin)
3670 return 0;
3671
3672 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003673 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003674 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003675
3676 return 0;
3677}
3678
Richard Fish160ea0d2006-09-06 13:58:25 +02003679/* add playback controls for LFE output */
3680static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3681 struct auto_pin_cfg *cfg)
3682{
3683 struct sigmatel_spec *spec = codec->spec;
3684 int err;
3685 hda_nid_t lfe_pin = 0x0;
3686 int i;
3687
3688 /*
3689 * search speaker outs and line outs for a mono speaker pin
3690 * with an amp. If one is found, add LFE controls
3691 * for it.
3692 */
3693 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3694 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003695 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003696 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3697 if (wcaps == AC_WCAP_OUT_AMP)
3698 /* found a mono speaker with an amp, must be lfe */
3699 lfe_pin = pin;
3700 }
3701
3702 /* if speaker_outs is 0, then speakers may be in line_outs */
3703 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3704 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3705 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003706 unsigned int defcfg;
Harvey Harrison8b551782008-02-29 11:56:48 +01003707 defcfg = snd_hda_codec_read(codec, pin, 0,
Richard Fish160ea0d2006-09-06 13:58:25 +02003708 AC_VERB_GET_CONFIG_DEFAULT,
3709 0x00);
Harvey Harrison8b551782008-02-29 11:56:48 +01003710 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003711 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003712 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3713 if (wcaps == AC_WCAP_OUT_AMP)
3714 /* found a mono speaker with an amp,
3715 must be lfe */
3716 lfe_pin = pin;
3717 }
3718 }
3719 }
3720
3721 if (lfe_pin) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003722 err = create_controls(spec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003723 if (err < 0)
3724 return err;
3725 }
3726
3727 return 0;
3728}
3729
Mattc7d4b2f2005-06-27 14:59:41 +02003730static int stac9200_parse_auto_config(struct hda_codec *codec)
3731{
3732 struct sigmatel_spec *spec = codec->spec;
3733 int err;
3734
Kailang Yangdf694da2005-12-05 19:42:22 +01003735 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003736 return err;
3737
3738 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3739 return err;
3740
Takashi Iwai82bc9552006-03-21 11:24:42 +01003741 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3742 return err;
3743
Richard Fish160ea0d2006-09-06 13:58:25 +02003744 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3745 return err;
3746
Takashi Iwai355a0ec2008-11-11 16:46:19 +01003747 if (spec->num_muxes > 0) {
3748 err = stac92xx_auto_create_mux_input_ctls(codec);
3749 if (err < 0)
3750 return err;
3751 }
3752
Takashi Iwai82bc9552006-03-21 11:24:42 +01003753 if (spec->autocfg.dig_out_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003754 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003755 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003756 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003757
Takashi Iwai603c4012008-07-30 15:01:44 +02003758 if (spec->kctls.list)
3759 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003760
3761 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003762 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003763
3764 return 1;
3765}
3766
Sam Revitch62fe78e2006-05-10 15:09:17 +02003767/*
3768 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3769 * funky external mute control using GPIO pins.
3770 */
3771
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003772static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003773 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003774{
3775 unsigned int gpiostate, gpiomask, gpiodir;
3776
3777 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3778 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003779 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003780
3781 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3782 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003783 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003784
3785 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3786 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003787 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003788
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003789 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003790 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3791
3792 snd_hda_codec_write(codec, codec->afg, 0,
3793 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003794 snd_hda_codec_read(codec, codec->afg, 0,
3795 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003796
3797 msleep(1);
3798
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003799 snd_hda_codec_read(codec, codec->afg, 0,
3800 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003801}
3802
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003803static int stac92xx_add_jack(struct hda_codec *codec,
3804 hda_nid_t nid, int type)
3805{
Takashi Iwaie4973e12008-11-18 09:32:42 +01003806#ifdef CONFIG_SND_JACK
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003807 struct sigmatel_spec *spec = codec->spec;
3808 struct sigmatel_jack *jack;
3809 int def_conf = snd_hda_codec_read(codec, nid,
3810 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
3811 int connectivity = get_defcfg_connect(def_conf);
3812 char name[32];
3813
3814 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
3815 return 0;
3816
3817 snd_array_init(&spec->jacks, sizeof(*jack), 32);
3818 jack = snd_array_new(&spec->jacks);
3819 if (!jack)
3820 return -ENOMEM;
3821 jack->nid = nid;
3822 jack->type = type;
3823
3824 sprintf(name, "%s at %s %s Jack",
3825 snd_hda_get_jack_type(def_conf),
3826 snd_hda_get_jack_connectivity(def_conf),
3827 snd_hda_get_jack_location(def_conf));
3828
3829 return snd_jack_new(codec->bus->card, name, type, &jack->jack);
Takashi Iwaie4973e12008-11-18 09:32:42 +01003830#else
3831 return 0;
3832#endif
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003833}
3834
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003835static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
3836 unsigned char type, int data)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003837{
3838 struct sigmatel_event *event;
3839
3840 snd_array_init(&spec->events, sizeof(*event), 32);
3841 event = snd_array_new(&spec->events);
3842 if (!event)
3843 return -ENOMEM;
3844 event->nid = nid;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003845 event->type = type;
3846 event->tag = spec->events.used;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003847 event->data = data;
3848
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003849 return event->tag;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003850}
3851
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003852static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
3853 hda_nid_t nid, unsigned char type)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003854{
3855 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003856 struct sigmatel_event *event = spec->events.list;
3857 int i;
3858
3859 for (i = 0; i < spec->events.used; i++, event++) {
3860 if (event->nid == nid && event->type == type)
3861 return event;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003862 }
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003863 return NULL;
3864}
3865
3866static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
3867 unsigned char tag)
3868{
3869 struct sigmatel_spec *spec = codec->spec;
3870 struct sigmatel_event *event = spec->events.list;
3871 int i;
3872
3873 for (i = 0; i < spec->events.used; i++, event++) {
3874 if (event->tag == tag)
3875 return event;
3876 }
3877 return NULL;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003878}
3879
Takashi Iwai314634b2006-09-21 11:56:18 +02003880static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003881 unsigned int type)
Takashi Iwai314634b2006-09-21 11:56:18 +02003882{
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003883 struct sigmatel_event *event;
3884 int tag;
3885
3886 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
3887 return;
3888 event = stac_get_event(codec, nid, type);
3889 if (event)
3890 tag = event->tag;
3891 else
3892 tag = stac_add_event(codec->spec, nid, type, 0);
3893 if (tag < 0)
3894 return;
3895 snd_hda_codec_write_cache(codec, nid, 0,
3896 AC_VERB_SET_UNSOLICITED_ENABLE,
3897 AC_USRSP_EN | tag);
Takashi Iwai314634b2006-09-21 11:56:18 +02003898}
3899
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003900static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3901{
3902 int i;
3903 for (i = 0; i < cfg->hp_outs; i++)
3904 if (cfg->hp_pins[i] == nid)
3905 return 1; /* nid is a HP-Out */
3906
3907 return 0; /* nid is not a HP-Out */
3908};
3909
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003910static void stac92xx_power_down(struct hda_codec *codec)
3911{
3912 struct sigmatel_spec *spec = codec->spec;
3913
3914 /* power down inactive DACs */
3915 hda_nid_t *dac;
3916 for (dac = spec->dac_list; *dac; dac++)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003917 if (!check_all_dac_nids(spec, *dac))
Takashi Iwai8c2f7672008-12-01 11:54:35 +01003918 snd_hda_codec_write(codec, *dac, 0,
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003919 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3920}
3921
Takashi Iwaif73d3582008-11-25 08:21:51 +01003922static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
3923 int enable);
3924
Mattc7d4b2f2005-06-27 14:59:41 +02003925static int stac92xx_init(struct hda_codec *codec)
3926{
3927 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003928 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01003929 unsigned int gpio;
Takashi Iwaie4973e12008-11-18 09:32:42 +01003930 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003931
Mattc7d4b2f2005-06-27 14:59:41 +02003932 snd_hda_sequence_write(codec, spec->init);
3933
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003934 /* power down adcs initially */
3935 if (spec->powerdown_adcs)
3936 for (i = 0; i < spec->num_adcs; i++)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01003937 snd_hda_codec_write(codec,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003938 spec->adc_nids[i], 0,
3939 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01003940
3941 /* set up GPIO */
3942 gpio = spec->gpio_data;
3943 /* turn on EAPD statically when spec->eapd_switch isn't set.
3944 * otherwise, unsol event will turn it on/off dynamically
3945 */
3946 if (!spec->eapd_switch)
3947 gpio |= spec->eapd_mask;
3948 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
3949
Takashi Iwai82bc9552006-03-21 11:24:42 +01003950 /* set up pins */
3951 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02003952 /* Enable unsolicited responses on the HP widget */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003953 for (i = 0; i < cfg->hp_outs; i++) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003954 hda_nid_t nid = cfg->hp_pins[i];
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003955 enable_pin_detect(codec, nid, STAC_HP_EVENT);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003956 }
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01003957 /* force to enable the first line-out; the others are set up
3958 * in unsol_event
3959 */
3960 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003961 AC_PINCTL_OUT_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003962 /* fake event to set up pins */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003963 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
3964 STAC_HP_EVENT);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003965 } else {
3966 stac92xx_auto_init_multi_out(codec);
3967 stac92xx_auto_init_hp_out(codec);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01003968 for (i = 0; i < cfg->hp_outs; i++)
3969 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003970 }
3971 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01003972 hda_nid_t nid = cfg->input_pins[i];
3973 if (nid) {
Takashi Iwai12dde4c2008-12-05 13:09:27 +01003974 unsigned int pinctl, conf;
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01003975 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
3976 /* for mic pins, force to initialize */
3977 pinctl = stac92xx_get_vref(codec, nid);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01003978 pinctl |= AC_PINCTL_IN_EN;
3979 stac92xx_auto_set_pinctl(codec, nid, pinctl);
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01003980 } else {
3981 pinctl = snd_hda_codec_read(codec, nid, 0,
3982 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3983 /* if PINCTL already set then skip */
Takashi Iwai12dde4c2008-12-05 13:09:27 +01003984 if (!(pinctl & AC_PINCTL_IN_EN)) {
3985 pinctl |= AC_PINCTL_IN_EN;
3986 stac92xx_auto_set_pinctl(codec, nid,
3987 pinctl);
3988 }
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01003989 }
Takashi Iwai12dde4c2008-12-05 13:09:27 +01003990 conf = snd_hda_codec_read(codec, nid, 0,
3991 AC_VERB_GET_CONFIG_DEFAULT, 0);
3992 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
3993 enable_pin_detect(codec, nid,
3994 STAC_INSERT_EVENT);
3995 stac_issue_unsol_event(codec, nid,
3996 STAC_INSERT_EVENT);
3997 }
Takashi Iwaic960a032006-03-23 17:06:28 +01003998 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01003999 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004000 for (i = 0; i < spec->num_dmics; i++)
4001 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4002 AC_PINCTL_IN_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004003 if (cfg->dig_out_pin)
4004 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
4005 AC_PINCTL_OUT_EN);
4006 if (cfg->dig_in_pin)
4007 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4008 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004009 for (i = 0; i < spec->num_pwrs; i++) {
4010 hda_nid_t nid = spec->pwr_nids[i];
4011 int pinctl, def_conf;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004012
Takashi Iwaieb632122008-12-19 16:39:48 +01004013 /* power on when no jack detection is available */
4014 if (!spec->hp_detect) {
4015 stac_toggle_power_map(codec, nid, 1);
4016 continue;
4017 }
4018
4019 if (is_nid_hp_pin(cfg, nid))
Takashi Iwaif73d3582008-11-25 08:21:51 +01004020 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004021
Takashi Iwaif73d3582008-11-25 08:21:51 +01004022 pinctl = snd_hda_codec_read(codec, nid, 0,
4023 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4024 /* outputs are only ports capable of power management
4025 * any attempts on powering down a input port cause the
4026 * referenced VREF to act quirky.
4027 */
Takashi Iwaieb632122008-12-19 16:39:48 +01004028 if (pinctl & AC_PINCTL_IN_EN) {
4029 stac_toggle_power_map(codec, nid, 1);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004030 continue;
Takashi Iwaieb632122008-12-19 16:39:48 +01004031 }
Takashi Iwaif73d3582008-11-25 08:21:51 +01004032 def_conf = snd_hda_codec_read(codec, nid, 0,
4033 AC_VERB_GET_CONFIG_DEFAULT, 0);
4034 def_conf = get_defcfg_connect(def_conf);
4035 /* skip any ports that don't have jacks since presence
4036 * detection is useless */
4037 if (def_conf != AC_JACK_PORT_COMPLEX) {
4038 if (def_conf != AC_JACK_PORT_NONE)
4039 stac_toggle_power_map(codec, nid, 1);
4040 continue;
4041 }
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004042 if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) {
4043 enable_pin_detect(codec, nid, STAC_PWR_EVENT);
4044 stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT);
4045 }
Takashi Iwaif73d3582008-11-25 08:21:51 +01004046 }
4047 if (spec->dac_list)
4048 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02004049 return 0;
4050}
4051
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004052static void stac92xx_free_jacks(struct hda_codec *codec)
4053{
Takashi Iwaie4973e12008-11-18 09:32:42 +01004054#ifdef CONFIG_SND_JACK
Takashi Iwaib94d3532008-11-21 09:08:06 +01004055 /* free jack instances manually when clearing/reconfiguring */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004056 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaib94d3532008-11-21 09:08:06 +01004057 if (!codec->bus->shutdown && spec->jacks.list) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004058 struct sigmatel_jack *jacks = spec->jacks.list;
4059 int i;
4060 for (i = 0; i < spec->jacks.used; i++)
4061 snd_device_free(codec->bus->card, &jacks[i].jack);
4062 }
4063 snd_array_free(&spec->jacks);
Takashi Iwaie4973e12008-11-18 09:32:42 +01004064#endif
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004065}
4066
Takashi Iwai603c4012008-07-30 15:01:44 +02004067static void stac92xx_free_kctls(struct hda_codec *codec)
4068{
4069 struct sigmatel_spec *spec = codec->spec;
4070
4071 if (spec->kctls.list) {
4072 struct snd_kcontrol_new *kctl = spec->kctls.list;
4073 int i;
4074 for (i = 0; i < spec->kctls.used; i++)
4075 kfree(kctl[i].name);
4076 }
4077 snd_array_free(&spec->kctls);
4078}
4079
Matt2f2f4252005-04-13 14:45:30 +02004080static void stac92xx_free(struct hda_codec *codec)
4081{
Mattc7d4b2f2005-06-27 14:59:41 +02004082 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004083
4084 if (! spec)
4085 return;
4086
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004087 kfree(spec->pin_configs);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004088 stac92xx_free_jacks(codec);
4089 snd_array_free(&spec->events);
Richard Fish11b44bb2006-08-23 18:31:34 +02004090
Mattc7d4b2f2005-06-27 14:59:41 +02004091 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004092 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02004093}
4094
Matt4e550962005-07-04 17:51:39 +02004095static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4096 unsigned int flag)
4097{
4098 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4099 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02004100
Takashi Iwaif9acba42007-05-29 18:01:06 +02004101 if (pin_ctl & AC_PINCTL_IN_EN) {
4102 /*
4103 * we need to check the current set-up direction of
4104 * shared input pins since they can be switched via
4105 * "xxx as Output" mixer switch
4106 */
4107 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004108 if (nid == spec->line_switch || nid == spec->mic_switch)
Takashi Iwaif9acba42007-05-29 18:01:06 +02004109 return;
4110 }
4111
Steve Longerbeam7b043892007-05-03 20:50:03 +02004112 /* if setting pin direction bits, clear the current
4113 direction bits first */
4114 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4115 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4116
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004117 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02004118 AC_VERB_SET_PIN_WIDGET_CONTROL,
4119 pin_ctl | flag);
4120}
4121
4122static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4123 unsigned int flag)
4124{
4125 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4126 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004127 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02004128 AC_VERB_SET_PIN_WIDGET_CONTROL,
4129 pin_ctl & ~flag);
4130}
4131
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004132static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02004133{
4134 if (!nid)
4135 return 0;
4136 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004137 & (1 << 31))
4138 return 1;
Takashi Iwai314634b2006-09-21 11:56:18 +02004139 return 0;
4140}
4141
Takashi Iwaid7a89432008-11-12 09:48:04 +01004142/* return non-zero if the hp-pin of the given array index isn't
4143 * a jack-detection target
4144 */
4145static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4146{
4147 struct auto_pin_cfg *cfg = &spec->autocfg;
4148
4149 /* ignore sensing of shared line and mic jacks */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004150 if (cfg->hp_pins[i] == spec->line_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004151 return 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004152 if (cfg->hp_pins[i] == spec->mic_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004153 return 1;
4154 /* ignore if the pin is set as line-out */
4155 if (cfg->hp_pins[i] == spec->hp_switch)
4156 return 1;
4157 return 0;
4158}
4159
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004160static void stac92xx_hp_detect(struct hda_codec *codec)
Matt4e550962005-07-04 17:51:39 +02004161{
4162 struct sigmatel_spec *spec = codec->spec;
4163 struct auto_pin_cfg *cfg = &spec->autocfg;
4164 int i, presence;
4165
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004166 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004167 if (spec->gpio_mute)
4168 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4169 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4170
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004171 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004172 if (presence)
4173 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01004174 if (no_hp_sensing(spec, i))
4175 continue;
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004176 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4177 if (presence) {
4178 unsigned int pinctl;
4179 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4180 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4181 if (pinctl & AC_PINCTL_IN_EN)
4182 presence = 0; /* mic- or line-input */
4183 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004184 }
Matt4e550962005-07-04 17:51:39 +02004185
4186 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004187 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004188 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004189 stac92xx_reset_pinctl(codec, spec->hp_switch,
4190 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004191 for (i = 0; i < cfg->line_outs; i++)
4192 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4193 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004194 for (i = 0; i < cfg->speaker_outs; i++)
4195 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4196 AC_PINCTL_OUT_EN);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004197 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004198 stac_gpio_set(codec, spec->gpio_mask,
4199 spec->gpio_dir, spec->gpio_data &
4200 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02004201 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004202 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004203 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004204 stac92xx_set_pinctl(codec, spec->hp_switch,
4205 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004206 for (i = 0; i < cfg->line_outs; i++)
4207 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4208 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004209 for (i = 0; i < cfg->speaker_outs; i++)
4210 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4211 AC_PINCTL_OUT_EN);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004212 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004213 stac_gpio_set(codec, spec->gpio_mask,
4214 spec->gpio_dir, spec->gpio_data |
4215 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02004216 }
Takashi Iwaid7a89432008-11-12 09:48:04 +01004217 /* toggle hp outs */
4218 for (i = 0; i < cfg->hp_outs; i++) {
4219 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4220 if (no_hp_sensing(spec, i))
4221 continue;
4222 if (presence)
4223 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
4224 else
4225 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
4226 }
Matt4e550962005-07-04 17:51:39 +02004227}
4228
Takashi Iwaif73d3582008-11-25 08:21:51 +01004229static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4230 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004231{
4232 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004233 unsigned int idx, val;
4234
4235 for (idx = 0; idx < spec->num_pwrs; idx++) {
4236 if (spec->pwr_nids[idx] == nid)
4237 break;
4238 }
4239 if (idx >= spec->num_pwrs)
4240 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004241
4242 /* several codecs have two power down bits */
4243 if (spec->pwr_mapping)
4244 idx = spec->pwr_mapping[idx];
4245 else
4246 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004247
Takashi Iwaif73d3582008-11-25 08:21:51 +01004248 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4249 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004250 val &= ~idx;
4251 else
4252 val |= idx;
4253
4254 /* power down unused output ports */
4255 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004256}
4257
Takashi Iwaif73d3582008-11-25 08:21:51 +01004258static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4259{
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004260 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
Takashi Iwaif73d3582008-11-25 08:21:51 +01004261}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004262
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004263static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4264{
4265 struct sigmatel_spec *spec = codec->spec;
4266 struct sigmatel_jack *jacks = spec->jacks.list;
4267
4268 if (jacks) {
4269 int i;
4270 for (i = 0; i < spec->jacks.used; i++) {
4271 if (jacks->nid == nid) {
4272 unsigned int pin_ctl =
4273 snd_hda_codec_read(codec, nid,
4274 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4275 0x00);
4276 int type = jacks->type;
4277 if (type == (SND_JACK_LINEOUT
4278 | SND_JACK_HEADPHONE))
4279 type = (pin_ctl & AC_PINCTL_HP_EN)
4280 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4281 snd_jack_report(jacks->jack,
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004282 get_pin_presence(codec, nid)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004283 ? type : 0);
4284 }
4285 jacks++;
4286 }
4287 }
4288}
Matt2f2f4252005-04-13 14:45:30 +02004289
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004290static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
4291 unsigned char type)
4292{
4293 struct sigmatel_event *event = stac_get_event(codec, nid, type);
4294 if (!event)
4295 return;
4296 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4297}
4298
Takashi Iwai314634b2006-09-21 11:56:18 +02004299static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4300{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004301 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004302 struct sigmatel_event *event;
4303 int tag, data;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004304
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004305 tag = (res >> 26) & 0x7f;
4306 event = stac_get_event_from_tag(codec, tag);
4307 if (!event)
4308 return;
4309
4310 switch (event->type) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004311 case STAC_HP_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004312 stac92xx_hp_detect(codec);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004313 /* fallthru */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004314 case STAC_INSERT_EVENT:
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004315 case STAC_PWR_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004316 if (spec->num_pwrs > 0)
4317 stac92xx_pin_sense(codec, event->nid);
4318 stac92xx_report_jack(codec, event->nid);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004319 break;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004320 case STAC_VREF_EVENT:
4321 data = snd_hda_codec_read(codec, codec->afg, 0,
4322 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004323 /* toggle VREF state based on GPIOx status */
4324 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004325 !!(data & (1 << event->data)));
Matthew Ranostay72474be2008-10-09 09:32:17 -04004326 break;
Takashi Iwai314634b2006-09-21 11:56:18 +02004327 }
4328}
4329
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004330#ifdef CONFIG_PROC_FS
4331static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4332 struct hda_codec *codec, hda_nid_t nid)
4333{
4334 if (nid == codec->afg)
4335 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4336 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4337}
4338
4339static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4340 struct hda_codec *codec,
4341 unsigned int verb)
4342{
4343 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4344 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4345}
4346
4347/* stac92hd71bxx, stac92hd73xx */
4348static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4349 struct hda_codec *codec, hda_nid_t nid)
4350{
4351 stac92hd_proc_hook(buffer, codec, nid);
4352 if (nid == codec->afg)
4353 analog_loop_proc_hook(buffer, codec, 0xfa0);
4354}
4355
4356static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4357 struct hda_codec *codec, hda_nid_t nid)
4358{
4359 if (nid == codec->afg)
4360 analog_loop_proc_hook(buffer, codec, 0xfe0);
4361}
4362
4363static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4364 struct hda_codec *codec, hda_nid_t nid)
4365{
4366 if (nid == codec->afg)
4367 analog_loop_proc_hook(buffer, codec, 0xfeb);
4368}
4369#else
4370#define stac92hd_proc_hook NULL
4371#define stac92hd7x_proc_hook NULL
4372#define stac9205_proc_hook NULL
4373#define stac927x_proc_hook NULL
4374#endif
4375
Takashi Iwaicb53c622007-08-10 17:21:45 +02004376#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004377static int stac92xx_resume(struct hda_codec *codec)
4378{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004379 struct sigmatel_spec *spec = codec->spec;
4380
Richard Fish11b44bb2006-08-23 18:31:34 +02004381 stac92xx_set_config_regs(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01004382 stac92xx_init(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004383 snd_hda_codec_resume_amp(codec);
4384 snd_hda_codec_resume_cache(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01004385 /* fake event to set up pins again to override cached values */
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004386 if (spec->hp_detect)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004387 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4388 STAC_HP_EVENT);
Mattff6fdc32005-06-27 15:06:52 +02004389 return 0;
4390}
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004391
4392static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4393{
4394 struct sigmatel_spec *spec = codec->spec;
4395 if (spec->eapd_mask)
4396 stac_gpio_set(codec, spec->gpio_mask,
4397 spec->gpio_dir, spec->gpio_data &
4398 ~spec->eapd_mask);
4399 return 0;
4400}
Mattff6fdc32005-06-27 15:06:52 +02004401#endif
4402
Matt2f2f4252005-04-13 14:45:30 +02004403static struct hda_codec_ops stac92xx_patch_ops = {
4404 .build_controls = stac92xx_build_controls,
4405 .build_pcms = stac92xx_build_pcms,
4406 .init = stac92xx_init,
4407 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02004408 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004409#ifdef SND_HDA_NEEDS_RESUME
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004410 .suspend = stac92xx_suspend,
Mattff6fdc32005-06-27 15:06:52 +02004411 .resume = stac92xx_resume,
4412#endif
Matt2f2f4252005-04-13 14:45:30 +02004413};
4414
4415static int patch_stac9200(struct hda_codec *codec)
4416{
4417 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004418 int err;
Matt2f2f4252005-04-13 14:45:30 +02004419
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004420 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004421 if (spec == NULL)
4422 return -ENOMEM;
4423
4424 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004425 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004426 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004427 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4428 stac9200_models,
4429 stac9200_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02004430 if (spec->board_config < 0) {
4431 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
4432 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004433 } else
4434 err = stac_save_pin_cfgs(codec,
4435 stac9200_brd_tbl[spec->board_config]);
4436 if (err < 0) {
4437 stac92xx_free(codec);
4438 return err;
Matt Porter403d1942005-11-29 15:00:51 +01004439 }
Matt2f2f4252005-04-13 14:45:30 +02004440
4441 spec->multiout.max_channels = 2;
4442 spec->multiout.num_dacs = 1;
4443 spec->multiout.dac_nids = stac9200_dac_nids;
4444 spec->adc_nids = stac9200_adc_nids;
4445 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02004446 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02004447 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004448 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004449 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004450
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02004451 if (spec->board_config == STAC_9200_M4 ||
4452 spec->board_config == STAC_9200_M4_2 ||
Tobin Davisbf277782008-02-03 20:31:47 +01004453 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02004454 spec->init = stac9200_eapd_init;
4455 else
4456 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004457 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004458
Takashi Iwai117f2572008-03-18 09:53:23 +01004459 if (spec->board_config == STAC_9200_PANASONIC) {
4460 spec->gpio_mask = spec->gpio_dir = 0x09;
4461 spec->gpio_data = 0x00;
4462 }
4463
Mattc7d4b2f2005-06-27 14:59:41 +02004464 err = stac9200_parse_auto_config(codec);
4465 if (err < 0) {
4466 stac92xx_free(codec);
4467 return err;
4468 }
Matt2f2f4252005-04-13 14:45:30 +02004469
Takashi Iwai2acc9dc2009-01-09 16:57:14 +01004470 /* CF-74 has no headphone detection, and the driver should *NOT*
4471 * do detection and HP/speaker toggle because the hardware does it.
4472 */
4473 if (spec->board_config == STAC_9200_PANASONIC)
4474 spec->hp_detect = 0;
4475
Matt2f2f4252005-04-13 14:45:30 +02004476 codec->patch_ops = stac92xx_patch_ops;
4477
4478 return 0;
4479}
4480
Tobin Davis8e21c342007-01-08 11:04:17 +01004481static int patch_stac925x(struct hda_codec *codec)
4482{
4483 struct sigmatel_spec *spec;
4484 int err;
4485
4486 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4487 if (spec == NULL)
4488 return -ENOMEM;
4489
4490 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004491 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01004492 spec->pin_nids = stac925x_pin_nids;
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02004493
4494 /* Check first for codec ID */
4495 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
4496 STAC_925x_MODELS,
4497 stac925x_models,
4498 stac925x_codec_id_cfg_tbl);
4499
4500 /* Now checks for PCI ID, if codec ID is not found */
4501 if (spec->board_config < 0)
4502 spec->board_config = snd_hda_check_board_config(codec,
4503 STAC_925x_MODELS,
Tobin Davis8e21c342007-01-08 11:04:17 +01004504 stac925x_models,
4505 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004506 again:
Tobin Davis8e21c342007-01-08 11:04:17 +01004507 if (spec->board_config < 0) {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02004508 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
Tobin Davis2c11f952007-05-17 09:36:34 +02004509 "using BIOS defaults\n");
Tobin Davis8e21c342007-01-08 11:04:17 +01004510 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004511 } else
4512 err = stac_save_pin_cfgs(codec,
4513 stac925x_brd_tbl[spec->board_config]);
4514 if (err < 0) {
4515 stac92xx_free(codec);
4516 return err;
Tobin Davis8e21c342007-01-08 11:04:17 +01004517 }
4518
4519 spec->multiout.max_channels = 2;
4520 spec->multiout.num_dacs = 1;
4521 spec->multiout.dac_nids = stac925x_dac_nids;
4522 spec->adc_nids = stac925x_adc_nids;
4523 spec->mux_nids = stac925x_mux_nids;
4524 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004525 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004526 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02004527 switch (codec->vendor_id) {
4528 case 0x83847632: /* STAC9202 */
4529 case 0x83847633: /* STAC9202D */
4530 case 0x83847636: /* STAC9251 */
4531 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02004532 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02004533 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004534 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4535 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02004536 break;
4537 default:
4538 spec->num_dmics = 0;
4539 break;
4540 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004541
4542 spec->init = stac925x_core_init;
4543 spec->mixer = stac925x_mixer;
4544
4545 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004546 if (!err) {
4547 if (spec->board_config < 0) {
4548 printk(KERN_WARNING "hda_codec: No auto-config is "
4549 "available, default to model=ref\n");
4550 spec->board_config = STAC_925x_REF;
4551 goto again;
4552 }
4553 err = -EINVAL;
4554 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004555 if (err < 0) {
4556 stac92xx_free(codec);
4557 return err;
4558 }
4559
4560 codec->patch_ops = stac92xx_patch_ops;
4561
4562 return 0;
4563}
4564
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004565static struct hda_input_mux stac92hd73xx_dmux = {
4566 .num_items = 4,
4567 .items = {
4568 { "Analog Inputs", 0x0b },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004569 { "Digital Mic 1", 0x09 },
4570 { "Digital Mic 2", 0x0a },
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004571 { "CD", 0x08 },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004572 }
4573};
4574
4575static int patch_stac92hd73xx(struct hda_codec *codec)
4576{
4577 struct sigmatel_spec *spec;
4578 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4579 int err = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004580 int num_dacs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004581
4582 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4583 if (spec == NULL)
4584 return -ENOMEM;
4585
4586 codec->spec = spec;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02004587 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004588 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4589 spec->pin_nids = stac92hd73xx_pin_nids;
4590 spec->board_config = snd_hda_check_board_config(codec,
4591 STAC_92HD73XX_MODELS,
4592 stac92hd73xx_models,
4593 stac92hd73xx_cfg_tbl);
4594again:
4595 if (spec->board_config < 0) {
4596 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4597 " STAC92HD73XX, using BIOS defaults\n");
4598 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004599 } else
4600 err = stac_save_pin_cfgs(codec,
4601 stac92hd73xx_brd_tbl[spec->board_config]);
4602 if (err < 0) {
4603 stac92xx_free(codec);
4604 return err;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004605 }
4606
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004607 num_dacs = snd_hda_get_connections(codec, 0x0a,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004608 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4609
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004610 if (num_dacs < 3 || num_dacs > 5) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004611 printk(KERN_WARNING "hda_codec: Could not determine "
4612 "number of channels defaulting to DAC count\n");
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004613 num_dacs = STAC92HD73_DAC_COUNT;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004614 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004615 switch (num_dacs) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004616 case 0x3: /* 6 Channel */
4617 spec->mixer = stac92hd73xx_6ch_mixer;
4618 spec->init = stac92hd73xx_6ch_core_init;
4619 break;
4620 case 0x4: /* 8 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004621 spec->mixer = stac92hd73xx_8ch_mixer;
4622 spec->init = stac92hd73xx_8ch_core_init;
4623 break;
4624 case 0x5: /* 10 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004625 spec->mixer = stac92hd73xx_10ch_mixer;
4626 spec->init = stac92hd73xx_10ch_core_init;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004627 }
4628 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004629
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004630 spec->aloopback_mask = 0x01;
4631 spec->aloopback_shift = 8;
4632
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004633 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004634 spec->mux_nids = stac92hd73xx_mux_nids;
4635 spec->adc_nids = stac92hd73xx_adc_nids;
4636 spec->dmic_nids = stac92hd73xx_dmic_nids;
4637 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004638 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostay89385032008-09-11 09:49:39 -04004639 spec->amp_nids = stac92hd73xx_amp_nids;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004640 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004641
4642 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4643 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01004644 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004645 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4646 sizeof(stac92hd73xx_dmux));
4647
Matthew Ranostaya7662642008-02-21 07:51:14 +01004648 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004649 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004650 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004651 /* fallthru */
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004652 case STAC_DELL_M6_AMIC:
4653 case STAC_DELL_M6_DMIC:
4654 case STAC_DELL_M6_BOTH:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004655 spec->num_smuxes = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004656 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4657 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004658 spec->eapd_switch = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004659 spec->num_amps = 1;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004660
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004661 if (spec->board_config != STAC_DELL_EQ)
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004662 spec->init = dell_m6_core_init;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004663 switch (spec->board_config) {
4664 case STAC_DELL_M6_AMIC: /* Analog Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004665 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4666 spec->num_dmics = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004667 spec->private_dimux.num_items = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004668 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004669 case STAC_DELL_M6_DMIC: /* Digital Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004670 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4671 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004672 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004673 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004674 case STAC_DELL_M6_BOTH: /* Both */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004675 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4676 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4677 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004678 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004679 break;
4680 }
4681 break;
4682 default:
4683 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004684 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004685 spec->eapd_switch = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004686 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004687 if (spec->board_config > STAC_92HD73XX_REF) {
4688 /* GPIO0 High = Enable EAPD */
4689 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4690 spec->gpio_data = 0x01;
4691 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004692 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004693
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004694 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4695 spec->pwr_nids = stac92hd73xx_pwr_nids;
4696
Matthew Ranostayd9737752008-09-07 12:03:41 +02004697 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004698
4699 if (!err) {
4700 if (spec->board_config < 0) {
4701 printk(KERN_WARNING "hda_codec: No auto-config is "
4702 "available, default to model=ref\n");
4703 spec->board_config = STAC_92HD73XX_REF;
4704 goto again;
4705 }
4706 err = -EINVAL;
4707 }
4708
4709 if (err < 0) {
4710 stac92xx_free(codec);
4711 return err;
4712 }
4713
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01004714 if (spec->board_config == STAC_92HD73XX_NO_JD)
4715 spec->hp_detect = 0;
4716
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004717 codec->patch_ops = stac92xx_patch_ops;
4718
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004719 codec->proc_widget_hook = stac92hd7x_proc_hook;
4720
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004721 return 0;
4722}
4723
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004724static struct hda_input_mux stac92hd83xxx_dmux = {
4725 .num_items = 3,
4726 .items = {
4727 { "Analog Inputs", 0x03 },
4728 { "Digital Mic 1", 0x04 },
4729 { "Digital Mic 2", 0x05 },
4730 }
4731};
4732
4733static int patch_stac92hd83xxx(struct hda_codec *codec)
4734{
4735 struct sigmatel_spec *spec;
4736 int err;
4737
4738 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4739 if (spec == NULL)
4740 return -ENOMEM;
4741
4742 codec->spec = spec;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004743 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004744 spec->mono_nid = 0x19;
4745 spec->digbeep_nid = 0x21;
4746 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4747 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4748 spec->adc_nids = stac92hd83xxx_adc_nids;
4749 spec->pwr_nids = stac92hd83xxx_pwr_nids;
4750 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4751 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004752 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004753
4754 spec->init = stac92hd83xxx_core_init;
4755 switch (codec->vendor_id) {
4756 case 0x111d7605:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004757 break;
4758 default:
4759 spec->num_pwrs--;
4760 spec->init++; /* switch to config #2 */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004761 }
4762
4763 spec->mixer = stac92hd83xxx_mixer;
4764 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4765 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4766 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
4767 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4768 spec->dinput_mux = &stac92hd83xxx_dmux;
4769 spec->pin_nids = stac92hd83xxx_pin_nids;
4770 spec->board_config = snd_hda_check_board_config(codec,
4771 STAC_92HD83XXX_MODELS,
4772 stac92hd83xxx_models,
4773 stac92hd83xxx_cfg_tbl);
4774again:
4775 if (spec->board_config < 0) {
4776 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4777 " STAC92HD83XXX, using BIOS defaults\n");
4778 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004779 } else
4780 err = stac_save_pin_cfgs(codec,
4781 stac92hd83xxx_brd_tbl[spec->board_config]);
4782 if (err < 0) {
4783 stac92xx_free(codec);
4784 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004785 }
4786
4787 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4788 if (!err) {
4789 if (spec->board_config < 0) {
4790 printk(KERN_WARNING "hda_codec: No auto-config is "
4791 "available, default to model=ref\n");
4792 spec->board_config = STAC_92HD83XXX_REF;
4793 goto again;
4794 }
4795 err = -EINVAL;
4796 }
4797
4798 if (err < 0) {
4799 stac92xx_free(codec);
4800 return err;
4801 }
4802
4803 codec->patch_ops = stac92xx_patch_ops;
4804
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004805 codec->proc_widget_hook = stac92hd_proc_hook;
4806
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004807 return 0;
4808}
4809
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004810static struct hda_input_mux stac92hd71bxx_dmux = {
4811 .num_items = 4,
4812 .items = {
4813 { "Analog Inputs", 0x00 },
4814 { "Mixer", 0x01 },
4815 { "Digital Mic 1", 0x02 },
4816 { "Digital Mic 2", 0x03 },
4817 }
4818};
4819
Matthew Ranostaye035b842007-11-06 11:53:55 +01004820static int patch_stac92hd71bxx(struct hda_codec *codec)
4821{
4822 struct sigmatel_spec *spec;
4823 int err = 0;
4824
4825 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4826 if (spec == NULL)
4827 return -ENOMEM;
4828
4829 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004830 codec->patch_ops = stac92xx_patch_ops;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004831 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004832 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004833 spec->pin_nids = stac92hd71bxx_pin_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004834 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux,
4835 sizeof(stac92hd71bxx_dmux));
Matthew Ranostaye035b842007-11-06 11:53:55 +01004836 spec->board_config = snd_hda_check_board_config(codec,
4837 STAC_92HD71BXX_MODELS,
4838 stac92hd71bxx_models,
4839 stac92hd71bxx_cfg_tbl);
4840again:
4841 if (spec->board_config < 0) {
4842 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4843 " STAC92HD71BXX, using BIOS defaults\n");
4844 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004845 } else
4846 err = stac_save_pin_cfgs(codec,
4847 stac92hd71bxx_brd_tbl[spec->board_config]);
4848 if (err < 0) {
4849 stac92xx_free(codec);
4850 return err;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004851 }
4852
Takashi Iwai41c3b642008-11-18 10:45:15 +01004853 if (spec->board_config > STAC_92HD71BXX_REF) {
4854 /* GPIO0 = EAPD */
4855 spec->gpio_mask = 0x01;
4856 spec->gpio_dir = 0x01;
4857 spec->gpio_data = 0x01;
4858 }
4859
Matthew Ranostay541eee82007-12-14 12:08:04 +01004860 switch (codec->vendor_id) {
4861 case 0x111d76b6: /* 4 Port without Analog Mixer */
4862 case 0x111d76b7:
4863 case 0x111d76b4: /* 6 Port without Analog Mixer */
4864 case 0x111d76b5:
4865 spec->mixer = stac92hd71bxx_mixer;
4866 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004867 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004868 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004869 case 0x111d7608: /* 5 Port with Analog Mixer */
Takashi Iwai8e5f2622008-11-15 19:28:54 +01004870 switch (spec->board_config) {
4871 case STAC_HP_M4:
Matthew Ranostay72474be2008-10-09 09:32:17 -04004872 /* Enable VREF power saving on GPIO1 detect */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004873 err = stac_add_event(spec, codec->afg,
4874 STAC_VREF_EVENT, 0x02);
4875 if (err < 0)
4876 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01004877 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay72474be2008-10-09 09:32:17 -04004878 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
4879 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004880 AC_VERB_SET_UNSOLICITED_ENABLE,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004881 AC_USRSP_EN | err);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004882 spec->gpio_mask |= 0x02;
4883 break;
4884 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004885 if ((codec->revision_id & 0xf) == 0 ||
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004886 (codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004887 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004888
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004889 /* no output amps */
4890 spec->num_pwrs = 0;
4891 spec->mixer = stac92hd71bxx_analog_mixer;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004892 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004893
4894 /* disable VSW */
4895 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004896 stac_change_pin_config(codec, 0xf, 0x40f000f0);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004897 break;
4898 case 0x111d7603: /* 6 Port with Analog Mixer */
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004899 if ((codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004900 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004901
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004902 /* no output amps */
4903 spec->num_pwrs = 0;
4904 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01004905 default:
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004906 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004907 spec->mixer = stac92hd71bxx_analog_mixer;
4908 spec->init = stac92hd71bxx_analog_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004909 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004910 }
4911
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004912 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004913 spec->aloopback_shift = 0;
4914
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004915 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004916 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004917 spec->mux_nids = stac92hd71bxx_mux_nids;
4918 spec->adc_nids = stac92hd71bxx_adc_nids;
4919 spec->dmic_nids = stac92hd71bxx_dmic_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004920 spec->dmux_nids = stac92hd71bxx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004921 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004922 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004923
4924 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
4925 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004926
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004927 switch (spec->board_config) {
4928 case STAC_HP_M4:
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004929 /* enable internal microphone */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004930 stac_change_pin_config(codec, 0x0e, 0x01813040);
Matthew Ranostayb9aea712008-10-09 08:37:28 -04004931 stac92xx_auto_set_pinctl(codec, 0x0e,
4932 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05004933 /* fallthru */
4934 case STAC_DELL_M4_2:
4935 spec->num_dmics = 0;
4936 spec->num_smuxes = 0;
4937 spec->num_dmuxes = 0;
4938 break;
4939 case STAC_DELL_M4_1:
4940 case STAC_DELL_M4_3:
4941 spec->num_dmics = 1;
4942 spec->num_smuxes = 0;
4943 spec->num_dmuxes = 0;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004944 break;
4945 default:
4946 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
4947 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
4948 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4949 };
4950
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004951 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004952 if (spec->dinput_mux)
4953 spec->private_dimux.num_items +=
4954 spec->num_dmics -
4955 (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004956
4957 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
4958 if (!err) {
4959 if (spec->board_config < 0) {
4960 printk(KERN_WARNING "hda_codec: No auto-config is "
4961 "available, default to model=ref\n");
4962 spec->board_config = STAC_92HD71BXX_REF;
4963 goto again;
4964 }
4965 err = -EINVAL;
4966 }
4967
4968 if (err < 0) {
4969 stac92xx_free(codec);
4970 return err;
4971 }
4972
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004973 codec->proc_widget_hook = stac92hd7x_proc_hook;
4974
Matthew Ranostaye035b842007-11-06 11:53:55 +01004975 return 0;
4976};
4977
Matt2f2f4252005-04-13 14:45:30 +02004978static int patch_stac922x(struct hda_codec *codec)
4979{
4980 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004981 int err;
Matt2f2f4252005-04-13 14:45:30 +02004982
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004983 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004984 if (spec == NULL)
4985 return -ENOMEM;
4986
4987 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004988 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004989 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004990 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
4991 stac922x_models,
4992 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08004993 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004994 spec->gpio_mask = spec->gpio_dir = 0x03;
4995 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004996 /* Intel Macs have all same PCI SSID, so we need to check
4997 * codec SSID to distinguish the exact models
4998 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004999 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005000 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005001
5002 case 0x106b0800:
5003 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02005004 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005005 case 0x106b0600:
5006 case 0x106b0700:
5007 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005008 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005009 case 0x106b0e00:
5010 case 0x106b0f00:
5011 case 0x106b1600:
5012 case 0x106b1700:
5013 case 0x106b0200:
5014 case 0x106b1e00:
5015 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005016 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005017 case 0x106b1a00:
5018 case 0x00000100:
5019 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02005020 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005021 case 0x106b0a00:
5022 case 0x106b2200:
5023 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02005024 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08005025 default:
5026 spec->board_config = STAC_INTEL_MAC_V3;
5027 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005028 }
5029 }
5030
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005031 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02005032 if (spec->board_config < 0) {
5033 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
5034 "using BIOS defaults\n");
5035 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005036 } else
5037 err = stac_save_pin_cfgs(codec,
5038 stac922x_brd_tbl[spec->board_config]);
5039 if (err < 0) {
5040 stac92xx_free(codec);
5041 return err;
Matt Porter403d1942005-11-29 15:00:51 +01005042 }
Matt2f2f4252005-04-13 14:45:30 +02005043
Matt2f2f4252005-04-13 14:45:30 +02005044 spec->adc_nids = stac922x_adc_nids;
5045 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005046 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005047 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005048 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005049 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02005050
5051 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02005052 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02005053
5054 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02005055
Matt Porter3cc08dc2006-01-23 15:27:49 +01005056 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005057 if (!err) {
5058 if (spec->board_config < 0) {
5059 printk(KERN_WARNING "hda_codec: No auto-config is "
5060 "available, default to model=ref\n");
5061 spec->board_config = STAC_D945_REF;
5062 goto again;
5063 }
5064 err = -EINVAL;
5065 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005066 if (err < 0) {
5067 stac92xx_free(codec);
5068 return err;
5069 }
5070
5071 codec->patch_ops = stac92xx_patch_ops;
5072
Takashi Iwai807a46362007-05-29 19:01:37 +02005073 /* Fix Mux capture level; max to 2 */
5074 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
5075 (0 << AC_AMPCAP_OFFSET_SHIFT) |
5076 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5077 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5078 (0 << AC_AMPCAP_MUTE_SHIFT));
5079
Matt Porter3cc08dc2006-01-23 15:27:49 +01005080 return 0;
5081}
5082
5083static int patch_stac927x(struct hda_codec *codec)
5084{
5085 struct sigmatel_spec *spec;
5086 int err;
5087
5088 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5089 if (spec == NULL)
5090 return -ENOMEM;
5091
5092 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005093 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005094 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005095 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5096 stac927x_models,
5097 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005098 again:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005099 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
5100 if (spec->board_config < 0)
5101 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
5102 "STAC927x, using BIOS defaults\n");
Richard Fish11b44bb2006-08-23 18:31:34 +02005103 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005104 } else
5105 err = stac_save_pin_cfgs(codec,
5106 stac927x_brd_tbl[spec->board_config]);
5107 if (err < 0) {
5108 stac92xx_free(codec);
5109 return err;
Matt Porter3cc08dc2006-01-23 15:27:49 +01005110 }
5111
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005112 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005113 spec->adc_nids = stac927x_adc_nids;
5114 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
5115 spec->mux_nids = stac927x_mux_nids;
5116 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005117 spec->smux_nids = stac927x_smux_nids;
5118 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04005119 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005120 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005121 spec->multiout.dac_nids = spec->dac_nids;
5122
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005123 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02005124 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005125 case STAC_D965_5ST:
5126 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005127 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005128 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005129 spec->num_dmics = 0;
5130
Tobin Davis93ed1502006-09-01 21:03:12 +02005131 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005132 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005133 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005134 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02005135 switch (codec->subsystem_id) {
5136 case 0x10280209:
5137 case 0x1028022e:
5138 /* correct the device field to SPDIF out */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005139 stac_change_pin_config(codec, 0x21, 0x01442070);
Matthew Ranostay780c8be2008-04-14 13:32:27 +02005140 break;
5141 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01005142 /* configure the analog microphone on some laptops */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005143 stac_change_pin_config(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01005144 /* correct the front output jack as a hp out */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005145 stac_change_pin_config(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01005146 /* correct the front input jack as a mic */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005147 stac_change_pin_config(codec, 0x0e, 0x02a79130);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01005148 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005149 case STAC_DELL_3ST:
5150 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005151 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005152 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005153 spec->dmic_nids = stac927x_dmic_nids;
5154 spec->num_dmics = STAC927X_NUM_DMICS;
5155
Tobin Davis93ed1502006-09-01 21:03:12 +02005156 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005157 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005158 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005159 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005160 break;
5161 default:
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005162 if (spec->board_config > STAC_D965_REF) {
5163 /* GPIO0 High = Enable EAPD */
5164 spec->eapd_mask = spec->gpio_mask = 0x01;
5165 spec->gpio_dir = spec->gpio_data = 0x01;
5166 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005167 spec->num_dmics = 0;
5168
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005169 spec->init = stac927x_core_init;
5170 spec->mixer = stac927x_mixer;
5171 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005172
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005173 spec->num_pwrs = 0;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005174 spec->aloopback_mask = 0x40;
5175 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005176 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005177
Matt Porter3cc08dc2006-01-23 15:27:49 +01005178 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005179 if (!err) {
5180 if (spec->board_config < 0) {
5181 printk(KERN_WARNING "hda_codec: No auto-config is "
5182 "available, default to model=ref\n");
5183 spec->board_config = STAC_D965_REF;
5184 goto again;
5185 }
5186 err = -EINVAL;
5187 }
Mattc7d4b2f2005-06-27 14:59:41 +02005188 if (err < 0) {
5189 stac92xx_free(codec);
5190 return err;
5191 }
Matt2f2f4252005-04-13 14:45:30 +02005192
5193 codec->patch_ops = stac92xx_patch_ops;
5194
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005195 codec->proc_widget_hook = stac927x_proc_hook;
5196
Takashi Iwai52987652008-01-16 16:09:47 +01005197 /*
5198 * !!FIXME!!
5199 * The STAC927x seem to require fairly long delays for certain
5200 * command sequences. With too short delays (even if the answer
5201 * is set to RIRB properly), it results in the silence output
5202 * on some hardwares like Dell.
5203 *
5204 * The below flag enables the longer delay (see get_response
5205 * in hda_intel.c).
5206 */
5207 codec->bus->needs_damn_long_delay = 1;
5208
Takashi Iwaie28d8322008-12-17 13:48:29 +01005209 /* no jack detecion for ref-no-jd model */
5210 if (spec->board_config == STAC_D965_REF_NO_JD)
5211 spec->hp_detect = 0;
5212
Matt2f2f4252005-04-13 14:45:30 +02005213 return 0;
5214}
5215
Matt Porterf3302a52006-07-31 12:49:34 +02005216static int patch_stac9205(struct hda_codec *codec)
5217{
5218 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02005219 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02005220
5221 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5222 if (spec == NULL)
5223 return -ENOMEM;
5224
5225 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005226 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005227 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005228 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
5229 stac9205_models,
5230 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005231 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02005232 if (spec->board_config < 0) {
5233 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
5234 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005235 } else
5236 err = stac_save_pin_cfgs(codec,
5237 stac9205_brd_tbl[spec->board_config]);
5238 if (err < 0) {
5239 stac92xx_free(codec);
5240 return err;
Matt Porterf3302a52006-07-31 12:49:34 +02005241 }
5242
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005243 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02005244 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005245 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02005246 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005247 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005248 spec->smux_nids = stac9205_smux_nids;
5249 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005250 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02005251 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005252 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005253 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005254 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02005255
5256 spec->init = stac9205_core_init;
5257 spec->mixer = stac9205_mixer;
5258
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005259 spec->aloopback_mask = 0x40;
5260 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005261 spec->eapd_switch = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02005262 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02005263
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005264 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005265 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02005266 /* Enable SPDIF in/out */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005267 stac_change_pin_config(codec, 0x1f, 0x01441030);
5268 stac_change_pin_config(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01005269
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005270 /* Enable unsol response for GPIO4/Dock HP connection */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005271 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
5272 if (err < 0)
5273 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005274 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005275 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
5276 snd_hda_codec_write_cache(codec, codec->afg, 0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005277 AC_VERB_SET_UNSOLICITED_ENABLE,
5278 AC_USRSP_EN | err);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005279
5280 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005281 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005282 spec->gpio_mask = 0x1b;
5283 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01005284 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005285 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02005286 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005287 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005288 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005289 case STAC_9205_REF:
5290 /* SPDIF-In enabled */
5291 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005292 default:
5293 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005294 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005295 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005296 break;
5297 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02005298
Matt Porterf3302a52006-07-31 12:49:34 +02005299 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005300 if (!err) {
5301 if (spec->board_config < 0) {
5302 printk(KERN_WARNING "hda_codec: No auto-config is "
5303 "available, default to model=ref\n");
5304 spec->board_config = STAC_9205_REF;
5305 goto again;
5306 }
5307 err = -EINVAL;
5308 }
Matt Porterf3302a52006-07-31 12:49:34 +02005309 if (err < 0) {
5310 stac92xx_free(codec);
5311 return err;
5312 }
5313
5314 codec->patch_ops = stac92xx_patch_ops;
5315
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005316 codec->proc_widget_hook = stac9205_proc_hook;
5317
Matt Porterf3302a52006-07-31 12:49:34 +02005318 return 0;
5319}
5320
Matt2f2f4252005-04-13 14:45:30 +02005321/*
Guillaume Munch6d859062006-08-22 17:15:47 +02005322 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01005323 */
5324
Guillaume Munch99ccc562006-08-16 19:35:12 +02005325/* static config for Sony VAIO FE550G and Sony VAIO AR */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005326static hda_nid_t vaio_dacs[] = { 0x2 };
5327#define VAIO_HP_DAC 0x5
5328static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
5329static hda_nid_t vaio_mux_nids[] = { 0x15 };
5330
5331static struct hda_input_mux vaio_mux = {
Takashi Iwaia3a2f422007-10-11 11:21:21 +02005332 .num_items = 3,
Takashi Iwaidb064e52006-03-16 16:04:58 +01005333 .items = {
Takashi Iwaid7737812006-04-25 13:05:43 +02005334 /* { "HP", 0x0 }, */
Takashi Iwai1624cb92007-07-05 13:10:51 +02005335 { "Mic Jack", 0x1 },
5336 { "Internal Mic", 0x2 },
Takashi Iwaidb064e52006-03-16 16:04:58 +01005337 { "PCM", 0x3 },
5338 }
5339};
5340
5341static struct hda_verb vaio_init[] = {
5342 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005343 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
Takashi Iwaidb064e52006-03-16 16:04:58 +01005344 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5345 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5346 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5347 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02005348 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005349 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5350 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5351 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5352 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5353 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5354 {}
5355};
5356
Guillaume Munch6d859062006-08-22 17:15:47 +02005357static struct hda_verb vaio_ar_init[] = {
5358 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
5359 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5360 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5361 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5362/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
5363 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02005364 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Guillaume Munch6d859062006-08-22 17:15:47 +02005365 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5366 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5367/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
5368 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5369 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5370 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5371 {}
5372};
5373
Takashi Iwaidb064e52006-03-16 16:04:58 +01005374static struct snd_kcontrol_new vaio_mixer[] = {
Takashi Iwai127e82e2008-11-14 14:03:33 +01005375 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x02, 0, HDA_OUTPUT),
5376 HDA_CODEC_MUTE("Headphone Playback Switch", 0x02, 0, HDA_OUTPUT),
5377 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x05, 0, HDA_OUTPUT),
5378 HDA_CODEC_MUTE("Speaker Playback Switch", 0x05, 0, HDA_OUTPUT),
Takashi Iwaidb064e52006-03-16 16:04:58 +01005379 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5380 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5381 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5382 {
5383 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5384 .name = "Capture Source",
5385 .count = 1,
5386 .info = stac92xx_mux_enum_info,
5387 .get = stac92xx_mux_enum_get,
5388 .put = stac92xx_mux_enum_put,
5389 },
5390 {}
5391};
5392
Guillaume Munch6d859062006-08-22 17:15:47 +02005393static struct snd_kcontrol_new vaio_ar_mixer[] = {
Takashi Iwai127e82e2008-11-14 14:03:33 +01005394 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x02, 0, HDA_OUTPUT),
5395 HDA_CODEC_MUTE("Headphone Playback Switch", 0x02, 0, HDA_OUTPUT),
5396 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x05, 0, HDA_OUTPUT),
5397 HDA_CODEC_MUTE("Speaker Playback Switch", 0x05, 0, HDA_OUTPUT),
Guillaume Munch6d859062006-08-22 17:15:47 +02005398 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5399 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5400 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5401 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
5402 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
5403 {
5404 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5405 .name = "Capture Source",
5406 .count = 1,
5407 .info = stac92xx_mux_enum_info,
5408 .get = stac92xx_mux_enum_get,
5409 .put = stac92xx_mux_enum_put,
5410 },
5411 {}
5412};
5413
5414static struct hda_codec_ops stac9872_patch_ops = {
Takashi Iwaidb064e52006-03-16 16:04:58 +01005415 .build_controls = stac92xx_build_controls,
5416 .build_pcms = stac92xx_build_pcms,
5417 .init = stac92xx_init,
5418 .free = stac92xx_free,
Takashi Iwaicb53c622007-08-10 17:21:45 +02005419#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaidb064e52006-03-16 16:04:58 +01005420 .resume = stac92xx_resume,
5421#endif
5422};
5423
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005424static int stac9872_vaio_init(struct hda_codec *codec)
5425{
5426 int err;
5427
5428 err = stac92xx_init(codec);
5429 if (err < 0)
5430 return err;
5431 if (codec->patch_ops.unsol_event)
5432 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
5433 return 0;
5434}
5435
5436static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
5437{
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01005438 if (get_pin_presence(codec, 0x0a)) {
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005439 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5440 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5441 } else {
5442 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5443 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5444 }
5445}
5446
5447static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
5448{
5449 switch (res >> 26) {
5450 case STAC_HP_EVENT:
5451 stac9872_vaio_hp_detect(codec, res);
5452 break;
5453 }
5454}
5455
5456static struct hda_codec_ops stac9872_vaio_patch_ops = {
5457 .build_controls = stac92xx_build_controls,
5458 .build_pcms = stac92xx_build_pcms,
5459 .init = stac9872_vaio_init,
5460 .free = stac92xx_free,
5461 .unsol_event = stac9872_vaio_unsol_event,
5462#ifdef CONFIG_PM
5463 .resume = stac92xx_resume,
5464#endif
5465};
5466
Guillaume Munch6d859062006-08-22 17:15:47 +02005467enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
5468 CXD9872RD_VAIO,
5469 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
5470 STAC9872AK_VAIO,
5471 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
5472 STAC9872K_VAIO,
5473 /* AR Series. id=0x83847664 and subsys=104D1300 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005474 CXD9872AKD_VAIO,
5475 STAC_9872_MODELS,
5476};
Takashi Iwaidb064e52006-03-16 16:04:58 +01005477
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005478static const char *stac9872_models[STAC_9872_MODELS] = {
5479 [CXD9872RD_VAIO] = "vaio",
5480 [CXD9872AKD_VAIO] = "vaio-ar",
5481};
5482
5483static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5484 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
5485 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
5486 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
Tobin Davis68e22542007-03-12 11:36:39 +01005487 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
Takashi Iwaidb064e52006-03-16 16:04:58 +01005488 {}
5489};
5490
Guillaume Munch6d859062006-08-22 17:15:47 +02005491static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01005492{
5493 struct sigmatel_spec *spec;
5494 int board_config;
5495
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005496 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5497 stac9872_models,
5498 stac9872_cfg_tbl);
Takashi Iwaidb064e52006-03-16 16:04:58 +01005499 if (board_config < 0)
5500 /* unknown config, let generic-parser do its job... */
5501 return snd_hda_parse_generic_codec(codec);
5502
5503 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5504 if (spec == NULL)
5505 return -ENOMEM;
5506
5507 codec->spec = spec;
5508 switch (board_config) {
Guillaume Munch6d859062006-08-22 17:15:47 +02005509 case CXD9872RD_VAIO:
5510 case STAC9872AK_VAIO:
5511 case STAC9872K_VAIO:
Takashi Iwaidb064e52006-03-16 16:04:58 +01005512 spec->mixer = vaio_mixer;
5513 spec->init = vaio_init;
5514 spec->multiout.max_channels = 2;
5515 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5516 spec->multiout.dac_nids = vaio_dacs;
5517 spec->multiout.hp_nid = VAIO_HP_DAC;
5518 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5519 spec->adc_nids = vaio_adcs;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005520 spec->num_pwrs = 0;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005521 spec->input_mux = &vaio_mux;
5522 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005523 codec->patch_ops = stac9872_vaio_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005524 break;
Guillaume Munch6d859062006-08-22 17:15:47 +02005525
5526 case CXD9872AKD_VAIO:
5527 spec->mixer = vaio_ar_mixer;
5528 spec->init = vaio_ar_init;
5529 spec->multiout.max_channels = 2;
5530 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5531 spec->multiout.dac_nids = vaio_dacs;
5532 spec->multiout.hp_nid = VAIO_HP_DAC;
5533 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005534 spec->num_pwrs = 0;
Guillaume Munch6d859062006-08-22 17:15:47 +02005535 spec->adc_nids = vaio_adcs;
5536 spec->input_mux = &vaio_mux;
5537 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005538 codec->patch_ops = stac9872_patch_ops;
Guillaume Munch6d859062006-08-22 17:15:47 +02005539 break;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005540 }
5541
Takashi Iwaidb064e52006-03-16 16:04:58 +01005542 return 0;
5543}
5544
5545
5546/*
Matt2f2f4252005-04-13 14:45:30 +02005547 * patch entries
5548 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +01005549static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
Matt2f2f4252005-04-13 14:45:30 +02005550 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5551 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5552 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5553 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5554 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5555 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5556 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02005557 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5558 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5559 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5560 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5561 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5562 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01005563 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5564 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5565 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5566 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5567 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5568 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5569 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5570 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5571 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5572 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01005573 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5574 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5575 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5576 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5577 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5578 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02005579 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5580 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02005581 /* The following does not take into account .id=0x83847661 when subsys =
5582 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5583 * currently not fully supported.
5584 */
5585 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5586 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5587 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02005588 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5589 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5590 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5591 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5592 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5593 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5594 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5595 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005596 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005597 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5598 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005599 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01005600 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5601 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005602 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01005603 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5604 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5605 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5606 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5607 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5608 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5609 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5610 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02005611 {} /* terminator */
5612};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01005613
5614MODULE_ALIAS("snd-hda-codec-id:8384*");
5615MODULE_ALIAS("snd-hda-codec-id:111d*");
5616
5617MODULE_LICENSE("GPL");
5618MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
5619
5620static struct hda_codec_preset_list sigmatel_list = {
5621 .preset = snd_hda_preset_sigmatel,
5622 .owner = THIS_MODULE,
5623};
5624
5625static int __init patch_sigmatel_init(void)
5626{
5627 return snd_hda_add_codec_preset(&sigmatel_list);
5628}
5629
5630static void __exit patch_sigmatel_exit(void)
5631{
5632 snd_hda_delete_codec_preset(&sigmatel_list);
5633}
5634
5635module_init(patch_sigmatel_init)
5636module_exit(patch_sigmatel_exit)