blob: c72c748322a11b8a2ffb74fe43e4c956a7739a34 [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>
Matt2f2f4252005-04-13 14:45:30 +020033#include "hda_codec.h"
34#include "hda_local.h"
Harvey Harrison3c9a3202008-02-29 11:59:26 +010035#include "hda_patch.h"
Matthew Ranostay1cd22242008-07-18 18:20:52 +020036#include "hda_beep.h"
Matt2f2f4252005-04-13 14:45:30 +020037
Matt4e550962005-07-04 17:51:39 +020038#define NUM_CONTROL_ALLOC 32
Matthew Ranostaya64135a2008-01-10 16:55:06 +010039#define STAC_PWR_EVENT 0x20
40#define STAC_HP_EVENT 0x30
Matt4e550962005-07-04 17:51:39 +020041
Takashi Iwaif5fcc132006-11-24 17:07:44 +010042enum {
43 STAC_REF,
Tobin Davisbf277782008-02-03 20:31:47 +010044 STAC_9200_OQO,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020045 STAC_9200_DELL_D21,
46 STAC_9200_DELL_D22,
47 STAC_9200_DELL_D23,
48 STAC_9200_DELL_M21,
49 STAC_9200_DELL_M22,
50 STAC_9200_DELL_M23,
51 STAC_9200_DELL_M24,
52 STAC_9200_DELL_M25,
53 STAC_9200_DELL_M26,
54 STAC_9200_DELL_M27,
Takashi Iwai1194b5b2007-10-10 10:04:26 +020055 STAC_9200_GATEWAY,
Takashi Iwai117f2572008-03-18 09:53:23 +010056 STAC_9200_PANASONIC,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010057 STAC_9200_MODELS
58};
59
60enum {
61 STAC_9205_REF,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020062 STAC_9205_DELL_M42,
Tobin Davisae0a8ed2007-08-13 15:50:29 +020063 STAC_9205_DELL_M43,
64 STAC_9205_DELL_M44,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010065 STAC_9205_MODELS
66};
67
68enum {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010069 STAC_92HD73XX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010070 STAC_DELL_M6,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010071 STAC_92HD73XX_MODELS
72};
73
74enum {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020075 STAC_92HD83XXX_REF,
76 STAC_92HD83XXX_MODELS
77};
78
79enum {
Matthew Ranostaye035b842007-11-06 11:53:55 +010080 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010081 STAC_DELL_M4_1,
82 STAC_DELL_M4_2,
Matthew Ranostaye035b842007-11-06 11:53:55 +010083 STAC_92HD71BXX_MODELS
84};
85
86enum {
Tobin Davis8e21c342007-01-08 11:04:17 +010087 STAC_925x_REF,
88 STAC_M2_2,
89 STAC_MA6,
Tobin Davis2c11f952007-05-17 09:36:34 +020090 STAC_PA6,
Tobin Davis8e21c342007-01-08 11:04:17 +010091 STAC_925x_MODELS
92};
93
94enum {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010095 STAC_D945_REF,
96 STAC_D945GTP3,
97 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +020098 STAC_INTEL_MAC_V1,
99 STAC_INTEL_MAC_V2,
100 STAC_INTEL_MAC_V3,
101 STAC_INTEL_MAC_V4,
102 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800103 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
104 * is given, one of the above models will be
105 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200106 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100107 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100108 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100109 STAC_MACBOOK_PRO_V1,
110 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200111 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200112 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300113 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200114 STAC_922X_DELL_D81,
115 STAC_922X_DELL_D82,
116 STAC_922X_DELL_M81,
117 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100118 STAC_922X_MODELS
119};
120
121enum {
122 STAC_D965_REF,
123 STAC_D965_3ST,
124 STAC_D965_5ST,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200125 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100126 STAC_DELL_BIOS,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100127 STAC_927X_MODELS
128};
Matt Porter403d1942005-11-29 15:00:51 +0100129
Matt2f2f4252005-04-13 14:45:30 +0200130struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100131 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200132 unsigned int num_mixers;
133
Matt Porter403d1942005-11-29 15:00:51 +0100134 int board_config;
Mattc7d4b2f2005-06-27 14:59:41 +0200135 unsigned int surr_switch: 1;
Matt Porter403d1942005-11-29 15:00:51 +0100136 unsigned int line_switch: 1;
137 unsigned int mic_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100138 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100139 unsigned int hp_detect: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200140
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100141 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200142 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100143 unsigned int gpio_mask;
144 unsigned int gpio_dir;
145 unsigned int gpio_data;
146 unsigned int gpio_mute;
147
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200148 /* stream */
149 unsigned int stream_delay;
150
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100151 /* analog loopback */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100152 unsigned char aloopback_mask;
153 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200154
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100155 /* power management */
156 unsigned int num_pwrs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200157 unsigned int *pwr_mapping;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100158 hda_nid_t *pwr_nids;
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100159 hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100160
Matt2f2f4252005-04-13 14:45:30 +0200161 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100162 struct hda_input_mux *mono_mux;
163 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200164 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100165 hda_nid_t dac_nids[5];
Matt2f2f4252005-04-13 14:45:30 +0200166
167 /* capture */
168 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200169 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200170 hda_nid_t *mux_nids;
171 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200172 hda_nid_t *dmic_nids;
173 unsigned int num_dmics;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100174 hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100175 unsigned int num_dmuxes;
Mattdabbed62005-06-14 10:19:34 +0200176 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100177 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200178 hda_nid_t anabeep_nid;
179 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200180
Matt2f2f4252005-04-13 14:45:30 +0200181 /* pin widgets */
182 hda_nid_t *pin_nids;
183 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200184 unsigned int *pin_configs;
Richard Fish11b44bb2006-08-23 18:31:34 +0200185 unsigned int *bios_pin_configs;
Matt2f2f4252005-04-13 14:45:30 +0200186
187 /* codec specific stuff */
188 struct hda_verb *init;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100189 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200190
191 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200192 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100193 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200194 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100195 unsigned int cur_mux[3];
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200196 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200197
Matt Porter403d1942005-11-29 15:00:51 +0100198 /* i/o switches */
199 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200200 unsigned int clfe_swap;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +0200201 unsigned int hp_switch;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200202 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200203
Mattc7d4b2f2005-06-27 14:59:41 +0200204 struct hda_pcm pcm_rec[2]; /* PCM information */
205
206 /* dynamic controls and input_mux */
207 struct auto_pin_cfg autocfg;
208 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100209 struct snd_kcontrol_new *kctl_alloc;
Matt Porter8b657272006-10-26 17:12:59 +0200210 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200211 struct hda_input_mux private_imux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100212 struct hda_input_mux private_mono_mux;
Matt2f2f4252005-04-13 14:45:30 +0200213};
214
215static hda_nid_t stac9200_adc_nids[1] = {
216 0x03,
217};
218
219static hda_nid_t stac9200_mux_nids[1] = {
220 0x0c,
221};
222
223static hda_nid_t stac9200_dac_nids[1] = {
224 0x02,
225};
226
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100227static hda_nid_t stac92hd73xx_pwr_nids[8] = {
228 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
229 0x0f, 0x10, 0x11
230};
231
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100232static hda_nid_t stac92hd73xx_adc_nids[2] = {
233 0x1a, 0x1b
234};
235
236#define STAC92HD73XX_NUM_DMICS 2
237static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
238 0x13, 0x14, 0
239};
240
241#define STAC92HD73_DAC_COUNT 5
242static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
243 0x15, 0x16, 0x17, 0x18, 0x19,
244};
245
246static hda_nid_t stac92hd73xx_mux_nids[4] = {
247 0x28, 0x29, 0x2a, 0x2b,
248};
249
250static hda_nid_t stac92hd73xx_dmux_nids[2] = {
251 0x20, 0x21,
252};
253
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200254#define STAC92HD83XXX_NUM_DMICS 2
255static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
256 0x11, 0x12, 0
257};
258
259#define STAC92HD81_DAC_COUNT 2
260#define STAC92HD83_DAC_COUNT 3
261static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = {
262 0x13, 0x14, 0x22,
263};
264
265static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
266 0x17, 0x18,
267};
268
269static hda_nid_t stac92hd83xxx_adc_nids[2] = {
270 0x15, 0x16,
271};
272
273static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
274 0xa, 0xb, 0xd, 0xe,
275};
276
277static unsigned int stac92hd83xxx_pwr_mapping[4] = {
278 0x03, 0x0c, 0x10, 0x40,
279};
280
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100281static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
282 0x0a, 0x0d, 0x0f
283};
284
Matthew Ranostaye035b842007-11-06 11:53:55 +0100285static hda_nid_t stac92hd71bxx_adc_nids[2] = {
286 0x12, 0x13,
287};
288
289static hda_nid_t stac92hd71bxx_mux_nids[2] = {
290 0x1a, 0x1b
291};
292
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100293static hda_nid_t stac92hd71bxx_dmux_nids[1] = {
294 0x1c,
295};
296
Takashi Iwaiaea7bb02008-02-25 18:26:41 +0100297static hda_nid_t stac92hd71bxx_dac_nids[1] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100298 0x10, /*0x11, */
299};
300
301#define STAC92HD71BXX_NUM_DMICS 2
302static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
303 0x18, 0x19, 0
304};
305
Tobin Davis8e21c342007-01-08 11:04:17 +0100306static hda_nid_t stac925x_adc_nids[1] = {
307 0x03,
308};
309
310static hda_nid_t stac925x_mux_nids[1] = {
311 0x0f,
312};
313
314static hda_nid_t stac925x_dac_nids[1] = {
315 0x02,
316};
317
Takashi Iwaif6e98522007-10-16 14:27:04 +0200318#define STAC925X_NUM_DMICS 1
319static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
320 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200321};
322
Takashi Iwai1697055e2007-12-18 18:05:52 +0100323static hda_nid_t stac925x_dmux_nids[1] = {
324 0x14,
325};
326
Matt2f2f4252005-04-13 14:45:30 +0200327static hda_nid_t stac922x_adc_nids[2] = {
328 0x06, 0x07,
329};
330
331static hda_nid_t stac922x_mux_nids[2] = {
332 0x12, 0x13,
333};
334
Matt Porter3cc08dc2006-01-23 15:27:49 +0100335static hda_nid_t stac927x_adc_nids[3] = {
336 0x07, 0x08, 0x09
337};
338
339static hda_nid_t stac927x_mux_nids[3] = {
340 0x15, 0x16, 0x17
341};
342
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100343static hda_nid_t stac927x_dac_nids[6] = {
344 0x02, 0x03, 0x04, 0x05, 0x06, 0
345};
346
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100347static hda_nid_t stac927x_dmux_nids[1] = {
348 0x1b,
349};
350
Matthew Ranostay7f168592007-10-18 17:38:17 +0200351#define STAC927X_NUM_DMICS 2
352static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
353 0x13, 0x14, 0
354};
355
Matt Porterf3302a52006-07-31 12:49:34 +0200356static hda_nid_t stac9205_adc_nids[2] = {
357 0x12, 0x13
358};
359
360static hda_nid_t stac9205_mux_nids[2] = {
361 0x19, 0x1a
362};
363
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100364static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100365 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100366};
367
Takashi Iwaif6e98522007-10-16 14:27:04 +0200368#define STAC9205_NUM_DMICS 2
369static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
370 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200371};
372
Mattc7d4b2f2005-06-27 14:59:41 +0200373static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200374 0x08, 0x09, 0x0d, 0x0e,
375 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200376};
377
Tobin Davis8e21c342007-01-08 11:04:17 +0100378static hda_nid_t stac925x_pin_nids[8] = {
379 0x07, 0x08, 0x0a, 0x0b,
380 0x0c, 0x0d, 0x10, 0x11,
381};
382
Matt2f2f4252005-04-13 14:45:30 +0200383static hda_nid_t stac922x_pin_nids[10] = {
384 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
385 0x0f, 0x10, 0x11, 0x15, 0x1b,
386};
387
Matthew Ranostaya7662642008-02-21 07:51:14 +0100388static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100389 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
390 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostaya7662642008-02-21 07:51:14 +0100391 0x14, 0x1e, 0x22
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100392};
393
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200394static hda_nid_t stac92hd83xxx_pin_nids[14] = {
395 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
396 0x0f, 0x10, 0x11, 0x12, 0x13,
397 0x1d, 0x1e, 0x1f, 0x20
398};
Matthew Ranostaye035b842007-11-06 11:53:55 +0100399static hda_nid_t stac92hd71bxx_pin_nids[10] = {
400 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
401 0x0f, 0x14, 0x18, 0x19, 0x1e,
402};
403
Matt Porter3cc08dc2006-01-23 15:27:49 +0100404static hda_nid_t stac927x_pin_nids[14] = {
405 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
406 0x0f, 0x10, 0x11, 0x12, 0x13,
407 0x14, 0x21, 0x22, 0x23,
408};
409
Matt Porterf3302a52006-07-31 12:49:34 +0200410static hda_nid_t stac9205_pin_nids[12] = {
411 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
412 0x0f, 0x14, 0x16, 0x17, 0x18,
413 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200414};
415
Matt Porter8b657272006-10-26 17:12:59 +0200416static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
417 struct snd_ctl_elem_info *uinfo)
418{
419 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
420 struct sigmatel_spec *spec = codec->spec;
421 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
422}
423
424static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
425 struct snd_ctl_elem_value *ucontrol)
426{
427 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
428 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100429 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200430
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100431 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200432 return 0;
433}
434
435static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
436 struct snd_ctl_elem_value *ucontrol)
437{
438 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
439 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100440 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200441
442 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100443 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200444}
445
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100446static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200447{
448 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
449 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200450 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200451}
452
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100453static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200454{
455 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
456 struct sigmatel_spec *spec = codec->spec;
457 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
458
459 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
460 return 0;
461}
462
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100463static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200464{
465 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
466 struct sigmatel_spec *spec = codec->spec;
467 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
468
Mattc7d4b2f2005-06-27 14:59:41 +0200469 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200470 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
471}
472
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100473static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
474 struct snd_ctl_elem_info *uinfo)
475{
476 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
477 struct sigmatel_spec *spec = codec->spec;
478 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
479}
480
481static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
482 struct snd_ctl_elem_value *ucontrol)
483{
484 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
485 struct sigmatel_spec *spec = codec->spec;
486
487 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
488 return 0;
489}
490
491static int stac92xx_mono_mux_enum_put(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
497 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
498 spec->mono_nid, &spec->cur_mmux);
499}
500
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200501#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
502
503static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
504 struct snd_ctl_elem_value *ucontrol)
505{
506 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100507 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200508 struct sigmatel_spec *spec = codec->spec;
509
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100510 ucontrol->value.integer.value[0] = !!(spec->aloopback &
511 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200512 return 0;
513}
514
515static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
516 struct snd_ctl_elem_value *ucontrol)
517{
518 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
519 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100520 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200521 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100522 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200523
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100524 idx_val = spec->aloopback_mask << idx;
525 if (ucontrol->value.integer.value[0])
526 val = spec->aloopback | idx_val;
527 else
528 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100529 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200530 return 0;
531
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100532 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200533
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100534 /* Only return the bits defined by the shift value of the
535 * first two bytes of the mask
536 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200537 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100538 kcontrol->private_value & 0xFFFF, 0x0);
539 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200540
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100541 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200542 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100543 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200544 } else {
545 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100546 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200547 }
548
549 snd_hda_codec_write_cache(codec, codec->afg, 0,
550 kcontrol->private_value >> 16, dac_mode);
551
552 return 1;
553}
554
Mattc7d4b2f2005-06-27 14:59:41 +0200555static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200556 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200557 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200558 {}
559};
560
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200561static struct hda_verb stac9200_eapd_init[] = {
562 /* set dac0mux for dac converter */
563 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
564 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
565 {}
566};
567
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100568static struct hda_verb stac92hd73xx_6ch_core_init[] = {
569 /* set master volume and direct control */
570 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
571 /* setup audio connections */
572 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
573 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
574 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
575 /* setup adcs to point to mixer */
576 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
577 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100578 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
579 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
580 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
581 /* setup import muxs */
582 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
583 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
584 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
585 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
586 {}
587};
588
Matthew Ranostayd654a662008-03-14 08:46:51 +0100589static struct hda_verb dell_eq_core_init[] = {
590 /* set master volume to max value without distortion
591 * and direct control */
592 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
593 /* setup audio connections */
594 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
595 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
596 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
597 /* setup adcs to point to mixer */
598 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
599 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
600 /* setup import muxs */
601 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
602 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
603 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
604 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
605 {}
606};
607
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100608static struct hda_verb dell_m6_core_init[] = {
Matthew Ranostay20f5f952008-09-01 08:17:56 +0200609 /* set master volume to max value without distortion
610 * and direct control */
611 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100612 /* setup audio connections */
Matthew Ranostay7747ecc2008-03-10 11:30:04 +0100613 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
614 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100615 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
616 /* setup adcs to point to mixer */
617 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
618 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
619 /* setup import muxs */
620 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
621 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
622 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
623 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
624 {}
625};
626
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100627static struct hda_verb stac92hd73xx_8ch_core_init[] = {
628 /* set master volume and direct control */
629 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
630 /* setup audio connections */
631 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
632 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
633 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
634 /* connect hp ports to dac3 */
635 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
636 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
637 /* setup adcs to point to mixer */
638 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
639 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100640 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
641 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
642 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
643 /* setup import muxs */
644 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
645 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
646 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
647 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
648 {}
649};
650
651static struct hda_verb stac92hd73xx_10ch_core_init[] = {
652 /* set master volume and direct control */
653 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
654 /* setup audio connections */
655 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
656 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
657 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
658 /* dac3 is connected to import3 mux */
659 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
660 /* connect hp ports to dac4 */
661 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
662 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
663 /* setup adcs to point to mixer */
664 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
665 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100666 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
667 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
668 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
669 /* setup import muxs */
670 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
671 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
672 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
673 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
674 {}
675};
676
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200677static struct hda_verb stac92hd83xxx_core_init[] = {
678 /* start of config #1 */
679 { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3},
680
681 /* start of config #2 */
682 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
683 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
684 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
685
686 /* power state controls amps */
687 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
688};
689
Matthew Ranostaye035b842007-11-06 11:53:55 +0100690static struct hda_verb stac92hd71bxx_core_init[] = {
691 /* set master volume and direct control */
692 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
693 /* connect headphone jack to dac1 */
694 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100695 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
696 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
697 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
698 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
699 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100700};
701
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200702#define HD_DISABLE_PORTF 3
Matthew Ranostay541eee82007-12-14 12:08:04 +0100703static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200704 /* start of config #1 */
705
706 /* connect port 0f to audio mixer */
707 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
708 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
709 /* unmute right and left channels for node 0x0f */
710 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
711 /* start of config #2 */
712
Matthew Ranostay541eee82007-12-14 12:08:04 +0100713 /* set master volume and direct control */
714 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
715 /* connect headphone jack to dac1 */
716 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200717 /* connect port 0d to audio mixer */
Matthew Ranostay9b359472007-11-07 13:03:12 +0100718 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostay9b359472007-11-07 13:03:12 +0100719 /* unmute dac0 input in audio mixer */
720 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200721 /* unmute right and left channels for nodes 0x0a, 0xd */
Matthew Ranostaye035b842007-11-06 11:53:55 +0100722 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
723 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100724 {}
725};
726
Tobin Davis8e21c342007-01-08 11:04:17 +0100727static struct hda_verb stac925x_core_init[] = {
728 /* set dac0mux for dac converter */
729 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
730 {}
731};
732
Mattc7d4b2f2005-06-27 14:59:41 +0200733static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200734 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200735 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200736 {}
737};
738
Tobin Davis93ed1502006-09-01 21:03:12 +0200739static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200740 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200741 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200742 /* unmute node 0x1b */
743 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
744 /* select node 0x03 as DAC */
745 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
746 {}
747};
748
Matt Porter3cc08dc2006-01-23 15:27:49 +0100749static struct hda_verb stac927x_core_init[] = {
750 /* set master volume and direct control */
751 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200752 /* enable analog pc beep path */
753 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100754 {}
755};
756
Matt Porterf3302a52006-07-31 12:49:34 +0200757static struct hda_verb stac9205_core_init[] = {
758 /* set master volume and direct control */
759 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200760 /* enable analog pc beep path */
761 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200762 {}
763};
764
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100765#define STAC_MONO_MUX \
766 { \
767 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
768 .name = "Mono Mux", \
769 .count = 1, \
770 .info = stac92xx_mono_mux_enum_info, \
771 .get = stac92xx_mono_mux_enum_get, \
772 .put = stac92xx_mono_mux_enum_put, \
773 }
774
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200775#define STAC_INPUT_SOURCE(cnt) \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200776 { \
777 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
778 .name = "Input Source", \
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200779 .count = cnt, \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200780 .info = stac92xx_mux_enum_info, \
781 .get = stac92xx_mux_enum_get, \
782 .put = stac92xx_mux_enum_put, \
783 }
784
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100785#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200786 { \
787 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
788 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100789 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200790 .info = stac92xx_aloopback_info, \
791 .get = stac92xx_aloopback_get, \
792 .put = stac92xx_aloopback_put, \
793 .private_value = verb_read | (verb_write << 16), \
794 }
795
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100796static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200797 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
798 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200799 STAC_INPUT_SOURCE(1),
Matt2f2f4252005-04-13 14:45:30 +0200800 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
801 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200802 { } /* end */
803};
804
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100805static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100806 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
807
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100808 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
809 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
810
811 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
812 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
813
814 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
815 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
816
817 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
818 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
819
820 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
821 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
822
823 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
824 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
825
826 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
827 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
828 { } /* end */
829};
830
831static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100832 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
833
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100834 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
835 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
836
837 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
838 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
839
840 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
841 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
842
843 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
844 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
845
846 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
847 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
848
849 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
850 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
851
852 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
853 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
854 { } /* end */
855};
856
857static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100858 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
859
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100860 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
861 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
862
863 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
864 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
865
866 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
867 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
868
869 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
870 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
871
872 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
873 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
874
875 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
876 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
877
878 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
879 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
880 { } /* end */
881};
882
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200883
884static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
885 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
886 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
887
888 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
889 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
890
891 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT),
892 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
893
894 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
895 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
896
897 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
898 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
899
900 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
901 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
902
903 /*
904 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
905 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
906 */
907 { } /* end */
908};
909
Matthew Ranostay541eee82007-12-14 12:08:04 +0100910static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100911 STAC_INPUT_SOURCE(2),
Matthew Ranostaye035b842007-11-06 11:53:55 +0100912
Matthew Ranostay9b359472007-11-07 13:03:12 +0100913 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
914 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay9b359472007-11-07 13:03:12 +0100915
916 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
917 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200918 /* analog pc-beep replaced with digital beep support */
919 /*
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +0200920 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
921 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200922 */
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +0200923
Matthew Ranostay9b359472007-11-07 13:03:12 +0100924 HDA_CODEC_MUTE("Analog Loopback 1", 0x17, 0x3, HDA_INPUT),
925 HDA_CODEC_MUTE("Analog Loopback 2", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +0100926 { } /* end */
927};
928
Matthew Ranostay541eee82007-12-14 12:08:04 +0100929static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +0100930 STAC_INPUT_SOURCE(2),
931 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
932
Matthew Ranostay541eee82007-12-14 12:08:04 +0100933 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
934 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +0100935
936 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
937 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +0100938 { } /* end */
939};
940
Tobin Davis8e21c342007-01-08 11:04:17 +0100941static struct snd_kcontrol_new stac925x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200942 STAC_INPUT_SOURCE(1),
Tobin Davis8e21c342007-01-08 11:04:17 +0100943 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +0200944 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +0100945 { } /* end */
946};
947
Takashi Iwaid1d985f2006-11-23 19:27:12 +0100948static struct snd_kcontrol_new stac9205_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200949 STAC_INPUT_SOURCE(2),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100950 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200951
952 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
953 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200954
955 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
956 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200957 { } /* end */
958};
959
960/* This needs to be generated dynamically based on sequence */
961static struct snd_kcontrol_new stac922x_mixer[] = {
962 STAC_INPUT_SOURCE(2),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200963 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
964 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200965
966 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
967 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200968 { } /* end */
969};
970
971
972static struct snd_kcontrol_new stac927x_mixer[] = {
973 STAC_INPUT_SOURCE(3),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100974 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200975
976 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
977 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200978
979 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
980 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200981
982 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
983 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
Matt Porterf3302a52006-07-31 12:49:34 +0200984 { } /* end */
985};
986
Takashi Iwai1697055e2007-12-18 18:05:52 +0100987static struct snd_kcontrol_new stac_dmux_mixer = {
988 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
989 .name = "Digital Input Source",
990 /* count set later */
991 .info = stac92xx_dmux_enum_info,
992 .get = stac92xx_dmux_enum_get,
993 .put = stac92xx_dmux_enum_put,
994};
995
Takashi Iwai2134ea42008-01-10 16:53:55 +0100996static const char *slave_vols[] = {
997 "Front Playback Volume",
998 "Surround Playback Volume",
999 "Center Playback Volume",
1000 "LFE Playback Volume",
1001 "Side Playback Volume",
1002 "Headphone Playback Volume",
1003 "Headphone Playback Volume",
1004 "Speaker Playback Volume",
1005 "External Speaker Playback Volume",
1006 "Speaker2 Playback Volume",
1007 NULL
1008};
1009
1010static const char *slave_sws[] = {
1011 "Front Playback Switch",
1012 "Surround Playback Switch",
1013 "Center Playback Switch",
1014 "LFE Playback Switch",
1015 "Side Playback Switch",
1016 "Headphone Playback Switch",
1017 "Headphone Playback Switch",
1018 "Speaker Playback Switch",
1019 "External Speaker Playback Switch",
1020 "Speaker2 Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001021 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001022 NULL
1023};
1024
Matt2f2f4252005-04-13 14:45:30 +02001025static int stac92xx_build_controls(struct hda_codec *codec)
1026{
1027 struct sigmatel_spec *spec = codec->spec;
1028 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001029 int i;
Matt2f2f4252005-04-13 14:45:30 +02001030
1031 err = snd_hda_add_new_ctls(codec, spec->mixer);
1032 if (err < 0)
1033 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001034
1035 for (i = 0; i < spec->num_mixers; i++) {
1036 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1037 if (err < 0)
1038 return err;
1039 }
Takashi Iwai1697055e2007-12-18 18:05:52 +01001040 if (spec->num_dmuxes > 0) {
1041 stac_dmux_mixer.count = spec->num_dmuxes;
1042 err = snd_ctl_add(codec->bus->card,
1043 snd_ctl_new1(&stac_dmux_mixer, codec));
1044 if (err < 0)
1045 return err;
1046 }
Mattc7d4b2f2005-06-27 14:59:41 +02001047
Mattdabbed62005-06-14 10:19:34 +02001048 if (spec->multiout.dig_out_nid) {
1049 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1050 if (err < 0)
1051 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001052 err = snd_hda_create_spdif_share_sw(codec,
1053 &spec->multiout);
1054 if (err < 0)
1055 return err;
1056 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001057 }
1058 if (spec->dig_in_nid) {
1059 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1060 if (err < 0)
1061 return err;
1062 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001063
1064 /* if we have no master control, let's create it */
1065 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001066 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001067 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001068 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001069 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001070 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001071 if (err < 0)
1072 return err;
1073 }
1074 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1075 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1076 NULL, slave_sws);
1077 if (err < 0)
1078 return err;
1079 }
1080
Mattdabbed62005-06-14 10:19:34 +02001081 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001082}
1083
Matt Porter403d1942005-11-29 15:00:51 +01001084static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001085 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001086 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1087};
1088
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001089/*
1090 STAC 9200 pin configs for
1091 102801A8
1092 102801DE
1093 102801E8
1094*/
1095static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001096 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1097 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001098};
1099
1100/*
1101 STAC 9200 pin configs for
1102 102801C0
1103 102801C1
1104*/
1105static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001106 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1107 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001108};
1109
1110/*
1111 STAC 9200 pin configs for
1112 102801C4 (Dell Dimension E310)
1113 102801C5
1114 102801C7
1115 102801D9
1116 102801DA
1117 102801E3
1118*/
1119static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001120 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1121 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001122};
1123
1124
1125/*
1126 STAC 9200-32 pin configs for
1127 102801B5 (Dell Inspiron 630m)
1128 102801D8 (Dell Inspiron 640m)
1129*/
1130static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001131 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1132 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001133};
1134
1135/*
1136 STAC 9200-32 pin configs for
1137 102801C2 (Dell Latitude D620)
1138 102801C8
1139 102801CC (Dell Latitude D820)
1140 102801D4
1141 102801D6
1142*/
1143static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001144 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1145 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001146};
1147
1148/*
1149 STAC 9200-32 pin configs for
1150 102801CE (Dell XPS M1710)
1151 102801CF (Dell Precision M90)
1152*/
1153static unsigned int dell9200_m23_pin_configs[8] = {
1154 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1155 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1156};
1157
1158/*
1159 STAC 9200-32 pin configs for
1160 102801C9
1161 102801CA
1162 102801CB (Dell Latitude 120L)
1163 102801D3
1164*/
1165static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001166 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1167 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001168};
1169
1170/*
1171 STAC 9200-32 pin configs for
1172 102801BD (Dell Inspiron E1505n)
1173 102801EE
1174 102801EF
1175*/
1176static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001177 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1178 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001179};
1180
1181/*
1182 STAC 9200-32 pin configs for
1183 102801F5 (Dell Inspiron 1501)
1184 102801F6
1185*/
1186static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001187 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1188 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001189};
1190
1191/*
1192 STAC 9200-32
1193 102801CD (Dell Inspiron E1705/9400)
1194*/
1195static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001196 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1197 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001198};
1199
Tobin Davisbf277782008-02-03 20:31:47 +01001200static unsigned int oqo9200_pin_configs[8] = {
1201 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1202 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1203};
1204
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001205
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001206static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1207 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001208 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001209 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1210 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1211 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1212 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1213 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1214 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1215 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1216 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1217 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1218 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001219 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001220};
1221
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001222static const char *stac9200_models[STAC_9200_MODELS] = {
1223 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001224 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001225 [STAC_9200_DELL_D21] = "dell-d21",
1226 [STAC_9200_DELL_D22] = "dell-d22",
1227 [STAC_9200_DELL_D23] = "dell-d23",
1228 [STAC_9200_DELL_M21] = "dell-m21",
1229 [STAC_9200_DELL_M22] = "dell-m22",
1230 [STAC_9200_DELL_M23] = "dell-m23",
1231 [STAC_9200_DELL_M24] = "dell-m24",
1232 [STAC_9200_DELL_M25] = "dell-m25",
1233 [STAC_9200_DELL_M26] = "dell-m26",
1234 [STAC_9200_DELL_M27] = "dell-m27",
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001235 [STAC_9200_GATEWAY] = "gateway",
Takashi Iwai117f2572008-03-18 09:53:23 +01001236 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001237};
1238
1239static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1240 /* SigmaTel reference board */
1241 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1242 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001243 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001244 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1245 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001246 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001247 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1248 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1249 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1250 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1251 "unknown Dell", STAC_9200_DELL_D22),
1252 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1253 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001254 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001255 "Dell Latitude D620", STAC_9200_DELL_M22),
1256 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1257 "unknown Dell", STAC_9200_DELL_D23),
1258 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1259 "unknown Dell", STAC_9200_DELL_D23),
1260 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1261 "unknown Dell", STAC_9200_DELL_M22),
1262 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1263 "unknown Dell", STAC_9200_DELL_M24),
1264 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1265 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001266 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001267 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001268 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001269 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001270 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001271 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001272 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001273 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001274 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001275 "Dell Precision M90", STAC_9200_DELL_M23),
1276 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1277 "unknown Dell", STAC_9200_DELL_M22),
1278 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1279 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001280 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001281 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001282 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001283 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1284 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1285 "unknown Dell", STAC_9200_DELL_D23),
1286 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1287 "unknown Dell", STAC_9200_DELL_D23),
1288 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1289 "unknown Dell", STAC_9200_DELL_D21),
1290 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1291 "unknown Dell", STAC_9200_DELL_D23),
1292 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1293 "unknown Dell", STAC_9200_DELL_D21),
1294 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1295 "unknown Dell", STAC_9200_DELL_M25),
1296 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1297 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001298 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001299 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1300 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1301 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001302 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001303 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001304 /* Gateway machines needs EAPD to be set on resume */
1305 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1306 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1307 STAC_9200_GATEWAY),
1308 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1309 STAC_9200_GATEWAY),
Tobin Davisbf277782008-02-03 20:31:47 +01001310 /* OQO Mobile */
1311 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001312 {} /* terminator */
1313};
1314
Tobin Davis8e21c342007-01-08 11:04:17 +01001315static unsigned int ref925x_pin_configs[8] = {
1316 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001317 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001318};
1319
1320static unsigned int stac925x_MA6_pin_configs[8] = {
1321 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1322 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1323};
1324
Tobin Davis2c11f952007-05-17 09:36:34 +02001325static unsigned int stac925x_PA6_pin_configs[8] = {
1326 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1327 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1328};
1329
Tobin Davis8e21c342007-01-08 11:04:17 +01001330static unsigned int stac925xM2_2_pin_configs[8] = {
Steve Longerbeam7353e142007-05-29 14:36:17 +02001331 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1332 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001333};
1334
1335static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1336 [STAC_REF] = ref925x_pin_configs,
1337 [STAC_M2_2] = stac925xM2_2_pin_configs,
1338 [STAC_MA6] = stac925x_MA6_pin_configs,
Tobin Davis2c11f952007-05-17 09:36:34 +02001339 [STAC_PA6] = stac925x_PA6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001340};
1341
1342static const char *stac925x_models[STAC_925x_MODELS] = {
1343 [STAC_REF] = "ref",
1344 [STAC_M2_2] = "m2-2",
1345 [STAC_MA6] = "m6",
Tobin Davis2c11f952007-05-17 09:36:34 +02001346 [STAC_PA6] = "pa6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001347};
1348
1349static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1350 /* SigmaTel reference board */
1351 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001352 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Tobin Davis8e21c342007-01-08 11:04:17 +01001353 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1354 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1355 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
Tobin Davis2c11f952007-05-17 09:36:34 +02001356 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
Tobin Davis8e21c342007-01-08 11:04:17 +01001357 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1358 {} /* terminator */
1359};
1360
Matthew Ranostaya7662642008-02-21 07:51:14 +01001361static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001362 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1363 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1364 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001365 0x01452050,
1366};
1367
1368static unsigned int dell_m6_pin_configs[13] = {
1369 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001370 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001371 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1372 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001373};
1374
1375static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001376 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1377 [STAC_DELL_M6] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001378};
1379
1380static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1381 [STAC_92HD73XX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001382 [STAC_DELL_M6] = "dell-m6",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001383};
1384
1385static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1386 /* SigmaTel reference board */
1387 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001388 "DFI LanParty", STAC_92HD73XX_REF),
1389 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1390 "unknown Dell", STAC_DELL_M6),
1391 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1392 "unknown Dell", STAC_DELL_M6),
1393 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1394 "unknown Dell", STAC_DELL_M6),
1395 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1396 "unknown Dell", STAC_DELL_M6),
1397 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1398 "unknown Dell", STAC_DELL_M6),
1399 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1400 "unknown Dell", STAC_DELL_M6),
1401 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1402 "unknown Dell", STAC_DELL_M6),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001403 {} /* terminator */
1404};
1405
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001406static unsigned int ref92hd83xxx_pin_configs[14] = {
1407 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1408 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1409 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1410 0x01451160, 0x98560170,
1411};
1412
1413static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1414 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1415};
1416
1417static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1418 [STAC_92HD83XXX_REF] = "ref",
1419};
1420
1421static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1422 /* SigmaTel reference board */
1423 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1424 "DFI LanParty", STAC_92HD71BXX_REF),
1425};
1426
Matthew Ranostaye035b842007-11-06 11:53:55 +01001427static unsigned int ref92hd71bxx_pin_configs[10] = {
1428 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostayb22b4822008-01-22 12:32:30 +01001429 0x0181302e, 0x01114010, 0x01019020, 0x90a000f0,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001430 0x90a000f0, 0x01452050,
1431};
1432
Matthew Ranostayaafc4412008-06-13 18:04:33 +02001433static unsigned int dell_m4_1_pin_configs[10] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001434 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001435 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001436 0x40f000f0, 0x4f0000f0,
1437};
1438
Matthew Ranostayaafc4412008-06-13 18:04:33 +02001439static unsigned int dell_m4_2_pin_configs[10] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001440 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1441 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1442 0x40f000f0, 0x044413b0,
1443};
1444
Matthew Ranostaye035b842007-11-06 11:53:55 +01001445static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1446 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001447 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1448 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001449};
1450
1451static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1452 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001453 [STAC_DELL_M4_1] = "dell-m4-1",
1454 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001455};
1456
1457static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1458 /* SigmaTel reference board */
1459 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1460 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001461 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1462 "unknown Dell", STAC_DELL_M4_1),
1463 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1464 "unknown Dell", STAC_DELL_M4_1),
1465 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1466 "unknown Dell", STAC_DELL_M4_1),
1467 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1468 "unknown Dell", STAC_DELL_M4_1),
1469 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1470 "unknown Dell", STAC_DELL_M4_1),
1471 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1472 "unknown Dell", STAC_DELL_M4_1),
1473 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1474 "unknown Dell", STAC_DELL_M4_1),
1475 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1476 "unknown Dell", STAC_DELL_M4_2),
1477 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1478 "unknown Dell", STAC_DELL_M4_2),
1479 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1480 "unknown Dell", STAC_DELL_M4_2),
1481 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1482 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001483 {} /* terminator */
1484};
1485
Matt Porter403d1942005-11-29 15:00:51 +01001486static unsigned int ref922x_pin_configs[10] = {
1487 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1488 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001489 0x40000100, 0x40000100,
1490};
1491
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001492/*
1493 STAC 922X pin configs for
1494 102801A7
1495 102801AB
1496 102801A9
1497 102801D1
1498 102801D2
1499*/
1500static unsigned int dell_922x_d81_pin_configs[10] = {
1501 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1502 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1503 0x01813122, 0x400001f2,
1504};
1505
1506/*
1507 STAC 922X pin configs for
1508 102801AC
1509 102801D0
1510*/
1511static unsigned int dell_922x_d82_pin_configs[10] = {
1512 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1513 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1514 0x01813122, 0x400001f1,
1515};
1516
1517/*
1518 STAC 922X pin configs for
1519 102801BF
1520*/
1521static unsigned int dell_922x_m81_pin_configs[10] = {
1522 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1523 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1524 0x40C003f1, 0x405003f0,
1525};
1526
1527/*
1528 STAC 9221 A1 pin configs for
1529 102801D7 (Dell XPS M1210)
1530*/
1531static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001532 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1533 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001534 0x508003f3, 0x405003f4,
1535};
1536
Matt Porter403d1942005-11-29 15:00:51 +01001537static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001538 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001539 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1540 0x02a19120, 0x40000100,
1541};
1542
1543static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001544 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1545 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001546 0x02a19320, 0x40000100,
1547};
1548
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001549static unsigned int intel_mac_v1_pin_configs[10] = {
1550 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1551 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001552 0x400000fc, 0x400000fb,
1553};
1554
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001555static unsigned int intel_mac_v2_pin_configs[10] = {
1556 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1557 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001558 0x400000fc, 0x400000fb,
1559};
1560
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001561static unsigned int intel_mac_v3_pin_configs[10] = {
1562 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1563 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1564 0x400000fc, 0x400000fb,
1565};
1566
1567static unsigned int intel_mac_v4_pin_configs[10] = {
1568 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1569 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1570 0x400000fc, 0x400000fb,
1571};
1572
1573static unsigned int intel_mac_v5_pin_configs[10] = {
1574 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1575 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1576 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001577};
1578
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001579static unsigned int ecs202_pin_configs[10] = {
1580 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1581 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1582 0x9037012e, 0x40e000f2,
1583};
Takashi Iwai76c08822007-06-19 12:17:42 +02001584
Takashi Iwai19039bd2006-06-28 15:52:16 +02001585static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001586 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001587 [STAC_D945GTP3] = d945gtp3_pin_configs,
1588 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001589 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1590 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1591 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1592 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1593 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001594 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001595 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001596 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1597 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1598 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1599 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1600 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1601 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001602 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001603 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1604 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1605 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1606 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001607};
1608
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001609static const char *stac922x_models[STAC_922X_MODELS] = {
1610 [STAC_D945_REF] = "ref",
1611 [STAC_D945GTP5] = "5stack",
1612 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001613 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1614 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1615 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1616 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1617 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001618 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001619 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001620 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001621 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001622 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1623 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001624 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001625 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001626 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001627 [STAC_922X_DELL_D81] = "dell-d81",
1628 [STAC_922X_DELL_D82] = "dell-d82",
1629 [STAC_922X_DELL_M81] = "dell-m81",
1630 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001631};
1632
1633static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1634 /* SigmaTel reference board */
1635 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1636 "DFI LanParty", STAC_D945_REF),
1637 /* Intel 945G based systems */
1638 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1639 "Intel D945G", STAC_D945GTP3),
1640 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1641 "Intel D945G", STAC_D945GTP3),
1642 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1643 "Intel D945G", STAC_D945GTP3),
1644 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1645 "Intel D945G", STAC_D945GTP3),
1646 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1647 "Intel D945G", STAC_D945GTP3),
1648 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1649 "Intel D945G", STAC_D945GTP3),
1650 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1651 "Intel D945G", STAC_D945GTP3),
1652 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1653 "Intel D945G", STAC_D945GTP3),
1654 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1655 "Intel D945G", STAC_D945GTP3),
1656 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1657 "Intel D945G", STAC_D945GTP3),
1658 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1659 "Intel D945G", STAC_D945GTP3),
1660 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1661 "Intel D945G", STAC_D945GTP3),
1662 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1663 "Intel D945G", STAC_D945GTP3),
1664 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1665 "Intel D945G", STAC_D945GTP3),
1666 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1667 "Intel D945G", STAC_D945GTP3),
1668 /* Intel D945G 5-stack systems */
1669 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1670 "Intel D945G", STAC_D945GTP5),
1671 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1672 "Intel D945G", STAC_D945GTP5),
1673 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1674 "Intel D945G", STAC_D945GTP5),
1675 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1676 "Intel D945G", STAC_D945GTP5),
1677 /* Intel 945P based systems */
1678 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1679 "Intel D945P", STAC_D945GTP3),
1680 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1681 "Intel D945P", STAC_D945GTP3),
1682 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1683 "Intel D945P", STAC_D945GTP3),
1684 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1685 "Intel D945P", STAC_D945GTP3),
1686 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1687 "Intel D945P", STAC_D945GTP3),
1688 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1689 "Intel D945P", STAC_D945GTP5),
1690 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08001691 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001692 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001693 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001694 /* Dell systems */
1695 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1696 "unknown Dell", STAC_922X_DELL_D81),
1697 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1698 "unknown Dell", STAC_922X_DELL_D81),
1699 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1700 "unknown Dell", STAC_922X_DELL_D81),
1701 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1702 "unknown Dell", STAC_922X_DELL_D82),
1703 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1704 "unknown Dell", STAC_922X_DELL_M81),
1705 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1706 "unknown Dell", STAC_922X_DELL_D82),
1707 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1708 "unknown Dell", STAC_922X_DELL_D81),
1709 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1710 "unknown Dell", STAC_922X_DELL_D81),
1711 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1712 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001713 /* ECS/PC Chips boards */
1714 SND_PCI_QUIRK(0x1019, 0x2144,
1715 "ECS/PC chips", STAC_ECS_202),
1716 SND_PCI_QUIRK(0x1019, 0x2608,
1717 "ECS/PC chips", STAC_ECS_202),
1718 SND_PCI_QUIRK(0x1019, 0x2633,
1719 "ECS/PC chips P17G/1333", STAC_ECS_202),
1720 SND_PCI_QUIRK(0x1019, 0x2811,
1721 "ECS/PC chips", STAC_ECS_202),
1722 SND_PCI_QUIRK(0x1019, 0x2812,
1723 "ECS/PC chips", STAC_ECS_202),
1724 SND_PCI_QUIRK(0x1019, 0x2813,
1725 "ECS/PC chips", STAC_ECS_202),
1726 SND_PCI_QUIRK(0x1019, 0x2814,
1727 "ECS/PC chips", STAC_ECS_202),
1728 SND_PCI_QUIRK(0x1019, 0x2815,
1729 "ECS/PC chips", STAC_ECS_202),
1730 SND_PCI_QUIRK(0x1019, 0x2816,
1731 "ECS/PC chips", STAC_ECS_202),
1732 SND_PCI_QUIRK(0x1019, 0x2817,
1733 "ECS/PC chips", STAC_ECS_202),
1734 SND_PCI_QUIRK(0x1019, 0x2818,
1735 "ECS/PC chips", STAC_ECS_202),
1736 SND_PCI_QUIRK(0x1019, 0x2819,
1737 "ECS/PC chips", STAC_ECS_202),
1738 SND_PCI_QUIRK(0x1019, 0x2820,
1739 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01001740 {} /* terminator */
1741};
1742
Matt Porter3cc08dc2006-01-23 15:27:49 +01001743static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02001744 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1745 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1746 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1747 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01001748};
1749
Tobin Davis93ed1502006-09-01 21:03:12 +02001750static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02001751 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1752 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1753 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1754 0x40000100, 0x40000100
1755};
1756
Tobin Davis93ed1502006-09-01 21:03:12 +02001757static unsigned int d965_5st_pin_configs[14] = {
1758 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1759 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1760 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1761 0x40000100, 0x40000100
1762};
1763
Tobin Davis4ff076e2007-08-07 11:48:12 +02001764static unsigned int dell_3st_pin_configs[14] = {
1765 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1766 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001767 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02001768 0x40c003fc, 0x40000100
1769};
1770
Tobin Davis93ed1502006-09-01 21:03:12 +02001771static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001772 [STAC_D965_REF] = ref927x_pin_configs,
1773 [STAC_D965_3ST] = d965_3st_pin_configs,
1774 [STAC_D965_5ST] = d965_5st_pin_configs,
1775 [STAC_DELL_3ST] = dell_3st_pin_configs,
1776 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01001777};
1778
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001779static const char *stac927x_models[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001780 [STAC_D965_REF] = "ref",
1781 [STAC_D965_3ST] = "3stack",
1782 [STAC_D965_5ST] = "5stack",
1783 [STAC_DELL_3ST] = "dell-3stack",
1784 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001785};
1786
1787static struct snd_pci_quirk stac927x_cfg_tbl[] = {
1788 /* SigmaTel reference board */
1789 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1790 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02001791 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001792 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
1793 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02001794 /* 965 based 3 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001795 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
1796 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
1797 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
1798 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
1799 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
1800 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
1801 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
1802 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
1803 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
1804 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
1805 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
1806 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
1807 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
1808 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
1809 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
1810 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02001811 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001812 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001813 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02001814 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
1815 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001816 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01001817 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
1818 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001819 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02001820 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001821 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
1822 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
1823 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
1824 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02001825 /* 965 based 5 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001826 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
1827 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
1828 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
1829 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
1830 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
1831 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
1832 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
1833 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
1834 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01001835 {} /* terminator */
1836};
1837
Matt Porterf3302a52006-07-31 12:49:34 +02001838static unsigned int ref9205_pin_configs[12] = {
1839 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001840 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02001841 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02001842};
1843
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001844/*
1845 STAC 9205 pin configs for
1846 102801F1
1847 102801F2
1848 102801FC
1849 102801FD
1850 10280204
1851 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01001852 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001853*/
1854static unsigned int dell_9205_m42_pin_configs[12] = {
1855 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
1856 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
1857 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
1858};
1859
1860/*
1861 STAC 9205 pin configs for
1862 102801F9
1863 102801FA
1864 102801FE
1865 102801FF (Dell Precision M4300)
1866 10280206
1867 10280200
1868 10280201
1869*/
1870static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001871 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
1872 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
1873 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
1874};
1875
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001876static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001877 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
1878 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
1879 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
1880};
1881
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001882static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001883 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001884 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
1885 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
1886 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Matt Porterf3302a52006-07-31 12:49:34 +02001887};
1888
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001889static const char *stac9205_models[STAC_9205_MODELS] = {
1890 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001891 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001892 [STAC_9205_DELL_M43] = "dell-m43",
1893 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001894};
1895
1896static struct snd_pci_quirk stac9205_cfg_tbl[] = {
1897 /* SigmaTel reference board */
1898 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1899 "DFI LanParty", STAC_9205_REF),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001900 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
1901 "unknown Dell", STAC_9205_DELL_M42),
1902 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
1903 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001904 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02001905 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001906 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
1907 "Dell Precision", STAC_9205_DELL_M43),
1908 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
1909 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001910 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
1911 "unknown Dell", STAC_9205_DELL_M42),
1912 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
1913 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001914 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
1915 "Dell Precision", STAC_9205_DELL_M43),
1916 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001917 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001918 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
1919 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02001920 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
1921 "Dell Precision", STAC_9205_DELL_M43),
1922 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
1923 "Dell Precision", STAC_9205_DELL_M43),
1924 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
1925 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001926 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
1927 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01001928 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
1929 "Dell Vostro 1500", STAC_9205_DELL_M42),
Matt Porterf3302a52006-07-31 12:49:34 +02001930 {} /* terminator */
1931};
1932
Richard Fish11b44bb2006-08-23 18:31:34 +02001933static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
1934{
1935 int i;
1936 struct sigmatel_spec *spec = codec->spec;
1937
1938 if (! spec->bios_pin_configs) {
1939 spec->bios_pin_configs = kcalloc(spec->num_pins,
1940 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
1941 if (! spec->bios_pin_configs)
1942 return -ENOMEM;
1943 }
1944
1945 for (i = 0; i < spec->num_pins; i++) {
1946 hda_nid_t nid = spec->pin_nids[i];
1947 unsigned int pin_cfg;
1948
1949 pin_cfg = snd_hda_codec_read(codec, nid, 0,
1950 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
1951 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
1952 nid, pin_cfg);
1953 spec->bios_pin_configs[i] = pin_cfg;
1954 }
1955
1956 return 0;
1957}
1958
Matthew Ranostay87d48362007-07-17 11:52:24 +02001959static void stac92xx_set_config_reg(struct hda_codec *codec,
1960 hda_nid_t pin_nid, unsigned int pin_config)
1961{
1962 int i;
1963 snd_hda_codec_write(codec, pin_nid, 0,
1964 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
1965 pin_config & 0x000000ff);
1966 snd_hda_codec_write(codec, pin_nid, 0,
1967 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
1968 (pin_config & 0x0000ff00) >> 8);
1969 snd_hda_codec_write(codec, pin_nid, 0,
1970 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
1971 (pin_config & 0x00ff0000) >> 16);
1972 snd_hda_codec_write(codec, pin_nid, 0,
1973 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
1974 pin_config >> 24);
1975 i = snd_hda_codec_read(codec, pin_nid, 0,
1976 AC_VERB_GET_CONFIG_DEFAULT,
1977 0x00);
1978 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
1979 pin_nid, i);
1980}
1981
Matt2f2f4252005-04-13 14:45:30 +02001982static void stac92xx_set_config_regs(struct hda_codec *codec)
1983{
1984 int i;
1985 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02001986
Matthew Ranostay87d48362007-07-17 11:52:24 +02001987 if (!spec->pin_configs)
1988 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02001989
Matthew Ranostay87d48362007-07-17 11:52:24 +02001990 for (i = 0; i < spec->num_pins; i++)
1991 stac92xx_set_config_reg(codec, spec->pin_nids[i],
1992 spec->pin_configs[i]);
Matt2f2f4252005-04-13 14:45:30 +02001993}
Matt2f2f4252005-04-13 14:45:30 +02001994
Matt2f2f4252005-04-13 14:45:30 +02001995/*
1996 * Analog playback callbacks
1997 */
1998static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
1999 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002000 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002001{
2002 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002003 if (spec->stream_delay)
2004 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002005 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2006 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002007}
2008
2009static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2010 struct hda_codec *codec,
2011 unsigned int stream_tag,
2012 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002013 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002014{
2015 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002016 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002017}
2018
2019static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2020 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002021 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002022{
2023 struct sigmatel_spec *spec = codec->spec;
2024 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2025}
2026
2027/*
Mattdabbed62005-06-14 10:19:34 +02002028 * Digital playback callbacks
2029 */
2030static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2031 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002032 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002033{
2034 struct sigmatel_spec *spec = codec->spec;
2035 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2036}
2037
2038static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2039 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002040 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002041{
2042 struct sigmatel_spec *spec = codec->spec;
2043 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2044}
2045
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002046static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2047 struct hda_codec *codec,
2048 unsigned int stream_tag,
2049 unsigned int format,
2050 struct snd_pcm_substream *substream)
2051{
2052 struct sigmatel_spec *spec = codec->spec;
2053 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2054 stream_tag, format, substream);
2055}
2056
Mattdabbed62005-06-14 10:19:34 +02002057
2058/*
Matt2f2f4252005-04-13 14:45:30 +02002059 * Analog capture callbacks
2060 */
2061static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2062 struct hda_codec *codec,
2063 unsigned int stream_tag,
2064 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002065 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002066{
2067 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002068 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002069
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002070 if (spec->powerdown_adcs) {
2071 msleep(40);
2072 snd_hda_codec_write_cache(codec, nid, 0,
2073 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2074 }
2075 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002076 return 0;
2077}
2078
2079static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2080 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002081 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002082{
2083 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002084 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002085
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002086 snd_hda_codec_cleanup_stream(codec, nid);
2087 if (spec->powerdown_adcs)
2088 snd_hda_codec_write_cache(codec, nid, 0,
2089 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002090 return 0;
2091}
2092
Mattdabbed62005-06-14 10:19:34 +02002093static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2094 .substreams = 1,
2095 .channels_min = 2,
2096 .channels_max = 2,
2097 /* NID is set in stac92xx_build_pcms */
2098 .ops = {
2099 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002100 .close = stac92xx_dig_playback_pcm_close,
2101 .prepare = stac92xx_dig_playback_pcm_prepare
Mattdabbed62005-06-14 10:19:34 +02002102 },
2103};
2104
2105static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2106 .substreams = 1,
2107 .channels_min = 2,
2108 .channels_max = 2,
2109 /* NID is set in stac92xx_build_pcms */
2110};
2111
Matt2f2f4252005-04-13 14:45:30 +02002112static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2113 .substreams = 1,
2114 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002115 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002116 .nid = 0x02, /* NID to query formats and rates */
2117 .ops = {
2118 .open = stac92xx_playback_pcm_open,
2119 .prepare = stac92xx_playback_pcm_prepare,
2120 .cleanup = stac92xx_playback_pcm_cleanup
2121 },
2122};
2123
Matt Porter3cc08dc2006-01-23 15:27:49 +01002124static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2125 .substreams = 1,
2126 .channels_min = 2,
2127 .channels_max = 2,
2128 .nid = 0x06, /* NID to query formats and rates */
2129 .ops = {
2130 .open = stac92xx_playback_pcm_open,
2131 .prepare = stac92xx_playback_pcm_prepare,
2132 .cleanup = stac92xx_playback_pcm_cleanup
2133 },
2134};
2135
Matt2f2f4252005-04-13 14:45:30 +02002136static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002137 .channels_min = 2,
2138 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002139 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002140 .ops = {
2141 .prepare = stac92xx_capture_pcm_prepare,
2142 .cleanup = stac92xx_capture_pcm_cleanup
2143 },
2144};
2145
2146static int stac92xx_build_pcms(struct hda_codec *codec)
2147{
2148 struct sigmatel_spec *spec = codec->spec;
2149 struct hda_pcm *info = spec->pcm_rec;
2150
2151 codec->num_pcms = 1;
2152 codec->pcm_info = info;
2153
Mattc7d4b2f2005-06-27 14:59:41 +02002154 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002155 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Matt2f2f4252005-04-13 14:45:30 +02002156 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002157 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002158 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002159
2160 if (spec->alt_switch) {
2161 codec->num_pcms++;
2162 info++;
2163 info->name = "STAC92xx Analog Alt";
2164 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2165 }
Matt2f2f4252005-04-13 14:45:30 +02002166
Mattdabbed62005-06-14 10:19:34 +02002167 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2168 codec->num_pcms++;
2169 info++;
2170 info->name = "STAC92xx Digital";
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002171 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Mattdabbed62005-06-14 10:19:34 +02002172 if (spec->multiout.dig_out_nid) {
2173 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2174 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2175 }
2176 if (spec->dig_in_nid) {
2177 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2178 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2179 }
2180 }
2181
Matt2f2f4252005-04-13 14:45:30 +02002182 return 0;
2183}
2184
Takashi Iwaic960a032006-03-23 17:06:28 +01002185static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2186{
2187 unsigned int pincap = snd_hda_param_read(codec, nid,
2188 AC_PAR_PIN_CAP);
2189 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2190 if (pincap & AC_PINCAP_VREF_100)
2191 return AC_PINCTL_VREF_100;
2192 if (pincap & AC_PINCAP_VREF_80)
2193 return AC_PINCTL_VREF_80;
2194 if (pincap & AC_PINCAP_VREF_50)
2195 return AC_PINCTL_VREF_50;
2196 if (pincap & AC_PINCAP_VREF_GRD)
2197 return AC_PINCTL_VREF_GRD;
2198 return 0;
2199}
2200
Matt Porter403d1942005-11-29 15:00:51 +01002201static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2202
2203{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002204 snd_hda_codec_write_cache(codec, nid, 0,
2205 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002206}
2207
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002208#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2209
2210static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2211 struct snd_ctl_elem_value *ucontrol)
2212{
2213 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2214 struct sigmatel_spec *spec = codec->spec;
2215
2216 ucontrol->value.integer.value[0] = spec->hp_switch;
2217 return 0;
2218}
2219
2220static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2221 struct snd_ctl_elem_value *ucontrol)
2222{
2223 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2224 struct sigmatel_spec *spec = codec->spec;
2225
2226 spec->hp_switch = ucontrol->value.integer.value[0];
2227
2228 /* check to be sure that the ports are upto date with
2229 * switch changes
2230 */
2231 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2232
2233 return 1;
2234}
2235
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002236#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002237
2238static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2239{
2240 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2241 struct sigmatel_spec *spec = codec->spec;
2242 int io_idx = kcontrol-> private_value & 0xff;
2243
2244 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2245 return 0;
2246}
2247
2248static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2249{
2250 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2251 struct sigmatel_spec *spec = codec->spec;
2252 hda_nid_t nid = kcontrol->private_value >> 8;
2253 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002254 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002255
2256 spec->io_switch[io_idx] = val;
2257
2258 if (val)
2259 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002260 else {
2261 unsigned int pinctl = AC_PINCTL_IN_EN;
2262 if (io_idx) /* set VREF for mic */
2263 pinctl |= stac92xx_get_vref(codec, nid);
2264 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2265 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002266
2267 /* check the auto-mute again: we need to mute/unmute the speaker
2268 * appropriately according to the pin direction
2269 */
2270 if (spec->hp_detect)
2271 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2272
Matt Porter403d1942005-11-29 15:00:51 +01002273 return 1;
2274}
2275
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002276#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2277
2278static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2279 struct snd_ctl_elem_value *ucontrol)
2280{
2281 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2282 struct sigmatel_spec *spec = codec->spec;
2283
2284 ucontrol->value.integer.value[0] = spec->clfe_swap;
2285 return 0;
2286}
2287
2288static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2289 struct snd_ctl_elem_value *ucontrol)
2290{
2291 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2292 struct sigmatel_spec *spec = codec->spec;
2293 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002294 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002295
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002296 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002297 return 0;
2298
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002299 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002300
2301 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2302 spec->clfe_swap ? 0x4 : 0x0);
2303
2304 return 1;
2305}
2306
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002307#define STAC_CODEC_HP_SWITCH(xname) \
2308 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2309 .name = xname, \
2310 .index = 0, \
2311 .info = stac92xx_hp_switch_info, \
2312 .get = stac92xx_hp_switch_get, \
2313 .put = stac92xx_hp_switch_put, \
2314 }
2315
Matt Porter403d1942005-11-29 15:00:51 +01002316#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2317 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2318 .name = xname, \
2319 .index = 0, \
2320 .info = stac92xx_io_switch_info, \
2321 .get = stac92xx_io_switch_get, \
2322 .put = stac92xx_io_switch_put, \
2323 .private_value = xpval, \
2324 }
2325
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002326#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2327 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2328 .name = xname, \
2329 .index = 0, \
2330 .info = stac92xx_clfe_switch_info, \
2331 .get = stac92xx_clfe_switch_get, \
2332 .put = stac92xx_clfe_switch_put, \
2333 .private_value = xpval, \
2334 }
Matt Porter403d1942005-11-29 15:00:51 +01002335
Mattc7d4b2f2005-06-27 14:59:41 +02002336enum {
2337 STAC_CTL_WIDGET_VOL,
2338 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002339 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002340 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002341 STAC_CTL_WIDGET_IO_SWITCH,
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002342 STAC_CTL_WIDGET_CLFE_SWITCH
Mattc7d4b2f2005-06-27 14:59:41 +02002343};
2344
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002345static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002346 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2347 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002348 STAC_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002349 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002350 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002351 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002352};
2353
2354/* add dynamic controls */
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002355static int stac92xx_add_control_idx(struct sigmatel_spec *spec, int type,
2356 int idx, const char *name, unsigned long val)
Mattc7d4b2f2005-06-27 14:59:41 +02002357{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002358 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002359
2360 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2361 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2362
2363 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2364 if (! knew)
2365 return -ENOMEM;
2366 if (spec->kctl_alloc) {
2367 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2368 kfree(spec->kctl_alloc);
2369 }
2370 spec->kctl_alloc = knew;
2371 spec->num_kctl_alloc = num;
2372 }
2373
2374 knew = &spec->kctl_alloc[spec->num_kctl_used];
2375 *knew = stac92xx_control_templates[type];
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002376 knew->index = idx;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002377 knew->name = kstrdup(name, GFP_KERNEL);
Mattc7d4b2f2005-06-27 14:59:41 +02002378 if (! knew->name)
2379 return -ENOMEM;
2380 knew->private_value = val;
2381 spec->num_kctl_used++;
2382 return 0;
2383}
2384
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002385
2386/* add dynamic controls */
2387static int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2388 const char *name, unsigned long val)
2389{
2390 return stac92xx_add_control_idx(spec, type, 0, name, val);
2391}
2392
Matt Porter403d1942005-11-29 15:00:51 +01002393/* flag inputs as additional dynamic lineouts */
2394static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2395{
2396 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002397 unsigned int wcaps, wtype;
2398 int i, num_dacs = 0;
2399
2400 /* use the wcaps cache to count all DACs available for line-outs */
2401 for (i = 0; i < codec->num_nodes; i++) {
2402 wcaps = codec->wcaps[i];
2403 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002404
Steve Longerbeam7b043892007-05-03 20:50:03 +02002405 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2406 num_dacs++;
2407 }
Matt Porter403d1942005-11-29 15:00:51 +01002408
Steve Longerbeam7b043892007-05-03 20:50:03 +02002409 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2410
Matt Porter403d1942005-11-29 15:00:51 +01002411 switch (cfg->line_outs) {
2412 case 3:
2413 /* add line-in as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002414 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002415 cfg->line_out_pins[cfg->line_outs] =
2416 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002417 spec->line_switch = 1;
2418 cfg->line_outs++;
2419 }
2420 break;
2421 case 2:
2422 /* add line-in as clfe and mic as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002423 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002424 cfg->line_out_pins[cfg->line_outs] =
2425 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002426 spec->line_switch = 1;
2427 cfg->line_outs++;
2428 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002429 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002430 cfg->line_out_pins[cfg->line_outs] =
2431 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002432 spec->mic_switch = 1;
2433 cfg->line_outs++;
2434 }
2435 break;
2436 case 1:
2437 /* add line-in as surr and mic as clfe */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002438 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002439 cfg->line_out_pins[cfg->line_outs] =
2440 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002441 spec->line_switch = 1;
2442 cfg->line_outs++;
2443 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002444 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002445 cfg->line_out_pins[cfg->line_outs] =
2446 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002447 spec->mic_switch = 1;
2448 cfg->line_outs++;
2449 }
2450 break;
2451 }
2452
2453 return 0;
2454}
2455
Steve Longerbeam7b043892007-05-03 20:50:03 +02002456
2457static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2458{
2459 int i;
2460
2461 for (i = 0; i < spec->multiout.num_dacs; i++) {
2462 if (spec->multiout.dac_nids[i] == nid)
2463 return 1;
2464 }
2465
2466 return 0;
2467}
2468
Matt Porter3cc08dc2006-01-23 15:27:49 +01002469/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02002470 * Fill in the dac_nids table from the parsed pin configuration
2471 * This function only works when every pin in line_out_pins[]
2472 * contains atleast one DAC in its connection list. Some 92xx
2473 * codecs are not connected directly to a DAC, such as the 9200
2474 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002475 */
Takashi Iwai19039bd2006-06-28 15:52:16 +02002476static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaidf802952007-07-02 19:18:00 +02002477 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002478{
2479 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002480 int i, j, conn_len = 0;
2481 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2482 unsigned int wcaps, wtype;
2483
Mattc7d4b2f2005-06-27 14:59:41 +02002484 for (i = 0; i < cfg->line_outs; i++) {
2485 nid = cfg->line_out_pins[i];
Steve Longerbeam7b043892007-05-03 20:50:03 +02002486 conn_len = snd_hda_get_connections(codec, nid, conn,
2487 HDA_MAX_CONNECTIONS);
2488 for (j = 0; j < conn_len; j++) {
2489 wcaps = snd_hda_param_read(codec, conn[j],
2490 AC_PAR_AUDIO_WIDGET_CAP);
2491 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002492 if (wtype != AC_WID_AUD_OUT ||
2493 (wcaps & AC_WCAP_DIGITAL))
2494 continue;
2495 /* conn[j] is a DAC routed to this line-out */
2496 if (!is_in_dac_nids(spec, conn[j]))
2497 break;
2498 }
2499
2500 if (j == conn_len) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002501 if (spec->multiout.num_dacs > 0) {
2502 /* we have already working output pins,
2503 * so let's drop the broken ones again
2504 */
2505 cfg->line_outs = spec->multiout.num_dacs;
2506 break;
2507 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002508 /* error out, no available DAC found */
2509 snd_printk(KERN_ERR
2510 "%s: No available DAC for pin 0x%x\n",
2511 __func__, nid);
2512 return -ENODEV;
2513 }
2514
2515 spec->multiout.dac_nids[i] = conn[j];
2516 spec->multiout.num_dacs++;
2517 if (conn_len > 1) {
2518 /* select this DAC in the pin's input mux */
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002519 snd_hda_codec_write_cache(codec, nid, 0,
2520 AC_VERB_SET_CONNECT_SEL, j);
Steve Longerbeam7b043892007-05-03 20:50:03 +02002521
2522 }
Mattc7d4b2f2005-06-27 14:59:41 +02002523 }
2524
Steve Longerbeam7b043892007-05-03 20:50:03 +02002525 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2526 spec->multiout.num_dacs,
2527 spec->multiout.dac_nids[0],
2528 spec->multiout.dac_nids[1],
2529 spec->multiout.dac_nids[2],
2530 spec->multiout.dac_nids[3],
2531 spec->multiout.dac_nids[4]);
Mattc7d4b2f2005-06-27 14:59:41 +02002532 return 0;
2533}
2534
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002535/* create volume control/switch for the given prefx type */
2536static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2537{
2538 char name[32];
2539 int err;
2540
2541 sprintf(name, "%s Playback Volume", pfx);
2542 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2543 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2544 if (err < 0)
2545 return err;
2546 sprintf(name, "%s Playback Switch", pfx);
2547 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2548 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2549 if (err < 0)
2550 return err;
2551 return 0;
2552}
2553
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002554static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2555{
2556 if (!spec->multiout.hp_nid)
2557 spec->multiout.hp_nid = nid;
2558 else if (spec->multiout.num_dacs > 4) {
2559 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2560 return 1;
2561 } else {
2562 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2563 spec->multiout.num_dacs++;
2564 }
2565 return 0;
2566}
2567
2568static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2569{
2570 if (is_in_dac_nids(spec, nid))
2571 return 1;
2572 if (spec->multiout.hp_nid == nid)
2573 return 1;
2574 return 0;
2575}
2576
Mattc7d4b2f2005-06-27 14:59:41 +02002577/* add playback controls from the parsed DAC table */
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002578static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
Takashi Iwai19039bd2006-06-28 15:52:16 +02002579 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002580{
Takashi Iwai19039bd2006-06-28 15:52:16 +02002581 static const char *chname[4] = {
2582 "Front", "Surround", NULL /*CLFE*/, "Side"
2583 };
Mattc7d4b2f2005-06-27 14:59:41 +02002584 hda_nid_t nid;
2585 int i, err;
2586
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002587 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002588 unsigned int wid_caps, pincap;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002589
2590
Takashi Iwai40ac8c42008-02-29 14:16:17 +01002591 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
Matt Porter403d1942005-11-29 15:00:51 +01002592 if (!spec->multiout.dac_nids[i])
Mattc7d4b2f2005-06-27 14:59:41 +02002593 continue;
2594
2595 nid = spec->multiout.dac_nids[i];
2596
2597 if (i == 2) {
2598 /* Center/LFE */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002599 err = create_controls(spec, "Center", nid, 1);
2600 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002601 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002602 err = create_controls(spec, "LFE", nid, 2);
2603 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002604 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002605
2606 wid_caps = get_wcaps(codec, nid);
2607
2608 if (wid_caps & AC_WCAP_LR_SWAP) {
2609 err = stac92xx_add_control(spec,
2610 STAC_CTL_WIDGET_CLFE_SWITCH,
2611 "Swap Center/LFE Playback Switch", nid);
2612
2613 if (err < 0)
2614 return err;
2615 }
2616
Mattc7d4b2f2005-06-27 14:59:41 +02002617 } else {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002618 err = create_controls(spec, chname[i], nid, 3);
2619 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002620 return err;
2621 }
2622 }
2623
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002624 if (cfg->hp_outs > 1) {
2625 err = stac92xx_add_control(spec,
2626 STAC_CTL_WIDGET_HP_SWITCH,
2627 "Headphone as Line Out Switch", 0);
2628 if (err < 0)
2629 return err;
2630 }
2631
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002632 if (spec->line_switch) {
2633 nid = cfg->input_pins[AUTO_PIN_LINE];
2634 pincap = snd_hda_param_read(codec, nid,
2635 AC_PAR_PIN_CAP);
2636 if (pincap & AC_PINCAP_OUT) {
2637 err = stac92xx_add_control(spec,
2638 STAC_CTL_WIDGET_IO_SWITCH,
2639 "Line In as Output Switch", nid << 8);
2640 if (err < 0)
2641 return err;
2642 }
2643 }
Matt Porter403d1942005-11-29 15:00:51 +01002644
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002645 if (spec->mic_switch) {
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002646 unsigned int def_conf;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002647 unsigned int mic_pin = AUTO_PIN_MIC;
2648again:
2649 nid = cfg->input_pins[mic_pin];
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002650 def_conf = snd_hda_codec_read(codec, nid, 0,
2651 AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002652 /* some laptops have an internal analog microphone
2653 * which can't be used as a output */
2654 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2655 pincap = snd_hda_param_read(codec, nid,
2656 AC_PAR_PIN_CAP);
2657 if (pincap & AC_PINCAP_OUT) {
2658 err = stac92xx_add_control(spec,
2659 STAC_CTL_WIDGET_IO_SWITCH,
2660 "Mic as Output Switch", (nid << 8) | 1);
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002661 nid = snd_hda_codec_read(codec, nid, 0,
2662 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2663 if (!check_in_dac_nids(spec, nid))
2664 add_spec_dacs(spec, nid);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002665 if (err < 0)
2666 return err;
2667 }
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002668 } else if (mic_pin == AUTO_PIN_MIC) {
2669 mic_pin = AUTO_PIN_FRONT_MIC;
2670 goto again;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002671 }
2672 }
Matt Porter403d1942005-11-29 15:00:51 +01002673
Mattc7d4b2f2005-06-27 14:59:41 +02002674 return 0;
2675}
2676
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002677/* add playback controls for Speaker and HP outputs */
2678static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2679 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002680{
2681 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02002682 hda_nid_t nid;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002683 int i, old_num_dacs, err;
Mattc7d4b2f2005-06-27 14:59:41 +02002684
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002685 old_num_dacs = spec->multiout.num_dacs;
2686 for (i = 0; i < cfg->hp_outs; i++) {
2687 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2688 if (wid_caps & AC_WCAP_UNSOL_CAP)
2689 spec->hp_detect = 1;
2690 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2691 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2692 if (check_in_dac_nids(spec, nid))
2693 nid = 0;
2694 if (! nid)
Mattc7d4b2f2005-06-27 14:59:41 +02002695 continue;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002696 add_spec_dacs(spec, nid);
2697 }
2698 for (i = 0; i < cfg->speaker_outs; i++) {
Steve Longerbeam7b043892007-05-03 20:50:03 +02002699 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002700 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2701 if (check_in_dac_nids(spec, nid))
2702 nid = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002703 if (! nid)
2704 continue;
2705 add_spec_dacs(spec, nid);
Mattc7d4b2f2005-06-27 14:59:41 +02002706 }
Matthew Ranostay1b290a52007-07-12 15:17:34 +02002707 for (i = 0; i < cfg->line_outs; i++) {
2708 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2709 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2710 if (check_in_dac_nids(spec, nid))
2711 nid = 0;
2712 if (! nid)
2713 continue;
2714 add_spec_dacs(spec, nid);
2715 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002716 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2717 static const char *pfxs[] = {
2718 "Speaker", "External Speaker", "Speaker2",
2719 };
2720 err = create_controls(spec, pfxs[i - old_num_dacs],
2721 spec->multiout.dac_nids[i], 3);
2722 if (err < 0)
2723 return err;
2724 }
2725 if (spec->multiout.hp_nid) {
Takashi Iwai2626a262008-03-14 09:18:32 +01002726 err = create_controls(spec, "Headphone",
2727 spec->multiout.hp_nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002728 if (err < 0)
2729 return err;
2730 }
Mattc7d4b2f2005-06-27 14:59:41 +02002731
2732 return 0;
2733}
2734
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002735/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002736static const char *stac92xx_mono_labels[4] = {
2737 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002738};
2739
2740/* create mono mux for mono out on capable codecs */
2741static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
2742{
2743 struct sigmatel_spec *spec = codec->spec;
2744 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
2745 int i, num_cons;
2746 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
2747
2748 num_cons = snd_hda_get_connections(codec,
2749 spec->mono_nid,
2750 con_lst,
2751 HDA_MAX_NUM_INPUTS);
2752 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
2753 return -EINVAL;
2754
2755 for (i = 0; i < num_cons; i++) {
2756 mono_mux->items[mono_mux->num_items].label =
2757 stac92xx_mono_labels[i];
2758 mono_mux->items[mono_mux->num_items].index = i;
2759 mono_mux->num_items++;
2760 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01002761
2762 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
2763 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002764}
2765
Matthew Ranostay1cd22242008-07-18 18:20:52 +02002766/* create PC beep volume controls */
2767static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
2768 hda_nid_t nid)
2769{
2770 struct sigmatel_spec *spec = codec->spec;
2771 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
2772 int err;
2773
2774 /* check for mute support for the the amp */
2775 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
2776 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
2777 "PC Beep Playback Switch",
2778 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
2779 if (err < 0)
2780 return err;
2781 }
2782
2783 /* check to see if there is volume support for the amp */
2784 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
2785 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
2786 "PC Beep Playback Volume",
2787 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
2788 if (err < 0)
2789 return err;
2790 }
2791 return 0;
2792}
2793
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002794static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
2795{
2796 struct sigmatel_spec *spec = codec->spec;
2797 int wcaps, nid, i, err = 0;
2798
2799 for (i = 0; i < spec->num_muxes; i++) {
2800 nid = spec->mux_nids[i];
2801 wcaps = get_wcaps(codec, nid);
2802
2803 if (wcaps & AC_WCAP_OUT_AMP) {
2804 err = stac92xx_add_control_idx(spec,
2805 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
2806 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
2807 if (err < 0)
2808 return err;
2809 }
2810 }
2811 return 0;
2812};
2813
Matt Porter8b657272006-10-26 17:12:59 +02002814/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01002815static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02002816 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
2817 "Digital Mic 3", "Digital Mic 4"
2818};
2819
2820/* create playback/capture controls for input pins on dmic capable codecs */
2821static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
2822 const struct auto_pin_cfg *cfg)
2823{
2824 struct sigmatel_spec *spec = codec->spec;
2825 struct hda_input_mux *dimux = &spec->private_dimux;
2826 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002827 int err, i, j;
2828 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02002829
2830 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
2831 dimux->items[dimux->num_items].index = 0;
2832 dimux->num_items++;
2833
2834 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002835 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02002836 int index;
2837 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002838 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02002839 unsigned int def_conf;
2840
2841 def_conf = snd_hda_codec_read(codec,
2842 spec->dmic_nids[i],
2843 0,
2844 AC_VERB_GET_CONFIG_DEFAULT,
2845 0);
2846 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
2847 continue;
2848
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002849 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02002850 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01002851 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02002852 con_lst,
2853 HDA_MAX_NUM_INPUTS);
2854 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002855 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02002856 index = j;
2857 goto found;
2858 }
2859 continue;
2860found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002861 wcaps = get_wcaps(codec, nid) &
2862 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002863
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002864 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002865 sprintf(name, "%s Capture Volume",
2866 stac92xx_dmic_labels[dimux->num_items]);
2867
2868 err = stac92xx_add_control(spec,
2869 STAC_CTL_WIDGET_VOL,
2870 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002871 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
2872 (wcaps & AC_WCAP_OUT_AMP) ?
2873 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002874 if (err < 0)
2875 return err;
2876 }
2877
Matt Porter8b657272006-10-26 17:12:59 +02002878 dimux->items[dimux->num_items].label =
2879 stac92xx_dmic_labels[dimux->num_items];
2880 dimux->items[dimux->num_items].index = index;
2881 dimux->num_items++;
2882 }
2883
2884 return 0;
2885}
2886
Mattc7d4b2f2005-06-27 14:59:41 +02002887/* create playback/capture controls for input pins */
2888static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
2889{
2890 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02002891 struct hda_input_mux *imux = &spec->private_imux;
2892 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
2893 int i, j, k;
2894
2895 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02002896 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02002897
Takashi Iwai314634b2006-09-21 11:56:18 +02002898 if (!cfg->input_pins[i])
2899 continue;
2900 index = -1;
2901 for (j = 0; j < spec->num_muxes; j++) {
2902 int num_cons;
2903 num_cons = snd_hda_get_connections(codec,
2904 spec->mux_nids[j],
2905 con_lst,
2906 HDA_MAX_NUM_INPUTS);
2907 for (k = 0; k < num_cons; k++)
2908 if (con_lst[k] == cfg->input_pins[i]) {
2909 index = k;
2910 goto found;
2911 }
Mattc7d4b2f2005-06-27 14:59:41 +02002912 }
Takashi Iwai314634b2006-09-21 11:56:18 +02002913 continue;
2914 found:
2915 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2916 imux->items[imux->num_items].index = index;
2917 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02002918 }
2919
Steve Longerbeam7b043892007-05-03 20:50:03 +02002920 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02002921 /*
2922 * Set the current input for the muxes.
2923 * The STAC9221 has two input muxes with identical source
2924 * NID lists. Hopefully this won't get confused.
2925 */
2926 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002927 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
2928 AC_VERB_SET_CONNECT_SEL,
2929 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02002930 }
2931 }
2932
Mattc7d4b2f2005-06-27 14:59:41 +02002933 return 0;
2934}
2935
Mattc7d4b2f2005-06-27 14:59:41 +02002936static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
2937{
2938 struct sigmatel_spec *spec = codec->spec;
2939 int i;
2940
2941 for (i = 0; i < spec->autocfg.line_outs; i++) {
2942 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2943 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2944 }
2945}
2946
2947static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
2948{
2949 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002950 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02002951
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002952 for (i = 0; i < spec->autocfg.hp_outs; i++) {
2953 hda_nid_t pin;
2954 pin = spec->autocfg.hp_pins[i];
2955 if (pin) /* connect to front */
2956 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
2957 }
2958 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
2959 hda_nid_t pin;
2960 pin = spec->autocfg.speaker_pins[i];
2961 if (pin) /* connect to front */
2962 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
2963 }
Mattc7d4b2f2005-06-27 14:59:41 +02002964}
2965
Matt Porter3cc08dc2006-01-23 15:27:49 +01002966static 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 +02002967{
2968 struct sigmatel_spec *spec = codec->spec;
2969 int err;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01002970 int hp_speaker_swap = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02002971
Matt Porter8b657272006-10-26 17:12:59 +02002972 if ((err = snd_hda_parse_pin_def_config(codec,
2973 &spec->autocfg,
2974 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002975 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01002976 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01002977 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02002978
Jiang Zhebcecd9b2007-11-12 12:57:03 +01002979 /* If we have no real line-out pin and multiple hp-outs, HPs should
2980 * be set up as multi-channel outputs.
2981 */
2982 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
2983 spec->autocfg.hp_outs > 1) {
2984 /* Copy hp_outs to line_outs, backup line_outs in
2985 * speaker_outs so that the following routines can handle
2986 * HP pins as primary outputs.
2987 */
2988 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
2989 sizeof(spec->autocfg.line_out_pins));
2990 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
2991 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
2992 sizeof(spec->autocfg.hp_pins));
2993 spec->autocfg.line_outs = spec->autocfg.hp_outs;
2994 hp_speaker_swap = 1;
2995 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01002996 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002997 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
2998 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01002999 u32 caps = query_amp_caps(codec,
3000 spec->autocfg.mono_out_pin, dir);
3001 hda_nid_t conn_list[1];
3002
3003 /* get the mixer node and then the mono mux if it exists */
3004 if (snd_hda_get_connections(codec,
3005 spec->autocfg.mono_out_pin, conn_list, 1) &&
3006 snd_hda_get_connections(codec, conn_list[0],
3007 conn_list, 1)) {
3008
3009 int wcaps = get_wcaps(codec, conn_list[0]);
3010 int wid_type = (wcaps & AC_WCAP_TYPE)
3011 >> AC_WCAP_TYPE_SHIFT;
3012 /* LR swap check, some stac925x have a mux that
3013 * changes the DACs output path instead of the
3014 * mono-mux path.
3015 */
3016 if (wid_type == AC_WID_AUD_SEL &&
3017 !(wcaps & AC_WCAP_LR_SWAP))
3018 spec->mono_nid = conn_list[0];
3019 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003020 if (dir) {
3021 hda_nid_t nid = spec->autocfg.mono_out_pin;
3022
3023 /* most mono outs have a least a mute/unmute switch */
3024 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3025 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3026 "Mono Playback Switch",
3027 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003028 if (err < 0)
3029 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003030 /* check for volume support for the amp */
3031 if ((caps & AC_AMPCAP_NUM_STEPS)
3032 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3033 err = stac92xx_add_control(spec,
3034 STAC_CTL_WIDGET_VOL,
3035 "Mono Playback Volume",
3036 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3037 if (err < 0)
3038 return err;
3039 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003040 }
3041
3042 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3043 AC_PINCTL_OUT_EN);
3044 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003045
Matt Porter403d1942005-11-29 15:00:51 +01003046 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
3047 return err;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003048 if (spec->multiout.num_dacs == 0)
3049 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
3050 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003051
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003052 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
3053
3054 if (err < 0)
3055 return err;
3056
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003057 /* setup analog beep controls */
3058 if (spec->anabeep_nid > 0) {
3059 err = stac92xx_auto_create_beep_ctls(codec,
3060 spec->anabeep_nid);
3061 if (err < 0)
3062 return err;
3063 }
3064
3065 /* setup digital beep controls and input device */
3066#ifdef CONFIG_SND_HDA_INPUT_BEEP
3067 if (spec->digbeep_nid > 0) {
3068 hda_nid_t nid = spec->digbeep_nid;
3069
3070 err = stac92xx_auto_create_beep_ctls(codec, nid);
3071 if (err < 0)
3072 return err;
3073 err = snd_hda_attach_beep_device(codec, nid);
3074 if (err < 0)
3075 return err;
3076 }
3077#endif
3078
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003079 if (hp_speaker_swap == 1) {
3080 /* Restore the hp_outs and line_outs */
3081 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3082 sizeof(spec->autocfg.line_out_pins));
3083 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3084 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
3085 sizeof(spec->autocfg.speaker_pins));
3086 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
3087 memset(spec->autocfg.speaker_pins, 0,
3088 sizeof(spec->autocfg.speaker_pins));
3089 spec->autocfg.speaker_outs = 0;
3090 }
3091
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003092 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3093
3094 if (err < 0)
3095 return err;
3096
3097 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3098
3099 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003100 return err;
3101
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003102 if (spec->mono_nid > 0) {
3103 err = stac92xx_auto_create_mono_output_ctls(codec);
3104 if (err < 0)
3105 return err;
3106 }
3107
Matt Porter8b657272006-10-26 17:12:59 +02003108 if (spec->num_dmics > 0)
3109 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3110 &spec->autocfg)) < 0)
3111 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003112 if (spec->num_muxes > 0) {
3113 err = stac92xx_auto_create_mux_input_ctls(codec);
3114 if (err < 0)
3115 return err;
3116 }
Matt Porter8b657272006-10-26 17:12:59 +02003117
Mattc7d4b2f2005-06-27 14:59:41 +02003118 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003119 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003120 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003121
Takashi Iwai82bc9552006-03-21 11:24:42 +01003122 if (spec->autocfg.dig_out_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003123 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003124 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003125 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003126
3127 if (spec->kctl_alloc)
3128 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3129
3130 spec->input_mux = &spec->private_imux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003131 if (!spec->dinput_mux)
3132 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003133 spec->mono_mux = &spec->private_mono_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003134
3135 return 1;
3136}
3137
Takashi Iwai82bc9552006-03-21 11:24:42 +01003138/* add playback controls for HP output */
3139static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3140 struct auto_pin_cfg *cfg)
3141{
3142 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003143 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003144 unsigned int wid_caps;
3145
3146 if (! pin)
3147 return 0;
3148
3149 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003150 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003151 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003152
3153 return 0;
3154}
3155
Richard Fish160ea0d2006-09-06 13:58:25 +02003156/* add playback controls for LFE output */
3157static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3158 struct auto_pin_cfg *cfg)
3159{
3160 struct sigmatel_spec *spec = codec->spec;
3161 int err;
3162 hda_nid_t lfe_pin = 0x0;
3163 int i;
3164
3165 /*
3166 * search speaker outs and line outs for a mono speaker pin
3167 * with an amp. If one is found, add LFE controls
3168 * for it.
3169 */
3170 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3171 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003172 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003173 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3174 if (wcaps == AC_WCAP_OUT_AMP)
3175 /* found a mono speaker with an amp, must be lfe */
3176 lfe_pin = pin;
3177 }
3178
3179 /* if speaker_outs is 0, then speakers may be in line_outs */
3180 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3181 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3182 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003183 unsigned int defcfg;
Harvey Harrison8b551782008-02-29 11:56:48 +01003184 defcfg = snd_hda_codec_read(codec, pin, 0,
Richard Fish160ea0d2006-09-06 13:58:25 +02003185 AC_VERB_GET_CONFIG_DEFAULT,
3186 0x00);
Harvey Harrison8b551782008-02-29 11:56:48 +01003187 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003188 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003189 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3190 if (wcaps == AC_WCAP_OUT_AMP)
3191 /* found a mono speaker with an amp,
3192 must be lfe */
3193 lfe_pin = pin;
3194 }
3195 }
3196 }
3197
3198 if (lfe_pin) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003199 err = create_controls(spec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003200 if (err < 0)
3201 return err;
3202 }
3203
3204 return 0;
3205}
3206
Mattc7d4b2f2005-06-27 14:59:41 +02003207static int stac9200_parse_auto_config(struct hda_codec *codec)
3208{
3209 struct sigmatel_spec *spec = codec->spec;
3210 int err;
3211
Kailang Yangdf694da2005-12-05 19:42:22 +01003212 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003213 return err;
3214
3215 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3216 return err;
3217
Takashi Iwai82bc9552006-03-21 11:24:42 +01003218 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3219 return err;
3220
Richard Fish160ea0d2006-09-06 13:58:25 +02003221 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3222 return err;
3223
Takashi Iwai82bc9552006-03-21 11:24:42 +01003224 if (spec->autocfg.dig_out_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003225 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003226 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003227 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003228
3229 if (spec->kctl_alloc)
3230 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3231
3232 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003233 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003234
3235 return 1;
3236}
3237
Sam Revitch62fe78e2006-05-10 15:09:17 +02003238/*
3239 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3240 * funky external mute control using GPIO pins.
3241 */
3242
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003243static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003244 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003245{
3246 unsigned int gpiostate, gpiomask, gpiodir;
3247
3248 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3249 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003250 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003251
3252 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3253 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003254 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003255
3256 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3257 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003258 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003259
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003260 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003261 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3262
3263 snd_hda_codec_write(codec, codec->afg, 0,
3264 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003265 snd_hda_codec_read(codec, codec->afg, 0,
3266 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003267
3268 msleep(1);
3269
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003270 snd_hda_codec_read(codec, codec->afg, 0,
3271 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003272}
3273
Takashi Iwai314634b2006-09-21 11:56:18 +02003274static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3275 unsigned int event)
3276{
3277 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003278 snd_hda_codec_write_cache(codec, nid, 0,
3279 AC_VERB_SET_UNSOLICITED_ENABLE,
3280 (AC_USRSP_EN | event));
Takashi Iwai314634b2006-09-21 11:56:18 +02003281}
3282
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003283static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3284{
3285 int i;
3286 for (i = 0; i < cfg->hp_outs; i++)
3287 if (cfg->hp_pins[i] == nid)
3288 return 1; /* nid is a HP-Out */
3289
3290 return 0; /* nid is not a HP-Out */
3291};
3292
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003293static void stac92xx_power_down(struct hda_codec *codec)
3294{
3295 struct sigmatel_spec *spec = codec->spec;
3296
3297 /* power down inactive DACs */
3298 hda_nid_t *dac;
3299 for (dac = spec->dac_list; *dac; dac++)
Matthew Ranostay44510892008-02-21 07:49:31 +01003300 if (!is_in_dac_nids(spec, *dac) &&
3301 spec->multiout.hp_nid != *dac)
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003302 snd_hda_codec_write_cache(codec, *dac, 0,
3303 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3304}
3305
Mattc7d4b2f2005-06-27 14:59:41 +02003306static int stac92xx_init(struct hda_codec *codec)
3307{
3308 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003309 struct auto_pin_cfg *cfg = &spec->autocfg;
3310 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003311
Mattc7d4b2f2005-06-27 14:59:41 +02003312 snd_hda_sequence_write(codec, spec->init);
3313
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003314 /* power down adcs initially */
3315 if (spec->powerdown_adcs)
3316 for (i = 0; i < spec->num_adcs; i++)
3317 snd_hda_codec_write_cache(codec,
3318 spec->adc_nids[i], 0,
3319 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003320 /* set up pins */
3321 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02003322 /* Enable unsolicited responses on the HP widget */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003323 for (i = 0; i < cfg->hp_outs; i++)
Takashi Iwai314634b2006-09-21 11:56:18 +02003324 enable_pin_detect(codec, cfg->hp_pins[i],
3325 STAC_HP_EVENT);
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01003326 /* force to enable the first line-out; the others are set up
3327 * in unsol_event
3328 */
3329 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3330 AC_PINCTL_OUT_EN);
Takashi Iwaieb995a82006-09-21 14:28:21 +02003331 stac92xx_auto_init_hp_out(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003332 /* fake event to set up pins */
3333 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3334 } else {
3335 stac92xx_auto_init_multi_out(codec);
3336 stac92xx_auto_init_hp_out(codec);
3337 }
3338 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01003339 hda_nid_t nid = cfg->input_pins[i];
3340 if (nid) {
3341 unsigned int pinctl = AC_PINCTL_IN_EN;
3342 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
3343 pinctl |= stac92xx_get_vref(codec, nid);
3344 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3345 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01003346 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003347 for (i = 0; i < spec->num_dmics; i++)
3348 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3349 AC_PINCTL_IN_EN);
3350 for (i = 0; i < spec->num_pwrs; i++) {
3351 int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
3352 ? STAC_HP_EVENT : STAC_PWR_EVENT;
3353 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
3354 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003355 int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
3356 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003357 def_conf = get_defcfg_connect(def_conf);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003358 /* outputs are only ports capable of power management
3359 * any attempts on powering down a input port cause the
3360 * referenced VREF to act quirky.
3361 */
3362 if (pinctl & AC_PINCTL_IN_EN)
3363 continue;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003364 /* skip any ports that don't have jacks since presence
3365 * detection is useless */
3366 if (def_conf && def_conf != AC_JACK_PORT_FIXED)
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003367 continue;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003368 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3369 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3370 }
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003371 if (spec->dac_list)
3372 stac92xx_power_down(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003373 if (cfg->dig_out_pin)
3374 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3375 AC_PINCTL_OUT_EN);
3376 if (cfg->dig_in_pin)
3377 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3378 AC_PINCTL_IN_EN);
3379
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003380 stac_gpio_set(codec, spec->gpio_mask,
3381 spec->gpio_dir, spec->gpio_data);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003382
Mattc7d4b2f2005-06-27 14:59:41 +02003383 return 0;
3384}
3385
Matt2f2f4252005-04-13 14:45:30 +02003386static void stac92xx_free(struct hda_codec *codec)
3387{
Mattc7d4b2f2005-06-27 14:59:41 +02003388 struct sigmatel_spec *spec = codec->spec;
3389 int i;
3390
3391 if (! spec)
3392 return;
3393
3394 if (spec->kctl_alloc) {
3395 for (i = 0; i < spec->num_kctl_used; i++)
3396 kfree(spec->kctl_alloc[i].name);
3397 kfree(spec->kctl_alloc);
3398 }
3399
Richard Fish11b44bb2006-08-23 18:31:34 +02003400 if (spec->bios_pin_configs)
3401 kfree(spec->bios_pin_configs);
3402
Mattc7d4b2f2005-06-27 14:59:41 +02003403 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003404 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02003405}
3406
Matt4e550962005-07-04 17:51:39 +02003407static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3408 unsigned int flag)
3409{
3410 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3411 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02003412
Takashi Iwaif9acba42007-05-29 18:01:06 +02003413 if (pin_ctl & AC_PINCTL_IN_EN) {
3414 /*
3415 * we need to check the current set-up direction of
3416 * shared input pins since they can be switched via
3417 * "xxx as Output" mixer switch
3418 */
3419 struct sigmatel_spec *spec = codec->spec;
3420 struct auto_pin_cfg *cfg = &spec->autocfg;
3421 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3422 spec->line_switch) ||
3423 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3424 spec->mic_switch))
3425 return;
3426 }
3427
Steve Longerbeam7b043892007-05-03 20:50:03 +02003428 /* if setting pin direction bits, clear the current
3429 direction bits first */
3430 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3431 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3432
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003433 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003434 AC_VERB_SET_PIN_WIDGET_CONTROL,
3435 pin_ctl | flag);
3436}
3437
3438static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3439 unsigned int flag)
3440{
3441 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3442 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003443 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003444 AC_VERB_SET_PIN_WIDGET_CONTROL,
3445 pin_ctl & ~flag);
3446}
3447
Jiang Zhe40c1d302007-11-12 13:05:16 +01003448static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02003449{
3450 if (!nid)
3451 return 0;
3452 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Jiang Zhe40c1d302007-11-12 13:05:16 +01003453 & (1 << 31)) {
3454 unsigned int pinctl;
3455 pinctl = snd_hda_codec_read(codec, nid, 0,
3456 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3457 if (pinctl & AC_PINCTL_IN_EN)
3458 return 0; /* mic- or line-input */
3459 else
3460 return 1; /* HP-output */
3461 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003462 return 0;
3463}
3464
3465static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
Matt4e550962005-07-04 17:51:39 +02003466{
3467 struct sigmatel_spec *spec = codec->spec;
3468 struct auto_pin_cfg *cfg = &spec->autocfg;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003469 int nid = cfg->hp_pins[cfg->hp_outs - 1];
Matt4e550962005-07-04 17:51:39 +02003470 int i, presence;
3471
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003472 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003473 if (spec->gpio_mute)
3474 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3475 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3476
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003477 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003478 if (presence)
3479 break;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003480 if (spec->hp_switch && cfg->hp_pins[i] == nid)
3481 break;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003482 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003483 }
Matt4e550962005-07-04 17:51:39 +02003484
3485 if (presence) {
3486 /* disable lineouts, enable hp */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003487 if (spec->hp_switch)
3488 stac92xx_reset_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003489 for (i = 0; i < cfg->line_outs; i++)
3490 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3491 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003492 for (i = 0; i < cfg->speaker_outs; i++)
3493 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3494 AC_PINCTL_OUT_EN);
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003495 if (spec->eapd_mask)
3496 stac_gpio_set(codec, spec->gpio_mask,
3497 spec->gpio_dir, spec->gpio_data &
3498 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003499 } else {
3500 /* enable lineouts, disable hp */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003501 if (spec->hp_switch)
3502 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003503 for (i = 0; i < cfg->line_outs; i++)
3504 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3505 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003506 for (i = 0; i < cfg->speaker_outs; i++)
3507 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3508 AC_PINCTL_OUT_EN);
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003509 if (spec->eapd_mask)
3510 stac_gpio_set(codec, spec->gpio_mask,
3511 spec->gpio_dir, spec->gpio_data |
3512 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003513 }
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003514 if (!spec->hp_switch && cfg->hp_outs > 1 && presence)
3515 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003516}
3517
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003518static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
3519{
3520 struct sigmatel_spec *spec = codec->spec;
3521 hda_nid_t nid = spec->pwr_nids[idx];
3522 int presence, val;
3523 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
3524 & 0x000000ff;
3525 presence = get_hp_pin_presence(codec, nid);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003526
3527 /* several codecs have two power down bits */
3528 if (spec->pwr_mapping)
3529 idx = spec->pwr_mapping[idx];
3530 else
3531 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003532
3533 if (presence)
3534 val &= ~idx;
3535 else
3536 val |= idx;
3537
3538 /* power down unused output ports */
3539 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
3540};
3541
Takashi Iwai314634b2006-09-21 11:56:18 +02003542static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
3543{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003544 struct sigmatel_spec *spec = codec->spec;
3545 int idx = res >> 26 & 0x0f;
3546
3547 switch ((res >> 26) & 0x30) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003548 case STAC_HP_EVENT:
3549 stac92xx_hp_detect(codec, res);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003550 /* fallthru */
3551 case STAC_PWR_EVENT:
3552 if (spec->num_pwrs > 0)
3553 stac92xx_pin_sense(codec, idx);
Takashi Iwai314634b2006-09-21 11:56:18 +02003554 }
3555}
3556
Takashi Iwaicb53c622007-08-10 17:21:45 +02003557#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02003558static int stac92xx_resume(struct hda_codec *codec)
3559{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003560 struct sigmatel_spec *spec = codec->spec;
3561
Richard Fish11b44bb2006-08-23 18:31:34 +02003562 stac92xx_set_config_regs(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003563 snd_hda_sequence_write(codec, spec->init);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003564 stac_gpio_set(codec, spec->gpio_mask,
3565 spec->gpio_dir, spec->gpio_data);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003566 snd_hda_codec_resume_amp(codec);
3567 snd_hda_codec_resume_cache(codec);
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003568 /* power down inactive DACs */
3569 if (spec->dac_list)
3570 stac92xx_power_down(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003571 /* invoke unsolicited event to reset the HP state */
3572 if (spec->hp_detect)
3573 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
Mattff6fdc32005-06-27 15:06:52 +02003574 return 0;
3575}
3576#endif
3577
Matt2f2f4252005-04-13 14:45:30 +02003578static struct hda_codec_ops stac92xx_patch_ops = {
3579 .build_controls = stac92xx_build_controls,
3580 .build_pcms = stac92xx_build_pcms,
3581 .init = stac92xx_init,
3582 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02003583 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003584#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02003585 .resume = stac92xx_resume,
3586#endif
Matt2f2f4252005-04-13 14:45:30 +02003587};
3588
3589static int patch_stac9200(struct hda_codec *codec)
3590{
3591 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003592 int err;
Matt2f2f4252005-04-13 14:45:30 +02003593
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003594 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02003595 if (spec == NULL)
3596 return -ENOMEM;
3597
3598 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003599 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02003600 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003601 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
3602 stac9200_models,
3603 stac9200_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02003604 if (spec->board_config < 0) {
3605 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
3606 err = stac92xx_save_bios_config_regs(codec);
3607 if (err < 0) {
3608 stac92xx_free(codec);
3609 return err;
3610 }
3611 spec->pin_configs = spec->bios_pin_configs;
3612 } else {
Matt Porter403d1942005-11-29 15:00:51 +01003613 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
3614 stac92xx_set_config_regs(codec);
3615 }
Matt2f2f4252005-04-13 14:45:30 +02003616
3617 spec->multiout.max_channels = 2;
3618 spec->multiout.num_dacs = 1;
3619 spec->multiout.dac_nids = stac9200_dac_nids;
3620 spec->adc_nids = stac9200_adc_nids;
3621 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02003622 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02003623 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003624 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003625 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003626
Tobin Davisbf277782008-02-03 20:31:47 +01003627 if (spec->board_config == STAC_9200_GATEWAY ||
3628 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02003629 spec->init = stac9200_eapd_init;
3630 else
3631 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02003632 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02003633
Takashi Iwai117f2572008-03-18 09:53:23 +01003634 if (spec->board_config == STAC_9200_PANASONIC) {
3635 spec->gpio_mask = spec->gpio_dir = 0x09;
3636 spec->gpio_data = 0x00;
3637 }
3638
Mattc7d4b2f2005-06-27 14:59:41 +02003639 err = stac9200_parse_auto_config(codec);
3640 if (err < 0) {
3641 stac92xx_free(codec);
3642 return err;
3643 }
Matt2f2f4252005-04-13 14:45:30 +02003644
3645 codec->patch_ops = stac92xx_patch_ops;
3646
3647 return 0;
3648}
3649
Tobin Davis8e21c342007-01-08 11:04:17 +01003650static int patch_stac925x(struct hda_codec *codec)
3651{
3652 struct sigmatel_spec *spec;
3653 int err;
3654
3655 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3656 if (spec == NULL)
3657 return -ENOMEM;
3658
3659 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003660 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01003661 spec->pin_nids = stac925x_pin_nids;
3662 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
3663 stac925x_models,
3664 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01003665 again:
Tobin Davis8e21c342007-01-08 11:04:17 +01003666 if (spec->board_config < 0) {
Tobin Davis2c11f952007-05-17 09:36:34 +02003667 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
3668 "using BIOS defaults\n");
Tobin Davis8e21c342007-01-08 11:04:17 +01003669 err = stac92xx_save_bios_config_regs(codec);
3670 if (err < 0) {
3671 stac92xx_free(codec);
3672 return err;
3673 }
3674 spec->pin_configs = spec->bios_pin_configs;
3675 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
3676 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
3677 stac92xx_set_config_regs(codec);
3678 }
3679
3680 spec->multiout.max_channels = 2;
3681 spec->multiout.num_dacs = 1;
3682 spec->multiout.dac_nids = stac925x_dac_nids;
3683 spec->adc_nids = stac925x_adc_nids;
3684 spec->mux_nids = stac925x_mux_nids;
3685 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003686 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003687 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02003688 switch (codec->vendor_id) {
3689 case 0x83847632: /* STAC9202 */
3690 case 0x83847633: /* STAC9202D */
3691 case 0x83847636: /* STAC9251 */
3692 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02003693 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02003694 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01003695 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
3696 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02003697 break;
3698 default:
3699 spec->num_dmics = 0;
3700 break;
3701 }
Tobin Davis8e21c342007-01-08 11:04:17 +01003702
3703 spec->init = stac925x_core_init;
3704 spec->mixer = stac925x_mixer;
3705
3706 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01003707 if (!err) {
3708 if (spec->board_config < 0) {
3709 printk(KERN_WARNING "hda_codec: No auto-config is "
3710 "available, default to model=ref\n");
3711 spec->board_config = STAC_925x_REF;
3712 goto again;
3713 }
3714 err = -EINVAL;
3715 }
Tobin Davis8e21c342007-01-08 11:04:17 +01003716 if (err < 0) {
3717 stac92xx_free(codec);
3718 return err;
3719 }
3720
3721 codec->patch_ops = stac92xx_patch_ops;
3722
3723 return 0;
3724}
3725
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003726static struct hda_input_mux stac92hd73xx_dmux = {
3727 .num_items = 4,
3728 .items = {
3729 { "Analog Inputs", 0x0b },
3730 { "CD", 0x08 },
3731 { "Digital Mic 1", 0x09 },
3732 { "Digital Mic 2", 0x0a },
3733 }
3734};
3735
3736static int patch_stac92hd73xx(struct hda_codec *codec)
3737{
3738 struct sigmatel_spec *spec;
3739 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
3740 int err = 0;
3741
3742 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3743 if (spec == NULL)
3744 return -ENOMEM;
3745
3746 codec->spec = spec;
3747 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
3748 spec->pin_nids = stac92hd73xx_pin_nids;
3749 spec->board_config = snd_hda_check_board_config(codec,
3750 STAC_92HD73XX_MODELS,
3751 stac92hd73xx_models,
3752 stac92hd73xx_cfg_tbl);
3753again:
3754 if (spec->board_config < 0) {
3755 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3756 " STAC92HD73XX, using BIOS defaults\n");
3757 err = stac92xx_save_bios_config_regs(codec);
3758 if (err < 0) {
3759 stac92xx_free(codec);
3760 return err;
3761 }
3762 spec->pin_configs = spec->bios_pin_configs;
3763 } else {
3764 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
3765 stac92xx_set_config_regs(codec);
3766 }
3767
3768 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
3769 conn, STAC92HD73_DAC_COUNT + 2) - 1;
3770
3771 if (spec->multiout.num_dacs < 0) {
3772 printk(KERN_WARNING "hda_codec: Could not determine "
3773 "number of channels defaulting to DAC count\n");
3774 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
3775 }
3776
3777 switch (spec->multiout.num_dacs) {
3778 case 0x3: /* 6 Channel */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003779 spec->multiout.hp_nid = 0x17;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003780 spec->mixer = stac92hd73xx_6ch_mixer;
3781 spec->init = stac92hd73xx_6ch_core_init;
3782 break;
3783 case 0x4: /* 8 Channel */
3784 spec->multiout.hp_nid = 0x18;
3785 spec->mixer = stac92hd73xx_8ch_mixer;
3786 spec->init = stac92hd73xx_8ch_core_init;
3787 break;
3788 case 0x5: /* 10 Channel */
3789 spec->multiout.hp_nid = 0x19;
3790 spec->mixer = stac92hd73xx_10ch_mixer;
3791 spec->init = stac92hd73xx_10ch_core_init;
3792 };
3793
3794 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
3795 spec->aloopback_mask = 0x01;
3796 spec->aloopback_shift = 8;
3797
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003798 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003799 spec->mux_nids = stac92hd73xx_mux_nids;
3800 spec->adc_nids = stac92hd73xx_adc_nids;
3801 spec->dmic_nids = stac92hd73xx_dmic_nids;
3802 spec->dmux_nids = stac92hd73xx_dmux_nids;
3803
3804 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
3805 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01003806 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003807 spec->dinput_mux = &stac92hd73xx_dmux;
3808 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003809 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003810 spec->gpio_data = 0x01;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003811
Matthew Ranostaya7662642008-02-21 07:51:14 +01003812 switch (spec->board_config) {
3813 case STAC_DELL_M6:
Matthew Ranostayd654a662008-03-14 08:46:51 +01003814 spec->init = dell_eq_core_init;
Matthew Ranostaya7662642008-02-21 07:51:14 +01003815 switch (codec->subsystem_id) {
3816 case 0x1028025e: /* Analog Mics */
3817 case 0x1028025f:
3818 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
3819 spec->num_dmics = 0;
3820 break;
Matthew Ranostayd654a662008-03-14 08:46:51 +01003821 case 0x10280271: /* Digital Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01003822 case 0x10280272:
Matthew Ranostayd654a662008-03-14 08:46:51 +01003823 spec->init = dell_m6_core_init;
3824 /* fall-through */
3825 case 0x10280254:
3826 case 0x10280255:
Matthew Ranostaya7662642008-02-21 07:51:14 +01003827 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
3828 spec->num_dmics = 1;
3829 break;
3830 case 0x10280256: /* Both */
3831 case 0x10280057:
3832 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
3833 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
3834 spec->num_dmics = 1;
3835 break;
3836 }
3837 break;
3838 default:
3839 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
3840 }
3841
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003842 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
3843 spec->pwr_nids = stac92hd73xx_pwr_nids;
3844
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003845 err = stac92xx_parse_auto_config(codec, 0x22, 0x24);
3846
3847 if (!err) {
3848 if (spec->board_config < 0) {
3849 printk(KERN_WARNING "hda_codec: No auto-config is "
3850 "available, default to model=ref\n");
3851 spec->board_config = STAC_92HD73XX_REF;
3852 goto again;
3853 }
3854 err = -EINVAL;
3855 }
3856
3857 if (err < 0) {
3858 stac92xx_free(codec);
3859 return err;
3860 }
3861
3862 codec->patch_ops = stac92xx_patch_ops;
3863
3864 return 0;
3865}
3866
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003867static struct hda_input_mux stac92hd83xxx_dmux = {
3868 .num_items = 3,
3869 .items = {
3870 { "Analog Inputs", 0x03 },
3871 { "Digital Mic 1", 0x04 },
3872 { "Digital Mic 2", 0x05 },
3873 }
3874};
3875
3876static int patch_stac92hd83xxx(struct hda_codec *codec)
3877{
3878 struct sigmatel_spec *spec;
3879 int err;
3880
3881 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3882 if (spec == NULL)
3883 return -ENOMEM;
3884
3885 codec->spec = spec;
3886 spec->mono_nid = 0x19;
3887 spec->digbeep_nid = 0x21;
3888 spec->dmic_nids = stac92hd83xxx_dmic_nids;
3889 spec->dmux_nids = stac92hd83xxx_dmux_nids;
3890 spec->adc_nids = stac92hd83xxx_adc_nids;
3891 spec->pwr_nids = stac92hd83xxx_pwr_nids;
3892 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
3893 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
3894 spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
3895
3896 spec->init = stac92hd83xxx_core_init;
3897 switch (codec->vendor_id) {
3898 case 0x111d7605:
3899 spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
3900 break;
3901 default:
3902 spec->num_pwrs--;
3903 spec->init++; /* switch to config #2 */
3904 spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
3905 }
3906
3907 spec->mixer = stac92hd83xxx_mixer;
3908 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
3909 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
3910 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
3911 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
3912 spec->dinput_mux = &stac92hd83xxx_dmux;
3913 spec->pin_nids = stac92hd83xxx_pin_nids;
3914 spec->board_config = snd_hda_check_board_config(codec,
3915 STAC_92HD83XXX_MODELS,
3916 stac92hd83xxx_models,
3917 stac92hd83xxx_cfg_tbl);
3918again:
3919 if (spec->board_config < 0) {
3920 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3921 " STAC92HD83XXX, using BIOS defaults\n");
3922 err = stac92xx_save_bios_config_regs(codec);
3923 if (err < 0) {
3924 stac92xx_free(codec);
3925 return err;
3926 }
3927 spec->pin_configs = spec->bios_pin_configs;
3928 } else {
3929 spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config];
3930 stac92xx_set_config_regs(codec);
3931 }
3932
3933 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
3934 if (!err) {
3935 if (spec->board_config < 0) {
3936 printk(KERN_WARNING "hda_codec: No auto-config is "
3937 "available, default to model=ref\n");
3938 spec->board_config = STAC_92HD83XXX_REF;
3939 goto again;
3940 }
3941 err = -EINVAL;
3942 }
3943
3944 if (err < 0) {
3945 stac92xx_free(codec);
3946 return err;
3947 }
3948
3949 codec->patch_ops = stac92xx_patch_ops;
3950
3951 return 0;
3952}
3953
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003954#ifdef SND_HDA_NEEDS_RESUME
3955static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr)
3956{
3957 struct sigmatel_spec *spec = codec->spec;
3958 int i;
3959 snd_hda_codec_write_cache(codec, codec->afg, 0,
3960 AC_VERB_SET_POWER_STATE, pwr);
3961
3962 msleep(1);
3963 for (i = 0; i < spec->num_adcs; i++) {
3964 snd_hda_codec_write_cache(codec,
3965 spec->adc_nids[i], 0,
3966 AC_VERB_SET_POWER_STATE, pwr);
3967 }
3968};
3969
3970static int stac92hd71xx_resume(struct hda_codec *codec)
3971{
3972 stac92hd71xx_set_power_state(codec, AC_PWRST_D0);
3973 return stac92xx_resume(codec);
3974}
3975
3976static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state)
3977{
3978 stac92hd71xx_set_power_state(codec, AC_PWRST_D3);
3979 return 0;
3980};
3981
3982#endif
3983
3984static struct hda_codec_ops stac92hd71bxx_patch_ops = {
3985 .build_controls = stac92xx_build_controls,
3986 .build_pcms = stac92xx_build_pcms,
3987 .init = stac92xx_init,
3988 .free = stac92xx_free,
3989 .unsol_event = stac92xx_unsol_event,
3990#ifdef SND_HDA_NEEDS_RESUME
3991 .resume = stac92hd71xx_resume,
3992 .suspend = stac92hd71xx_suspend,
3993#endif
3994};
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003995
Matthew Ranostaye035b842007-11-06 11:53:55 +01003996static int patch_stac92hd71bxx(struct hda_codec *codec)
3997{
3998 struct sigmatel_spec *spec;
3999 int err = 0;
4000
4001 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4002 if (spec == NULL)
4003 return -ENOMEM;
4004
4005 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004006 codec->patch_ops = stac92xx_patch_ops;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004007 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004008 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004009 spec->pin_nids = stac92hd71bxx_pin_nids;
4010 spec->board_config = snd_hda_check_board_config(codec,
4011 STAC_92HD71BXX_MODELS,
4012 stac92hd71bxx_models,
4013 stac92hd71bxx_cfg_tbl);
4014again:
4015 if (spec->board_config < 0) {
4016 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4017 " STAC92HD71BXX, using BIOS defaults\n");
4018 err = stac92xx_save_bios_config_regs(codec);
4019 if (err < 0) {
4020 stac92xx_free(codec);
4021 return err;
4022 }
4023 spec->pin_configs = spec->bios_pin_configs;
4024 } else {
4025 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
4026 stac92xx_set_config_regs(codec);
4027 }
4028
Matthew Ranostay541eee82007-12-14 12:08:04 +01004029 switch (codec->vendor_id) {
4030 case 0x111d76b6: /* 4 Port without Analog Mixer */
4031 case 0x111d76b7:
4032 case 0x111d76b4: /* 6 Port without Analog Mixer */
4033 case 0x111d76b5:
4034 spec->mixer = stac92hd71bxx_mixer;
4035 spec->init = stac92hd71bxx_core_init;
4036 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004037 case 0x111d7608: /* 5 Port with Analog Mixer */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004038 if ((codec->revision_id & 0xf) == 0 ||
4039 (codec->revision_id & 0xf) == 1) {
4040#ifdef SND_HDA_NEEDS_RESUME
4041 codec->patch_ops = stac92hd71bxx_patch_ops;
4042#endif
4043 spec->stream_delay = 40; /* 40 milliseconds */
4044 }
4045
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004046 /* no output amps */
4047 spec->num_pwrs = 0;
4048 spec->mixer = stac92hd71bxx_analog_mixer;
4049
4050 /* disable VSW */
4051 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
4052 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
4053 break;
4054 case 0x111d7603: /* 6 Port with Analog Mixer */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004055 if ((codec->revision_id & 0xf) == 1) {
4056#ifdef SND_HDA_NEEDS_RESUME
4057 codec->patch_ops = stac92hd71bxx_patch_ops;
4058#endif
4059 spec->stream_delay = 40; /* 40 milliseconds */
4060 }
4061
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004062 /* no output amps */
4063 spec->num_pwrs = 0;
4064 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01004065 default:
4066 spec->mixer = stac92hd71bxx_analog_mixer;
4067 spec->init = stac92hd71bxx_analog_core_init;
4068 }
4069
4070 spec->aloopback_mask = 0x20;
4071 spec->aloopback_shift = 0;
4072
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004073 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004074 spec->gpio_mask = 0x01;
4075 spec->gpio_dir = 0x01;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004076 spec->gpio_data = 0x01;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004077
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004078 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004079 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004080 spec->mux_nids = stac92hd71bxx_mux_nids;
4081 spec->adc_nids = stac92hd71bxx_adc_nids;
4082 spec->dmic_nids = stac92hd71bxx_dmic_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004083 spec->dmux_nids = stac92hd71bxx_dmux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004084 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004085
4086 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
4087 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
4088 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004089 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004090
Takashi Iwaiaea7bb02008-02-25 18:26:41 +01004091 spec->multiout.num_dacs = 1;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004092 spec->multiout.hp_nid = 0x11;
4093 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
4094
4095 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
4096 if (!err) {
4097 if (spec->board_config < 0) {
4098 printk(KERN_WARNING "hda_codec: No auto-config is "
4099 "available, default to model=ref\n");
4100 spec->board_config = STAC_92HD71BXX_REF;
4101 goto again;
4102 }
4103 err = -EINVAL;
4104 }
4105
4106 if (err < 0) {
4107 stac92xx_free(codec);
4108 return err;
4109 }
4110
Matthew Ranostaye035b842007-11-06 11:53:55 +01004111 return 0;
4112};
4113
Matt2f2f4252005-04-13 14:45:30 +02004114static int patch_stac922x(struct hda_codec *codec)
4115{
4116 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004117 int err;
Matt2f2f4252005-04-13 14:45:30 +02004118
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004119 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004120 if (spec == NULL)
4121 return -ENOMEM;
4122
4123 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004124 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004125 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004126 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
4127 stac922x_models,
4128 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08004129 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004130 spec->gpio_mask = spec->gpio_dir = 0x03;
4131 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004132 /* Intel Macs have all same PCI SSID, so we need to check
4133 * codec SSID to distinguish the exact models
4134 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004135 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004136 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004137
4138 case 0x106b0800:
4139 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02004140 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004141 case 0x106b0600:
4142 case 0x106b0700:
4143 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004144 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004145 case 0x106b0e00:
4146 case 0x106b0f00:
4147 case 0x106b1600:
4148 case 0x106b1700:
4149 case 0x106b0200:
4150 case 0x106b1e00:
4151 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004152 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004153 case 0x106b1a00:
4154 case 0x00000100:
4155 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02004156 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004157 case 0x106b0a00:
4158 case 0x106b2200:
4159 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02004160 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08004161 default:
4162 spec->board_config = STAC_INTEL_MAC_V3;
4163 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004164 }
4165 }
4166
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004167 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004168 if (spec->board_config < 0) {
4169 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
4170 "using BIOS defaults\n");
4171 err = stac92xx_save_bios_config_regs(codec);
4172 if (err < 0) {
4173 stac92xx_free(codec);
4174 return err;
4175 }
4176 spec->pin_configs = spec->bios_pin_configs;
4177 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
Matt Porter403d1942005-11-29 15:00:51 +01004178 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
4179 stac92xx_set_config_regs(codec);
4180 }
Matt2f2f4252005-04-13 14:45:30 +02004181
Matt2f2f4252005-04-13 14:45:30 +02004182 spec->adc_nids = stac922x_adc_nids;
4183 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004184 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004185 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004186 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004187 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004188
4189 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004190 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004191
4192 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02004193
Matt Porter3cc08dc2006-01-23 15:27:49 +01004194 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004195 if (!err) {
4196 if (spec->board_config < 0) {
4197 printk(KERN_WARNING "hda_codec: No auto-config is "
4198 "available, default to model=ref\n");
4199 spec->board_config = STAC_D945_REF;
4200 goto again;
4201 }
4202 err = -EINVAL;
4203 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004204 if (err < 0) {
4205 stac92xx_free(codec);
4206 return err;
4207 }
4208
4209 codec->patch_ops = stac92xx_patch_ops;
4210
Takashi Iwai807a46362007-05-29 19:01:37 +02004211 /* Fix Mux capture level; max to 2 */
4212 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
4213 (0 << AC_AMPCAP_OFFSET_SHIFT) |
4214 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4215 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4216 (0 << AC_AMPCAP_MUTE_SHIFT));
4217
Matt Porter3cc08dc2006-01-23 15:27:49 +01004218 return 0;
4219}
4220
4221static int patch_stac927x(struct hda_codec *codec)
4222{
4223 struct sigmatel_spec *spec;
4224 int err;
4225
4226 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4227 if (spec == NULL)
4228 return -ENOMEM;
4229
4230 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004231 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004232 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004233 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
4234 stac927x_models,
4235 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004236 again:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004237 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
4238 if (spec->board_config < 0)
4239 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4240 "STAC927x, using BIOS defaults\n");
Richard Fish11b44bb2006-08-23 18:31:34 +02004241 err = stac92xx_save_bios_config_regs(codec);
4242 if (err < 0) {
4243 stac92xx_free(codec);
4244 return err;
4245 }
4246 spec->pin_configs = spec->bios_pin_configs;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004247 } else {
Matt Porter3cc08dc2006-01-23 15:27:49 +01004248 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
4249 stac92xx_set_config_regs(codec);
4250 }
4251
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004252 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004253 spec->adc_nids = stac927x_adc_nids;
4254 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
4255 spec->mux_nids = stac927x_mux_nids;
4256 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004257 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004258 spec->multiout.dac_nids = spec->dac_nids;
4259
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004260 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02004261 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004262 case STAC_D965_5ST:
4263 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004264 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004265 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004266 spec->num_dmics = 0;
4267
Tobin Davis93ed1502006-09-01 21:03:12 +02004268 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004269 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004270 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004271 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02004272 switch (codec->subsystem_id) {
4273 case 0x10280209:
4274 case 0x1028022e:
4275 /* correct the device field to SPDIF out */
4276 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
4277 break;
4278 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01004279 /* configure the analog microphone on some laptops */
4280 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01004281 /* correct the front output jack as a hp out */
Matthew Ranostay7989fba2008-02-21 07:50:12 +01004282 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01004283 /* correct the front input jack as a mic */
4284 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
4285 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004286 case STAC_DELL_3ST:
4287 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004288 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004289 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004290 spec->dmic_nids = stac927x_dmic_nids;
4291 spec->num_dmics = STAC927X_NUM_DMICS;
4292
Tobin Davis93ed1502006-09-01 21:03:12 +02004293 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004294 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004295 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004296 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004297 break;
4298 default:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004299 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004300 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004301 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004302 spec->num_dmics = 0;
4303
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004304 spec->init = stac927x_core_init;
4305 spec->mixer = stac927x_mixer;
4306 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004307
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004308 spec->num_pwrs = 0;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004309 spec->aloopback_mask = 0x40;
4310 spec->aloopback_shift = 0;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004311
Matt Porter3cc08dc2006-01-23 15:27:49 +01004312 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004313 if (!err) {
4314 if (spec->board_config < 0) {
4315 printk(KERN_WARNING "hda_codec: No auto-config is "
4316 "available, default to model=ref\n");
4317 spec->board_config = STAC_D965_REF;
4318 goto again;
4319 }
4320 err = -EINVAL;
4321 }
Mattc7d4b2f2005-06-27 14:59:41 +02004322 if (err < 0) {
4323 stac92xx_free(codec);
4324 return err;
4325 }
Matt2f2f4252005-04-13 14:45:30 +02004326
4327 codec->patch_ops = stac92xx_patch_ops;
4328
Takashi Iwai52987652008-01-16 16:09:47 +01004329 /*
4330 * !!FIXME!!
4331 * The STAC927x seem to require fairly long delays for certain
4332 * command sequences. With too short delays (even if the answer
4333 * is set to RIRB properly), it results in the silence output
4334 * on some hardwares like Dell.
4335 *
4336 * The below flag enables the longer delay (see get_response
4337 * in hda_intel.c).
4338 */
4339 codec->bus->needs_damn_long_delay = 1;
4340
Matt2f2f4252005-04-13 14:45:30 +02004341 return 0;
4342}
4343
Matt Porterf3302a52006-07-31 12:49:34 +02004344static int patch_stac9205(struct hda_codec *codec)
4345{
4346 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02004347 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02004348
4349 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4350 if (spec == NULL)
4351 return -ENOMEM;
4352
4353 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004354 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004355 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004356 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
4357 stac9205_models,
4358 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004359 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004360 if (spec->board_config < 0) {
4361 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
4362 err = stac92xx_save_bios_config_regs(codec);
4363 if (err < 0) {
4364 stac92xx_free(codec);
4365 return err;
4366 }
4367 spec->pin_configs = spec->bios_pin_configs;
4368 } else {
Matt Porterf3302a52006-07-31 12:49:34 +02004369 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
4370 stac92xx_set_config_regs(codec);
4371 }
4372
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004373 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02004374 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004375 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02004376 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004377 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004378 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02004379 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004380 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004381 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004382 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02004383
4384 spec->init = stac9205_core_init;
4385 spec->mixer = stac9205_mixer;
4386
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004387 spec->aloopback_mask = 0x40;
4388 spec->aloopback_shift = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02004389 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02004390
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004391 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004392 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02004393 /* Enable SPDIF in/out */
4394 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
4395 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01004396
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004397 /* Enable unsol response for GPIO4/Dock HP connection */
4398 snd_hda_codec_write(codec, codec->afg, 0,
4399 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4400 snd_hda_codec_write_cache(codec, codec->afg, 0,
4401 AC_VERB_SET_UNSOLICITED_ENABLE,
4402 (AC_USRSP_EN | STAC_HP_EVENT));
4403
4404 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004405 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004406 spec->gpio_mask = 0x1b;
4407 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01004408 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004409 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02004410 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004411 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004412 break;
4413 default:
4414 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004415 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004416 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004417 break;
4418 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02004419
Matt Porterf3302a52006-07-31 12:49:34 +02004420 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004421 if (!err) {
4422 if (spec->board_config < 0) {
4423 printk(KERN_WARNING "hda_codec: No auto-config is "
4424 "available, default to model=ref\n");
4425 spec->board_config = STAC_9205_REF;
4426 goto again;
4427 }
4428 err = -EINVAL;
4429 }
Matt Porterf3302a52006-07-31 12:49:34 +02004430 if (err < 0) {
4431 stac92xx_free(codec);
4432 return err;
4433 }
4434
4435 codec->patch_ops = stac92xx_patch_ops;
4436
4437 return 0;
4438}
4439
Matt2f2f4252005-04-13 14:45:30 +02004440/*
Guillaume Munch6d859062006-08-22 17:15:47 +02004441 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01004442 */
4443
Guillaume Munch99ccc562006-08-16 19:35:12 +02004444/* static config for Sony VAIO FE550G and Sony VAIO AR */
Takashi Iwaidb064e52006-03-16 16:04:58 +01004445static hda_nid_t vaio_dacs[] = { 0x2 };
4446#define VAIO_HP_DAC 0x5
4447static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
4448static hda_nid_t vaio_mux_nids[] = { 0x15 };
4449
4450static struct hda_input_mux vaio_mux = {
Takashi Iwaia3a2f422007-10-11 11:21:21 +02004451 .num_items = 3,
Takashi Iwaidb064e52006-03-16 16:04:58 +01004452 .items = {
Takashi Iwaid7737812006-04-25 13:05:43 +02004453 /* { "HP", 0x0 }, */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004454 { "Mic Jack", 0x1 },
4455 { "Internal Mic", 0x2 },
Takashi Iwaidb064e52006-03-16 16:04:58 +01004456 { "PCM", 0x3 },
4457 }
4458};
4459
4460static struct hda_verb vaio_init[] = {
4461 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004462 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
Takashi Iwaidb064e52006-03-16 16:04:58 +01004463 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4464 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4465 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4466 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004467 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01004468 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4469 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4470 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4471 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4472 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4473 {}
4474};
4475
Guillaume Munch6d859062006-08-22 17:15:47 +02004476static struct hda_verb vaio_ar_init[] = {
4477 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
4478 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4479 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4480 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4481/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
4482 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004483 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Guillaume Munch6d859062006-08-22 17:15:47 +02004484 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4485 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4486/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
4487 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4488 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4489 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4490 {}
4491};
4492
Takashi Iwaidb064e52006-03-16 16:04:58 +01004493/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02004494static struct hda_bind_ctls vaio_bind_master_vol = {
4495 .ops = &snd_hda_bind_vol,
4496 .values = {
4497 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4498 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4499 0
4500 },
4501};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004502
4503/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02004504static struct hda_bind_ctls vaio_bind_master_sw = {
4505 .ops = &snd_hda_bind_sw,
4506 .values = {
4507 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4508 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4509 0,
4510 },
4511};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004512
4513static struct snd_kcontrol_new vaio_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02004514 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4515 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Takashi Iwaidb064e52006-03-16 16:04:58 +01004516 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4517 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4518 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4519 {
4520 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4521 .name = "Capture Source",
4522 .count = 1,
4523 .info = stac92xx_mux_enum_info,
4524 .get = stac92xx_mux_enum_get,
4525 .put = stac92xx_mux_enum_put,
4526 },
4527 {}
4528};
4529
Guillaume Munch6d859062006-08-22 17:15:47 +02004530static struct snd_kcontrol_new vaio_ar_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02004531 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4532 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Guillaume Munch6d859062006-08-22 17:15:47 +02004533 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4534 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4535 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4536 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
4537 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
4538 {
4539 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4540 .name = "Capture Source",
4541 .count = 1,
4542 .info = stac92xx_mux_enum_info,
4543 .get = stac92xx_mux_enum_get,
4544 .put = stac92xx_mux_enum_put,
4545 },
4546 {}
4547};
4548
4549static struct hda_codec_ops stac9872_patch_ops = {
Takashi Iwaidb064e52006-03-16 16:04:58 +01004550 .build_controls = stac92xx_build_controls,
4551 .build_pcms = stac92xx_build_pcms,
4552 .init = stac92xx_init,
4553 .free = stac92xx_free,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004554#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaidb064e52006-03-16 16:04:58 +01004555 .resume = stac92xx_resume,
4556#endif
4557};
4558
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004559static int stac9872_vaio_init(struct hda_codec *codec)
4560{
4561 int err;
4562
4563 err = stac92xx_init(codec);
4564 if (err < 0)
4565 return err;
4566 if (codec->patch_ops.unsol_event)
4567 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
4568 return 0;
4569}
4570
4571static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
4572{
Jiang Zhe40c1d302007-11-12 13:05:16 +01004573 if (get_hp_pin_presence(codec, 0x0a)) {
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004574 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4575 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4576 } else {
4577 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4578 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4579 }
4580}
4581
4582static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
4583{
4584 switch (res >> 26) {
4585 case STAC_HP_EVENT:
4586 stac9872_vaio_hp_detect(codec, res);
4587 break;
4588 }
4589}
4590
4591static struct hda_codec_ops stac9872_vaio_patch_ops = {
4592 .build_controls = stac92xx_build_controls,
4593 .build_pcms = stac92xx_build_pcms,
4594 .init = stac9872_vaio_init,
4595 .free = stac92xx_free,
4596 .unsol_event = stac9872_vaio_unsol_event,
4597#ifdef CONFIG_PM
4598 .resume = stac92xx_resume,
4599#endif
4600};
4601
Guillaume Munch6d859062006-08-22 17:15:47 +02004602enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
4603 CXD9872RD_VAIO,
4604 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
4605 STAC9872AK_VAIO,
4606 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
4607 STAC9872K_VAIO,
4608 /* AR Series. id=0x83847664 and subsys=104D1300 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004609 CXD9872AKD_VAIO,
4610 STAC_9872_MODELS,
4611};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004612
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004613static const char *stac9872_models[STAC_9872_MODELS] = {
4614 [CXD9872RD_VAIO] = "vaio",
4615 [CXD9872AKD_VAIO] = "vaio-ar",
4616};
4617
4618static struct snd_pci_quirk stac9872_cfg_tbl[] = {
4619 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
4620 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
4621 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
Tobin Davis68e22542007-03-12 11:36:39 +01004622 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
Takashi Iwaidb064e52006-03-16 16:04:58 +01004623 {}
4624};
4625
Guillaume Munch6d859062006-08-22 17:15:47 +02004626static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01004627{
4628 struct sigmatel_spec *spec;
4629 int board_config;
4630
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004631 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
4632 stac9872_models,
4633 stac9872_cfg_tbl);
Takashi Iwaidb064e52006-03-16 16:04:58 +01004634 if (board_config < 0)
4635 /* unknown config, let generic-parser do its job... */
4636 return snd_hda_parse_generic_codec(codec);
4637
4638 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4639 if (spec == NULL)
4640 return -ENOMEM;
4641
4642 codec->spec = spec;
4643 switch (board_config) {
Guillaume Munch6d859062006-08-22 17:15:47 +02004644 case CXD9872RD_VAIO:
4645 case STAC9872AK_VAIO:
4646 case STAC9872K_VAIO:
Takashi Iwaidb064e52006-03-16 16:04:58 +01004647 spec->mixer = vaio_mixer;
4648 spec->init = vaio_init;
4649 spec->multiout.max_channels = 2;
4650 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
4651 spec->multiout.dac_nids = vaio_dacs;
4652 spec->multiout.hp_nid = VAIO_HP_DAC;
4653 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
4654 spec->adc_nids = vaio_adcs;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004655 spec->num_pwrs = 0;
Takashi Iwaidb064e52006-03-16 16:04:58 +01004656 spec->input_mux = &vaio_mux;
4657 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004658 codec->patch_ops = stac9872_vaio_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01004659 break;
Guillaume Munch6d859062006-08-22 17:15:47 +02004660
4661 case CXD9872AKD_VAIO:
4662 spec->mixer = vaio_ar_mixer;
4663 spec->init = vaio_ar_init;
4664 spec->multiout.max_channels = 2;
4665 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
4666 spec->multiout.dac_nids = vaio_dacs;
4667 spec->multiout.hp_nid = VAIO_HP_DAC;
4668 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004669 spec->num_pwrs = 0;
Guillaume Munch6d859062006-08-22 17:15:47 +02004670 spec->adc_nids = vaio_adcs;
4671 spec->input_mux = &vaio_mux;
4672 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004673 codec->patch_ops = stac9872_patch_ops;
Guillaume Munch6d859062006-08-22 17:15:47 +02004674 break;
Takashi Iwaidb064e52006-03-16 16:04:58 +01004675 }
4676
Takashi Iwaidb064e52006-03-16 16:04:58 +01004677 return 0;
4678}
4679
4680
4681/*
Matt2f2f4252005-04-13 14:45:30 +02004682 * patch entries
4683 */
4684struct hda_codec_preset snd_hda_preset_sigmatel[] = {
4685 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
4686 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
4687 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
4688 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
4689 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
4690 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
4691 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02004692 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
4693 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
4694 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
4695 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
4696 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
4697 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01004698 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
4699 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
4700 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
4701 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
4702 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
4703 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
4704 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
4705 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
4706 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
4707 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01004708 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
4709 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
4710 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
4711 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
4712 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
4713 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02004714 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
4715 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02004716 /* The following does not take into account .id=0x83847661 when subsys =
4717 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
4718 * currently not fully supported.
4719 */
4720 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
4721 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
4722 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02004723 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
4724 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
4725 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
4726 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
4727 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
4728 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
4729 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
4730 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004731 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004732 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
4733 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004734 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01004735 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
4736 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004737 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01004738 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
4739 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
4740 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
4741 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
4742 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
4743 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
4744 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
4745 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02004746 {} /* terminator */
4747};