blob: 1aa3f6cbcb9616620b436af5a6d66dd9f6a1aafe [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"
Harvey Harrison3c9a3202008-02-29 11:59:26 +010036#include "hda_patch.h"
Matthew Ranostay1cd22242008-07-18 18:20:52 +020037#include "hda_beep.h"
Matt2f2f4252005-04-13 14:45:30 +020038
Matthew Ranostayc39555d2008-11-14 17:46:22 -050039#define STAC_VREF_EVENT 0x00
Matthew Ranostay74aeaab2008-10-25 01:06:04 -040040#define STAC_INSERT_EVENT 0x10
Matthew Ranostaya64135a2008-01-10 16:55:06 +010041#define STAC_PWR_EVENT 0x20
42#define STAC_HP_EVENT 0x30
Matt4e550962005-07-04 17:51:39 +020043
Takashi Iwaif5fcc132006-11-24 17:07:44 +010044enum {
45 STAC_REF,
Tobin Davisbf277782008-02-03 20:31:47 +010046 STAC_9200_OQO,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020047 STAC_9200_DELL_D21,
48 STAC_9200_DELL_D22,
49 STAC_9200_DELL_D23,
50 STAC_9200_DELL_M21,
51 STAC_9200_DELL_M22,
52 STAC_9200_DELL_M23,
53 STAC_9200_DELL_M24,
54 STAC_9200_DELL_M25,
55 STAC_9200_DELL_M26,
56 STAC_9200_DELL_M27,
Takashi Iwai1194b5b2007-10-10 10:04:26 +020057 STAC_9200_GATEWAY,
Takashi Iwai117f2572008-03-18 09:53:23 +010058 STAC_9200_PANASONIC,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010059 STAC_9200_MODELS
60};
61
62enum {
63 STAC_9205_REF,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020064 STAC_9205_DELL_M42,
Tobin Davisae0a8ed2007-08-13 15:50:29 +020065 STAC_9205_DELL_M43,
66 STAC_9205_DELL_M44,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010067 STAC_9205_MODELS
68};
69
70enum {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010071 STAC_92HD73XX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010072 STAC_DELL_M6,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -050073 STAC_DELL_EQ,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010074 STAC_92HD73XX_MODELS
75};
76
77enum {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020078 STAC_92HD83XXX_REF,
79 STAC_92HD83XXX_MODELS
80};
81
82enum {
Matthew Ranostaye035b842007-11-06 11:53:55 +010083 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010084 STAC_DELL_M4_1,
85 STAC_DELL_M4_2,
Matthew Ranostay6a14f582008-09-12 12:02:30 -040086 STAC_HP_M4,
Matthew Ranostaye035b842007-11-06 11:53:55 +010087 STAC_92HD71BXX_MODELS
88};
89
90enum {
Tobin Davis8e21c342007-01-08 11:04:17 +010091 STAC_925x_REF,
92 STAC_M2_2,
93 STAC_MA6,
Tobin Davis2c11f952007-05-17 09:36:34 +020094 STAC_PA6,
Tobin Davis8e21c342007-01-08 11:04:17 +010095 STAC_925x_MODELS
96};
97
98enum {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010099 STAC_D945_REF,
100 STAC_D945GTP3,
101 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200102 STAC_INTEL_MAC_V1,
103 STAC_INTEL_MAC_V2,
104 STAC_INTEL_MAC_V3,
105 STAC_INTEL_MAC_V4,
106 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800107 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
108 * is given, one of the above models will be
109 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200110 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100111 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100112 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100113 STAC_MACBOOK_PRO_V1,
114 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200115 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200116 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300117 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200118 STAC_922X_DELL_D81,
119 STAC_922X_DELL_D82,
120 STAC_922X_DELL_M81,
121 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100122 STAC_922X_MODELS
123};
124
125enum {
126 STAC_D965_REF,
127 STAC_D965_3ST,
128 STAC_D965_5ST,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200129 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100130 STAC_DELL_BIOS,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100131 STAC_927X_MODELS
132};
Matt Porter403d1942005-11-29 15:00:51 +0100133
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400134struct sigmatel_event {
135 hda_nid_t nid;
136 int data;
137};
138
139struct sigmatel_jack {
140 hda_nid_t nid;
141 int type;
142 struct snd_jack *jack;
143};
144
Matt2f2f4252005-04-13 14:45:30 +0200145struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100146 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200147 unsigned int num_mixers;
148
Matt Porter403d1942005-11-29 15:00:51 +0100149 int board_config;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -0500150 unsigned int eapd_switch: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200151 unsigned int surr_switch: 1;
Matt Porter403d1942005-11-29 15:00:51 +0100152 unsigned int line_switch: 1;
153 unsigned int mic_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100154 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100155 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400156 unsigned int spdif_mute: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200157
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100158 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200159 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100160 unsigned int gpio_mask;
161 unsigned int gpio_dir;
162 unsigned int gpio_data;
163 unsigned int gpio_mute;
164
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200165 /* stream */
166 unsigned int stream_delay;
167
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100168 /* analog loopback */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100169 unsigned char aloopback_mask;
170 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200171
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100172 /* power management */
173 unsigned int num_pwrs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200174 unsigned int *pwr_mapping;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100175 hda_nid_t *pwr_nids;
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100176 hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100177
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400178 /* jack detection */
179 struct snd_array jacks;
180
181 /* events */
182 struct snd_array events;
183
Matt2f2f4252005-04-13 14:45:30 +0200184 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100185 struct hda_input_mux *mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400186 struct hda_input_mux *amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100187 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200188 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100189 hda_nid_t dac_nids[5];
Matt2f2f4252005-04-13 14:45:30 +0200190
191 /* capture */
192 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200193 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200194 hda_nid_t *mux_nids;
195 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200196 hda_nid_t *dmic_nids;
197 unsigned int num_dmics;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100198 hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100199 unsigned int num_dmuxes;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200200 hda_nid_t *smux_nids;
201 unsigned int num_smuxes;
Matthew Ranostay65973632008-09-16 10:39:37 -0400202 const char **spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200203
Mattdabbed62005-06-14 10:19:34 +0200204 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100205 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200206 hda_nid_t anabeep_nid;
207 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200208
Matt2f2f4252005-04-13 14:45:30 +0200209 /* pin widgets */
210 hda_nid_t *pin_nids;
211 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200212 unsigned int *pin_configs;
Richard Fish11b44bb2006-08-23 18:31:34 +0200213 unsigned int *bios_pin_configs;
Matt2f2f4252005-04-13 14:45:30 +0200214
215 /* codec specific stuff */
216 struct hda_verb *init;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100217 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200218
219 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200220 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100221 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200222 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100223 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200224 struct hda_input_mux *sinput_mux;
225 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400226 unsigned int cur_amux;
227 hda_nid_t *amp_nids;
228 unsigned int num_amps;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200229 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200230
Matt Porter403d1942005-11-29 15:00:51 +0100231 /* i/o switches */
232 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200233 unsigned int clfe_swap;
Takashi Iwaid7a89432008-11-12 09:48:04 +0100234 unsigned int hp_switch; /* NID of HP as line-out */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200235 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200236
Mattc7d4b2f2005-06-27 14:59:41 +0200237 struct hda_pcm pcm_rec[2]; /* PCM information */
238
239 /* dynamic controls and input_mux */
240 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200241 struct snd_array kctls;
Matt Porter8b657272006-10-26 17:12:59 +0200242 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200243 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200244 struct hda_input_mux private_smux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400245 struct hda_input_mux private_amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100246 struct hda_input_mux private_mono_mux;
Matt2f2f4252005-04-13 14:45:30 +0200247};
248
249static hda_nid_t stac9200_adc_nids[1] = {
250 0x03,
251};
252
253static hda_nid_t stac9200_mux_nids[1] = {
254 0x0c,
255};
256
257static hda_nid_t stac9200_dac_nids[1] = {
258 0x02,
259};
260
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100261static hda_nid_t stac92hd73xx_pwr_nids[8] = {
262 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
263 0x0f, 0x10, 0x11
264};
265
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400266static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
267 0x26, 0,
268};
269
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100270static hda_nid_t stac92hd73xx_adc_nids[2] = {
271 0x1a, 0x1b
272};
273
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400274#define DELL_M6_AMP 2
275static hda_nid_t stac92hd73xx_amp_nids[3] = {
276 0x0b, 0x0c, 0x0e
Matthew Ranostay89385032008-09-11 09:49:39 -0400277};
278
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100279#define STAC92HD73XX_NUM_DMICS 2
280static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
281 0x13, 0x14, 0
282};
283
284#define STAC92HD73_DAC_COUNT 5
285static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
286 0x15, 0x16, 0x17, 0x18, 0x19,
287};
288
289static hda_nid_t stac92hd73xx_mux_nids[4] = {
290 0x28, 0x29, 0x2a, 0x2b,
291};
292
293static hda_nid_t stac92hd73xx_dmux_nids[2] = {
294 0x20, 0x21,
295};
296
Matthew Ranostayd9737752008-09-07 12:03:41 +0200297static hda_nid_t stac92hd73xx_smux_nids[2] = {
298 0x22, 0x23,
299};
300
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200301#define STAC92HD83XXX_NUM_DMICS 2
302static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
303 0x11, 0x12, 0
304};
305
306#define STAC92HD81_DAC_COUNT 2
307#define STAC92HD83_DAC_COUNT 3
308static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = {
309 0x13, 0x14, 0x22,
310};
311
312static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
313 0x17, 0x18,
314};
315
316static hda_nid_t stac92hd83xxx_adc_nids[2] = {
317 0x15, 0x16,
318};
319
320static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
321 0xa, 0xb, 0xd, 0xe,
322};
323
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400324static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
325 0x1e, 0,
326};
327
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200328static unsigned int stac92hd83xxx_pwr_mapping[4] = {
329 0x03, 0x0c, 0x10, 0x40,
330};
331
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100332static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
333 0x0a, 0x0d, 0x0f
334};
335
Matthew Ranostaye035b842007-11-06 11:53:55 +0100336static hda_nid_t stac92hd71bxx_adc_nids[2] = {
337 0x12, 0x13,
338};
339
340static hda_nid_t stac92hd71bxx_mux_nids[2] = {
341 0x1a, 0x1b
342};
343
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400344static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
345 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100346};
347
Matthew Ranostayd9737752008-09-07 12:03:41 +0200348static hda_nid_t stac92hd71bxx_smux_nids[2] = {
349 0x24, 0x25,
350};
351
Takashi Iwaiaea7bb02008-02-25 18:26:41 +0100352static hda_nid_t stac92hd71bxx_dac_nids[1] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100353 0x10, /*0x11, */
354};
355
356#define STAC92HD71BXX_NUM_DMICS 2
357static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
358 0x18, 0x19, 0
359};
360
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400361static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
362 0x22, 0
363};
364
Tobin Davis8e21c342007-01-08 11:04:17 +0100365static hda_nid_t stac925x_adc_nids[1] = {
366 0x03,
367};
368
369static hda_nid_t stac925x_mux_nids[1] = {
370 0x0f,
371};
372
373static hda_nid_t stac925x_dac_nids[1] = {
374 0x02,
375};
376
Takashi Iwaif6e98522007-10-16 14:27:04 +0200377#define STAC925X_NUM_DMICS 1
378static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
379 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200380};
381
Takashi Iwai1697055e2007-12-18 18:05:52 +0100382static hda_nid_t stac925x_dmux_nids[1] = {
383 0x14,
384};
385
Matt2f2f4252005-04-13 14:45:30 +0200386static hda_nid_t stac922x_adc_nids[2] = {
387 0x06, 0x07,
388};
389
390static hda_nid_t stac922x_mux_nids[2] = {
391 0x12, 0x13,
392};
393
Matt Porter3cc08dc2006-01-23 15:27:49 +0100394static hda_nid_t stac927x_adc_nids[3] = {
395 0x07, 0x08, 0x09
396};
397
398static hda_nid_t stac927x_mux_nids[3] = {
399 0x15, 0x16, 0x17
400};
401
Matthew Ranostayd9737752008-09-07 12:03:41 +0200402static hda_nid_t stac927x_smux_nids[1] = {
403 0x21,
404};
405
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100406static hda_nid_t stac927x_dac_nids[6] = {
407 0x02, 0x03, 0x04, 0x05, 0x06, 0
408};
409
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100410static hda_nid_t stac927x_dmux_nids[1] = {
411 0x1b,
412};
413
Matthew Ranostay7f168592007-10-18 17:38:17 +0200414#define STAC927X_NUM_DMICS 2
415static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
416 0x13, 0x14, 0
417};
418
Matthew Ranostay65973632008-09-16 10:39:37 -0400419static const char *stac927x_spdif_labels[5] = {
420 "Digital Playback", "ADAT", "Analog Mux 1",
421 "Analog Mux 2", "Analog Mux 3"
422};
423
Matt Porterf3302a52006-07-31 12:49:34 +0200424static hda_nid_t stac9205_adc_nids[2] = {
425 0x12, 0x13
426};
427
428static hda_nid_t stac9205_mux_nids[2] = {
429 0x19, 0x1a
430};
431
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100432static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100433 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100434};
435
Matthew Ranostayd9737752008-09-07 12:03:41 +0200436static hda_nid_t stac9205_smux_nids[1] = {
437 0x21,
438};
439
Takashi Iwaif6e98522007-10-16 14:27:04 +0200440#define STAC9205_NUM_DMICS 2
441static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
442 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200443};
444
Mattc7d4b2f2005-06-27 14:59:41 +0200445static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200446 0x08, 0x09, 0x0d, 0x0e,
447 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200448};
449
Tobin Davis8e21c342007-01-08 11:04:17 +0100450static hda_nid_t stac925x_pin_nids[8] = {
451 0x07, 0x08, 0x0a, 0x0b,
452 0x0c, 0x0d, 0x10, 0x11,
453};
454
Matt2f2f4252005-04-13 14:45:30 +0200455static hda_nid_t stac922x_pin_nids[10] = {
456 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
457 0x0f, 0x10, 0x11, 0x15, 0x1b,
458};
459
Matthew Ranostaya7662642008-02-21 07:51:14 +0100460static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100461 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
462 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200463 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100464};
465
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200466static hda_nid_t stac92hd83xxx_pin_nids[14] = {
467 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
468 0x0f, 0x10, 0x11, 0x12, 0x13,
469 0x1d, 0x1e, 0x1f, 0x20
470};
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400471static hda_nid_t stac92hd71bxx_pin_nids[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100472 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
473 0x0f, 0x14, 0x18, 0x19, 0x1e,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400474 0x1f,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100475};
476
Matt Porter3cc08dc2006-01-23 15:27:49 +0100477static hda_nid_t stac927x_pin_nids[14] = {
478 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
479 0x0f, 0x10, 0x11, 0x12, 0x13,
480 0x14, 0x21, 0x22, 0x23,
481};
482
Matt Porterf3302a52006-07-31 12:49:34 +0200483static hda_nid_t stac9205_pin_nids[12] = {
484 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
485 0x0f, 0x14, 0x16, 0x17, 0x18,
486 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200487};
488
Matthew Ranostay89385032008-09-11 09:49:39 -0400489#define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
490
491static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
492 struct snd_ctl_elem_value *ucontrol)
493{
494 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
495 struct sigmatel_spec *spec = codec->spec;
496 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
497
498 kcontrol->private_value ^= get_amp_nid(kcontrol);
499 kcontrol->private_value |= nid;
500
501 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
502}
503
504static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
505 struct snd_ctl_elem_value *ucontrol)
506{
507 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
508 struct sigmatel_spec *spec = codec->spec;
509 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
510
511 kcontrol->private_value ^= get_amp_nid(kcontrol);
512 kcontrol->private_value |= nid;
513
514 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
515}
516
Matt Porter8b657272006-10-26 17:12:59 +0200517static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
518 struct snd_ctl_elem_info *uinfo)
519{
520 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
521 struct sigmatel_spec *spec = codec->spec;
522 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
523}
524
525static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
526 struct snd_ctl_elem_value *ucontrol)
527{
528 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
529 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100530 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200531
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100532 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200533 return 0;
534}
535
536static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
537 struct snd_ctl_elem_value *ucontrol)
538{
539 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
540 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100541 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200542
543 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100544 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200545}
546
Matthew Ranostayd9737752008-09-07 12:03:41 +0200547static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
548 struct snd_ctl_elem_info *uinfo)
549{
550 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
551 struct sigmatel_spec *spec = codec->spec;
552 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
553}
554
555static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
556 struct snd_ctl_elem_value *ucontrol)
557{
558 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
559 struct sigmatel_spec *spec = codec->spec;
560 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
561
562 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
563 return 0;
564}
565
566static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
567 struct snd_ctl_elem_value *ucontrol)
568{
569 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
570 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400571 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200572 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400573 int err, val;
574 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200575
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400576 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200577 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400578 if (err < 0)
579 return err;
580
581 if (spec->spdif_mute) {
582 if (smux_idx == 0)
583 nid = spec->multiout.dig_out_nid;
584 else
585 nid = codec->slave_dig_outs[smux_idx - 1];
586 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
587 val = AMP_OUT_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400588 else
Takashi Iwaic1e99bd2008-10-29 08:03:42 +0100589 val = AMP_OUT_UNMUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400590 /* un/mute SPDIF out */
591 snd_hda_codec_write_cache(codec, nid, 0,
592 AC_VERB_SET_AMP_GAIN_MUTE, val);
593 }
594 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200595}
596
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100597static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200598{
599 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
600 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200601 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200602}
603
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100604static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200605{
606 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
607 struct sigmatel_spec *spec = codec->spec;
608 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
609
610 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
611 return 0;
612}
613
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100614static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200615{
616 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
617 struct sigmatel_spec *spec = codec->spec;
618 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
619
Mattc7d4b2f2005-06-27 14:59:41 +0200620 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200621 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
622}
623
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100624static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
625 struct snd_ctl_elem_info *uinfo)
626{
627 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
628 struct sigmatel_spec *spec = codec->spec;
629 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
630}
631
632static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
633 struct snd_ctl_elem_value *ucontrol)
634{
635 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
636 struct sigmatel_spec *spec = codec->spec;
637
638 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
639 return 0;
640}
641
642static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
643 struct snd_ctl_elem_value *ucontrol)
644{
645 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
646 struct sigmatel_spec *spec = codec->spec;
647
648 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
649 spec->mono_nid, &spec->cur_mmux);
650}
651
Matthew Ranostay89385032008-09-11 09:49:39 -0400652static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
653 struct snd_ctl_elem_info *uinfo)
654{
655 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
656 struct sigmatel_spec *spec = codec->spec;
657 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
658}
659
660static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
661 struct snd_ctl_elem_value *ucontrol)
662{
663 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
664 struct sigmatel_spec *spec = codec->spec;
665
666 ucontrol->value.enumerated.item[0] = spec->cur_amux;
667 return 0;
668}
669
670static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
671 struct snd_ctl_elem_value *ucontrol)
672{
673 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
674 struct sigmatel_spec *spec = codec->spec;
675 struct snd_kcontrol *ctl =
676 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
677 if (!ctl)
678 return -EINVAL;
679
680 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
681 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
682
683 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
684 0, &spec->cur_amux);
685}
686
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200687#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
688
689static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
690 struct snd_ctl_elem_value *ucontrol)
691{
692 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100693 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200694 struct sigmatel_spec *spec = codec->spec;
695
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100696 ucontrol->value.integer.value[0] = !!(spec->aloopback &
697 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200698 return 0;
699}
700
701static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
702 struct snd_ctl_elem_value *ucontrol)
703{
704 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
705 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100706 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200707 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100708 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200709
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100710 idx_val = spec->aloopback_mask << idx;
711 if (ucontrol->value.integer.value[0])
712 val = spec->aloopback | idx_val;
713 else
714 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100715 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200716 return 0;
717
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100718 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200719
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100720 /* Only return the bits defined by the shift value of the
721 * first two bytes of the mask
722 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200723 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100724 kcontrol->private_value & 0xFFFF, 0x0);
725 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200726
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100727 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200728 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100729 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200730 } else {
731 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100732 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200733 }
734
735 snd_hda_codec_write_cache(codec, codec->afg, 0,
736 kcontrol->private_value >> 16, dac_mode);
737
738 return 1;
739}
740
Mattc7d4b2f2005-06-27 14:59:41 +0200741static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200742 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200743 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200744 {}
745};
746
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200747static struct hda_verb stac9200_eapd_init[] = {
748 /* set dac0mux for dac converter */
749 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
750 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
751 {}
752};
753
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100754static struct hda_verb stac92hd73xx_6ch_core_init[] = {
755 /* set master volume and direct control */
756 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
757 /* setup audio connections */
758 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
759 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
760 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
761 /* setup adcs to point to mixer */
762 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
763 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100764 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
765 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
766 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
767 /* setup import muxs */
768 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
769 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
770 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
771 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
772 {}
773};
774
Matthew Ranostayd654a662008-03-14 08:46:51 +0100775static struct hda_verb dell_eq_core_init[] = {
776 /* set master volume to max value without distortion
777 * and direct control */
778 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
779 /* setup audio connections */
780 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
Matthew Ranostayf7cf0a72008-09-13 10:36:58 -0400781 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x02},
782 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100783 /* setup adcs to point to mixer */
784 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
785 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
786 /* setup import muxs */
787 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
788 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
789 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
790 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
791 {}
792};
793
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100794static struct hda_verb dell_m6_core_init[] = {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -0500795 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100796 /* setup audio connections */
Matthew Ranostay7747ecc2008-03-10 11:30:04 +0100797 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
798 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100799 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
800 /* setup adcs to point to mixer */
801 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
802 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
803 /* setup import muxs */
804 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
805 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
806 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
807 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
808 {}
809};
810
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100811static struct hda_verb stac92hd73xx_8ch_core_init[] = {
812 /* set master volume and direct control */
813 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
814 /* setup audio connections */
815 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
816 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
817 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
818 /* connect hp ports to dac3 */
819 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
820 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
821 /* setup adcs to point to mixer */
822 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
823 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100824 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
825 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
826 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
827 /* setup import muxs */
828 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
829 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
830 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
831 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
832 {}
833};
834
835static struct hda_verb stac92hd73xx_10ch_core_init[] = {
836 /* set master volume and direct control */
837 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
838 /* setup audio connections */
839 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
840 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
841 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
842 /* dac3 is connected to import3 mux */
843 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
844 /* connect hp ports to dac4 */
845 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
846 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
847 /* setup adcs to point to mixer */
848 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
849 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100850 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
851 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
852 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
853 /* setup import muxs */
854 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
855 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
856 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
857 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
858 {}
859};
860
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200861static struct hda_verb stac92hd83xxx_core_init[] = {
862 /* start of config #1 */
863 { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3},
864
865 /* start of config #2 */
866 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
867 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
868 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
869
870 /* power state controls amps */
871 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
872};
873
Matthew Ranostaye035b842007-11-06 11:53:55 +0100874static struct hda_verb stac92hd71bxx_core_init[] = {
875 /* set master volume and direct control */
876 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
877 /* connect headphone jack to dac1 */
878 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100879 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
880 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
881 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
882 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100883};
884
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400885#define HD_DISABLE_PORTF 2
Matthew Ranostay541eee82007-12-14 12:08:04 +0100886static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200887 /* start of config #1 */
888
889 /* connect port 0f to audio mixer */
890 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200891 /* unmute right and left channels for node 0x0f */
892 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
893 /* start of config #2 */
894
Matthew Ranostay541eee82007-12-14 12:08:04 +0100895 /* set master volume and direct control */
896 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
897 /* connect headphone jack to dac1 */
898 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200899 /* unmute right and left channels for nodes 0x0a, 0xd */
Matthew Ranostaye035b842007-11-06 11:53:55 +0100900 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
901 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100902 {}
903};
904
Tobin Davis8e21c342007-01-08 11:04:17 +0100905static struct hda_verb stac925x_core_init[] = {
906 /* set dac0mux for dac converter */
907 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
908 {}
909};
910
Mattc7d4b2f2005-06-27 14:59:41 +0200911static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200912 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200913 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200914 {}
915};
916
Tobin Davis93ed1502006-09-01 21:03:12 +0200917static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200918 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200919 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200920 /* unmute node 0x1b */
921 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
922 /* select node 0x03 as DAC */
923 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
924 {}
925};
926
Matt Porter3cc08dc2006-01-23 15:27:49 +0100927static struct hda_verb stac927x_core_init[] = {
928 /* set master volume and direct control */
929 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200930 /* enable analog pc beep path */
931 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100932 {}
933};
934
Matt Porterf3302a52006-07-31 12:49:34 +0200935static struct hda_verb stac9205_core_init[] = {
936 /* set master volume and direct control */
937 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200938 /* enable analog pc beep path */
939 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200940 {}
941};
942
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100943#define STAC_MONO_MUX \
944 { \
945 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
946 .name = "Mono Mux", \
947 .count = 1, \
948 .info = stac92xx_mono_mux_enum_info, \
949 .get = stac92xx_mono_mux_enum_get, \
950 .put = stac92xx_mono_mux_enum_put, \
951 }
952
Matthew Ranostay89385032008-09-11 09:49:39 -0400953#define STAC_AMP_MUX \
954 { \
955 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
956 .name = "Amp Selector Capture Switch", \
957 .count = 1, \
958 .info = stac92xx_amp_mux_enum_info, \
959 .get = stac92xx_amp_mux_enum_get, \
960 .put = stac92xx_amp_mux_enum_put, \
961 }
962
963#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
964 { \
965 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
966 .name = xname, \
967 .index = 0, \
968 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
969 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
970 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
971 .info = stac92xx_amp_volume_info, \
972 .get = stac92xx_amp_volume_get, \
973 .put = stac92xx_amp_volume_put, \
974 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
975 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
976 }
977
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200978#define STAC_INPUT_SOURCE(cnt) \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200979 { \
980 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
981 .name = "Input Source", \
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200982 .count = cnt, \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200983 .info = stac92xx_mux_enum_info, \
984 .get = stac92xx_mux_enum_get, \
985 .put = stac92xx_mux_enum_put, \
986 }
987
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100988#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200989 { \
990 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
991 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100992 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200993 .info = stac92xx_aloopback_info, \
994 .get = stac92xx_aloopback_get, \
995 .put = stac92xx_aloopback_put, \
996 .private_value = verb_read | (verb_write << 16), \
997 }
998
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100999static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +02001000 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
1001 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001002 STAC_INPUT_SOURCE(1),
Matt2f2f4252005-04-13 14:45:30 +02001003 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
1004 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001005 { } /* end */
1006};
1007
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04001008#define DELL_M6_MIXER 6
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001009static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04001010 /* start of config #1 */
1011 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1012 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1013
1014 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1015 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1016
1017 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1018 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1019
1020 /* start of config #2 */
1021 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1022 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1023
1024 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1025 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1026
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001027 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1028
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001029 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1030 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1031
1032 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1033 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1034
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001035 { } /* end */
1036};
1037
1038static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001039 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1040
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001041 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1042 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1043
1044 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1045 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1046
1047 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1048 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1049
1050 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1051 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1052
1053 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1054 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1055
1056 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1057 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1058
1059 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1060 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1061 { } /* end */
1062};
1063
1064static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001065 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1066
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001067 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1068 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1069
1070 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1071 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1072
1073 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1074 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1075
1076 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1077 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1078
1079 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1080 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1081
1082 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1083 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1084
1085 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1086 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1087 { } /* end */
1088};
1089
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001090
1091static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1092 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1093 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1094
1095 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1096 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1097
1098 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT),
1099 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
1100
1101 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
1102 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
1103
1104 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
1105 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
1106
1107 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
1108 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
1109
1110 /*
1111 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
1112 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
1113 */
1114 { } /* end */
1115};
1116
Matthew Ranostay541eee82007-12-14 12:08:04 +01001117static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001118 STAC_INPUT_SOURCE(2),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001119 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001120
Matthew Ranostay9b359472007-11-07 13:03:12 +01001121 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1122 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay9b359472007-11-07 13:03:12 +01001123
1124 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1125 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001126 /* analog pc-beep replaced with digital beep support */
1127 /*
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001128 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1129 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001130 */
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001131
Matthew Ranostay687cb982008-10-11 13:52:43 -04001132 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1133 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001134
Matthew Ranostay687cb982008-10-11 13:52:43 -04001135 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1136 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001137
1138 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1139 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1140
1141 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1142 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001143 { } /* end */
1144};
1145
Matthew Ranostay541eee82007-12-14 12:08:04 +01001146static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +01001147 STAC_INPUT_SOURCE(2),
1148 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1149
Matthew Ranostay541eee82007-12-14 12:08:04 +01001150 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1151 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001152
1153 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1154 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001155 { } /* end */
1156};
1157
Tobin Davis8e21c342007-01-08 11:04:17 +01001158static struct snd_kcontrol_new stac925x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001159 STAC_INPUT_SOURCE(1),
Tobin Davis8e21c342007-01-08 11:04:17 +01001160 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +02001161 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001162 { } /* end */
1163};
1164
Takashi Iwaid1d985f2006-11-23 19:27:12 +01001165static struct snd_kcontrol_new stac9205_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001166 STAC_INPUT_SOURCE(2),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001167 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001168
1169 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1170 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001171
1172 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1173 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001174 { } /* end */
1175};
1176
1177/* This needs to be generated dynamically based on sequence */
1178static struct snd_kcontrol_new stac922x_mixer[] = {
1179 STAC_INPUT_SOURCE(2),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001180 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1181 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001182
1183 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1184 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001185 { } /* end */
1186};
1187
1188
1189static struct snd_kcontrol_new stac927x_mixer[] = {
1190 STAC_INPUT_SOURCE(3),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001191 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001192
1193 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1194 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001195
1196 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1197 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001198
1199 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1200 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
Matt Porterf3302a52006-07-31 12:49:34 +02001201 { } /* end */
1202};
1203
Takashi Iwai1697055e2007-12-18 18:05:52 +01001204static struct snd_kcontrol_new stac_dmux_mixer = {
1205 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1206 .name = "Digital Input Source",
1207 /* count set later */
1208 .info = stac92xx_dmux_enum_info,
1209 .get = stac92xx_dmux_enum_get,
1210 .put = stac92xx_dmux_enum_put,
1211};
1212
Matthew Ranostayd9737752008-09-07 12:03:41 +02001213static struct snd_kcontrol_new stac_smux_mixer = {
1214 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001215 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001216 /* count set later */
1217 .info = stac92xx_smux_enum_info,
1218 .get = stac92xx_smux_enum_get,
1219 .put = stac92xx_smux_enum_put,
1220};
1221
Takashi Iwai2134ea42008-01-10 16:53:55 +01001222static const char *slave_vols[] = {
1223 "Front Playback Volume",
1224 "Surround Playback Volume",
1225 "Center Playback Volume",
1226 "LFE Playback Volume",
1227 "Side Playback Volume",
1228 "Headphone Playback Volume",
1229 "Headphone Playback Volume",
1230 "Speaker Playback Volume",
1231 "External Speaker Playback Volume",
1232 "Speaker2 Playback Volume",
1233 NULL
1234};
1235
1236static const char *slave_sws[] = {
1237 "Front Playback Switch",
1238 "Surround Playback Switch",
1239 "Center Playback Switch",
1240 "LFE Playback Switch",
1241 "Side Playback Switch",
1242 "Headphone Playback Switch",
1243 "Headphone Playback Switch",
1244 "Speaker Playback Switch",
1245 "External Speaker Playback Switch",
1246 "Speaker2 Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001247 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001248 NULL
1249};
1250
Takashi Iwai603c4012008-07-30 15:01:44 +02001251static void stac92xx_free_kctls(struct hda_codec *codec);
1252
Matt2f2f4252005-04-13 14:45:30 +02001253static int stac92xx_build_controls(struct hda_codec *codec)
1254{
1255 struct sigmatel_spec *spec = codec->spec;
1256 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001257 int i;
Matt2f2f4252005-04-13 14:45:30 +02001258
1259 err = snd_hda_add_new_ctls(codec, spec->mixer);
1260 if (err < 0)
1261 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001262
1263 for (i = 0; i < spec->num_mixers; i++) {
1264 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1265 if (err < 0)
1266 return err;
1267 }
Takashi Iwai1697055e2007-12-18 18:05:52 +01001268 if (spec->num_dmuxes > 0) {
1269 stac_dmux_mixer.count = spec->num_dmuxes;
Takashi Iwaid13bd412008-07-30 15:01:45 +02001270 err = snd_hda_ctl_add(codec,
Takashi Iwai1697055e2007-12-18 18:05:52 +01001271 snd_ctl_new1(&stac_dmux_mixer, codec));
1272 if (err < 0)
1273 return err;
1274 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001275 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001276 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1277 struct hda_input_mux *smux = &spec->private_smux;
1278 /* check for mute support on SPDIF out */
1279 if (wcaps & AC_WCAP_OUT_AMP) {
1280 smux->items[smux->num_items].label = "Off";
1281 smux->items[smux->num_items].index = 0;
1282 smux->num_items++;
1283 spec->spdif_mute = 1;
1284 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001285 stac_smux_mixer.count = spec->num_smuxes;
1286 err = snd_ctl_add(codec->bus->card,
1287 snd_ctl_new1(&stac_smux_mixer, codec));
1288 if (err < 0)
1289 return err;
1290 }
Mattc7d4b2f2005-06-27 14:59:41 +02001291
Mattdabbed62005-06-14 10:19:34 +02001292 if (spec->multiout.dig_out_nid) {
1293 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1294 if (err < 0)
1295 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001296 err = snd_hda_create_spdif_share_sw(codec,
1297 &spec->multiout);
1298 if (err < 0)
1299 return err;
1300 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001301 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001302 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001303 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1304 if (err < 0)
1305 return err;
1306 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001307
1308 /* if we have no master control, let's create it */
1309 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001310 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001311 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001312 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001313 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001314 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001315 if (err < 0)
1316 return err;
1317 }
1318 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1319 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1320 NULL, slave_sws);
1321 if (err < 0)
1322 return err;
1323 }
1324
Takashi Iwai603c4012008-07-30 15:01:44 +02001325 stac92xx_free_kctls(codec); /* no longer needed */
Mattdabbed62005-06-14 10:19:34 +02001326 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001327}
1328
Matt Porter403d1942005-11-29 15:00:51 +01001329static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001330 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001331 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1332};
1333
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001334/*
1335 STAC 9200 pin configs for
1336 102801A8
1337 102801DE
1338 102801E8
1339*/
1340static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001341 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1342 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001343};
1344
1345/*
1346 STAC 9200 pin configs for
1347 102801C0
1348 102801C1
1349*/
1350static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001351 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1352 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001353};
1354
1355/*
1356 STAC 9200 pin configs for
1357 102801C4 (Dell Dimension E310)
1358 102801C5
1359 102801C7
1360 102801D9
1361 102801DA
1362 102801E3
1363*/
1364static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001365 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1366 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001367};
1368
1369
1370/*
1371 STAC 9200-32 pin configs for
1372 102801B5 (Dell Inspiron 630m)
1373 102801D8 (Dell Inspiron 640m)
1374*/
1375static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001376 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1377 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001378};
1379
1380/*
1381 STAC 9200-32 pin configs for
1382 102801C2 (Dell Latitude D620)
1383 102801C8
1384 102801CC (Dell Latitude D820)
1385 102801D4
1386 102801D6
1387*/
1388static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001389 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1390 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001391};
1392
1393/*
1394 STAC 9200-32 pin configs for
1395 102801CE (Dell XPS M1710)
1396 102801CF (Dell Precision M90)
1397*/
1398static unsigned int dell9200_m23_pin_configs[8] = {
1399 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1400 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1401};
1402
1403/*
1404 STAC 9200-32 pin configs for
1405 102801C9
1406 102801CA
1407 102801CB (Dell Latitude 120L)
1408 102801D3
1409*/
1410static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001411 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1412 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001413};
1414
1415/*
1416 STAC 9200-32 pin configs for
1417 102801BD (Dell Inspiron E1505n)
1418 102801EE
1419 102801EF
1420*/
1421static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001422 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1423 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001424};
1425
1426/*
1427 STAC 9200-32 pin configs for
1428 102801F5 (Dell Inspiron 1501)
1429 102801F6
1430*/
1431static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001432 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1433 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001434};
1435
1436/*
1437 STAC 9200-32
1438 102801CD (Dell Inspiron E1705/9400)
1439*/
1440static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001441 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1442 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001443};
1444
Tobin Davisbf277782008-02-03 20:31:47 +01001445static unsigned int oqo9200_pin_configs[8] = {
1446 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1447 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1448};
1449
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001450
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001451static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1452 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001453 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001454 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1455 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1456 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1457 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1458 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1459 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1460 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1461 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1462 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1463 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001464 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001465};
1466
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001467static const char *stac9200_models[STAC_9200_MODELS] = {
1468 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001469 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001470 [STAC_9200_DELL_D21] = "dell-d21",
1471 [STAC_9200_DELL_D22] = "dell-d22",
1472 [STAC_9200_DELL_D23] = "dell-d23",
1473 [STAC_9200_DELL_M21] = "dell-m21",
1474 [STAC_9200_DELL_M22] = "dell-m22",
1475 [STAC_9200_DELL_M23] = "dell-m23",
1476 [STAC_9200_DELL_M24] = "dell-m24",
1477 [STAC_9200_DELL_M25] = "dell-m25",
1478 [STAC_9200_DELL_M26] = "dell-m26",
1479 [STAC_9200_DELL_M27] = "dell-m27",
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001480 [STAC_9200_GATEWAY] = "gateway",
Takashi Iwai117f2572008-03-18 09:53:23 +01001481 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001482};
1483
1484static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1485 /* SigmaTel reference board */
1486 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1487 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001488 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001489 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1490 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001491 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001492 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1493 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1494 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1495 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1496 "unknown Dell", STAC_9200_DELL_D22),
1497 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1498 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001499 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001500 "Dell Latitude D620", STAC_9200_DELL_M22),
1501 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1502 "unknown Dell", STAC_9200_DELL_D23),
1503 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1504 "unknown Dell", STAC_9200_DELL_D23),
1505 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1506 "unknown Dell", STAC_9200_DELL_M22),
1507 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1508 "unknown Dell", STAC_9200_DELL_M24),
1509 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1510 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001511 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001512 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001513 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001514 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001515 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001516 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001517 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001518 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001519 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001520 "Dell Precision M90", STAC_9200_DELL_M23),
1521 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1522 "unknown Dell", STAC_9200_DELL_M22),
1523 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1524 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001525 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001526 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001527 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001528 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1529 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1530 "unknown Dell", STAC_9200_DELL_D23),
1531 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1532 "unknown Dell", STAC_9200_DELL_D23),
1533 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1534 "unknown Dell", STAC_9200_DELL_D21),
1535 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1536 "unknown Dell", STAC_9200_DELL_D23),
1537 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1538 "unknown Dell", STAC_9200_DELL_D21),
1539 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1540 "unknown Dell", STAC_9200_DELL_M25),
1541 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1542 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001543 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001544 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1545 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1546 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001547 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001548 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001549 /* Gateway machines needs EAPD to be set on resume */
1550 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1551 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1552 STAC_9200_GATEWAY),
1553 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1554 STAC_9200_GATEWAY),
Tobin Davisbf277782008-02-03 20:31:47 +01001555 /* OQO Mobile */
1556 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001557 {} /* terminator */
1558};
1559
Tobin Davis8e21c342007-01-08 11:04:17 +01001560static unsigned int ref925x_pin_configs[8] = {
1561 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001562 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001563};
1564
1565static unsigned int stac925x_MA6_pin_configs[8] = {
1566 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1567 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1568};
1569
Tobin Davis2c11f952007-05-17 09:36:34 +02001570static unsigned int stac925x_PA6_pin_configs[8] = {
1571 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1572 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1573};
1574
Tobin Davis8e21c342007-01-08 11:04:17 +01001575static unsigned int stac925xM2_2_pin_configs[8] = {
Steve Longerbeam7353e142007-05-29 14:36:17 +02001576 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1577 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001578};
1579
1580static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1581 [STAC_REF] = ref925x_pin_configs,
1582 [STAC_M2_2] = stac925xM2_2_pin_configs,
1583 [STAC_MA6] = stac925x_MA6_pin_configs,
Tobin Davis2c11f952007-05-17 09:36:34 +02001584 [STAC_PA6] = stac925x_PA6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001585};
1586
1587static const char *stac925x_models[STAC_925x_MODELS] = {
1588 [STAC_REF] = "ref",
1589 [STAC_M2_2] = "m2-2",
1590 [STAC_MA6] = "m6",
Tobin Davis2c11f952007-05-17 09:36:34 +02001591 [STAC_PA6] = "pa6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001592};
1593
1594static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1595 /* SigmaTel reference board */
1596 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001597 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Tobin Davis8e21c342007-01-08 11:04:17 +01001598 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1599 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1600 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
Tobin Davis2c11f952007-05-17 09:36:34 +02001601 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
Tobin Davis8e21c342007-01-08 11:04:17 +01001602 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1603 {} /* terminator */
1604};
1605
Matthew Ranostaya7662642008-02-21 07:51:14 +01001606static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001607 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1608 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1609 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001610 0x01452050,
1611};
1612
1613static unsigned int dell_m6_pin_configs[13] = {
1614 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001615 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001616 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1617 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001618};
1619
1620static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001621 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1622 [STAC_DELL_M6] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001623 [STAC_DELL_EQ] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001624};
1625
1626static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1627 [STAC_92HD73XX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001628 [STAC_DELL_M6] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001629 [STAC_DELL_EQ] = "dell-eq",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001630};
1631
1632static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1633 /* SigmaTel reference board */
1634 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001635 "DFI LanParty", STAC_92HD73XX_REF),
1636 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1637 "unknown Dell", STAC_DELL_M6),
1638 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1639 "unknown Dell", STAC_DELL_M6),
1640 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1641 "unknown Dell", STAC_DELL_M6),
1642 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1643 "unknown Dell", STAC_DELL_M6),
1644 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1645 "unknown Dell", STAC_DELL_M6),
1646 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1647 "unknown Dell", STAC_DELL_M6),
1648 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1649 "unknown Dell", STAC_DELL_M6),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001650 {} /* terminator */
1651};
1652
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001653static unsigned int ref92hd83xxx_pin_configs[14] = {
1654 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1655 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1656 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1657 0x01451160, 0x98560170,
1658};
1659
1660static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1661 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1662};
1663
1664static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1665 [STAC_92HD83XXX_REF] = "ref",
1666};
1667
1668static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1669 /* SigmaTel reference board */
1670 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1671 "DFI LanParty", STAC_92HD71BXX_REF),
1672};
1673
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001674static unsigned int ref92hd71bxx_pin_configs[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001675 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001676 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001677 0x90a000f0, 0x01452050, 0x01452050,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001678};
1679
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001680static unsigned int dell_m4_1_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001681 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001682 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001683 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001684};
1685
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001686static unsigned int dell_m4_2_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001687 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1688 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001689 0x40f000f0, 0x044413b0, 0x044413b0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001690};
1691
Matthew Ranostaye035b842007-11-06 11:53:55 +01001692static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1693 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001694 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1695 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001696 [STAC_HP_M4] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001697};
1698
1699static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1700 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001701 [STAC_DELL_M4_1] = "dell-m4-1",
1702 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001703 [STAC_HP_M4] = "hp-m4",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001704};
1705
1706static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1707 /* SigmaTel reference board */
1708 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1709 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001710 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1711 "unknown HP", STAC_HP_M4),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001712 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1713 "unknown Dell", STAC_DELL_M4_1),
1714 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1715 "unknown Dell", STAC_DELL_M4_1),
1716 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1717 "unknown Dell", STAC_DELL_M4_1),
1718 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1719 "unknown Dell", STAC_DELL_M4_1),
1720 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1721 "unknown Dell", STAC_DELL_M4_1),
1722 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1723 "unknown Dell", STAC_DELL_M4_1),
1724 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1725 "unknown Dell", STAC_DELL_M4_1),
1726 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1727 "unknown Dell", STAC_DELL_M4_2),
1728 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1729 "unknown Dell", STAC_DELL_M4_2),
1730 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1731 "unknown Dell", STAC_DELL_M4_2),
1732 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1733 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001734 {} /* terminator */
1735};
1736
Matt Porter403d1942005-11-29 15:00:51 +01001737static unsigned int ref922x_pin_configs[10] = {
1738 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1739 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001740 0x40000100, 0x40000100,
1741};
1742
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001743/*
1744 STAC 922X pin configs for
1745 102801A7
1746 102801AB
1747 102801A9
1748 102801D1
1749 102801D2
1750*/
1751static unsigned int dell_922x_d81_pin_configs[10] = {
1752 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1753 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1754 0x01813122, 0x400001f2,
1755};
1756
1757/*
1758 STAC 922X pin configs for
1759 102801AC
1760 102801D0
1761*/
1762static unsigned int dell_922x_d82_pin_configs[10] = {
1763 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1764 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1765 0x01813122, 0x400001f1,
1766};
1767
1768/*
1769 STAC 922X pin configs for
1770 102801BF
1771*/
1772static unsigned int dell_922x_m81_pin_configs[10] = {
1773 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1774 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1775 0x40C003f1, 0x405003f0,
1776};
1777
1778/*
1779 STAC 9221 A1 pin configs for
1780 102801D7 (Dell XPS M1210)
1781*/
1782static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001783 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1784 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001785 0x508003f3, 0x405003f4,
1786};
1787
Matt Porter403d1942005-11-29 15:00:51 +01001788static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001789 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001790 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1791 0x02a19120, 0x40000100,
1792};
1793
1794static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001795 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1796 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001797 0x02a19320, 0x40000100,
1798};
1799
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001800static unsigned int intel_mac_v1_pin_configs[10] = {
1801 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1802 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001803 0x400000fc, 0x400000fb,
1804};
1805
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001806static unsigned int intel_mac_v2_pin_configs[10] = {
1807 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1808 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001809 0x400000fc, 0x400000fb,
1810};
1811
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001812static unsigned int intel_mac_v3_pin_configs[10] = {
1813 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1814 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1815 0x400000fc, 0x400000fb,
1816};
1817
1818static unsigned int intel_mac_v4_pin_configs[10] = {
1819 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1820 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1821 0x400000fc, 0x400000fb,
1822};
1823
1824static unsigned int intel_mac_v5_pin_configs[10] = {
1825 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1826 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1827 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001828};
1829
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001830static unsigned int ecs202_pin_configs[10] = {
1831 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1832 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1833 0x9037012e, 0x40e000f2,
1834};
Takashi Iwai76c08822007-06-19 12:17:42 +02001835
Takashi Iwai19039bd2006-06-28 15:52:16 +02001836static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001837 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001838 [STAC_D945GTP3] = d945gtp3_pin_configs,
1839 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001840 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1841 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1842 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1843 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1844 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001845 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001846 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001847 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1848 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1849 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1850 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1851 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1852 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001853 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001854 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1855 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1856 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1857 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001858};
1859
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001860static const char *stac922x_models[STAC_922X_MODELS] = {
1861 [STAC_D945_REF] = "ref",
1862 [STAC_D945GTP5] = "5stack",
1863 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001864 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1865 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1866 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1867 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1868 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001869 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001870 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001871 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001872 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001873 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1874 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001875 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001876 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001877 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001878 [STAC_922X_DELL_D81] = "dell-d81",
1879 [STAC_922X_DELL_D82] = "dell-d82",
1880 [STAC_922X_DELL_M81] = "dell-m81",
1881 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001882};
1883
1884static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1885 /* SigmaTel reference board */
1886 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1887 "DFI LanParty", STAC_D945_REF),
1888 /* Intel 945G based systems */
1889 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1890 "Intel D945G", STAC_D945GTP3),
1891 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1892 "Intel D945G", STAC_D945GTP3),
1893 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1894 "Intel D945G", STAC_D945GTP3),
1895 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1896 "Intel D945G", STAC_D945GTP3),
1897 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1898 "Intel D945G", STAC_D945GTP3),
1899 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1900 "Intel D945G", STAC_D945GTP3),
1901 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1902 "Intel D945G", STAC_D945GTP3),
1903 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1904 "Intel D945G", STAC_D945GTP3),
1905 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1906 "Intel D945G", STAC_D945GTP3),
1907 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1908 "Intel D945G", STAC_D945GTP3),
1909 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1910 "Intel D945G", STAC_D945GTP3),
1911 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1912 "Intel D945G", STAC_D945GTP3),
1913 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1914 "Intel D945G", STAC_D945GTP3),
1915 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1916 "Intel D945G", STAC_D945GTP3),
1917 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1918 "Intel D945G", STAC_D945GTP3),
1919 /* Intel D945G 5-stack systems */
1920 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1921 "Intel D945G", STAC_D945GTP5),
1922 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1923 "Intel D945G", STAC_D945GTP5),
1924 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1925 "Intel D945G", STAC_D945GTP5),
1926 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1927 "Intel D945G", STAC_D945GTP5),
1928 /* Intel 945P based systems */
1929 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1930 "Intel D945P", STAC_D945GTP3),
1931 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1932 "Intel D945P", STAC_D945GTP3),
1933 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1934 "Intel D945P", STAC_D945GTP3),
1935 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1936 "Intel D945P", STAC_D945GTP3),
1937 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1938 "Intel D945P", STAC_D945GTP3),
1939 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1940 "Intel D945P", STAC_D945GTP5),
1941 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08001942 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001943 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001944 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001945 /* Dell systems */
1946 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1947 "unknown Dell", STAC_922X_DELL_D81),
1948 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1949 "unknown Dell", STAC_922X_DELL_D81),
1950 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1951 "unknown Dell", STAC_922X_DELL_D81),
1952 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1953 "unknown Dell", STAC_922X_DELL_D82),
1954 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1955 "unknown Dell", STAC_922X_DELL_M81),
1956 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1957 "unknown Dell", STAC_922X_DELL_D82),
1958 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1959 "unknown Dell", STAC_922X_DELL_D81),
1960 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1961 "unknown Dell", STAC_922X_DELL_D81),
1962 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1963 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001964 /* ECS/PC Chips boards */
1965 SND_PCI_QUIRK(0x1019, 0x2144,
1966 "ECS/PC chips", STAC_ECS_202),
1967 SND_PCI_QUIRK(0x1019, 0x2608,
1968 "ECS/PC chips", STAC_ECS_202),
1969 SND_PCI_QUIRK(0x1019, 0x2633,
1970 "ECS/PC chips P17G/1333", STAC_ECS_202),
1971 SND_PCI_QUIRK(0x1019, 0x2811,
1972 "ECS/PC chips", STAC_ECS_202),
1973 SND_PCI_QUIRK(0x1019, 0x2812,
1974 "ECS/PC chips", STAC_ECS_202),
1975 SND_PCI_QUIRK(0x1019, 0x2813,
1976 "ECS/PC chips", STAC_ECS_202),
1977 SND_PCI_QUIRK(0x1019, 0x2814,
1978 "ECS/PC chips", STAC_ECS_202),
1979 SND_PCI_QUIRK(0x1019, 0x2815,
1980 "ECS/PC chips", STAC_ECS_202),
1981 SND_PCI_QUIRK(0x1019, 0x2816,
1982 "ECS/PC chips", STAC_ECS_202),
1983 SND_PCI_QUIRK(0x1019, 0x2817,
1984 "ECS/PC chips", STAC_ECS_202),
1985 SND_PCI_QUIRK(0x1019, 0x2818,
1986 "ECS/PC chips", STAC_ECS_202),
1987 SND_PCI_QUIRK(0x1019, 0x2819,
1988 "ECS/PC chips", STAC_ECS_202),
1989 SND_PCI_QUIRK(0x1019, 0x2820,
1990 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01001991 {} /* terminator */
1992};
1993
Matt Porter3cc08dc2006-01-23 15:27:49 +01001994static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02001995 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1996 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1997 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1998 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01001999};
2000
Tobin Davis93ed1502006-09-01 21:03:12 +02002001static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002002 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2003 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2004 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2005 0x40000100, 0x40000100
2006};
2007
Tobin Davis93ed1502006-09-01 21:03:12 +02002008static unsigned int d965_5st_pin_configs[14] = {
2009 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2010 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2011 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2012 0x40000100, 0x40000100
2013};
2014
Tobin Davis4ff076e2007-08-07 11:48:12 +02002015static unsigned int dell_3st_pin_configs[14] = {
2016 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2017 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002018 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002019 0x40c003fc, 0x40000100
2020};
2021
Tobin Davis93ed1502006-09-01 21:03:12 +02002022static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002023 [STAC_D965_REF] = ref927x_pin_configs,
2024 [STAC_D965_3ST] = d965_3st_pin_configs,
2025 [STAC_D965_5ST] = d965_5st_pin_configs,
2026 [STAC_DELL_3ST] = dell_3st_pin_configs,
2027 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002028};
2029
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002030static const char *stac927x_models[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002031 [STAC_D965_REF] = "ref",
2032 [STAC_D965_3ST] = "3stack",
2033 [STAC_D965_5ST] = "5stack",
2034 [STAC_DELL_3ST] = "dell-3stack",
2035 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002036};
2037
2038static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2039 /* SigmaTel reference board */
2040 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2041 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002042 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002043 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2044 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002045 /* 965 based 3 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002046 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
2047 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
2048 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
2049 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
2050 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
2051 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
2052 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
2053 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
2054 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
2055 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
2056 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
2057 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
2058 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
2059 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
2060 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
2061 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002062 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002063 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002064 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002065 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2066 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002067 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002068 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2069 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002070 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02002071 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002072 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2073 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2074 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2075 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002076 /* 965 based 5 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002077 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2078 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2079 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2080 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2081 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2082 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2083 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2084 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2085 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002086 {} /* terminator */
2087};
2088
Matt Porterf3302a52006-07-31 12:49:34 +02002089static unsigned int ref9205_pin_configs[12] = {
2090 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002091 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002092 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002093};
2094
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002095/*
2096 STAC 9205 pin configs for
2097 102801F1
2098 102801F2
2099 102801FC
2100 102801FD
2101 10280204
2102 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002103 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002104*/
2105static unsigned int dell_9205_m42_pin_configs[12] = {
2106 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2107 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2108 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2109};
2110
2111/*
2112 STAC 9205 pin configs for
2113 102801F9
2114 102801FA
2115 102801FE
2116 102801FF (Dell Precision M4300)
2117 10280206
2118 10280200
2119 10280201
2120*/
2121static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002122 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2123 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2124 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2125};
2126
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002127static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002128 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2129 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2130 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2131};
2132
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002133static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002134 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002135 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2136 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2137 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Matt Porterf3302a52006-07-31 12:49:34 +02002138};
2139
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002140static const char *stac9205_models[STAC_9205_MODELS] = {
2141 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002142 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002143 [STAC_9205_DELL_M43] = "dell-m43",
2144 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002145};
2146
2147static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2148 /* SigmaTel reference board */
2149 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2150 "DFI LanParty", STAC_9205_REF),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002151 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2152 "unknown Dell", STAC_9205_DELL_M42),
2153 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2154 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002155 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002156 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002157 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2158 "Dell Precision", STAC_9205_DELL_M43),
2159 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2160 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002161 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2162 "unknown Dell", STAC_9205_DELL_M42),
2163 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2164 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002165 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2166 "Dell Precision", STAC_9205_DELL_M43),
2167 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002168 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002169 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2170 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002171 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2172 "Dell Precision", STAC_9205_DELL_M43),
2173 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2174 "Dell Precision", STAC_9205_DELL_M43),
2175 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2176 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002177 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2178 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002179 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2180 "Dell Vostro 1500", STAC_9205_DELL_M42),
Matt Porterf3302a52006-07-31 12:49:34 +02002181 {} /* terminator */
2182};
2183
Richard Fish11b44bb2006-08-23 18:31:34 +02002184static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2185{
2186 int i;
2187 struct sigmatel_spec *spec = codec->spec;
2188
2189 if (! spec->bios_pin_configs) {
2190 spec->bios_pin_configs = kcalloc(spec->num_pins,
2191 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
2192 if (! spec->bios_pin_configs)
2193 return -ENOMEM;
2194 }
2195
2196 for (i = 0; i < spec->num_pins; i++) {
2197 hda_nid_t nid = spec->pin_nids[i];
2198 unsigned int pin_cfg;
2199
2200 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2201 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2202 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2203 nid, pin_cfg);
2204 spec->bios_pin_configs[i] = pin_cfg;
2205 }
2206
2207 return 0;
2208}
2209
Matthew Ranostay87d48362007-07-17 11:52:24 +02002210static void stac92xx_set_config_reg(struct hda_codec *codec,
2211 hda_nid_t pin_nid, unsigned int pin_config)
2212{
2213 int i;
2214 snd_hda_codec_write(codec, pin_nid, 0,
2215 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2216 pin_config & 0x000000ff);
2217 snd_hda_codec_write(codec, pin_nid, 0,
2218 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2219 (pin_config & 0x0000ff00) >> 8);
2220 snd_hda_codec_write(codec, pin_nid, 0,
2221 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2222 (pin_config & 0x00ff0000) >> 16);
2223 snd_hda_codec_write(codec, pin_nid, 0,
2224 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2225 pin_config >> 24);
2226 i = snd_hda_codec_read(codec, pin_nid, 0,
2227 AC_VERB_GET_CONFIG_DEFAULT,
2228 0x00);
2229 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2230 pin_nid, i);
2231}
2232
Matt2f2f4252005-04-13 14:45:30 +02002233static void stac92xx_set_config_regs(struct hda_codec *codec)
2234{
2235 int i;
2236 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002237
Matthew Ranostay87d48362007-07-17 11:52:24 +02002238 if (!spec->pin_configs)
2239 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002240
Matthew Ranostay87d48362007-07-17 11:52:24 +02002241 for (i = 0; i < spec->num_pins; i++)
2242 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2243 spec->pin_configs[i]);
Matt2f2f4252005-04-13 14:45:30 +02002244}
Matt2f2f4252005-04-13 14:45:30 +02002245
Matt2f2f4252005-04-13 14:45:30 +02002246/*
2247 * Analog playback callbacks
2248 */
2249static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2250 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002251 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002252{
2253 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002254 if (spec->stream_delay)
2255 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002256 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2257 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002258}
2259
2260static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2261 struct hda_codec *codec,
2262 unsigned int stream_tag,
2263 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002264 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002265{
2266 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002267 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002268}
2269
2270static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2271 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002272 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002273{
2274 struct sigmatel_spec *spec = codec->spec;
2275 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2276}
2277
2278/*
Mattdabbed62005-06-14 10:19:34 +02002279 * Digital playback callbacks
2280 */
2281static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2282 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002283 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002284{
2285 struct sigmatel_spec *spec = codec->spec;
2286 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2287}
2288
2289static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2290 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002291 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002292{
2293 struct sigmatel_spec *spec = codec->spec;
2294 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2295}
2296
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002297static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2298 struct hda_codec *codec,
2299 unsigned int stream_tag,
2300 unsigned int format,
2301 struct snd_pcm_substream *substream)
2302{
2303 struct sigmatel_spec *spec = codec->spec;
2304 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2305 stream_tag, format, substream);
2306}
2307
Mattdabbed62005-06-14 10:19:34 +02002308
2309/*
Matt2f2f4252005-04-13 14:45:30 +02002310 * Analog capture callbacks
2311 */
2312static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2313 struct hda_codec *codec,
2314 unsigned int stream_tag,
2315 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002316 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002317{
2318 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002319 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002320
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002321 if (spec->powerdown_adcs) {
2322 msleep(40);
2323 snd_hda_codec_write_cache(codec, nid, 0,
2324 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2325 }
2326 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002327 return 0;
2328}
2329
2330static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2331 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002332 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002333{
2334 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002335 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002336
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002337 snd_hda_codec_cleanup_stream(codec, nid);
2338 if (spec->powerdown_adcs)
2339 snd_hda_codec_write_cache(codec, nid, 0,
2340 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002341 return 0;
2342}
2343
Mattdabbed62005-06-14 10:19:34 +02002344static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2345 .substreams = 1,
2346 .channels_min = 2,
2347 .channels_max = 2,
2348 /* NID is set in stac92xx_build_pcms */
2349 .ops = {
2350 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002351 .close = stac92xx_dig_playback_pcm_close,
2352 .prepare = stac92xx_dig_playback_pcm_prepare
Mattdabbed62005-06-14 10:19:34 +02002353 },
2354};
2355
2356static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2357 .substreams = 1,
2358 .channels_min = 2,
2359 .channels_max = 2,
2360 /* NID is set in stac92xx_build_pcms */
2361};
2362
Matt2f2f4252005-04-13 14:45:30 +02002363static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2364 .substreams = 1,
2365 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002366 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002367 .nid = 0x02, /* NID to query formats and rates */
2368 .ops = {
2369 .open = stac92xx_playback_pcm_open,
2370 .prepare = stac92xx_playback_pcm_prepare,
2371 .cleanup = stac92xx_playback_pcm_cleanup
2372 },
2373};
2374
Matt Porter3cc08dc2006-01-23 15:27:49 +01002375static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2376 .substreams = 1,
2377 .channels_min = 2,
2378 .channels_max = 2,
2379 .nid = 0x06, /* NID to query formats and rates */
2380 .ops = {
2381 .open = stac92xx_playback_pcm_open,
2382 .prepare = stac92xx_playback_pcm_prepare,
2383 .cleanup = stac92xx_playback_pcm_cleanup
2384 },
2385};
2386
Matt2f2f4252005-04-13 14:45:30 +02002387static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002388 .channels_min = 2,
2389 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002390 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002391 .ops = {
2392 .prepare = stac92xx_capture_pcm_prepare,
2393 .cleanup = stac92xx_capture_pcm_cleanup
2394 },
2395};
2396
2397static int stac92xx_build_pcms(struct hda_codec *codec)
2398{
2399 struct sigmatel_spec *spec = codec->spec;
2400 struct hda_pcm *info = spec->pcm_rec;
2401
2402 codec->num_pcms = 1;
2403 codec->pcm_info = info;
2404
Mattc7d4b2f2005-06-27 14:59:41 +02002405 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002406 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Matt2f2f4252005-04-13 14:45:30 +02002407 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002408 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002409 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002410
2411 if (spec->alt_switch) {
2412 codec->num_pcms++;
2413 info++;
2414 info->name = "STAC92xx Analog Alt";
2415 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2416 }
Matt2f2f4252005-04-13 14:45:30 +02002417
Mattdabbed62005-06-14 10:19:34 +02002418 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2419 codec->num_pcms++;
2420 info++;
2421 info->name = "STAC92xx Digital";
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002422 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Mattdabbed62005-06-14 10:19:34 +02002423 if (spec->multiout.dig_out_nid) {
2424 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2425 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2426 }
2427 if (spec->dig_in_nid) {
2428 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2429 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2430 }
2431 }
2432
Matt2f2f4252005-04-13 14:45:30 +02002433 return 0;
2434}
2435
Takashi Iwaic960a032006-03-23 17:06:28 +01002436static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2437{
2438 unsigned int pincap = snd_hda_param_read(codec, nid,
2439 AC_PAR_PIN_CAP);
2440 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2441 if (pincap & AC_PINCAP_VREF_100)
2442 return AC_PINCTL_VREF_100;
2443 if (pincap & AC_PINCAP_VREF_80)
2444 return AC_PINCTL_VREF_80;
2445 if (pincap & AC_PINCAP_VREF_50)
2446 return AC_PINCTL_VREF_50;
2447 if (pincap & AC_PINCAP_VREF_GRD)
2448 return AC_PINCTL_VREF_GRD;
2449 return 0;
2450}
2451
Matt Porter403d1942005-11-29 15:00:51 +01002452static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2453
2454{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002455 snd_hda_codec_write_cache(codec, nid, 0,
2456 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002457}
2458
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002459#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2460
2461static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2462 struct snd_ctl_elem_value *ucontrol)
2463{
2464 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2465 struct sigmatel_spec *spec = codec->spec;
2466
Takashi Iwaid7a89432008-11-12 09:48:04 +01002467 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002468 return 0;
2469}
2470
2471static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2472 struct snd_ctl_elem_value *ucontrol)
2473{
2474 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2475 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002476 int nid = kcontrol->private_value;
2477
2478 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002479
2480 /* check to be sure that the ports are upto date with
2481 * switch changes
2482 */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04002483 codec->patch_ops.unsol_event(codec, (STAC_HP_EVENT | nid) << 26);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002484
2485 return 1;
2486}
2487
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002488#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002489
2490static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2491{
2492 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2493 struct sigmatel_spec *spec = codec->spec;
2494 int io_idx = kcontrol-> private_value & 0xff;
2495
2496 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2497 return 0;
2498}
2499
2500static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2501{
2502 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2503 struct sigmatel_spec *spec = codec->spec;
2504 hda_nid_t nid = kcontrol->private_value >> 8;
2505 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002506 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002507
2508 spec->io_switch[io_idx] = val;
2509
2510 if (val)
2511 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002512 else {
2513 unsigned int pinctl = AC_PINCTL_IN_EN;
2514 if (io_idx) /* set VREF for mic */
2515 pinctl |= stac92xx_get_vref(codec, nid);
2516 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2517 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002518
2519 /* check the auto-mute again: we need to mute/unmute the speaker
2520 * appropriately according to the pin direction
2521 */
2522 if (spec->hp_detect)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04002523 codec->patch_ops.unsol_event(codec,
2524 (STAC_HP_EVENT | nid) << 26);
Jiang Zhe40c1d302007-11-12 13:05:16 +01002525
Matt Porter403d1942005-11-29 15:00:51 +01002526 return 1;
2527}
2528
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002529#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2530
2531static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2532 struct snd_ctl_elem_value *ucontrol)
2533{
2534 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2535 struct sigmatel_spec *spec = codec->spec;
2536
2537 ucontrol->value.integer.value[0] = spec->clfe_swap;
2538 return 0;
2539}
2540
2541static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2542 struct snd_ctl_elem_value *ucontrol)
2543{
2544 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2545 struct sigmatel_spec *spec = codec->spec;
2546 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002547 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002548
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002549 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002550 return 0;
2551
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002552 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002553
2554 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2555 spec->clfe_swap ? 0x4 : 0x0);
2556
2557 return 1;
2558}
2559
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002560#define STAC_CODEC_HP_SWITCH(xname) \
2561 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2562 .name = xname, \
2563 .index = 0, \
2564 .info = stac92xx_hp_switch_info, \
2565 .get = stac92xx_hp_switch_get, \
2566 .put = stac92xx_hp_switch_put, \
2567 }
2568
Matt Porter403d1942005-11-29 15:00:51 +01002569#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2570 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2571 .name = xname, \
2572 .index = 0, \
2573 .info = stac92xx_io_switch_info, \
2574 .get = stac92xx_io_switch_get, \
2575 .put = stac92xx_io_switch_put, \
2576 .private_value = xpval, \
2577 }
2578
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002579#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2580 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2581 .name = xname, \
2582 .index = 0, \
2583 .info = stac92xx_clfe_switch_info, \
2584 .get = stac92xx_clfe_switch_get, \
2585 .put = stac92xx_clfe_switch_put, \
2586 .private_value = xpval, \
2587 }
Matt Porter403d1942005-11-29 15:00:51 +01002588
Mattc7d4b2f2005-06-27 14:59:41 +02002589enum {
2590 STAC_CTL_WIDGET_VOL,
2591 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002592 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002593 STAC_CTL_WIDGET_AMP_MUX,
2594 STAC_CTL_WIDGET_AMP_VOL,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002595 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002596 STAC_CTL_WIDGET_IO_SWITCH,
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002597 STAC_CTL_WIDGET_CLFE_SWITCH
Mattc7d4b2f2005-06-27 14:59:41 +02002598};
2599
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002600static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002601 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2602 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002603 STAC_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002604 STAC_AMP_MUX,
2605 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002606 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002607 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002608 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002609};
2610
2611/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002612static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2613 struct snd_kcontrol_new *ktemp,
2614 int idx, const char *name,
2615 unsigned long val)
Mattc7d4b2f2005-06-27 14:59:41 +02002616{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002617 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002618
Takashi Iwai603c4012008-07-30 15:01:44 +02002619 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2620 knew = snd_array_new(&spec->kctls);
2621 if (!knew)
2622 return -ENOMEM;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002623 *knew = *ktemp;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002624 knew->index = idx;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002625 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002626 if (!knew->name)
Mattc7d4b2f2005-06-27 14:59:41 +02002627 return -ENOMEM;
2628 knew->private_value = val;
Mattc7d4b2f2005-06-27 14:59:41 +02002629 return 0;
2630}
2631
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002632static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2633 int type, int idx, const char *name,
2634 unsigned long val)
2635{
2636 return stac92xx_add_control_temp(spec,
2637 &stac92xx_control_templates[type],
2638 idx, name, val);
2639}
2640
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002641
2642/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002643static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2644 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002645{
2646 return stac92xx_add_control_idx(spec, type, 0, name, val);
2647}
2648
Matt Porter403d1942005-11-29 15:00:51 +01002649/* flag inputs as additional dynamic lineouts */
2650static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2651{
2652 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002653 unsigned int wcaps, wtype;
2654 int i, num_dacs = 0;
2655
2656 /* use the wcaps cache to count all DACs available for line-outs */
2657 for (i = 0; i < codec->num_nodes; i++) {
2658 wcaps = codec->wcaps[i];
2659 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002660
Steve Longerbeam7b043892007-05-03 20:50:03 +02002661 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2662 num_dacs++;
2663 }
Matt Porter403d1942005-11-29 15:00:51 +01002664
Steve Longerbeam7b043892007-05-03 20:50:03 +02002665 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2666
Matt Porter403d1942005-11-29 15:00:51 +01002667 switch (cfg->line_outs) {
2668 case 3:
2669 /* add line-in as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002670 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002671 cfg->line_out_pins[cfg->line_outs] =
2672 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002673 spec->line_switch = 1;
2674 cfg->line_outs++;
2675 }
2676 break;
2677 case 2:
2678 /* add line-in as clfe and mic as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002679 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002680 cfg->line_out_pins[cfg->line_outs] =
2681 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002682 spec->line_switch = 1;
2683 cfg->line_outs++;
2684 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002685 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002686 cfg->line_out_pins[cfg->line_outs] =
2687 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002688 spec->mic_switch = 1;
2689 cfg->line_outs++;
2690 }
2691 break;
2692 case 1:
2693 /* add line-in as surr and mic as clfe */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002694 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002695 cfg->line_out_pins[cfg->line_outs] =
2696 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002697 spec->line_switch = 1;
2698 cfg->line_outs++;
2699 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002700 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002701 cfg->line_out_pins[cfg->line_outs] =
2702 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002703 spec->mic_switch = 1;
2704 cfg->line_outs++;
2705 }
2706 break;
2707 }
2708
2709 return 0;
2710}
2711
Steve Longerbeam7b043892007-05-03 20:50:03 +02002712
2713static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2714{
2715 int i;
2716
2717 for (i = 0; i < spec->multiout.num_dacs; i++) {
2718 if (spec->multiout.dac_nids[i] == nid)
2719 return 1;
2720 }
2721
2722 return 0;
2723}
2724
Matt Porter3cc08dc2006-01-23 15:27:49 +01002725/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02002726 * Fill in the dac_nids table from the parsed pin configuration
2727 * This function only works when every pin in line_out_pins[]
2728 * contains atleast one DAC in its connection list. Some 92xx
2729 * codecs are not connected directly to a DAC, such as the 9200
2730 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002731 */
Takashi Iwai19039bd2006-06-28 15:52:16 +02002732static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaidf802952007-07-02 19:18:00 +02002733 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002734{
2735 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002736 int i, j, conn_len = 0;
2737 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2738 unsigned int wcaps, wtype;
2739
Mattc7d4b2f2005-06-27 14:59:41 +02002740 for (i = 0; i < cfg->line_outs; i++) {
2741 nid = cfg->line_out_pins[i];
Steve Longerbeam7b043892007-05-03 20:50:03 +02002742 conn_len = snd_hda_get_connections(codec, nid, conn,
2743 HDA_MAX_CONNECTIONS);
2744 for (j = 0; j < conn_len; j++) {
2745 wcaps = snd_hda_param_read(codec, conn[j],
2746 AC_PAR_AUDIO_WIDGET_CAP);
2747 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002748 if (wtype != AC_WID_AUD_OUT ||
2749 (wcaps & AC_WCAP_DIGITAL))
2750 continue;
2751 /* conn[j] is a DAC routed to this line-out */
2752 if (!is_in_dac_nids(spec, conn[j]))
2753 break;
2754 }
2755
2756 if (j == conn_len) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002757 if (spec->multiout.num_dacs > 0) {
2758 /* we have already working output pins,
2759 * so let's drop the broken ones again
2760 */
2761 cfg->line_outs = spec->multiout.num_dacs;
2762 break;
2763 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002764 /* error out, no available DAC found */
2765 snd_printk(KERN_ERR
2766 "%s: No available DAC for pin 0x%x\n",
2767 __func__, nid);
2768 return -ENODEV;
2769 }
2770
2771 spec->multiout.dac_nids[i] = conn[j];
2772 spec->multiout.num_dacs++;
2773 if (conn_len > 1) {
2774 /* select this DAC in the pin's input mux */
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002775 snd_hda_codec_write_cache(codec, nid, 0,
2776 AC_VERB_SET_CONNECT_SEL, j);
Steve Longerbeam7b043892007-05-03 20:50:03 +02002777
2778 }
Mattc7d4b2f2005-06-27 14:59:41 +02002779 }
2780
Steve Longerbeam7b043892007-05-03 20:50:03 +02002781 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2782 spec->multiout.num_dacs,
2783 spec->multiout.dac_nids[0],
2784 spec->multiout.dac_nids[1],
2785 spec->multiout.dac_nids[2],
2786 spec->multiout.dac_nids[3],
2787 spec->multiout.dac_nids[4]);
Mattc7d4b2f2005-06-27 14:59:41 +02002788 return 0;
2789}
2790
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002791/* create volume control/switch for the given prefx type */
2792static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2793{
2794 char name[32];
2795 int err;
2796
2797 sprintf(name, "%s Playback Volume", pfx);
2798 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2799 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2800 if (err < 0)
2801 return err;
2802 sprintf(name, "%s Playback Switch", pfx);
2803 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2804 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2805 if (err < 0)
2806 return err;
2807 return 0;
2808}
2809
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002810static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2811{
2812 if (!spec->multiout.hp_nid)
2813 spec->multiout.hp_nid = nid;
2814 else if (spec->multiout.num_dacs > 4) {
2815 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2816 return 1;
2817 } else {
2818 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2819 spec->multiout.num_dacs++;
2820 }
2821 return 0;
2822}
2823
2824static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2825{
2826 if (is_in_dac_nids(spec, nid))
2827 return 1;
2828 if (spec->multiout.hp_nid == nid)
2829 return 1;
2830 return 0;
2831}
2832
Mattc7d4b2f2005-06-27 14:59:41 +02002833/* add playback controls from the parsed DAC table */
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002834static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
Takashi Iwai19039bd2006-06-28 15:52:16 +02002835 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002836{
Takashi Iwai19039bd2006-06-28 15:52:16 +02002837 static const char *chname[4] = {
2838 "Front", "Surround", NULL /*CLFE*/, "Side"
2839 };
Matthew Ranostayd21995e2008-10-13 13:22:45 -04002840 hda_nid_t nid = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02002841 int i, err;
2842
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002843 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002844 unsigned int wid_caps, pincap;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002845
2846
Takashi Iwai40ac8c42008-02-29 14:16:17 +01002847 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
Matt Porter403d1942005-11-29 15:00:51 +01002848 if (!spec->multiout.dac_nids[i])
Mattc7d4b2f2005-06-27 14:59:41 +02002849 continue;
2850
2851 nid = spec->multiout.dac_nids[i];
2852
2853 if (i == 2) {
2854 /* Center/LFE */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002855 err = create_controls(spec, "Center", nid, 1);
2856 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002857 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002858 err = create_controls(spec, "LFE", nid, 2);
2859 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002860 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002861
2862 wid_caps = get_wcaps(codec, nid);
2863
2864 if (wid_caps & AC_WCAP_LR_SWAP) {
2865 err = stac92xx_add_control(spec,
2866 STAC_CTL_WIDGET_CLFE_SWITCH,
2867 "Swap Center/LFE Playback Switch", nid);
2868
2869 if (err < 0)
2870 return err;
2871 }
2872
Mattc7d4b2f2005-06-27 14:59:41 +02002873 } else {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002874 err = create_controls(spec, chname[i], nid, 3);
2875 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002876 return err;
2877 }
2878 }
2879
Matthew Ranostayfedb7562008-09-23 21:46:30 -04002880 if ((spec->multiout.num_dacs - cfg->line_outs) > 0 &&
2881 cfg->hp_outs && !spec->multiout.hp_nid)
2882 spec->multiout.hp_nid = nid;
2883
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002884 if (cfg->hp_outs > 1) {
2885 err = stac92xx_add_control(spec,
2886 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01002887 "Headphone as Line Out Switch",
2888 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002889 if (err < 0)
2890 return err;
2891 }
2892
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002893 if (spec->line_switch) {
2894 nid = cfg->input_pins[AUTO_PIN_LINE];
2895 pincap = snd_hda_param_read(codec, nid,
2896 AC_PAR_PIN_CAP);
2897 if (pincap & AC_PINCAP_OUT) {
2898 err = stac92xx_add_control(spec,
2899 STAC_CTL_WIDGET_IO_SWITCH,
2900 "Line In as Output Switch", nid << 8);
2901 if (err < 0)
2902 return err;
2903 }
2904 }
Matt Porter403d1942005-11-29 15:00:51 +01002905
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002906 if (spec->mic_switch) {
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002907 unsigned int def_conf;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002908 unsigned int mic_pin = AUTO_PIN_MIC;
2909again:
2910 nid = cfg->input_pins[mic_pin];
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002911 def_conf = snd_hda_codec_read(codec, nid, 0,
2912 AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002913 /* some laptops have an internal analog microphone
2914 * which can't be used as a output */
2915 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2916 pincap = snd_hda_param_read(codec, nid,
2917 AC_PAR_PIN_CAP);
2918 if (pincap & AC_PINCAP_OUT) {
2919 err = stac92xx_add_control(spec,
2920 STAC_CTL_WIDGET_IO_SWITCH,
2921 "Mic as Output Switch", (nid << 8) | 1);
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002922 nid = snd_hda_codec_read(codec, nid, 0,
2923 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2924 if (!check_in_dac_nids(spec, nid))
2925 add_spec_dacs(spec, nid);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002926 if (err < 0)
2927 return err;
2928 }
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002929 } else if (mic_pin == AUTO_PIN_MIC) {
2930 mic_pin = AUTO_PIN_FRONT_MIC;
2931 goto again;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002932 }
2933 }
Matt Porter403d1942005-11-29 15:00:51 +01002934
Mattc7d4b2f2005-06-27 14:59:41 +02002935 return 0;
2936}
2937
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002938/* add playback controls for Speaker and HP outputs */
2939static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2940 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002941{
2942 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02002943 hda_nid_t nid;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002944 int i, old_num_dacs, err;
Mattc7d4b2f2005-06-27 14:59:41 +02002945
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002946 old_num_dacs = spec->multiout.num_dacs;
2947 for (i = 0; i < cfg->hp_outs; i++) {
2948 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2949 if (wid_caps & AC_WCAP_UNSOL_CAP)
2950 spec->hp_detect = 1;
2951 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2952 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2953 if (check_in_dac_nids(spec, nid))
2954 nid = 0;
2955 if (! nid)
Mattc7d4b2f2005-06-27 14:59:41 +02002956 continue;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002957 add_spec_dacs(spec, nid);
2958 }
2959 for (i = 0; i < cfg->speaker_outs; i++) {
Steve Longerbeam7b043892007-05-03 20:50:03 +02002960 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002961 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2962 if (check_in_dac_nids(spec, nid))
2963 nid = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002964 if (! nid)
2965 continue;
2966 add_spec_dacs(spec, nid);
Mattc7d4b2f2005-06-27 14:59:41 +02002967 }
Matthew Ranostay1b290a52007-07-12 15:17:34 +02002968 for (i = 0; i < cfg->line_outs; i++) {
2969 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2970 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2971 if (check_in_dac_nids(spec, nid))
2972 nid = 0;
2973 if (! nid)
2974 continue;
2975 add_spec_dacs(spec, nid);
2976 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002977 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2978 static const char *pfxs[] = {
2979 "Speaker", "External Speaker", "Speaker2",
2980 };
2981 err = create_controls(spec, pfxs[i - old_num_dacs],
2982 spec->multiout.dac_nids[i], 3);
2983 if (err < 0)
2984 return err;
2985 }
2986 if (spec->multiout.hp_nid) {
Takashi Iwai2626a262008-03-14 09:18:32 +01002987 err = create_controls(spec, "Headphone",
2988 spec->multiout.hp_nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002989 if (err < 0)
2990 return err;
2991 }
Mattc7d4b2f2005-06-27 14:59:41 +02002992
2993 return 0;
2994}
2995
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002996/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002997static const char *stac92xx_mono_labels[4] = {
2998 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002999};
3000
3001/* create mono mux for mono out on capable codecs */
3002static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3003{
3004 struct sigmatel_spec *spec = codec->spec;
3005 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3006 int i, num_cons;
3007 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3008
3009 num_cons = snd_hda_get_connections(codec,
3010 spec->mono_nid,
3011 con_lst,
3012 HDA_MAX_NUM_INPUTS);
3013 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3014 return -EINVAL;
3015
3016 for (i = 0; i < num_cons; i++) {
3017 mono_mux->items[mono_mux->num_items].label =
3018 stac92xx_mono_labels[i];
3019 mono_mux->items[mono_mux->num_items].index = i;
3020 mono_mux->num_items++;
3021 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003022
3023 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3024 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003025}
3026
Matthew Ranostay89385032008-09-11 09:49:39 -04003027/* labels for amp mux outputs */
3028static const char *stac92xx_amp_labels[3] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04003029 "Front Microphone", "Microphone", "Line In",
Matthew Ranostay89385032008-09-11 09:49:39 -04003030};
3031
3032/* create amp out controls mux on capable codecs */
3033static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3034{
3035 struct sigmatel_spec *spec = codec->spec;
3036 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3037 int i, err;
3038
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003039 for (i = 0; i < spec->num_amps; i++) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003040 amp_mux->items[amp_mux->num_items].label =
3041 stac92xx_amp_labels[i];
3042 amp_mux->items[amp_mux->num_items].index = i;
3043 amp_mux->num_items++;
3044 }
3045
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003046 if (spec->num_amps > 1) {
3047 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3048 "Amp Selector Capture Switch", 0);
3049 if (err < 0)
3050 return err;
3051 }
Matthew Ranostay89385032008-09-11 09:49:39 -04003052 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3053 "Amp Capture Volume",
3054 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3055}
3056
3057
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003058/* create PC beep volume controls */
3059static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3060 hda_nid_t nid)
3061{
3062 struct sigmatel_spec *spec = codec->spec;
3063 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3064 int err;
3065
3066 /* check for mute support for the the amp */
3067 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3068 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3069 "PC Beep Playback Switch",
3070 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3071 if (err < 0)
3072 return err;
3073 }
3074
3075 /* check to see if there is volume support for the amp */
3076 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3077 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3078 "PC Beep Playback Volume",
3079 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3080 if (err < 0)
3081 return err;
3082 }
3083 return 0;
3084}
3085
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003086#ifdef CONFIG_SND_HDA_INPUT_BEEP
3087#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3088
3089static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3090 struct snd_ctl_elem_value *ucontrol)
3091{
3092 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3093 ucontrol->value.integer.value[0] = codec->beep->enabled;
3094 return 0;
3095}
3096
3097static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3098 struct snd_ctl_elem_value *ucontrol)
3099{
3100 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3101 int enabled = !!ucontrol->value.integer.value[0];
3102 if (codec->beep->enabled != enabled) {
3103 codec->beep->enabled = enabled;
3104 return 1;
3105 }
3106 return 0;
3107}
3108
3109static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3110 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3111 .info = stac92xx_dig_beep_switch_info,
3112 .get = stac92xx_dig_beep_switch_get,
3113 .put = stac92xx_dig_beep_switch_put,
3114};
3115
3116static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3117{
3118 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3119 0, "PC Beep Playback Switch", 0);
3120}
3121#endif
3122
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003123static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3124{
3125 struct sigmatel_spec *spec = codec->spec;
3126 int wcaps, nid, i, err = 0;
3127
3128 for (i = 0; i < spec->num_muxes; i++) {
3129 nid = spec->mux_nids[i];
3130 wcaps = get_wcaps(codec, nid);
3131
3132 if (wcaps & AC_WCAP_OUT_AMP) {
3133 err = stac92xx_add_control_idx(spec,
3134 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3135 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3136 if (err < 0)
3137 return err;
3138 }
3139 }
3140 return 0;
3141};
3142
Matthew Ranostayd9737752008-09-07 12:03:41 +02003143static const char *stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003144 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003145};
3146
3147static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3148{
3149 struct sigmatel_spec *spec = codec->spec;
3150 struct hda_input_mux *spdif_mux = &spec->private_smux;
Matthew Ranostay65973632008-09-16 10:39:37 -04003151 const char **labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003152 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003153 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003154
3155 num_cons = snd_hda_get_connections(codec,
3156 spec->smux_nids[0],
3157 con_lst,
3158 HDA_MAX_NUM_INPUTS);
Matthew Ranostay65973632008-09-16 10:39:37 -04003159 if (!num_cons)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003160 return -EINVAL;
3161
Matthew Ranostay65973632008-09-16 10:39:37 -04003162 if (!labels)
3163 labels = stac92xx_spdif_labels;
3164
Matthew Ranostayd9737752008-09-07 12:03:41 +02003165 for (i = 0; i < num_cons; i++) {
Matthew Ranostay65973632008-09-16 10:39:37 -04003166 spdif_mux->items[spdif_mux->num_items].label = labels[i];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003167 spdif_mux->items[spdif_mux->num_items].index = i;
3168 spdif_mux->num_items++;
3169 }
3170
3171 return 0;
3172}
3173
Matt Porter8b657272006-10-26 17:12:59 +02003174/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003175static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003176 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3177 "Digital Mic 3", "Digital Mic 4"
3178};
3179
3180/* create playback/capture controls for input pins on dmic capable codecs */
3181static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3182 const struct auto_pin_cfg *cfg)
3183{
3184 struct sigmatel_spec *spec = codec->spec;
3185 struct hda_input_mux *dimux = &spec->private_dimux;
3186 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003187 int err, i, j;
3188 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02003189
3190 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3191 dimux->items[dimux->num_items].index = 0;
3192 dimux->num_items++;
3193
3194 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003195 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003196 int index;
3197 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003198 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02003199 unsigned int def_conf;
3200
3201 def_conf = snd_hda_codec_read(codec,
3202 spec->dmic_nids[i],
3203 0,
3204 AC_VERB_GET_CONFIG_DEFAULT,
3205 0);
3206 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3207 continue;
3208
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003209 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02003210 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003211 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02003212 con_lst,
3213 HDA_MAX_NUM_INPUTS);
3214 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003215 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02003216 index = j;
3217 goto found;
3218 }
3219 continue;
3220found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003221 wcaps = get_wcaps(codec, nid) &
3222 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003223
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003224 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003225 sprintf(name, "%s Capture Volume",
3226 stac92xx_dmic_labels[dimux->num_items]);
3227
3228 err = stac92xx_add_control(spec,
3229 STAC_CTL_WIDGET_VOL,
3230 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003231 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3232 (wcaps & AC_WCAP_OUT_AMP) ?
3233 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003234 if (err < 0)
3235 return err;
3236 }
3237
Matt Porter8b657272006-10-26 17:12:59 +02003238 dimux->items[dimux->num_items].label =
3239 stac92xx_dmic_labels[dimux->num_items];
3240 dimux->items[dimux->num_items].index = index;
3241 dimux->num_items++;
3242 }
3243
3244 return 0;
3245}
3246
Mattc7d4b2f2005-06-27 14:59:41 +02003247/* create playback/capture controls for input pins */
3248static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3249{
3250 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003251 struct hda_input_mux *imux = &spec->private_imux;
3252 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3253 int i, j, k;
3254
3255 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003256 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02003257
Takashi Iwai314634b2006-09-21 11:56:18 +02003258 if (!cfg->input_pins[i])
3259 continue;
3260 index = -1;
3261 for (j = 0; j < spec->num_muxes; j++) {
3262 int num_cons;
3263 num_cons = snd_hda_get_connections(codec,
3264 spec->mux_nids[j],
3265 con_lst,
3266 HDA_MAX_NUM_INPUTS);
3267 for (k = 0; k < num_cons; k++)
3268 if (con_lst[k] == cfg->input_pins[i]) {
3269 index = k;
3270 goto found;
3271 }
Mattc7d4b2f2005-06-27 14:59:41 +02003272 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003273 continue;
3274 found:
3275 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3276 imux->items[imux->num_items].index = index;
3277 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003278 }
3279
Steve Longerbeam7b043892007-05-03 20:50:03 +02003280 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003281 /*
3282 * Set the current input for the muxes.
3283 * The STAC9221 has two input muxes with identical source
3284 * NID lists. Hopefully this won't get confused.
3285 */
3286 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003287 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3288 AC_VERB_SET_CONNECT_SEL,
3289 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003290 }
3291 }
3292
Mattc7d4b2f2005-06-27 14:59:41 +02003293 return 0;
3294}
3295
Mattc7d4b2f2005-06-27 14:59:41 +02003296static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3297{
3298 struct sigmatel_spec *spec = codec->spec;
3299 int i;
3300
3301 for (i = 0; i < spec->autocfg.line_outs; i++) {
3302 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3303 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3304 }
3305}
3306
3307static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3308{
3309 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003310 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003311
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003312 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3313 hda_nid_t pin;
3314 pin = spec->autocfg.hp_pins[i];
3315 if (pin) /* connect to front */
3316 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3317 }
3318 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3319 hda_nid_t pin;
3320 pin = spec->autocfg.speaker_pins[i];
3321 if (pin) /* connect to front */
3322 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3323 }
Mattc7d4b2f2005-06-27 14:59:41 +02003324}
3325
Matt Porter3cc08dc2006-01-23 15:27:49 +01003326static 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 +02003327{
3328 struct sigmatel_spec *spec = codec->spec;
3329 int err;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003330 int hp_speaker_swap = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003331
Matt Porter8b657272006-10-26 17:12:59 +02003332 if ((err = snd_hda_parse_pin_def_config(codec,
3333 &spec->autocfg,
3334 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003335 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003336 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003337 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003338
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003339 /* If we have no real line-out pin and multiple hp-outs, HPs should
3340 * be set up as multi-channel outputs.
3341 */
3342 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3343 spec->autocfg.hp_outs > 1) {
3344 /* Copy hp_outs to line_outs, backup line_outs in
3345 * speaker_outs so that the following routines can handle
3346 * HP pins as primary outputs.
3347 */
3348 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3349 sizeof(spec->autocfg.line_out_pins));
3350 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3351 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3352 sizeof(spec->autocfg.hp_pins));
3353 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3354 hp_speaker_swap = 1;
3355 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003356 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003357 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3358 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003359 u32 caps = query_amp_caps(codec,
3360 spec->autocfg.mono_out_pin, dir);
3361 hda_nid_t conn_list[1];
3362
3363 /* get the mixer node and then the mono mux if it exists */
3364 if (snd_hda_get_connections(codec,
3365 spec->autocfg.mono_out_pin, conn_list, 1) &&
3366 snd_hda_get_connections(codec, conn_list[0],
3367 conn_list, 1)) {
3368
3369 int wcaps = get_wcaps(codec, conn_list[0]);
3370 int wid_type = (wcaps & AC_WCAP_TYPE)
3371 >> AC_WCAP_TYPE_SHIFT;
3372 /* LR swap check, some stac925x have a mux that
3373 * changes the DACs output path instead of the
3374 * mono-mux path.
3375 */
3376 if (wid_type == AC_WID_AUD_SEL &&
3377 !(wcaps & AC_WCAP_LR_SWAP))
3378 spec->mono_nid = conn_list[0];
3379 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003380 if (dir) {
3381 hda_nid_t nid = spec->autocfg.mono_out_pin;
3382
3383 /* most mono outs have a least a mute/unmute switch */
3384 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3385 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3386 "Mono Playback Switch",
3387 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003388 if (err < 0)
3389 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003390 /* check for volume support for the amp */
3391 if ((caps & AC_AMPCAP_NUM_STEPS)
3392 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3393 err = stac92xx_add_control(spec,
3394 STAC_CTL_WIDGET_VOL,
3395 "Mono Playback Volume",
3396 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3397 if (err < 0)
3398 return err;
3399 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003400 }
3401
3402 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3403 AC_PINCTL_OUT_EN);
3404 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003405
Matt Porter403d1942005-11-29 15:00:51 +01003406 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
3407 return err;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003408 if (spec->multiout.num_dacs == 0)
3409 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
3410 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003411
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003412 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
3413
3414 if (err < 0)
3415 return err;
3416
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003417 /* setup analog beep controls */
3418 if (spec->anabeep_nid > 0) {
3419 err = stac92xx_auto_create_beep_ctls(codec,
3420 spec->anabeep_nid);
3421 if (err < 0)
3422 return err;
3423 }
3424
3425 /* setup digital beep controls and input device */
3426#ifdef CONFIG_SND_HDA_INPUT_BEEP
3427 if (spec->digbeep_nid > 0) {
3428 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003429 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003430
3431 err = stac92xx_auto_create_beep_ctls(codec, nid);
3432 if (err < 0)
3433 return err;
3434 err = snd_hda_attach_beep_device(codec, nid);
3435 if (err < 0)
3436 return err;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003437 /* if no beep switch is available, make its own one */
3438 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3439 if (codec->beep &&
3440 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3441 err = stac92xx_beep_switch_ctl(codec);
3442 if (err < 0)
3443 return err;
3444 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003445 }
3446#endif
3447
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003448 if (hp_speaker_swap == 1) {
3449 /* Restore the hp_outs and line_outs */
3450 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3451 sizeof(spec->autocfg.line_out_pins));
3452 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3453 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
3454 sizeof(spec->autocfg.speaker_pins));
3455 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
3456 memset(spec->autocfg.speaker_pins, 0,
3457 sizeof(spec->autocfg.speaker_pins));
3458 spec->autocfg.speaker_outs = 0;
3459 }
3460
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003461 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3462
3463 if (err < 0)
3464 return err;
3465
3466 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3467
3468 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003469 return err;
3470
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003471 if (spec->mono_nid > 0) {
3472 err = stac92xx_auto_create_mono_output_ctls(codec);
3473 if (err < 0)
3474 return err;
3475 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003476 if (spec->num_amps > 0) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003477 err = stac92xx_auto_create_amp_output_ctls(codec);
3478 if (err < 0)
3479 return err;
3480 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003481 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003482 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3483 &spec->autocfg)) < 0)
3484 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003485 if (spec->num_muxes > 0) {
3486 err = stac92xx_auto_create_mux_input_ctls(codec);
3487 if (err < 0)
3488 return err;
3489 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003490 if (spec->num_smuxes > 0) {
3491 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3492 if (err < 0)
3493 return err;
3494 }
Matt Porter8b657272006-10-26 17:12:59 +02003495
Mattc7d4b2f2005-06-27 14:59:41 +02003496 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003497 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003498 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003499
Takashi Iwai82bc9552006-03-21 11:24:42 +01003500 if (spec->autocfg.dig_out_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003501 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003502 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003503 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003504
Takashi Iwai603c4012008-07-30 15:01:44 +02003505 if (spec->kctls.list)
3506 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003507
3508 spec->input_mux = &spec->private_imux;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003509 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003510 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003511 spec->mono_mux = &spec->private_mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -04003512 spec->amp_mux = &spec->private_amp_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003513 return 1;
3514}
3515
Takashi Iwai82bc9552006-03-21 11:24:42 +01003516/* add playback controls for HP output */
3517static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3518 struct auto_pin_cfg *cfg)
3519{
3520 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003521 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003522 unsigned int wid_caps;
3523
3524 if (! pin)
3525 return 0;
3526
3527 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003528 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003529 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003530
3531 return 0;
3532}
3533
Richard Fish160ea0d2006-09-06 13:58:25 +02003534/* add playback controls for LFE output */
3535static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3536 struct auto_pin_cfg *cfg)
3537{
3538 struct sigmatel_spec *spec = codec->spec;
3539 int err;
3540 hda_nid_t lfe_pin = 0x0;
3541 int i;
3542
3543 /*
3544 * search speaker outs and line outs for a mono speaker pin
3545 * with an amp. If one is found, add LFE controls
3546 * for it.
3547 */
3548 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3549 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003550 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003551 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3552 if (wcaps == AC_WCAP_OUT_AMP)
3553 /* found a mono speaker with an amp, must be lfe */
3554 lfe_pin = pin;
3555 }
3556
3557 /* if speaker_outs is 0, then speakers may be in line_outs */
3558 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3559 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3560 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003561 unsigned int defcfg;
Harvey Harrison8b551782008-02-29 11:56:48 +01003562 defcfg = snd_hda_codec_read(codec, pin, 0,
Richard Fish160ea0d2006-09-06 13:58:25 +02003563 AC_VERB_GET_CONFIG_DEFAULT,
3564 0x00);
Harvey Harrison8b551782008-02-29 11:56:48 +01003565 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003566 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003567 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3568 if (wcaps == AC_WCAP_OUT_AMP)
3569 /* found a mono speaker with an amp,
3570 must be lfe */
3571 lfe_pin = pin;
3572 }
3573 }
3574 }
3575
3576 if (lfe_pin) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003577 err = create_controls(spec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003578 if (err < 0)
3579 return err;
3580 }
3581
3582 return 0;
3583}
3584
Mattc7d4b2f2005-06-27 14:59:41 +02003585static int stac9200_parse_auto_config(struct hda_codec *codec)
3586{
3587 struct sigmatel_spec *spec = codec->spec;
3588 int err;
3589
Kailang Yangdf694da2005-12-05 19:42:22 +01003590 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003591 return err;
3592
3593 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3594 return err;
3595
Takashi Iwai82bc9552006-03-21 11:24:42 +01003596 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3597 return err;
3598
Richard Fish160ea0d2006-09-06 13:58:25 +02003599 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3600 return err;
3601
Takashi Iwai355a0ec2008-11-11 16:46:19 +01003602 if (spec->num_muxes > 0) {
3603 err = stac92xx_auto_create_mux_input_ctls(codec);
3604 if (err < 0)
3605 return err;
3606 }
3607
Takashi Iwai82bc9552006-03-21 11:24:42 +01003608 if (spec->autocfg.dig_out_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003609 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003610 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003611 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003612
Takashi Iwai603c4012008-07-30 15:01:44 +02003613 if (spec->kctls.list)
3614 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003615
3616 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003617 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003618
3619 return 1;
3620}
3621
Sam Revitch62fe78e2006-05-10 15:09:17 +02003622/*
3623 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3624 * funky external mute control using GPIO pins.
3625 */
3626
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003627static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003628 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003629{
3630 unsigned int gpiostate, gpiomask, gpiodir;
3631
3632 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3633 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003634 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003635
3636 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3637 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003638 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003639
3640 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3641 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003642 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003643
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003644 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003645 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3646
3647 snd_hda_codec_write(codec, codec->afg, 0,
3648 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003649 snd_hda_codec_read(codec, codec->afg, 0,
3650 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003651
3652 msleep(1);
3653
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003654 snd_hda_codec_read(codec, codec->afg, 0,
3655 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003656}
3657
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003658static int stac92xx_add_jack(struct hda_codec *codec,
3659 hda_nid_t nid, int type)
3660{
3661 struct sigmatel_spec *spec = codec->spec;
3662 struct sigmatel_jack *jack;
3663 int def_conf = snd_hda_codec_read(codec, nid,
3664 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
3665 int connectivity = get_defcfg_connect(def_conf);
3666 char name[32];
3667
3668 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
3669 return 0;
3670
3671 snd_array_init(&spec->jacks, sizeof(*jack), 32);
3672 jack = snd_array_new(&spec->jacks);
3673 if (!jack)
3674 return -ENOMEM;
3675 jack->nid = nid;
3676 jack->type = type;
3677
3678 sprintf(name, "%s at %s %s Jack",
3679 snd_hda_get_jack_type(def_conf),
3680 snd_hda_get_jack_connectivity(def_conf),
3681 snd_hda_get_jack_location(def_conf));
3682
3683 return snd_jack_new(codec->bus->card, name, type, &jack->jack);
3684}
3685
3686static int stac92xx_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
3687 int data)
3688{
3689 struct sigmatel_event *event;
3690
3691 snd_array_init(&spec->events, sizeof(*event), 32);
3692 event = snd_array_new(&spec->events);
3693 if (!event)
3694 return -ENOMEM;
3695 event->nid = nid;
3696 event->data = data;
3697
3698 return 0;
3699}
3700
3701static int stac92xx_event_data(struct hda_codec *codec, hda_nid_t nid)
3702{
3703 struct sigmatel_spec *spec = codec->spec;
3704 struct sigmatel_event *events = spec->events.list;
3705 if (events) {
3706 int i;
3707 for (i = 0; i < spec->events.used; i++)
3708 if (events[i].nid == nid)
3709 return events[i].data;
3710 }
3711 return 0;
3712}
3713
Takashi Iwai314634b2006-09-21 11:56:18 +02003714static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3715 unsigned int event)
3716{
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003717 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) {
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003718 snd_hda_codec_write_cache(codec, nid, 0,
3719 AC_VERB_SET_UNSOLICITED_ENABLE,
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003720 (AC_USRSP_EN | event | nid));
3721 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003722}
3723
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003724static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3725{
3726 int i;
3727 for (i = 0; i < cfg->hp_outs; i++)
3728 if (cfg->hp_pins[i] == nid)
3729 return 1; /* nid is a HP-Out */
3730
3731 return 0; /* nid is not a HP-Out */
3732};
3733
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003734static void stac92xx_power_down(struct hda_codec *codec)
3735{
3736 struct sigmatel_spec *spec = codec->spec;
3737
3738 /* power down inactive DACs */
3739 hda_nid_t *dac;
3740 for (dac = spec->dac_list; *dac; dac++)
Matthew Ranostay44510892008-02-21 07:49:31 +01003741 if (!is_in_dac_nids(spec, *dac) &&
3742 spec->multiout.hp_nid != *dac)
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003743 snd_hda_codec_write_cache(codec, *dac, 0,
3744 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3745}
3746
Mattc7d4b2f2005-06-27 14:59:41 +02003747static int stac92xx_init(struct hda_codec *codec)
3748{
3749 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003750 struct auto_pin_cfg *cfg = &spec->autocfg;
Matthew Ranostay45a6ac12008-10-15 14:45:38 -04003751 int i, err;
Mattc7d4b2f2005-06-27 14:59:41 +02003752
Mattc7d4b2f2005-06-27 14:59:41 +02003753 snd_hda_sequence_write(codec, spec->init);
3754
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003755 /* power down adcs initially */
3756 if (spec->powerdown_adcs)
3757 for (i = 0; i < spec->num_adcs; i++)
3758 snd_hda_codec_write_cache(codec,
3759 spec->adc_nids[i], 0,
3760 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003761 /* set up pins */
3762 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02003763 /* Enable unsolicited responses on the HP widget */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003764 for (i = 0; i < cfg->hp_outs; i++) {
3765 int type = SND_JACK_HEADPHONE;
3766 hda_nid_t nid = cfg->hp_pins[i];
3767 enable_pin_detect(codec, nid, STAC_HP_EVENT | nid);
3768 /* jack detection */
3769 if (cfg->hp_outs == i)
3770 type |= SND_JACK_LINEOUT;
3771 err = stac92xx_add_jack(codec, nid, type);
3772 if (err < 0)
3773 return err;
3774
3775 }
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01003776 /* force to enable the first line-out; the others are set up
3777 * in unsol_event
3778 */
3779 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003780 AC_PINCTL_OUT_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003781 /* fake event to set up pins */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003782 codec->patch_ops.unsol_event(codec,
3783 (STAC_HP_EVENT | spec->autocfg.hp_pins[0]) << 26);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003784 } else {
3785 stac92xx_auto_init_multi_out(codec);
3786 stac92xx_auto_init_hp_out(codec);
3787 }
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003788 for (i = 0; i < cfg->line_outs; i++) {
3789 err = stac92xx_add_jack(codec,
3790 cfg->line_out_pins[i], SND_JACK_LINEOUT);
3791 if (err < 0)
3792 return err;
3793 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01003794 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01003795 hda_nid_t nid = cfg->input_pins[i];
3796 if (nid) {
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01003797 unsigned int pinctl;
3798 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
3799 /* for mic pins, force to initialize */
3800 pinctl = stac92xx_get_vref(codec, nid);
3801 } else {
3802 pinctl = snd_hda_codec_read(codec, nid, 0,
3803 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3804 /* if PINCTL already set then skip */
3805 if (pinctl & AC_PINCTL_IN_EN)
3806 continue;
3807 }
3808 pinctl |= AC_PINCTL_IN_EN;
Takashi Iwaic960a032006-03-23 17:06:28 +01003809 stac92xx_auto_set_pinctl(codec, nid, pinctl);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003810 err = stac92xx_add_jack(codec, nid,
3811 SND_JACK_MICROPHONE);
3812 if (err < 0)
3813 return err;
3814 enable_pin_detect(codec, nid, STAC_INSERT_EVENT | nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01003815 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01003816 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003817 for (i = 0; i < spec->num_dmics; i++)
3818 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3819 AC_PINCTL_IN_EN);
3820 for (i = 0; i < spec->num_pwrs; i++) {
3821 int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
3822 ? STAC_HP_EVENT : STAC_PWR_EVENT;
3823 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
3824 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003825 int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
3826 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003827 def_conf = get_defcfg_connect(def_conf);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003828 /* outputs are only ports capable of power management
3829 * any attempts on powering down a input port cause the
3830 * referenced VREF to act quirky.
3831 */
3832 if (pinctl & AC_PINCTL_IN_EN)
3833 continue;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003834 /* skip any ports that don't have jacks since presence
3835 * detection is useless */
3836 if (def_conf && def_conf != AC_JACK_PORT_FIXED)
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003837 continue;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003838 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3839 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3840 }
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003841 if (spec->dac_list)
3842 stac92xx_power_down(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003843 if (cfg->dig_out_pin)
3844 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3845 AC_PINCTL_OUT_EN);
3846 if (cfg->dig_in_pin)
3847 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3848 AC_PINCTL_IN_EN);
3849
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003850 stac_gpio_set(codec, spec->gpio_mask,
3851 spec->gpio_dir, spec->gpio_data);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003852
Mattc7d4b2f2005-06-27 14:59:41 +02003853 return 0;
3854}
3855
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003856static void stac92xx_free_jacks(struct hda_codec *codec)
3857{
3858 struct sigmatel_spec *spec = codec->spec;
3859 if (spec->jacks.list) {
3860 struct sigmatel_jack *jacks = spec->jacks.list;
3861 int i;
3862 for (i = 0; i < spec->jacks.used; i++)
3863 snd_device_free(codec->bus->card, &jacks[i].jack);
3864 }
3865 snd_array_free(&spec->jacks);
3866}
3867
Takashi Iwai603c4012008-07-30 15:01:44 +02003868static void stac92xx_free_kctls(struct hda_codec *codec)
3869{
3870 struct sigmatel_spec *spec = codec->spec;
3871
3872 if (spec->kctls.list) {
3873 struct snd_kcontrol_new *kctl = spec->kctls.list;
3874 int i;
3875 for (i = 0; i < spec->kctls.used; i++)
3876 kfree(kctl[i].name);
3877 }
3878 snd_array_free(&spec->kctls);
3879}
3880
Matt2f2f4252005-04-13 14:45:30 +02003881static void stac92xx_free(struct hda_codec *codec)
3882{
Mattc7d4b2f2005-06-27 14:59:41 +02003883 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003884
3885 if (! spec)
3886 return;
3887
Richard Fish11b44bb2006-08-23 18:31:34 +02003888 if (spec->bios_pin_configs)
3889 kfree(spec->bios_pin_configs);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003890 stac92xx_free_jacks(codec);
3891 snd_array_free(&spec->events);
Richard Fish11b44bb2006-08-23 18:31:34 +02003892
Mattc7d4b2f2005-06-27 14:59:41 +02003893 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003894 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02003895}
3896
Matt4e550962005-07-04 17:51:39 +02003897static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3898 unsigned int flag)
3899{
3900 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3901 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02003902
Takashi Iwaif9acba42007-05-29 18:01:06 +02003903 if (pin_ctl & AC_PINCTL_IN_EN) {
3904 /*
3905 * we need to check the current set-up direction of
3906 * shared input pins since they can be switched via
3907 * "xxx as Output" mixer switch
3908 */
3909 struct sigmatel_spec *spec = codec->spec;
3910 struct auto_pin_cfg *cfg = &spec->autocfg;
3911 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3912 spec->line_switch) ||
3913 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3914 spec->mic_switch))
3915 return;
3916 }
3917
Steve Longerbeam7b043892007-05-03 20:50:03 +02003918 /* if setting pin direction bits, clear the current
3919 direction bits first */
3920 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3921 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3922
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003923 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003924 AC_VERB_SET_PIN_WIDGET_CONTROL,
3925 pin_ctl | flag);
3926}
3927
3928static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3929 unsigned int flag)
3930{
3931 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3932 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003933 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003934 AC_VERB_SET_PIN_WIDGET_CONTROL,
3935 pin_ctl & ~flag);
3936}
3937
Jiang Zhe40c1d302007-11-12 13:05:16 +01003938static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02003939{
3940 if (!nid)
3941 return 0;
3942 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Jiang Zhe40c1d302007-11-12 13:05:16 +01003943 & (1 << 31)) {
3944 unsigned int pinctl;
3945 pinctl = snd_hda_codec_read(codec, nid, 0,
3946 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3947 if (pinctl & AC_PINCTL_IN_EN)
3948 return 0; /* mic- or line-input */
3949 else
3950 return 1; /* HP-output */
3951 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003952 return 0;
3953}
3954
Takashi Iwaid7a89432008-11-12 09:48:04 +01003955/* return non-zero if the hp-pin of the given array index isn't
3956 * a jack-detection target
3957 */
3958static int no_hp_sensing(struct sigmatel_spec *spec, int i)
3959{
3960 struct auto_pin_cfg *cfg = &spec->autocfg;
3961
3962 /* ignore sensing of shared line and mic jacks */
3963 if (spec->line_switch &&
3964 cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_LINE])
3965 return 1;
3966 if (spec->mic_switch &&
3967 cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_MIC])
3968 return 1;
3969 /* ignore if the pin is set as line-out */
3970 if (cfg->hp_pins[i] == spec->hp_switch)
3971 return 1;
3972 return 0;
3973}
3974
Takashi Iwai314634b2006-09-21 11:56:18 +02003975static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
Matt4e550962005-07-04 17:51:39 +02003976{
3977 struct sigmatel_spec *spec = codec->spec;
3978 struct auto_pin_cfg *cfg = &spec->autocfg;
3979 int i, presence;
3980
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003981 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003982 if (spec->gpio_mute)
3983 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3984 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3985
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003986 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003987 if (presence)
3988 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01003989 if (no_hp_sensing(spec, i))
3990 continue;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003991 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003992 }
Matt4e550962005-07-04 17:51:39 +02003993
3994 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01003995 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003996 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01003997 stac92xx_reset_pinctl(codec, spec->hp_switch,
3998 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003999 for (i = 0; i < cfg->line_outs; i++)
4000 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4001 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004002 for (i = 0; i < cfg->speaker_outs; i++)
4003 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4004 AC_PINCTL_OUT_EN);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004005 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004006 stac_gpio_set(codec, spec->gpio_mask,
4007 spec->gpio_dir, spec->gpio_data &
4008 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02004009 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004010 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004011 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004012 stac92xx_set_pinctl(codec, spec->hp_switch,
4013 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004014 for (i = 0; i < cfg->line_outs; i++)
4015 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4016 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004017 for (i = 0; i < cfg->speaker_outs; i++)
4018 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4019 AC_PINCTL_OUT_EN);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004020 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004021 stac_gpio_set(codec, spec->gpio_mask,
4022 spec->gpio_dir, spec->gpio_data |
4023 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02004024 }
Takashi Iwaid7a89432008-11-12 09:48:04 +01004025 /* toggle hp outs */
4026 for (i = 0; i < cfg->hp_outs; i++) {
4027 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4028 if (no_hp_sensing(spec, i))
4029 continue;
4030 if (presence)
4031 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
4032 else
4033 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
4034 }
Matt4e550962005-07-04 17:51:39 +02004035}
4036
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004037static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
4038{
4039 struct sigmatel_spec *spec = codec->spec;
4040 hda_nid_t nid = spec->pwr_nids[idx];
4041 int presence, val;
4042 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
4043 & 0x000000ff;
4044 presence = get_hp_pin_presence(codec, nid);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004045
4046 /* several codecs have two power down bits */
4047 if (spec->pwr_mapping)
4048 idx = spec->pwr_mapping[idx];
4049 else
4050 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004051
4052 if (presence)
4053 val &= ~idx;
4054 else
4055 val |= idx;
4056
4057 /* power down unused output ports */
4058 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004059}
4060
4061static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4062{
4063 struct sigmatel_spec *spec = codec->spec;
4064 struct sigmatel_jack *jacks = spec->jacks.list;
4065
4066 if (jacks) {
4067 int i;
4068 for (i = 0; i < spec->jacks.used; i++) {
4069 if (jacks->nid == nid) {
4070 unsigned int pin_ctl =
4071 snd_hda_codec_read(codec, nid,
4072 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4073 0x00);
4074 int type = jacks->type;
4075 if (type == (SND_JACK_LINEOUT
4076 | SND_JACK_HEADPHONE))
4077 type = (pin_ctl & AC_PINCTL_HP_EN)
4078 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4079 snd_jack_report(jacks->jack,
4080 get_hp_pin_presence(codec, nid)
4081 ? type : 0);
4082 }
4083 jacks++;
4084 }
4085 }
4086}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004087
Takashi Iwai314634b2006-09-21 11:56:18 +02004088static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4089{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004090 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004091 int event = (res >> 26) & 0x70;
4092 int nid = res >> 26 & 0x0f;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004093
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004094 switch (event) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004095 case STAC_HP_EVENT:
4096 stac92xx_hp_detect(codec, res);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004097 /* fallthru */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004098 case STAC_INSERT_EVENT:
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004099 case STAC_PWR_EVENT:
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004100 if (nid) {
4101 if (spec->num_pwrs > 0)
4102 stac92xx_pin_sense(codec, nid);
4103 stac92xx_report_jack(codec, nid);
4104 }
Matthew Ranostay72474be2008-10-09 09:32:17 -04004105 break;
4106 case STAC_VREF_EVENT: {
4107 int data = snd_hda_codec_read(codec, codec->afg, 0,
4108 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004109 int idx = stac92xx_event_data(codec, nid);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004110 /* toggle VREF state based on GPIOx status */
4111 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4112 !!(data & (1 << idx)));
4113 break;
4114 }
Takashi Iwai314634b2006-09-21 11:56:18 +02004115 }
4116}
4117
Takashi Iwaicb53c622007-08-10 17:21:45 +02004118#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004119static int stac92xx_resume(struct hda_codec *codec)
4120{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004121 struct sigmatel_spec *spec = codec->spec;
4122
Richard Fish11b44bb2006-08-23 18:31:34 +02004123 stac92xx_set_config_regs(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004124 snd_hda_sequence_write(codec, spec->init);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004125 stac_gpio_set(codec, spec->gpio_mask,
4126 spec->gpio_dir, spec->gpio_data);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004127 snd_hda_codec_resume_amp(codec);
4128 snd_hda_codec_resume_cache(codec);
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004129 /* power down inactive DACs */
4130 if (spec->dac_list)
4131 stac92xx_power_down(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004132 /* invoke unsolicited event to reset the HP state */
4133 if (spec->hp_detect)
4134 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
Mattff6fdc32005-06-27 15:06:52 +02004135 return 0;
4136}
4137#endif
4138
Matt2f2f4252005-04-13 14:45:30 +02004139static struct hda_codec_ops stac92xx_patch_ops = {
4140 .build_controls = stac92xx_build_controls,
4141 .build_pcms = stac92xx_build_pcms,
4142 .init = stac92xx_init,
4143 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02004144 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004145#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004146 .resume = stac92xx_resume,
4147#endif
Matt2f2f4252005-04-13 14:45:30 +02004148};
4149
4150static int patch_stac9200(struct hda_codec *codec)
4151{
4152 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004153 int err;
Matt2f2f4252005-04-13 14:45:30 +02004154
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004155 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004156 if (spec == NULL)
4157 return -ENOMEM;
4158
4159 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004160 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004161 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004162 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4163 stac9200_models,
4164 stac9200_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02004165 if (spec->board_config < 0) {
4166 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
4167 err = stac92xx_save_bios_config_regs(codec);
4168 if (err < 0) {
4169 stac92xx_free(codec);
4170 return err;
4171 }
4172 spec->pin_configs = spec->bios_pin_configs;
4173 } else {
Matt Porter403d1942005-11-29 15:00:51 +01004174 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
4175 stac92xx_set_config_regs(codec);
4176 }
Matt2f2f4252005-04-13 14:45:30 +02004177
4178 spec->multiout.max_channels = 2;
4179 spec->multiout.num_dacs = 1;
4180 spec->multiout.dac_nids = stac9200_dac_nids;
4181 spec->adc_nids = stac9200_adc_nids;
4182 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02004183 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02004184 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004185 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004186 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004187
Tobin Davisbf277782008-02-03 20:31:47 +01004188 if (spec->board_config == STAC_9200_GATEWAY ||
4189 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02004190 spec->init = stac9200_eapd_init;
4191 else
4192 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004193 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004194
Takashi Iwai117f2572008-03-18 09:53:23 +01004195 if (spec->board_config == STAC_9200_PANASONIC) {
4196 spec->gpio_mask = spec->gpio_dir = 0x09;
4197 spec->gpio_data = 0x00;
4198 }
4199
Mattc7d4b2f2005-06-27 14:59:41 +02004200 err = stac9200_parse_auto_config(codec);
4201 if (err < 0) {
4202 stac92xx_free(codec);
4203 return err;
4204 }
Matt2f2f4252005-04-13 14:45:30 +02004205
4206 codec->patch_ops = stac92xx_patch_ops;
4207
4208 return 0;
4209}
4210
Tobin Davis8e21c342007-01-08 11:04:17 +01004211static int patch_stac925x(struct hda_codec *codec)
4212{
4213 struct sigmatel_spec *spec;
4214 int err;
4215
4216 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4217 if (spec == NULL)
4218 return -ENOMEM;
4219
4220 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004221 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01004222 spec->pin_nids = stac925x_pin_nids;
4223 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
4224 stac925x_models,
4225 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004226 again:
Tobin Davis8e21c342007-01-08 11:04:17 +01004227 if (spec->board_config < 0) {
Tobin Davis2c11f952007-05-17 09:36:34 +02004228 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
4229 "using BIOS defaults\n");
Tobin Davis8e21c342007-01-08 11:04:17 +01004230 err = stac92xx_save_bios_config_regs(codec);
4231 if (err < 0) {
4232 stac92xx_free(codec);
4233 return err;
4234 }
4235 spec->pin_configs = spec->bios_pin_configs;
4236 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
4237 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
4238 stac92xx_set_config_regs(codec);
4239 }
4240
4241 spec->multiout.max_channels = 2;
4242 spec->multiout.num_dacs = 1;
4243 spec->multiout.dac_nids = stac925x_dac_nids;
4244 spec->adc_nids = stac925x_adc_nids;
4245 spec->mux_nids = stac925x_mux_nids;
4246 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004247 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004248 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02004249 switch (codec->vendor_id) {
4250 case 0x83847632: /* STAC9202 */
4251 case 0x83847633: /* STAC9202D */
4252 case 0x83847636: /* STAC9251 */
4253 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02004254 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02004255 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004256 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4257 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02004258 break;
4259 default:
4260 spec->num_dmics = 0;
4261 break;
4262 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004263
4264 spec->init = stac925x_core_init;
4265 spec->mixer = stac925x_mixer;
4266
4267 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004268 if (!err) {
4269 if (spec->board_config < 0) {
4270 printk(KERN_WARNING "hda_codec: No auto-config is "
4271 "available, default to model=ref\n");
4272 spec->board_config = STAC_925x_REF;
4273 goto again;
4274 }
4275 err = -EINVAL;
4276 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004277 if (err < 0) {
4278 stac92xx_free(codec);
4279 return err;
4280 }
4281
4282 codec->patch_ops = stac92xx_patch_ops;
4283
4284 return 0;
4285}
4286
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004287static struct hda_input_mux stac92hd73xx_dmux = {
4288 .num_items = 4,
4289 .items = {
4290 { "Analog Inputs", 0x0b },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004291 { "Digital Mic 1", 0x09 },
4292 { "Digital Mic 2", 0x0a },
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004293 { "CD", 0x08 },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004294 }
4295};
4296
4297static int patch_stac92hd73xx(struct hda_codec *codec)
4298{
4299 struct sigmatel_spec *spec;
4300 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4301 int err = 0;
4302
4303 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4304 if (spec == NULL)
4305 return -ENOMEM;
4306
4307 codec->spec = spec;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02004308 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004309 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4310 spec->pin_nids = stac92hd73xx_pin_nids;
4311 spec->board_config = snd_hda_check_board_config(codec,
4312 STAC_92HD73XX_MODELS,
4313 stac92hd73xx_models,
4314 stac92hd73xx_cfg_tbl);
4315again:
4316 if (spec->board_config < 0) {
4317 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4318 " STAC92HD73XX, using BIOS defaults\n");
4319 err = stac92xx_save_bios_config_regs(codec);
4320 if (err < 0) {
4321 stac92xx_free(codec);
4322 return err;
4323 }
4324 spec->pin_configs = spec->bios_pin_configs;
4325 } else {
4326 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
4327 stac92xx_set_config_regs(codec);
4328 }
4329
4330 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
4331 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4332
4333 if (spec->multiout.num_dacs < 0) {
4334 printk(KERN_WARNING "hda_codec: Could not determine "
4335 "number of channels defaulting to DAC count\n");
4336 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
4337 }
4338
4339 switch (spec->multiout.num_dacs) {
4340 case 0x3: /* 6 Channel */
4341 spec->mixer = stac92hd73xx_6ch_mixer;
4342 spec->init = stac92hd73xx_6ch_core_init;
4343 break;
4344 case 0x4: /* 8 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004345 spec->mixer = stac92hd73xx_8ch_mixer;
4346 spec->init = stac92hd73xx_8ch_core_init;
4347 break;
4348 case 0x5: /* 10 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004349 spec->mixer = stac92hd73xx_10ch_mixer;
4350 spec->init = stac92hd73xx_10ch_core_init;
4351 };
4352
4353 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
4354 spec->aloopback_mask = 0x01;
4355 spec->aloopback_shift = 8;
4356
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004357 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004358 spec->mux_nids = stac92hd73xx_mux_nids;
4359 spec->adc_nids = stac92hd73xx_adc_nids;
4360 spec->dmic_nids = stac92hd73xx_dmic_nids;
4361 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004362 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostay89385032008-09-11 09:49:39 -04004363 spec->amp_nids = stac92hd73xx_amp_nids;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004364 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004365
4366 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4367 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01004368 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004369 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4370 sizeof(stac92hd73xx_dmux));
4371
Matthew Ranostaya7662642008-02-21 07:51:14 +01004372 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004373 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004374 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004375 /* fallthru */
4376 case STAC_DELL_M6:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004377 spec->num_smuxes = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004378 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4379 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004380 spec->eapd_switch = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004381 spec->num_amps = 1;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004382
4383 if (!spec->init)
4384 spec->init = dell_m6_core_init;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004385 switch (codec->subsystem_id) {
4386 case 0x1028025e: /* Analog Mics */
4387 case 0x1028025f:
4388 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4389 spec->num_dmics = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004390 spec->private_dimux.num_items = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004391 break;
Matthew Ranostayd654a662008-03-14 08:46:51 +01004392 case 0x10280271: /* Digital Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004393 case 0x10280272:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004394 case 0x10280254:
4395 case 0x10280255:
Matthew Ranostaya7662642008-02-21 07:51:14 +01004396 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4397 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004398 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004399 break;
4400 case 0x10280256: /* Both */
4401 case 0x10280057:
4402 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4403 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4404 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004405 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004406 break;
4407 }
4408 break;
4409 default:
4410 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004411 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004412 spec->eapd_switch = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004413 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004414 if (spec->board_config > STAC_92HD73XX_REF) {
4415 /* GPIO0 High = Enable EAPD */
4416 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4417 spec->gpio_data = 0x01;
4418 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004419 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004420
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004421 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4422 spec->pwr_nids = stac92hd73xx_pwr_nids;
4423
Matthew Ranostayd9737752008-09-07 12:03:41 +02004424 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004425
4426 if (!err) {
4427 if (spec->board_config < 0) {
4428 printk(KERN_WARNING "hda_codec: No auto-config is "
4429 "available, default to model=ref\n");
4430 spec->board_config = STAC_92HD73XX_REF;
4431 goto again;
4432 }
4433 err = -EINVAL;
4434 }
4435
4436 if (err < 0) {
4437 stac92xx_free(codec);
4438 return err;
4439 }
4440
4441 codec->patch_ops = stac92xx_patch_ops;
4442
4443 return 0;
4444}
4445
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004446static struct hda_input_mux stac92hd83xxx_dmux = {
4447 .num_items = 3,
4448 .items = {
4449 { "Analog Inputs", 0x03 },
4450 { "Digital Mic 1", 0x04 },
4451 { "Digital Mic 2", 0x05 },
4452 }
4453};
4454
4455static int patch_stac92hd83xxx(struct hda_codec *codec)
4456{
4457 struct sigmatel_spec *spec;
4458 int err;
4459
4460 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4461 if (spec == NULL)
4462 return -ENOMEM;
4463
4464 codec->spec = spec;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004465 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004466 spec->mono_nid = 0x19;
4467 spec->digbeep_nid = 0x21;
4468 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4469 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4470 spec->adc_nids = stac92hd83xxx_adc_nids;
4471 spec->pwr_nids = stac92hd83xxx_pwr_nids;
4472 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4473 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
4474 spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
4475
4476 spec->init = stac92hd83xxx_core_init;
4477 switch (codec->vendor_id) {
4478 case 0x111d7605:
4479 spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
4480 break;
4481 default:
4482 spec->num_pwrs--;
4483 spec->init++; /* switch to config #2 */
4484 spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
4485 }
4486
4487 spec->mixer = stac92hd83xxx_mixer;
4488 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4489 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4490 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
4491 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4492 spec->dinput_mux = &stac92hd83xxx_dmux;
4493 spec->pin_nids = stac92hd83xxx_pin_nids;
4494 spec->board_config = snd_hda_check_board_config(codec,
4495 STAC_92HD83XXX_MODELS,
4496 stac92hd83xxx_models,
4497 stac92hd83xxx_cfg_tbl);
4498again:
4499 if (spec->board_config < 0) {
4500 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4501 " STAC92HD83XXX, using BIOS defaults\n");
4502 err = stac92xx_save_bios_config_regs(codec);
4503 if (err < 0) {
4504 stac92xx_free(codec);
4505 return err;
4506 }
4507 spec->pin_configs = spec->bios_pin_configs;
4508 } else {
4509 spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config];
4510 stac92xx_set_config_regs(codec);
4511 }
4512
4513 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4514 if (!err) {
4515 if (spec->board_config < 0) {
4516 printk(KERN_WARNING "hda_codec: No auto-config is "
4517 "available, default to model=ref\n");
4518 spec->board_config = STAC_92HD83XXX_REF;
4519 goto again;
4520 }
4521 err = -EINVAL;
4522 }
4523
4524 if (err < 0) {
4525 stac92xx_free(codec);
4526 return err;
4527 }
4528
4529 codec->patch_ops = stac92xx_patch_ops;
4530
4531 return 0;
4532}
4533
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004534#ifdef SND_HDA_NEEDS_RESUME
4535static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr)
4536{
4537 struct sigmatel_spec *spec = codec->spec;
4538 int i;
4539 snd_hda_codec_write_cache(codec, codec->afg, 0,
4540 AC_VERB_SET_POWER_STATE, pwr);
4541
4542 msleep(1);
4543 for (i = 0; i < spec->num_adcs; i++) {
4544 snd_hda_codec_write_cache(codec,
4545 spec->adc_nids[i], 0,
4546 AC_VERB_SET_POWER_STATE, pwr);
4547 }
4548};
4549
4550static int stac92hd71xx_resume(struct hda_codec *codec)
4551{
4552 stac92hd71xx_set_power_state(codec, AC_PWRST_D0);
4553 return stac92xx_resume(codec);
4554}
4555
4556static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state)
4557{
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004558 struct sigmatel_spec *spec = codec->spec;
4559
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004560 stac92hd71xx_set_power_state(codec, AC_PWRST_D3);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004561 if (spec->eapd_mask)
4562 stac_gpio_set(codec, spec->gpio_mask,
4563 spec->gpio_dir, spec->gpio_data &
4564 ~spec->eapd_mask);
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004565 return 0;
4566};
4567
4568#endif
4569
4570static struct hda_codec_ops stac92hd71bxx_patch_ops = {
4571 .build_controls = stac92xx_build_controls,
4572 .build_pcms = stac92xx_build_pcms,
4573 .init = stac92xx_init,
4574 .free = stac92xx_free,
4575 .unsol_event = stac92xx_unsol_event,
4576#ifdef SND_HDA_NEEDS_RESUME
4577 .resume = stac92hd71xx_resume,
4578 .suspend = stac92hd71xx_suspend,
4579#endif
4580};
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004581
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004582static struct hda_input_mux stac92hd71bxx_dmux = {
4583 .num_items = 4,
4584 .items = {
4585 { "Analog Inputs", 0x00 },
4586 { "Mixer", 0x01 },
4587 { "Digital Mic 1", 0x02 },
4588 { "Digital Mic 2", 0x03 },
4589 }
4590};
4591
Matthew Ranostaye035b842007-11-06 11:53:55 +01004592static int patch_stac92hd71bxx(struct hda_codec *codec)
4593{
4594 struct sigmatel_spec *spec;
4595 int err = 0;
4596
4597 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4598 if (spec == NULL)
4599 return -ENOMEM;
4600
4601 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004602 codec->patch_ops = stac92xx_patch_ops;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004603 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004604 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004605 spec->pin_nids = stac92hd71bxx_pin_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004606 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux,
4607 sizeof(stac92hd71bxx_dmux));
Matthew Ranostaye035b842007-11-06 11:53:55 +01004608 spec->board_config = snd_hda_check_board_config(codec,
4609 STAC_92HD71BXX_MODELS,
4610 stac92hd71bxx_models,
4611 stac92hd71bxx_cfg_tbl);
4612again:
4613 if (spec->board_config < 0) {
4614 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4615 " STAC92HD71BXX, using BIOS defaults\n");
4616 err = stac92xx_save_bios_config_regs(codec);
4617 if (err < 0) {
4618 stac92xx_free(codec);
4619 return err;
4620 }
4621 spec->pin_configs = spec->bios_pin_configs;
4622 } else {
4623 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
4624 stac92xx_set_config_regs(codec);
4625 }
4626
Matthew Ranostay541eee82007-12-14 12:08:04 +01004627 switch (codec->vendor_id) {
4628 case 0x111d76b6: /* 4 Port without Analog Mixer */
4629 case 0x111d76b7:
4630 case 0x111d76b4: /* 6 Port without Analog Mixer */
4631 case 0x111d76b5:
4632 spec->mixer = stac92hd71bxx_mixer;
4633 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004634 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004635 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004636 case 0x111d7608: /* 5 Port with Analog Mixer */
Matthew Ranostay72474be2008-10-09 09:32:17 -04004637 switch (codec->subsystem_id) {
4638 case 0x103c361a:
4639 /* Enable VREF power saving on GPIO1 detect */
4640 snd_hda_codec_write(codec, codec->afg, 0,
4641 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
4642 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004643 AC_VERB_SET_UNSOLICITED_ENABLE,
4644 (AC_USRSP_EN | STAC_VREF_EVENT | codec->afg));
4645 err = stac92xx_add_event(spec, codec->afg, 0x02);
4646 if (err < 0)
4647 return err;
Matthew Ranostay72474be2008-10-09 09:32:17 -04004648 spec->gpio_mask |= 0x02;
4649 break;
4650 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004651 if ((codec->revision_id & 0xf) == 0 ||
4652 (codec->revision_id & 0xf) == 1) {
4653#ifdef SND_HDA_NEEDS_RESUME
4654 codec->patch_ops = stac92hd71bxx_patch_ops;
4655#endif
4656 spec->stream_delay = 40; /* 40 milliseconds */
4657 }
4658
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004659 /* no output amps */
4660 spec->num_pwrs = 0;
4661 spec->mixer = stac92hd71bxx_analog_mixer;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004662 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004663
4664 /* disable VSW */
4665 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
4666 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
4667 break;
4668 case 0x111d7603: /* 6 Port with Analog Mixer */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004669 if ((codec->revision_id & 0xf) == 1) {
4670#ifdef SND_HDA_NEEDS_RESUME
4671 codec->patch_ops = stac92hd71bxx_patch_ops;
4672#endif
4673 spec->stream_delay = 40; /* 40 milliseconds */
4674 }
4675
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004676 /* no output amps */
4677 spec->num_pwrs = 0;
4678 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01004679 default:
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004680 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004681 spec->mixer = stac92hd71bxx_analog_mixer;
4682 spec->init = stac92hd71bxx_analog_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004683 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004684 }
4685
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004686 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004687 spec->aloopback_shift = 0;
4688
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004689 if (spec->board_config > STAC_92HD71BXX_REF) {
4690 /* GPIO0 = EAPD */
4691 spec->gpio_mask = 0x01;
4692 spec->gpio_dir = 0x01;
4693 spec->gpio_data = 0x01;
4694 }
Matthew Ranostaye035b842007-11-06 11:53:55 +01004695
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004696 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004697 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004698 spec->mux_nids = stac92hd71bxx_mux_nids;
4699 spec->adc_nids = stac92hd71bxx_adc_nids;
4700 spec->dmic_nids = stac92hd71bxx_dmic_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004701 spec->dmux_nids = stac92hd71bxx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004702 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004703 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004704
4705 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
4706 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004707
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004708 switch (spec->board_config) {
4709 case STAC_HP_M4:
4710 spec->num_dmics = 0;
Matthew Ranostayb9aea712008-10-09 08:37:28 -04004711 spec->num_smuxes = 0;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004712 spec->num_dmuxes = 0;
4713
4714 /* enable internal microphone */
Matthew Ranostayb9aea712008-10-09 08:37:28 -04004715 stac92xx_set_config_reg(codec, 0x0e, 0x01813040);
4716 stac92xx_auto_set_pinctl(codec, 0x0e,
4717 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004718 break;
4719 default:
4720 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
4721 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
4722 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4723 };
4724
Takashi Iwaiaea7bb02008-02-25 18:26:41 +01004725 spec->multiout.num_dacs = 1;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004726 spec->multiout.hp_nid = 0x11;
4727 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004728 if (spec->dinput_mux)
4729 spec->private_dimux.num_items +=
4730 spec->num_dmics -
4731 (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004732
4733 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
4734 if (!err) {
4735 if (spec->board_config < 0) {
4736 printk(KERN_WARNING "hda_codec: No auto-config is "
4737 "available, default to model=ref\n");
4738 spec->board_config = STAC_92HD71BXX_REF;
4739 goto again;
4740 }
4741 err = -EINVAL;
4742 }
4743
4744 if (err < 0) {
4745 stac92xx_free(codec);
4746 return err;
4747 }
4748
Matthew Ranostaye035b842007-11-06 11:53:55 +01004749 return 0;
4750};
4751
Matt2f2f4252005-04-13 14:45:30 +02004752static int patch_stac922x(struct hda_codec *codec)
4753{
4754 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004755 int err;
Matt2f2f4252005-04-13 14:45:30 +02004756
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004757 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004758 if (spec == NULL)
4759 return -ENOMEM;
4760
4761 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004762 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004763 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004764 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
4765 stac922x_models,
4766 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08004767 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004768 spec->gpio_mask = spec->gpio_dir = 0x03;
4769 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004770 /* Intel Macs have all same PCI SSID, so we need to check
4771 * codec SSID to distinguish the exact models
4772 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004773 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004774 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004775
4776 case 0x106b0800:
4777 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02004778 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004779 case 0x106b0600:
4780 case 0x106b0700:
4781 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004782 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004783 case 0x106b0e00:
4784 case 0x106b0f00:
4785 case 0x106b1600:
4786 case 0x106b1700:
4787 case 0x106b0200:
4788 case 0x106b1e00:
4789 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004790 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004791 case 0x106b1a00:
4792 case 0x00000100:
4793 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02004794 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004795 case 0x106b0a00:
4796 case 0x106b2200:
4797 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02004798 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08004799 default:
4800 spec->board_config = STAC_INTEL_MAC_V3;
4801 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004802 }
4803 }
4804
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004805 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004806 if (spec->board_config < 0) {
4807 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
4808 "using BIOS defaults\n");
4809 err = stac92xx_save_bios_config_regs(codec);
4810 if (err < 0) {
4811 stac92xx_free(codec);
4812 return err;
4813 }
4814 spec->pin_configs = spec->bios_pin_configs;
4815 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
Matt Porter403d1942005-11-29 15:00:51 +01004816 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
4817 stac92xx_set_config_regs(codec);
4818 }
Matt2f2f4252005-04-13 14:45:30 +02004819
Matt2f2f4252005-04-13 14:45:30 +02004820 spec->adc_nids = stac922x_adc_nids;
4821 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004822 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004823 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004824 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004825 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004826
4827 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004828 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004829
4830 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02004831
Matt Porter3cc08dc2006-01-23 15:27:49 +01004832 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004833 if (!err) {
4834 if (spec->board_config < 0) {
4835 printk(KERN_WARNING "hda_codec: No auto-config is "
4836 "available, default to model=ref\n");
4837 spec->board_config = STAC_D945_REF;
4838 goto again;
4839 }
4840 err = -EINVAL;
4841 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004842 if (err < 0) {
4843 stac92xx_free(codec);
4844 return err;
4845 }
4846
4847 codec->patch_ops = stac92xx_patch_ops;
4848
Takashi Iwai807a46362007-05-29 19:01:37 +02004849 /* Fix Mux capture level; max to 2 */
4850 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
4851 (0 << AC_AMPCAP_OFFSET_SHIFT) |
4852 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4853 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4854 (0 << AC_AMPCAP_MUTE_SHIFT));
4855
Matt Porter3cc08dc2006-01-23 15:27:49 +01004856 return 0;
4857}
4858
4859static int patch_stac927x(struct hda_codec *codec)
4860{
4861 struct sigmatel_spec *spec;
4862 int err;
4863
4864 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4865 if (spec == NULL)
4866 return -ENOMEM;
4867
4868 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004869 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004870 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004871 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
4872 stac927x_models,
4873 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004874 again:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004875 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
4876 if (spec->board_config < 0)
4877 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4878 "STAC927x, using BIOS defaults\n");
Richard Fish11b44bb2006-08-23 18:31:34 +02004879 err = stac92xx_save_bios_config_regs(codec);
4880 if (err < 0) {
4881 stac92xx_free(codec);
4882 return err;
4883 }
4884 spec->pin_configs = spec->bios_pin_configs;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004885 } else {
Matt Porter3cc08dc2006-01-23 15:27:49 +01004886 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
4887 stac92xx_set_config_regs(codec);
4888 }
4889
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004890 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004891 spec->adc_nids = stac927x_adc_nids;
4892 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
4893 spec->mux_nids = stac927x_mux_nids;
4894 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004895 spec->smux_nids = stac927x_smux_nids;
4896 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04004897 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004898 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004899 spec->multiout.dac_nids = spec->dac_nids;
4900
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004901 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02004902 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004903 case STAC_D965_5ST:
4904 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004905 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004906 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004907 spec->num_dmics = 0;
4908
Tobin Davis93ed1502006-09-01 21:03:12 +02004909 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004910 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004911 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004912 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02004913 switch (codec->subsystem_id) {
4914 case 0x10280209:
4915 case 0x1028022e:
4916 /* correct the device field to SPDIF out */
4917 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
4918 break;
4919 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01004920 /* configure the analog microphone on some laptops */
4921 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01004922 /* correct the front output jack as a hp out */
Matthew Ranostay7989fba2008-02-21 07:50:12 +01004923 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01004924 /* correct the front input jack as a mic */
4925 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
4926 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004927 case STAC_DELL_3ST:
4928 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004929 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004930 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004931 spec->dmic_nids = stac927x_dmic_nids;
4932 spec->num_dmics = STAC927X_NUM_DMICS;
4933
Tobin Davis93ed1502006-09-01 21:03:12 +02004934 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004935 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004936 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004937 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004938 break;
4939 default:
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004940 if (spec->board_config > STAC_D965_REF) {
4941 /* GPIO0 High = Enable EAPD */
4942 spec->eapd_mask = spec->gpio_mask = 0x01;
4943 spec->gpio_dir = spec->gpio_data = 0x01;
4944 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004945 spec->num_dmics = 0;
4946
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004947 spec->init = stac927x_core_init;
4948 spec->mixer = stac927x_mixer;
4949 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004950
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004951 spec->num_pwrs = 0;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004952 spec->aloopback_mask = 0x40;
4953 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004954 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004955
Matt Porter3cc08dc2006-01-23 15:27:49 +01004956 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004957 if (!err) {
4958 if (spec->board_config < 0) {
4959 printk(KERN_WARNING "hda_codec: No auto-config is "
4960 "available, default to model=ref\n");
4961 spec->board_config = STAC_D965_REF;
4962 goto again;
4963 }
4964 err = -EINVAL;
4965 }
Mattc7d4b2f2005-06-27 14:59:41 +02004966 if (err < 0) {
4967 stac92xx_free(codec);
4968 return err;
4969 }
Matt2f2f4252005-04-13 14:45:30 +02004970
4971 codec->patch_ops = stac92xx_patch_ops;
4972
Takashi Iwai52987652008-01-16 16:09:47 +01004973 /*
4974 * !!FIXME!!
4975 * The STAC927x seem to require fairly long delays for certain
4976 * command sequences. With too short delays (even if the answer
4977 * is set to RIRB properly), it results in the silence output
4978 * on some hardwares like Dell.
4979 *
4980 * The below flag enables the longer delay (see get_response
4981 * in hda_intel.c).
4982 */
4983 codec->bus->needs_damn_long_delay = 1;
4984
Matt2f2f4252005-04-13 14:45:30 +02004985 return 0;
4986}
4987
Matt Porterf3302a52006-07-31 12:49:34 +02004988static int patch_stac9205(struct hda_codec *codec)
4989{
4990 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02004991 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02004992
4993 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4994 if (spec == NULL)
4995 return -ENOMEM;
4996
4997 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004998 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004999 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005000 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
5001 stac9205_models,
5002 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005003 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02005004 if (spec->board_config < 0) {
5005 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
5006 err = stac92xx_save_bios_config_regs(codec);
5007 if (err < 0) {
5008 stac92xx_free(codec);
5009 return err;
5010 }
5011 spec->pin_configs = spec->bios_pin_configs;
5012 } else {
Matt Porterf3302a52006-07-31 12:49:34 +02005013 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
5014 stac92xx_set_config_regs(codec);
5015 }
5016
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005017 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02005018 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005019 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02005020 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005021 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005022 spec->smux_nids = stac9205_smux_nids;
5023 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005024 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02005025 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005026 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005027 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005028 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02005029
5030 spec->init = stac9205_core_init;
5031 spec->mixer = stac9205_mixer;
5032
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005033 spec->aloopback_mask = 0x40;
5034 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005035 spec->eapd_switch = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02005036 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02005037
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005038 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005039 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02005040 /* Enable SPDIF in/out */
5041 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
5042 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01005043
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005044 /* Enable unsol response for GPIO4/Dock HP connection */
5045 snd_hda_codec_write(codec, codec->afg, 0,
5046 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
5047 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005048 AC_VERB_SET_UNSOLICITED_ENABLE,
5049 (AC_USRSP_EN | STAC_VREF_EVENT | codec->afg));
5050 err = stac92xx_add_event(spec, codec->afg, 0x01);
5051 if (err < 0)
5052 return err;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005053
5054 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005055 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005056 spec->gpio_mask = 0x1b;
5057 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01005058 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005059 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02005060 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005061 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005062 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005063 case STAC_9205_REF:
5064 /* SPDIF-In enabled */
5065 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005066 default:
5067 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005068 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005069 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005070 break;
5071 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02005072
Matt Porterf3302a52006-07-31 12:49:34 +02005073 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005074 if (!err) {
5075 if (spec->board_config < 0) {
5076 printk(KERN_WARNING "hda_codec: No auto-config is "
5077 "available, default to model=ref\n");
5078 spec->board_config = STAC_9205_REF;
5079 goto again;
5080 }
5081 err = -EINVAL;
5082 }
Matt Porterf3302a52006-07-31 12:49:34 +02005083 if (err < 0) {
5084 stac92xx_free(codec);
5085 return err;
5086 }
5087
5088 codec->patch_ops = stac92xx_patch_ops;
5089
5090 return 0;
5091}
5092
Matt2f2f4252005-04-13 14:45:30 +02005093/*
Guillaume Munch6d859062006-08-22 17:15:47 +02005094 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01005095 */
5096
Guillaume Munch99ccc562006-08-16 19:35:12 +02005097/* static config for Sony VAIO FE550G and Sony VAIO AR */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005098static hda_nid_t vaio_dacs[] = { 0x2 };
5099#define VAIO_HP_DAC 0x5
5100static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
5101static hda_nid_t vaio_mux_nids[] = { 0x15 };
5102
5103static struct hda_input_mux vaio_mux = {
Takashi Iwaia3a2f422007-10-11 11:21:21 +02005104 .num_items = 3,
Takashi Iwaidb064e52006-03-16 16:04:58 +01005105 .items = {
Takashi Iwaid7737812006-04-25 13:05:43 +02005106 /* { "HP", 0x0 }, */
Takashi Iwai1624cb92007-07-05 13:10:51 +02005107 { "Mic Jack", 0x1 },
5108 { "Internal Mic", 0x2 },
Takashi Iwaidb064e52006-03-16 16:04:58 +01005109 { "PCM", 0x3 },
5110 }
5111};
5112
5113static struct hda_verb vaio_init[] = {
5114 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005115 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
Takashi Iwaidb064e52006-03-16 16:04:58 +01005116 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5117 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5118 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5119 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02005120 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005121 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5122 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5123 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5124 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5125 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5126 {}
5127};
5128
Guillaume Munch6d859062006-08-22 17:15:47 +02005129static struct hda_verb vaio_ar_init[] = {
5130 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
5131 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5132 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5133 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5134/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
5135 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02005136 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Guillaume Munch6d859062006-08-22 17:15:47 +02005137 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5138 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5139/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
5140 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5141 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5142 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5143 {}
5144};
5145
Takashi Iwaidb064e52006-03-16 16:04:58 +01005146static struct snd_kcontrol_new vaio_mixer[] = {
Takashi Iwai127e82e2008-11-14 14:03:33 +01005147 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x02, 0, HDA_OUTPUT),
5148 HDA_CODEC_MUTE("Headphone Playback Switch", 0x02, 0, HDA_OUTPUT),
5149 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x05, 0, HDA_OUTPUT),
5150 HDA_CODEC_MUTE("Speaker Playback Switch", 0x05, 0, HDA_OUTPUT),
Takashi Iwaidb064e52006-03-16 16:04:58 +01005151 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5152 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5153 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5154 {
5155 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5156 .name = "Capture Source",
5157 .count = 1,
5158 .info = stac92xx_mux_enum_info,
5159 .get = stac92xx_mux_enum_get,
5160 .put = stac92xx_mux_enum_put,
5161 },
5162 {}
5163};
5164
Guillaume Munch6d859062006-08-22 17:15:47 +02005165static struct snd_kcontrol_new vaio_ar_mixer[] = {
Takashi Iwai127e82e2008-11-14 14:03:33 +01005166 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x02, 0, HDA_OUTPUT),
5167 HDA_CODEC_MUTE("Headphone Playback Switch", 0x02, 0, HDA_OUTPUT),
5168 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x05, 0, HDA_OUTPUT),
5169 HDA_CODEC_MUTE("Speaker Playback Switch", 0x05, 0, HDA_OUTPUT),
Guillaume Munch6d859062006-08-22 17:15:47 +02005170 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5171 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5172 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5173 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
5174 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
5175 {
5176 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5177 .name = "Capture Source",
5178 .count = 1,
5179 .info = stac92xx_mux_enum_info,
5180 .get = stac92xx_mux_enum_get,
5181 .put = stac92xx_mux_enum_put,
5182 },
5183 {}
5184};
5185
5186static struct hda_codec_ops stac9872_patch_ops = {
Takashi Iwaidb064e52006-03-16 16:04:58 +01005187 .build_controls = stac92xx_build_controls,
5188 .build_pcms = stac92xx_build_pcms,
5189 .init = stac92xx_init,
5190 .free = stac92xx_free,
Takashi Iwaicb53c622007-08-10 17:21:45 +02005191#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaidb064e52006-03-16 16:04:58 +01005192 .resume = stac92xx_resume,
5193#endif
5194};
5195
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005196static int stac9872_vaio_init(struct hda_codec *codec)
5197{
5198 int err;
5199
5200 err = stac92xx_init(codec);
5201 if (err < 0)
5202 return err;
5203 if (codec->patch_ops.unsol_event)
5204 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
5205 return 0;
5206}
5207
5208static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
5209{
Jiang Zhe40c1d302007-11-12 13:05:16 +01005210 if (get_hp_pin_presence(codec, 0x0a)) {
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005211 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5212 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5213 } else {
5214 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5215 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5216 }
5217}
5218
5219static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
5220{
5221 switch (res >> 26) {
5222 case STAC_HP_EVENT:
5223 stac9872_vaio_hp_detect(codec, res);
5224 break;
5225 }
5226}
5227
5228static struct hda_codec_ops stac9872_vaio_patch_ops = {
5229 .build_controls = stac92xx_build_controls,
5230 .build_pcms = stac92xx_build_pcms,
5231 .init = stac9872_vaio_init,
5232 .free = stac92xx_free,
5233 .unsol_event = stac9872_vaio_unsol_event,
5234#ifdef CONFIG_PM
5235 .resume = stac92xx_resume,
5236#endif
5237};
5238
Guillaume Munch6d859062006-08-22 17:15:47 +02005239enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
5240 CXD9872RD_VAIO,
5241 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
5242 STAC9872AK_VAIO,
5243 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
5244 STAC9872K_VAIO,
5245 /* AR Series. id=0x83847664 and subsys=104D1300 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005246 CXD9872AKD_VAIO,
5247 STAC_9872_MODELS,
5248};
Takashi Iwaidb064e52006-03-16 16:04:58 +01005249
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005250static const char *stac9872_models[STAC_9872_MODELS] = {
5251 [CXD9872RD_VAIO] = "vaio",
5252 [CXD9872AKD_VAIO] = "vaio-ar",
5253};
5254
5255static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5256 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
5257 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
5258 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
Tobin Davis68e22542007-03-12 11:36:39 +01005259 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
Takashi Iwaidb064e52006-03-16 16:04:58 +01005260 {}
5261};
5262
Guillaume Munch6d859062006-08-22 17:15:47 +02005263static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01005264{
5265 struct sigmatel_spec *spec;
5266 int board_config;
5267
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005268 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5269 stac9872_models,
5270 stac9872_cfg_tbl);
Takashi Iwaidb064e52006-03-16 16:04:58 +01005271 if (board_config < 0)
5272 /* unknown config, let generic-parser do its job... */
5273 return snd_hda_parse_generic_codec(codec);
5274
5275 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5276 if (spec == NULL)
5277 return -ENOMEM;
5278
5279 codec->spec = spec;
5280 switch (board_config) {
Guillaume Munch6d859062006-08-22 17:15:47 +02005281 case CXD9872RD_VAIO:
5282 case STAC9872AK_VAIO:
5283 case STAC9872K_VAIO:
Takashi Iwaidb064e52006-03-16 16:04:58 +01005284 spec->mixer = vaio_mixer;
5285 spec->init = vaio_init;
5286 spec->multiout.max_channels = 2;
5287 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5288 spec->multiout.dac_nids = vaio_dacs;
5289 spec->multiout.hp_nid = VAIO_HP_DAC;
5290 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5291 spec->adc_nids = vaio_adcs;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005292 spec->num_pwrs = 0;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005293 spec->input_mux = &vaio_mux;
5294 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005295 codec->patch_ops = stac9872_vaio_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005296 break;
Guillaume Munch6d859062006-08-22 17:15:47 +02005297
5298 case CXD9872AKD_VAIO:
5299 spec->mixer = vaio_ar_mixer;
5300 spec->init = vaio_ar_init;
5301 spec->multiout.max_channels = 2;
5302 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5303 spec->multiout.dac_nids = vaio_dacs;
5304 spec->multiout.hp_nid = VAIO_HP_DAC;
5305 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005306 spec->num_pwrs = 0;
Guillaume Munch6d859062006-08-22 17:15:47 +02005307 spec->adc_nids = vaio_adcs;
5308 spec->input_mux = &vaio_mux;
5309 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005310 codec->patch_ops = stac9872_patch_ops;
Guillaume Munch6d859062006-08-22 17:15:47 +02005311 break;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005312 }
5313
Takashi Iwaidb064e52006-03-16 16:04:58 +01005314 return 0;
5315}
5316
5317
5318/*
Matt2f2f4252005-04-13 14:45:30 +02005319 * patch entries
5320 */
5321struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5322 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5323 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5324 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5325 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5326 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5327 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5328 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02005329 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5330 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5331 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5332 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5333 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5334 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01005335 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5336 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5337 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5338 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5339 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5340 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5341 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5342 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5343 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5344 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01005345 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5346 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5347 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5348 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5349 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5350 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02005351 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5352 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02005353 /* The following does not take into account .id=0x83847661 when subsys =
5354 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5355 * currently not fully supported.
5356 */
5357 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5358 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5359 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02005360 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5361 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5362 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5363 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5364 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5365 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5366 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5367 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005368 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005369 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5370 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005371 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01005372 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5373 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005374 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01005375 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5376 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5377 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5378 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5379 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5380 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5381 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5382 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02005383 {} /* terminator */
5384};