blob: 16fc3aeeb136adaf93877ca86e0d95aaa146ce38 [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 Ranostay6a14f582008-09-12 12:02:30 -040083 STAC_HP_M4,
Matthew Ranostaye035b842007-11-06 11:53:55 +010084 STAC_92HD71BXX_MODELS
85};
86
87enum {
Tobin Davis8e21c342007-01-08 11:04:17 +010088 STAC_925x_REF,
89 STAC_M2_2,
90 STAC_MA6,
Tobin Davis2c11f952007-05-17 09:36:34 +020091 STAC_PA6,
Tobin Davis8e21c342007-01-08 11:04:17 +010092 STAC_925x_MODELS
93};
94
95enum {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010096 STAC_D945_REF,
97 STAC_D945GTP3,
98 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +020099 STAC_INTEL_MAC_V1,
100 STAC_INTEL_MAC_V2,
101 STAC_INTEL_MAC_V3,
102 STAC_INTEL_MAC_V4,
103 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800104 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
105 * is given, one of the above models will be
106 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200107 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100108 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100109 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100110 STAC_MACBOOK_PRO_V1,
111 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200112 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200113 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300114 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200115 STAC_922X_DELL_D81,
116 STAC_922X_DELL_D82,
117 STAC_922X_DELL_M81,
118 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100119 STAC_922X_MODELS
120};
121
122enum {
123 STAC_D965_REF,
124 STAC_D965_3ST,
125 STAC_D965_5ST,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200126 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100127 STAC_DELL_BIOS,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100128 STAC_927X_MODELS
129};
Matt Porter403d1942005-11-29 15:00:51 +0100130
Matt2f2f4252005-04-13 14:45:30 +0200131struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100132 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200133 unsigned int num_mixers;
134
Matt Porter403d1942005-11-29 15:00:51 +0100135 int board_config;
Mattc7d4b2f2005-06-27 14:59:41 +0200136 unsigned int surr_switch: 1;
Matt Porter403d1942005-11-29 15:00:51 +0100137 unsigned int line_switch: 1;
138 unsigned int mic_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100139 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100140 unsigned int hp_detect: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200141
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100142 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200143 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100144 unsigned int gpio_mask;
145 unsigned int gpio_dir;
146 unsigned int gpio_data;
147 unsigned int gpio_mute;
148
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200149 /* stream */
150 unsigned int stream_delay;
151
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100152 /* analog loopback */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100153 unsigned char aloopback_mask;
154 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200155
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100156 /* power management */
157 unsigned int num_pwrs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200158 unsigned int *pwr_mapping;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100159 hda_nid_t *pwr_nids;
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100160 hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100161
Matt2f2f4252005-04-13 14:45:30 +0200162 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100163 struct hda_input_mux *mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400164 struct hda_input_mux *amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100165 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200166 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100167 hda_nid_t dac_nids[5];
Matt2f2f4252005-04-13 14:45:30 +0200168
169 /* capture */
170 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200171 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200172 hda_nid_t *mux_nids;
173 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200174 hda_nid_t *dmic_nids;
175 unsigned int num_dmics;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100176 hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100177 unsigned int num_dmuxes;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200178 hda_nid_t *smux_nids;
179 unsigned int num_smuxes;
180
Mattdabbed62005-06-14 10:19:34 +0200181 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100182 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200183 hda_nid_t anabeep_nid;
184 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200185
Matt2f2f4252005-04-13 14:45:30 +0200186 /* pin widgets */
187 hda_nid_t *pin_nids;
188 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200189 unsigned int *pin_configs;
Richard Fish11b44bb2006-08-23 18:31:34 +0200190 unsigned int *bios_pin_configs;
Matt2f2f4252005-04-13 14:45:30 +0200191
192 /* codec specific stuff */
193 struct hda_verb *init;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100194 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200195
196 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200197 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100198 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200199 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100200 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200201 struct hda_input_mux *sinput_mux;
202 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400203 unsigned int cur_amux;
204 hda_nid_t *amp_nids;
205 unsigned int num_amps;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200206 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200207
Matt Porter403d1942005-11-29 15:00:51 +0100208 /* i/o switches */
209 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200210 unsigned int clfe_swap;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +0200211 unsigned int hp_switch;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200212 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200213
Mattc7d4b2f2005-06-27 14:59:41 +0200214 struct hda_pcm pcm_rec[2]; /* PCM information */
215
216 /* dynamic controls and input_mux */
217 struct auto_pin_cfg autocfg;
218 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100219 struct snd_kcontrol_new *kctl_alloc;
Matt Porter8b657272006-10-26 17:12:59 +0200220 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200221 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200222 struct hda_input_mux private_smux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400223 struct hda_input_mux private_amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100224 struct hda_input_mux private_mono_mux;
Matt2f2f4252005-04-13 14:45:30 +0200225};
226
227static hda_nid_t stac9200_adc_nids[1] = {
228 0x03,
229};
230
231static hda_nid_t stac9200_mux_nids[1] = {
232 0x0c,
233};
234
235static hda_nid_t stac9200_dac_nids[1] = {
236 0x02,
237};
238
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100239static hda_nid_t stac92hd73xx_pwr_nids[8] = {
240 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
241 0x0f, 0x10, 0x11
242};
243
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400244static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
245 0x26, 0,
246};
247
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100248static hda_nid_t stac92hd73xx_adc_nids[2] = {
249 0x1a, 0x1b
250};
251
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400252#define DELL_M6_AMP 2
253static hda_nid_t stac92hd73xx_amp_nids[3] = {
254 0x0b, 0x0c, 0x0e
Matthew Ranostay89385032008-09-11 09:49:39 -0400255};
256
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100257#define STAC92HD73XX_NUM_DMICS 2
258static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
259 0x13, 0x14, 0
260};
261
262#define STAC92HD73_DAC_COUNT 5
263static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
264 0x15, 0x16, 0x17, 0x18, 0x19,
265};
266
267static hda_nid_t stac92hd73xx_mux_nids[4] = {
268 0x28, 0x29, 0x2a, 0x2b,
269};
270
271static hda_nid_t stac92hd73xx_dmux_nids[2] = {
272 0x20, 0x21,
273};
274
Matthew Ranostayd9737752008-09-07 12:03:41 +0200275static hda_nid_t stac92hd73xx_smux_nids[2] = {
276 0x22, 0x23,
277};
278
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200279#define STAC92HD83XXX_NUM_DMICS 2
280static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
281 0x11, 0x12, 0
282};
283
284#define STAC92HD81_DAC_COUNT 2
285#define STAC92HD83_DAC_COUNT 3
286static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = {
287 0x13, 0x14, 0x22,
288};
289
290static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
291 0x17, 0x18,
292};
293
294static hda_nid_t stac92hd83xxx_adc_nids[2] = {
295 0x15, 0x16,
296};
297
298static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
299 0xa, 0xb, 0xd, 0xe,
300};
301
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400302static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
303 0x1e, 0,
304};
305
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200306static unsigned int stac92hd83xxx_pwr_mapping[4] = {
307 0x03, 0x0c, 0x10, 0x40,
308};
309
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100310static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
311 0x0a, 0x0d, 0x0f
312};
313
Matthew Ranostaye035b842007-11-06 11:53:55 +0100314static hda_nid_t stac92hd71bxx_adc_nids[2] = {
315 0x12, 0x13,
316};
317
318static hda_nid_t stac92hd71bxx_mux_nids[2] = {
319 0x1a, 0x1b
320};
321
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100322static hda_nid_t stac92hd71bxx_dmux_nids[1] = {
323 0x1c,
324};
325
Matthew Ranostayd9737752008-09-07 12:03:41 +0200326static hda_nid_t stac92hd71bxx_smux_nids[2] = {
327 0x24, 0x25,
328};
329
Takashi Iwaiaea7bb02008-02-25 18:26:41 +0100330static hda_nid_t stac92hd71bxx_dac_nids[1] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100331 0x10, /*0x11, */
332};
333
334#define STAC92HD71BXX_NUM_DMICS 2
335static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
336 0x18, 0x19, 0
337};
338
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400339static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
340 0x22, 0
341};
342
Tobin Davis8e21c342007-01-08 11:04:17 +0100343static hda_nid_t stac925x_adc_nids[1] = {
344 0x03,
345};
346
347static hda_nid_t stac925x_mux_nids[1] = {
348 0x0f,
349};
350
351static hda_nid_t stac925x_dac_nids[1] = {
352 0x02,
353};
354
Takashi Iwaif6e98522007-10-16 14:27:04 +0200355#define STAC925X_NUM_DMICS 1
356static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
357 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200358};
359
Takashi Iwai1697055e2007-12-18 18:05:52 +0100360static hda_nid_t stac925x_dmux_nids[1] = {
361 0x14,
362};
363
Matt2f2f4252005-04-13 14:45:30 +0200364static hda_nid_t stac922x_adc_nids[2] = {
365 0x06, 0x07,
366};
367
368static hda_nid_t stac922x_mux_nids[2] = {
369 0x12, 0x13,
370};
371
Matt Porter3cc08dc2006-01-23 15:27:49 +0100372static hda_nid_t stac927x_adc_nids[3] = {
373 0x07, 0x08, 0x09
374};
375
376static hda_nid_t stac927x_mux_nids[3] = {
377 0x15, 0x16, 0x17
378};
379
Matthew Ranostayd9737752008-09-07 12:03:41 +0200380static hda_nid_t stac927x_smux_nids[1] = {
381 0x21,
382};
383
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100384static hda_nid_t stac927x_dac_nids[6] = {
385 0x02, 0x03, 0x04, 0x05, 0x06, 0
386};
387
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100388static hda_nid_t stac927x_dmux_nids[1] = {
389 0x1b,
390};
391
Matthew Ranostay7f168592007-10-18 17:38:17 +0200392#define STAC927X_NUM_DMICS 2
393static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
394 0x13, 0x14, 0
395};
396
Matt Porterf3302a52006-07-31 12:49:34 +0200397static hda_nid_t stac9205_adc_nids[2] = {
398 0x12, 0x13
399};
400
401static hda_nid_t stac9205_mux_nids[2] = {
402 0x19, 0x1a
403};
404
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100405static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100406 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100407};
408
Matthew Ranostayd9737752008-09-07 12:03:41 +0200409static hda_nid_t stac9205_smux_nids[1] = {
410 0x21,
411};
412
Takashi Iwaif6e98522007-10-16 14:27:04 +0200413#define STAC9205_NUM_DMICS 2
414static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
415 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200416};
417
Mattc7d4b2f2005-06-27 14:59:41 +0200418static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200419 0x08, 0x09, 0x0d, 0x0e,
420 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200421};
422
Tobin Davis8e21c342007-01-08 11:04:17 +0100423static hda_nid_t stac925x_pin_nids[8] = {
424 0x07, 0x08, 0x0a, 0x0b,
425 0x0c, 0x0d, 0x10, 0x11,
426};
427
Matt2f2f4252005-04-13 14:45:30 +0200428static hda_nid_t stac922x_pin_nids[10] = {
429 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
430 0x0f, 0x10, 0x11, 0x15, 0x1b,
431};
432
Matthew Ranostaya7662642008-02-21 07:51:14 +0100433static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100434 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
435 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200436 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100437};
438
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200439static hda_nid_t stac92hd83xxx_pin_nids[14] = {
440 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
441 0x0f, 0x10, 0x11, 0x12, 0x13,
442 0x1d, 0x1e, 0x1f, 0x20
443};
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400444static hda_nid_t stac92hd71bxx_pin_nids[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100445 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
446 0x0f, 0x14, 0x18, 0x19, 0x1e,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400447 0x1f,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100448};
449
Matt Porter3cc08dc2006-01-23 15:27:49 +0100450static hda_nid_t stac927x_pin_nids[14] = {
451 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
452 0x0f, 0x10, 0x11, 0x12, 0x13,
453 0x14, 0x21, 0x22, 0x23,
454};
455
Matt Porterf3302a52006-07-31 12:49:34 +0200456static hda_nid_t stac9205_pin_nids[12] = {
457 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
458 0x0f, 0x14, 0x16, 0x17, 0x18,
459 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200460};
461
Matthew Ranostay89385032008-09-11 09:49:39 -0400462#define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
463
464static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
465 struct snd_ctl_elem_value *ucontrol)
466{
467 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
468 struct sigmatel_spec *spec = codec->spec;
469 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
470
471 kcontrol->private_value ^= get_amp_nid(kcontrol);
472 kcontrol->private_value |= nid;
473
474 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
475}
476
477static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
478 struct snd_ctl_elem_value *ucontrol)
479{
480 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
481 struct sigmatel_spec *spec = codec->spec;
482 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
483
484 kcontrol->private_value ^= get_amp_nid(kcontrol);
485 kcontrol->private_value |= nid;
486
487 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
488}
489
Matt Porter8b657272006-10-26 17:12:59 +0200490static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
491 struct snd_ctl_elem_info *uinfo)
492{
493 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
494 struct sigmatel_spec *spec = codec->spec;
495 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
496}
497
498static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
499 struct snd_ctl_elem_value *ucontrol)
500{
501 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
502 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100503 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200504
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100505 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200506 return 0;
507}
508
509static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
510 struct snd_ctl_elem_value *ucontrol)
511{
512 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
513 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100514 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200515
516 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100517 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200518}
519
Matthew Ranostayd9737752008-09-07 12:03:41 +0200520static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
521 struct snd_ctl_elem_info *uinfo)
522{
523 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
524 struct sigmatel_spec *spec = codec->spec;
525 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
526}
527
528static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
529 struct snd_ctl_elem_value *ucontrol)
530{
531 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
532 struct sigmatel_spec *spec = codec->spec;
533 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
534
535 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
536 return 0;
537}
538
539static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
540 struct snd_ctl_elem_value *ucontrol)
541{
542 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
543 struct sigmatel_spec *spec = codec->spec;
544 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
545
546 return snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
547 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
548}
549
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100550static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200551{
552 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
553 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200554 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200555}
556
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100557static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200558{
559 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
560 struct sigmatel_spec *spec = codec->spec;
561 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
562
563 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
564 return 0;
565}
566
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100567static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200568{
569 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
570 struct sigmatel_spec *spec = codec->spec;
571 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
572
Mattc7d4b2f2005-06-27 14:59:41 +0200573 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200574 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
575}
576
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100577static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
578 struct snd_ctl_elem_info *uinfo)
579{
580 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
581 struct sigmatel_spec *spec = codec->spec;
582 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
583}
584
585static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
586 struct snd_ctl_elem_value *ucontrol)
587{
588 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
589 struct sigmatel_spec *spec = codec->spec;
590
591 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
592 return 0;
593}
594
595static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
596 struct snd_ctl_elem_value *ucontrol)
597{
598 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
599 struct sigmatel_spec *spec = codec->spec;
600
601 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
602 spec->mono_nid, &spec->cur_mmux);
603}
604
Matthew Ranostay89385032008-09-11 09:49:39 -0400605static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
606 struct snd_ctl_elem_info *uinfo)
607{
608 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
609 struct sigmatel_spec *spec = codec->spec;
610 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
611}
612
613static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
614 struct snd_ctl_elem_value *ucontrol)
615{
616 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
617 struct sigmatel_spec *spec = codec->spec;
618
619 ucontrol->value.enumerated.item[0] = spec->cur_amux;
620 return 0;
621}
622
623static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
624 struct snd_ctl_elem_value *ucontrol)
625{
626 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
627 struct sigmatel_spec *spec = codec->spec;
628 struct snd_kcontrol *ctl =
629 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
630 if (!ctl)
631 return -EINVAL;
632
633 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
634 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
635
636 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
637 0, &spec->cur_amux);
638}
639
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200640#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
641
642static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
643 struct snd_ctl_elem_value *ucontrol)
644{
645 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100646 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200647 struct sigmatel_spec *spec = codec->spec;
648
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100649 ucontrol->value.integer.value[0] = !!(spec->aloopback &
650 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200651 return 0;
652}
653
654static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
655 struct snd_ctl_elem_value *ucontrol)
656{
657 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
658 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100659 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200660 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100661 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200662
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100663 idx_val = spec->aloopback_mask << idx;
664 if (ucontrol->value.integer.value[0])
665 val = spec->aloopback | idx_val;
666 else
667 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100668 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200669 return 0;
670
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100671 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200672
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100673 /* Only return the bits defined by the shift value of the
674 * first two bytes of the mask
675 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200676 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100677 kcontrol->private_value & 0xFFFF, 0x0);
678 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200679
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100680 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200681 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100682 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200683 } else {
684 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100685 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200686 }
687
688 snd_hda_codec_write_cache(codec, codec->afg, 0,
689 kcontrol->private_value >> 16, dac_mode);
690
691 return 1;
692}
693
Mattc7d4b2f2005-06-27 14:59:41 +0200694static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200695 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200696 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200697 {}
698};
699
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200700static struct hda_verb stac9200_eapd_init[] = {
701 /* set dac0mux for dac converter */
702 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
703 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
704 {}
705};
706
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100707static struct hda_verb stac92hd73xx_6ch_core_init[] = {
708 /* set master volume and direct control */
709 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
710 /* setup audio connections */
711 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
712 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
713 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
714 /* setup adcs to point to mixer */
715 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
716 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100717 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
718 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
719 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
720 /* setup import muxs */
721 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
722 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
723 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
724 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
725 {}
726};
727
Matthew Ranostayd654a662008-03-14 08:46:51 +0100728static struct hda_verb dell_eq_core_init[] = {
729 /* set master volume to max value without distortion
730 * and direct control */
731 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
732 /* setup audio connections */
733 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
Matthew Ranostayf7cf0a72008-09-13 10:36:58 -0400734 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x02},
735 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100736 /* setup adcs to point to mixer */
737 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
738 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
739 /* setup import muxs */
740 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
741 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
742 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
743 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
744 {}
745};
746
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100747static struct hda_verb dell_m6_core_init[] = {
Matthew Ranostay20f5f952008-09-01 08:17:56 +0200748 /* set master volume to max value without distortion
749 * and direct control */
750 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100751 /* setup audio connections */
Matthew Ranostay7747ecc2008-03-10 11:30:04 +0100752 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
753 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100754 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
755 /* setup adcs to point to mixer */
756 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
757 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
758 /* setup import muxs */
759 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
760 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
761 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
762 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
763 {}
764};
765
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100766static struct hda_verb stac92hd73xx_8ch_core_init[] = {
767 /* set master volume and direct control */
768 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
769 /* setup audio connections */
770 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
771 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
772 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
773 /* connect hp ports to dac3 */
774 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
775 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
776 /* setup adcs to point to mixer */
777 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
778 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100779 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
780 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
781 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
782 /* setup import muxs */
783 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
784 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
785 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
786 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
787 {}
788};
789
790static struct hda_verb stac92hd73xx_10ch_core_init[] = {
791 /* set master volume and direct control */
792 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
793 /* setup audio connections */
794 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
795 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
796 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
797 /* dac3 is connected to import3 mux */
798 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
799 /* connect hp ports to dac4 */
800 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
801 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
802 /* setup adcs to point to mixer */
803 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
804 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100805 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
806 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
807 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
808 /* setup import muxs */
809 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
810 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
811 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
812 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
813 {}
814};
815
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200816static struct hda_verb stac92hd83xxx_core_init[] = {
817 /* start of config #1 */
818 { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3},
819
820 /* start of config #2 */
821 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
822 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
823 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
824
825 /* power state controls amps */
826 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
827};
828
Matthew Ranostaye035b842007-11-06 11:53:55 +0100829static struct hda_verb stac92hd71bxx_core_init[] = {
830 /* set master volume and direct control */
831 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
832 /* connect headphone jack to dac1 */
833 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100834 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
835 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
836 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
837 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
838 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100839};
840
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200841#define HD_DISABLE_PORTF 3
Matthew Ranostay541eee82007-12-14 12:08:04 +0100842static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200843 /* start of config #1 */
844
845 /* connect port 0f to audio mixer */
846 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
847 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
848 /* unmute right and left channels for node 0x0f */
849 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
850 /* start of config #2 */
851
Matthew Ranostay541eee82007-12-14 12:08:04 +0100852 /* set master volume and direct control */
853 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
854 /* connect headphone jack to dac1 */
855 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200856 /* connect port 0d to audio mixer */
Matthew Ranostay9b359472007-11-07 13:03:12 +0100857 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostay9b359472007-11-07 13:03:12 +0100858 /* unmute dac0 input in audio mixer */
859 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200860 /* unmute right and left channels for nodes 0x0a, 0xd */
Matthew Ranostaye035b842007-11-06 11:53:55 +0100861 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
862 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100863 {}
864};
865
Tobin Davis8e21c342007-01-08 11:04:17 +0100866static struct hda_verb stac925x_core_init[] = {
867 /* set dac0mux for dac converter */
868 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
869 {}
870};
871
Mattc7d4b2f2005-06-27 14:59:41 +0200872static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200873 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200874 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200875 {}
876};
877
Tobin Davis93ed1502006-09-01 21:03:12 +0200878static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200879 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200880 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200881 /* unmute node 0x1b */
882 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
883 /* select node 0x03 as DAC */
884 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
885 {}
886};
887
Matt Porter3cc08dc2006-01-23 15:27:49 +0100888static struct hda_verb stac927x_core_init[] = {
889 /* set master volume and direct control */
890 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200891 /* enable analog pc beep path */
892 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100893 {}
894};
895
Matt Porterf3302a52006-07-31 12:49:34 +0200896static struct hda_verb stac9205_core_init[] = {
897 /* set master volume and direct control */
898 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200899 /* enable analog pc beep path */
900 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200901 {}
902};
903
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100904#define STAC_MONO_MUX \
905 { \
906 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
907 .name = "Mono Mux", \
908 .count = 1, \
909 .info = stac92xx_mono_mux_enum_info, \
910 .get = stac92xx_mono_mux_enum_get, \
911 .put = stac92xx_mono_mux_enum_put, \
912 }
913
Matthew Ranostay89385032008-09-11 09:49:39 -0400914#define STAC_AMP_MUX \
915 { \
916 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
917 .name = "Amp Selector Capture Switch", \
918 .count = 1, \
919 .info = stac92xx_amp_mux_enum_info, \
920 .get = stac92xx_amp_mux_enum_get, \
921 .put = stac92xx_amp_mux_enum_put, \
922 }
923
924#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
925 { \
926 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
927 .name = xname, \
928 .index = 0, \
929 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
930 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
931 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
932 .info = stac92xx_amp_volume_info, \
933 .get = stac92xx_amp_volume_get, \
934 .put = stac92xx_amp_volume_put, \
935 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
936 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
937 }
938
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200939#define STAC_INPUT_SOURCE(cnt) \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200940 { \
941 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
942 .name = "Input Source", \
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200943 .count = cnt, \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200944 .info = stac92xx_mux_enum_info, \
945 .get = stac92xx_mux_enum_get, \
946 .put = stac92xx_mux_enum_put, \
947 }
948
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100949#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200950 { \
951 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
952 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100953 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200954 .info = stac92xx_aloopback_info, \
955 .get = stac92xx_aloopback_get, \
956 .put = stac92xx_aloopback_put, \
957 .private_value = verb_read | (verb_write << 16), \
958 }
959
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100960static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200961 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
962 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200963 STAC_INPUT_SOURCE(1),
Matt2f2f4252005-04-13 14:45:30 +0200964 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
965 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200966 { } /* end */
967};
968
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400969#define DELL_M6_MIXER 6
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100970static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400971 /* start of config #1 */
972 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
973 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
974
975 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
976 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
977
978 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
979 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
980
981 /* start of config #2 */
982 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
983 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
984
985 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
986 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
987
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100988 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
989
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100990 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
991 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
992
993 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
994 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
995
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100996 { } /* end */
997};
998
999static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001000 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1001
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001002 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1003 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1004
1005 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1006 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1007
1008 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1009 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1010
1011 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1012 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1013
1014 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1015 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1016
1017 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1018 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1019
1020 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1021 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1022 { } /* end */
1023};
1024
1025static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001026 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1027
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001028 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1029 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1030
1031 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1032 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1033
1034 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1035 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1036
1037 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1038 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1039
1040 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1041 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1042
1043 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1044 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1045
1046 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1047 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1048 { } /* end */
1049};
1050
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001051
1052static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1053 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1054 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1055
1056 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1057 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1058
1059 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT),
1060 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
1061
1062 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
1063 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
1064
1065 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
1066 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
1067
1068 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
1069 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
1070
1071 /*
1072 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
1073 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
1074 */
1075 { } /* end */
1076};
1077
Matthew Ranostay541eee82007-12-14 12:08:04 +01001078static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001079 STAC_INPUT_SOURCE(2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001080
Matthew Ranostay9b359472007-11-07 13:03:12 +01001081 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1082 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay9b359472007-11-07 13:03:12 +01001083
1084 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1085 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001086 /* analog pc-beep replaced with digital beep support */
1087 /*
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001088 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1089 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001090 */
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001091
Matthew Ranostay9b359472007-11-07 13:03:12 +01001092 HDA_CODEC_MUTE("Analog Loopback 1", 0x17, 0x3, HDA_INPUT),
1093 HDA_CODEC_MUTE("Analog Loopback 2", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001094 { } /* end */
1095};
1096
Matthew Ranostay541eee82007-12-14 12:08:04 +01001097static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +01001098 STAC_INPUT_SOURCE(2),
1099 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1100
Matthew Ranostay541eee82007-12-14 12:08:04 +01001101 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1102 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001103
1104 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1105 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001106 { } /* end */
1107};
1108
Tobin Davis8e21c342007-01-08 11:04:17 +01001109static struct snd_kcontrol_new stac925x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001110 STAC_INPUT_SOURCE(1),
Tobin Davis8e21c342007-01-08 11:04:17 +01001111 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +02001112 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001113 { } /* end */
1114};
1115
Takashi Iwaid1d985f2006-11-23 19:27:12 +01001116static struct snd_kcontrol_new stac9205_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001117 STAC_INPUT_SOURCE(2),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001118 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001119
1120 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1121 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001122
1123 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1124 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001125 { } /* end */
1126};
1127
1128/* This needs to be generated dynamically based on sequence */
1129static struct snd_kcontrol_new stac922x_mixer[] = {
1130 STAC_INPUT_SOURCE(2),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001131 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1132 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001133
1134 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1135 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001136 { } /* end */
1137};
1138
1139
1140static struct snd_kcontrol_new stac927x_mixer[] = {
1141 STAC_INPUT_SOURCE(3),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001142 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001143
1144 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1145 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001146
1147 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1148 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001149
1150 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1151 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
Matt Porterf3302a52006-07-31 12:49:34 +02001152 { } /* end */
1153};
1154
Takashi Iwai1697055e2007-12-18 18:05:52 +01001155static struct snd_kcontrol_new stac_dmux_mixer = {
1156 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1157 .name = "Digital Input Source",
1158 /* count set later */
1159 .info = stac92xx_dmux_enum_info,
1160 .get = stac92xx_dmux_enum_get,
1161 .put = stac92xx_dmux_enum_put,
1162};
1163
Matthew Ranostayd9737752008-09-07 12:03:41 +02001164static struct snd_kcontrol_new stac_smux_mixer = {
1165 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001166 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001167 /* count set later */
1168 .info = stac92xx_smux_enum_info,
1169 .get = stac92xx_smux_enum_get,
1170 .put = stac92xx_smux_enum_put,
1171};
1172
Takashi Iwai2134ea42008-01-10 16:53:55 +01001173static const char *slave_vols[] = {
1174 "Front Playback Volume",
1175 "Surround Playback Volume",
1176 "Center Playback Volume",
1177 "LFE Playback Volume",
1178 "Side Playback Volume",
1179 "Headphone Playback Volume",
1180 "Headphone Playback Volume",
1181 "Speaker Playback Volume",
1182 "External Speaker Playback Volume",
1183 "Speaker2 Playback Volume",
1184 NULL
1185};
1186
1187static const char *slave_sws[] = {
1188 "Front Playback Switch",
1189 "Surround Playback Switch",
1190 "Center Playback Switch",
1191 "LFE Playback Switch",
1192 "Side Playback Switch",
1193 "Headphone Playback Switch",
1194 "Headphone Playback Switch",
1195 "Speaker Playback Switch",
1196 "External Speaker Playback Switch",
1197 "Speaker2 Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001198 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001199 NULL
1200};
1201
Matt2f2f4252005-04-13 14:45:30 +02001202static int stac92xx_build_controls(struct hda_codec *codec)
1203{
1204 struct sigmatel_spec *spec = codec->spec;
1205 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001206 int i;
Matt2f2f4252005-04-13 14:45:30 +02001207
1208 err = snd_hda_add_new_ctls(codec, spec->mixer);
1209 if (err < 0)
1210 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001211
1212 for (i = 0; i < spec->num_mixers; i++) {
1213 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1214 if (err < 0)
1215 return err;
1216 }
Takashi Iwai1697055e2007-12-18 18:05:52 +01001217 if (spec->num_dmuxes > 0) {
1218 stac_dmux_mixer.count = spec->num_dmuxes;
1219 err = snd_ctl_add(codec->bus->card,
1220 snd_ctl_new1(&stac_dmux_mixer, codec));
1221 if (err < 0)
1222 return err;
1223 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001224 if (spec->num_smuxes > 0) {
1225 stac_smux_mixer.count = spec->num_smuxes;
1226 err = snd_ctl_add(codec->bus->card,
1227 snd_ctl_new1(&stac_smux_mixer, codec));
1228 if (err < 0)
1229 return err;
1230 }
Mattc7d4b2f2005-06-27 14:59:41 +02001231
Mattdabbed62005-06-14 10:19:34 +02001232 if (spec->multiout.dig_out_nid) {
1233 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1234 if (err < 0)
1235 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001236 err = snd_hda_create_spdif_share_sw(codec,
1237 &spec->multiout);
1238 if (err < 0)
1239 return err;
1240 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001241 }
1242 if (spec->dig_in_nid) {
1243 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1244 if (err < 0)
1245 return err;
1246 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001247
1248 /* if we have no master control, let's create it */
1249 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001250 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001251 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001252 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001253 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001254 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001255 if (err < 0)
1256 return err;
1257 }
1258 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1259 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1260 NULL, slave_sws);
1261 if (err < 0)
1262 return err;
1263 }
1264
Mattdabbed62005-06-14 10:19:34 +02001265 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001266}
1267
Matt Porter403d1942005-11-29 15:00:51 +01001268static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001269 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001270 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1271};
1272
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001273/*
1274 STAC 9200 pin configs for
1275 102801A8
1276 102801DE
1277 102801E8
1278*/
1279static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001280 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1281 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001282};
1283
1284/*
1285 STAC 9200 pin configs for
1286 102801C0
1287 102801C1
1288*/
1289static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001290 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1291 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001292};
1293
1294/*
1295 STAC 9200 pin configs for
1296 102801C4 (Dell Dimension E310)
1297 102801C5
1298 102801C7
1299 102801D9
1300 102801DA
1301 102801E3
1302*/
1303static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001304 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1305 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001306};
1307
1308
1309/*
1310 STAC 9200-32 pin configs for
1311 102801B5 (Dell Inspiron 630m)
1312 102801D8 (Dell Inspiron 640m)
1313*/
1314static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001315 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1316 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001317};
1318
1319/*
1320 STAC 9200-32 pin configs for
1321 102801C2 (Dell Latitude D620)
1322 102801C8
1323 102801CC (Dell Latitude D820)
1324 102801D4
1325 102801D6
1326*/
1327static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001328 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1329 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001330};
1331
1332/*
1333 STAC 9200-32 pin configs for
1334 102801CE (Dell XPS M1710)
1335 102801CF (Dell Precision M90)
1336*/
1337static unsigned int dell9200_m23_pin_configs[8] = {
1338 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1339 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1340};
1341
1342/*
1343 STAC 9200-32 pin configs for
1344 102801C9
1345 102801CA
1346 102801CB (Dell Latitude 120L)
1347 102801D3
1348*/
1349static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001350 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1351 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001352};
1353
1354/*
1355 STAC 9200-32 pin configs for
1356 102801BD (Dell Inspiron E1505n)
1357 102801EE
1358 102801EF
1359*/
1360static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001361 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1362 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001363};
1364
1365/*
1366 STAC 9200-32 pin configs for
1367 102801F5 (Dell Inspiron 1501)
1368 102801F6
1369*/
1370static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001371 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1372 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001373};
1374
1375/*
1376 STAC 9200-32
1377 102801CD (Dell Inspiron E1705/9400)
1378*/
1379static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001380 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1381 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001382};
1383
Tobin Davisbf277782008-02-03 20:31:47 +01001384static unsigned int oqo9200_pin_configs[8] = {
1385 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1386 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1387};
1388
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001389
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001390static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1391 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001392 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001393 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1394 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1395 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1396 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1397 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1398 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1399 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1400 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1401 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1402 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001403 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001404};
1405
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001406static const char *stac9200_models[STAC_9200_MODELS] = {
1407 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001408 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001409 [STAC_9200_DELL_D21] = "dell-d21",
1410 [STAC_9200_DELL_D22] = "dell-d22",
1411 [STAC_9200_DELL_D23] = "dell-d23",
1412 [STAC_9200_DELL_M21] = "dell-m21",
1413 [STAC_9200_DELL_M22] = "dell-m22",
1414 [STAC_9200_DELL_M23] = "dell-m23",
1415 [STAC_9200_DELL_M24] = "dell-m24",
1416 [STAC_9200_DELL_M25] = "dell-m25",
1417 [STAC_9200_DELL_M26] = "dell-m26",
1418 [STAC_9200_DELL_M27] = "dell-m27",
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001419 [STAC_9200_GATEWAY] = "gateway",
Takashi Iwai117f2572008-03-18 09:53:23 +01001420 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001421};
1422
1423static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1424 /* SigmaTel reference board */
1425 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1426 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001427 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001428 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1429 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001430 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001431 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1432 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1433 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1434 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1435 "unknown Dell", STAC_9200_DELL_D22),
1436 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1437 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001438 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001439 "Dell Latitude D620", STAC_9200_DELL_M22),
1440 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1441 "unknown Dell", STAC_9200_DELL_D23),
1442 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1443 "unknown Dell", STAC_9200_DELL_D23),
1444 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1445 "unknown Dell", STAC_9200_DELL_M22),
1446 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1447 "unknown Dell", STAC_9200_DELL_M24),
1448 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1449 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001450 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001451 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001452 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001453 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001454 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001455 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001456 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001457 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001458 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001459 "Dell Precision M90", STAC_9200_DELL_M23),
1460 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1461 "unknown Dell", STAC_9200_DELL_M22),
1462 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1463 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001464 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001465 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001466 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001467 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1468 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1469 "unknown Dell", STAC_9200_DELL_D23),
1470 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1471 "unknown Dell", STAC_9200_DELL_D23),
1472 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1473 "unknown Dell", STAC_9200_DELL_D21),
1474 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1475 "unknown Dell", STAC_9200_DELL_D23),
1476 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1477 "unknown Dell", STAC_9200_DELL_D21),
1478 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1479 "unknown Dell", STAC_9200_DELL_M25),
1480 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1481 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001482 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001483 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1484 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1485 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001486 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001487 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001488 /* Gateway machines needs EAPD to be set on resume */
1489 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1490 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1491 STAC_9200_GATEWAY),
1492 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1493 STAC_9200_GATEWAY),
Tobin Davisbf277782008-02-03 20:31:47 +01001494 /* OQO Mobile */
1495 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001496 {} /* terminator */
1497};
1498
Tobin Davis8e21c342007-01-08 11:04:17 +01001499static unsigned int ref925x_pin_configs[8] = {
1500 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001501 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001502};
1503
1504static unsigned int stac925x_MA6_pin_configs[8] = {
1505 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1506 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1507};
1508
Tobin Davis2c11f952007-05-17 09:36:34 +02001509static unsigned int stac925x_PA6_pin_configs[8] = {
1510 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1511 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1512};
1513
Tobin Davis8e21c342007-01-08 11:04:17 +01001514static unsigned int stac925xM2_2_pin_configs[8] = {
Steve Longerbeam7353e142007-05-29 14:36:17 +02001515 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1516 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001517};
1518
1519static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1520 [STAC_REF] = ref925x_pin_configs,
1521 [STAC_M2_2] = stac925xM2_2_pin_configs,
1522 [STAC_MA6] = stac925x_MA6_pin_configs,
Tobin Davis2c11f952007-05-17 09:36:34 +02001523 [STAC_PA6] = stac925x_PA6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001524};
1525
1526static const char *stac925x_models[STAC_925x_MODELS] = {
1527 [STAC_REF] = "ref",
1528 [STAC_M2_2] = "m2-2",
1529 [STAC_MA6] = "m6",
Tobin Davis2c11f952007-05-17 09:36:34 +02001530 [STAC_PA6] = "pa6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001531};
1532
1533static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1534 /* SigmaTel reference board */
1535 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001536 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Tobin Davis8e21c342007-01-08 11:04:17 +01001537 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1538 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1539 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
Tobin Davis2c11f952007-05-17 09:36:34 +02001540 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
Tobin Davis8e21c342007-01-08 11:04:17 +01001541 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1542 {} /* terminator */
1543};
1544
Matthew Ranostaya7662642008-02-21 07:51:14 +01001545static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001546 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1547 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1548 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001549 0x01452050,
1550};
1551
1552static unsigned int dell_m6_pin_configs[13] = {
1553 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001554 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001555 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1556 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001557};
1558
1559static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001560 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1561 [STAC_DELL_M6] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001562};
1563
1564static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1565 [STAC_92HD73XX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001566 [STAC_DELL_M6] = "dell-m6",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001567};
1568
1569static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1570 /* SigmaTel reference board */
1571 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001572 "DFI LanParty", STAC_92HD73XX_REF),
1573 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1574 "unknown Dell", STAC_DELL_M6),
1575 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1576 "unknown Dell", STAC_DELL_M6),
1577 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1578 "unknown Dell", STAC_DELL_M6),
1579 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1580 "unknown Dell", STAC_DELL_M6),
1581 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1582 "unknown Dell", STAC_DELL_M6),
1583 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1584 "unknown Dell", STAC_DELL_M6),
1585 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1586 "unknown Dell", STAC_DELL_M6),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001587 {} /* terminator */
1588};
1589
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001590static unsigned int ref92hd83xxx_pin_configs[14] = {
1591 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1592 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1593 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1594 0x01451160, 0x98560170,
1595};
1596
1597static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1598 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1599};
1600
1601static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1602 [STAC_92HD83XXX_REF] = "ref",
1603};
1604
1605static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1606 /* SigmaTel reference board */
1607 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1608 "DFI LanParty", STAC_92HD71BXX_REF),
1609};
1610
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001611static unsigned int ref92hd71bxx_pin_configs[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001612 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostayb22b4822008-01-22 12:32:30 +01001613 0x0181302e, 0x01114010, 0x01019020, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001614 0x90a000f0, 0x01452050, 0x01452050,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001615};
1616
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001617static unsigned int dell_m4_1_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001618 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001619 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001620 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001621};
1622
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001623static unsigned int dell_m4_2_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001624 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1625 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001626 0x40f000f0, 0x044413b0, 0x044413b0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001627};
1628
Matthew Ranostaye035b842007-11-06 11:53:55 +01001629static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1630 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001631 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1632 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001633 [STAC_HP_M4] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001634};
1635
1636static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1637 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001638 [STAC_DELL_M4_1] = "dell-m4-1",
1639 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001640 [STAC_HP_M4] = "hp-m4",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001641};
1642
1643static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1644 /* SigmaTel reference board */
1645 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1646 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001647 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1648 "unknown Dell", STAC_DELL_M4_1),
1649 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1650 "unknown Dell", STAC_DELL_M4_1),
1651 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1652 "unknown Dell", STAC_DELL_M4_1),
1653 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1654 "unknown Dell", STAC_DELL_M4_1),
1655 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1656 "unknown Dell", STAC_DELL_M4_1),
1657 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1658 "unknown Dell", STAC_DELL_M4_1),
1659 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1660 "unknown Dell", STAC_DELL_M4_1),
1661 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1662 "unknown Dell", STAC_DELL_M4_2),
1663 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1664 "unknown Dell", STAC_DELL_M4_2),
1665 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1666 "unknown Dell", STAC_DELL_M4_2),
1667 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1668 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001669 {} /* terminator */
1670};
1671
Matt Porter403d1942005-11-29 15:00:51 +01001672static unsigned int ref922x_pin_configs[10] = {
1673 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1674 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001675 0x40000100, 0x40000100,
1676};
1677
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001678/*
1679 STAC 922X pin configs for
1680 102801A7
1681 102801AB
1682 102801A9
1683 102801D1
1684 102801D2
1685*/
1686static unsigned int dell_922x_d81_pin_configs[10] = {
1687 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1688 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1689 0x01813122, 0x400001f2,
1690};
1691
1692/*
1693 STAC 922X pin configs for
1694 102801AC
1695 102801D0
1696*/
1697static unsigned int dell_922x_d82_pin_configs[10] = {
1698 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1699 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1700 0x01813122, 0x400001f1,
1701};
1702
1703/*
1704 STAC 922X pin configs for
1705 102801BF
1706*/
1707static unsigned int dell_922x_m81_pin_configs[10] = {
1708 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1709 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1710 0x40C003f1, 0x405003f0,
1711};
1712
1713/*
1714 STAC 9221 A1 pin configs for
1715 102801D7 (Dell XPS M1210)
1716*/
1717static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001718 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1719 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001720 0x508003f3, 0x405003f4,
1721};
1722
Matt Porter403d1942005-11-29 15:00:51 +01001723static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001724 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001725 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1726 0x02a19120, 0x40000100,
1727};
1728
1729static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001730 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1731 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001732 0x02a19320, 0x40000100,
1733};
1734
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001735static unsigned int intel_mac_v1_pin_configs[10] = {
1736 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1737 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001738 0x400000fc, 0x400000fb,
1739};
1740
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001741static unsigned int intel_mac_v2_pin_configs[10] = {
1742 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1743 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001744 0x400000fc, 0x400000fb,
1745};
1746
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001747static unsigned int intel_mac_v3_pin_configs[10] = {
1748 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1749 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1750 0x400000fc, 0x400000fb,
1751};
1752
1753static unsigned int intel_mac_v4_pin_configs[10] = {
1754 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1755 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1756 0x400000fc, 0x400000fb,
1757};
1758
1759static unsigned int intel_mac_v5_pin_configs[10] = {
1760 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1761 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1762 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001763};
1764
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001765static unsigned int ecs202_pin_configs[10] = {
1766 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1767 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1768 0x9037012e, 0x40e000f2,
1769};
Takashi Iwai76c08822007-06-19 12:17:42 +02001770
Takashi Iwai19039bd2006-06-28 15:52:16 +02001771static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001772 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001773 [STAC_D945GTP3] = d945gtp3_pin_configs,
1774 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001775 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1776 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1777 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1778 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1779 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001780 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001781 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001782 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1783 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1784 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1785 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1786 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1787 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001788 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001789 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1790 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1791 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1792 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001793};
1794
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001795static const char *stac922x_models[STAC_922X_MODELS] = {
1796 [STAC_D945_REF] = "ref",
1797 [STAC_D945GTP5] = "5stack",
1798 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001799 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1800 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1801 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1802 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1803 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001804 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001805 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001806 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001807 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001808 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1809 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001810 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001811 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001812 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001813 [STAC_922X_DELL_D81] = "dell-d81",
1814 [STAC_922X_DELL_D82] = "dell-d82",
1815 [STAC_922X_DELL_M81] = "dell-m81",
1816 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001817};
1818
1819static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1820 /* SigmaTel reference board */
1821 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1822 "DFI LanParty", STAC_D945_REF),
1823 /* Intel 945G based systems */
1824 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1825 "Intel D945G", STAC_D945GTP3),
1826 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1827 "Intel D945G", STAC_D945GTP3),
1828 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1829 "Intel D945G", STAC_D945GTP3),
1830 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1831 "Intel D945G", STAC_D945GTP3),
1832 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1833 "Intel D945G", STAC_D945GTP3),
1834 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1835 "Intel D945G", STAC_D945GTP3),
1836 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1837 "Intel D945G", STAC_D945GTP3),
1838 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1839 "Intel D945G", STAC_D945GTP3),
1840 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1841 "Intel D945G", STAC_D945GTP3),
1842 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1843 "Intel D945G", STAC_D945GTP3),
1844 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1845 "Intel D945G", STAC_D945GTP3),
1846 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1847 "Intel D945G", STAC_D945GTP3),
1848 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1849 "Intel D945G", STAC_D945GTP3),
1850 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1851 "Intel D945G", STAC_D945GTP3),
1852 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1853 "Intel D945G", STAC_D945GTP3),
1854 /* Intel D945G 5-stack systems */
1855 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1856 "Intel D945G", STAC_D945GTP5),
1857 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1858 "Intel D945G", STAC_D945GTP5),
1859 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1860 "Intel D945G", STAC_D945GTP5),
1861 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1862 "Intel D945G", STAC_D945GTP5),
1863 /* Intel 945P based systems */
1864 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1865 "Intel D945P", STAC_D945GTP3),
1866 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1867 "Intel D945P", STAC_D945GTP3),
1868 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1869 "Intel D945P", STAC_D945GTP3),
1870 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1871 "Intel D945P", STAC_D945GTP3),
1872 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1873 "Intel D945P", STAC_D945GTP3),
1874 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1875 "Intel D945P", STAC_D945GTP5),
1876 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08001877 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001878 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001879 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001880 /* Dell systems */
1881 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1882 "unknown Dell", STAC_922X_DELL_D81),
1883 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1884 "unknown Dell", STAC_922X_DELL_D81),
1885 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1886 "unknown Dell", STAC_922X_DELL_D81),
1887 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1888 "unknown Dell", STAC_922X_DELL_D82),
1889 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1890 "unknown Dell", STAC_922X_DELL_M81),
1891 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1892 "unknown Dell", STAC_922X_DELL_D82),
1893 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1894 "unknown Dell", STAC_922X_DELL_D81),
1895 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1896 "unknown Dell", STAC_922X_DELL_D81),
1897 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1898 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001899 /* ECS/PC Chips boards */
1900 SND_PCI_QUIRK(0x1019, 0x2144,
1901 "ECS/PC chips", STAC_ECS_202),
1902 SND_PCI_QUIRK(0x1019, 0x2608,
1903 "ECS/PC chips", STAC_ECS_202),
1904 SND_PCI_QUIRK(0x1019, 0x2633,
1905 "ECS/PC chips P17G/1333", STAC_ECS_202),
1906 SND_PCI_QUIRK(0x1019, 0x2811,
1907 "ECS/PC chips", STAC_ECS_202),
1908 SND_PCI_QUIRK(0x1019, 0x2812,
1909 "ECS/PC chips", STAC_ECS_202),
1910 SND_PCI_QUIRK(0x1019, 0x2813,
1911 "ECS/PC chips", STAC_ECS_202),
1912 SND_PCI_QUIRK(0x1019, 0x2814,
1913 "ECS/PC chips", STAC_ECS_202),
1914 SND_PCI_QUIRK(0x1019, 0x2815,
1915 "ECS/PC chips", STAC_ECS_202),
1916 SND_PCI_QUIRK(0x1019, 0x2816,
1917 "ECS/PC chips", STAC_ECS_202),
1918 SND_PCI_QUIRK(0x1019, 0x2817,
1919 "ECS/PC chips", STAC_ECS_202),
1920 SND_PCI_QUIRK(0x1019, 0x2818,
1921 "ECS/PC chips", STAC_ECS_202),
1922 SND_PCI_QUIRK(0x1019, 0x2819,
1923 "ECS/PC chips", STAC_ECS_202),
1924 SND_PCI_QUIRK(0x1019, 0x2820,
1925 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01001926 {} /* terminator */
1927};
1928
Matt Porter3cc08dc2006-01-23 15:27:49 +01001929static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02001930 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1931 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1932 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1933 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01001934};
1935
Tobin Davis93ed1502006-09-01 21:03:12 +02001936static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02001937 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1938 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1939 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1940 0x40000100, 0x40000100
1941};
1942
Tobin Davis93ed1502006-09-01 21:03:12 +02001943static unsigned int d965_5st_pin_configs[14] = {
1944 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1945 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1946 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1947 0x40000100, 0x40000100
1948};
1949
Tobin Davis4ff076e2007-08-07 11:48:12 +02001950static unsigned int dell_3st_pin_configs[14] = {
1951 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1952 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001953 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02001954 0x40c003fc, 0x40000100
1955};
1956
Tobin Davis93ed1502006-09-01 21:03:12 +02001957static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001958 [STAC_D965_REF] = ref927x_pin_configs,
1959 [STAC_D965_3ST] = d965_3st_pin_configs,
1960 [STAC_D965_5ST] = d965_5st_pin_configs,
1961 [STAC_DELL_3ST] = dell_3st_pin_configs,
1962 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01001963};
1964
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001965static const char *stac927x_models[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001966 [STAC_D965_REF] = "ref",
1967 [STAC_D965_3ST] = "3stack",
1968 [STAC_D965_5ST] = "5stack",
1969 [STAC_DELL_3ST] = "dell-3stack",
1970 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001971};
1972
1973static struct snd_pci_quirk stac927x_cfg_tbl[] = {
1974 /* SigmaTel reference board */
1975 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1976 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02001977 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001978 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
1979 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02001980 /* 965 based 3 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001981 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
1982 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
1983 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
1984 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
1985 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
1986 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
1987 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
1988 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
1989 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
1990 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
1991 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
1992 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
1993 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
1994 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
1995 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
1996 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02001997 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001998 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001999 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002000 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2001 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002002 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002003 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2004 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002005 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02002006 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002007 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2008 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2009 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2010 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002011 /* 965 based 5 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002012 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2013 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2014 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2015 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2016 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2017 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2018 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2019 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2020 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002021 {} /* terminator */
2022};
2023
Matt Porterf3302a52006-07-31 12:49:34 +02002024static unsigned int ref9205_pin_configs[12] = {
2025 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002026 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002027 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002028};
2029
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002030/*
2031 STAC 9205 pin configs for
2032 102801F1
2033 102801F2
2034 102801FC
2035 102801FD
2036 10280204
2037 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002038 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002039*/
2040static unsigned int dell_9205_m42_pin_configs[12] = {
2041 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2042 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2043 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2044};
2045
2046/*
2047 STAC 9205 pin configs for
2048 102801F9
2049 102801FA
2050 102801FE
2051 102801FF (Dell Precision M4300)
2052 10280206
2053 10280200
2054 10280201
2055*/
2056static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002057 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2058 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2059 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2060};
2061
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002062static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002063 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2064 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2065 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2066};
2067
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002068static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002069 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002070 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2071 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2072 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Matt Porterf3302a52006-07-31 12:49:34 +02002073};
2074
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002075static const char *stac9205_models[STAC_9205_MODELS] = {
2076 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002077 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002078 [STAC_9205_DELL_M43] = "dell-m43",
2079 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002080};
2081
2082static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2083 /* SigmaTel reference board */
2084 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2085 "DFI LanParty", STAC_9205_REF),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002086 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2087 "unknown Dell", STAC_9205_DELL_M42),
2088 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2089 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002090 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002091 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002092 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2093 "Dell Precision", STAC_9205_DELL_M43),
2094 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2095 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002096 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2097 "unknown Dell", STAC_9205_DELL_M42),
2098 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2099 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002100 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2101 "Dell Precision", STAC_9205_DELL_M43),
2102 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002103 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002104 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2105 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002106 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2107 "Dell Precision", STAC_9205_DELL_M43),
2108 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2109 "Dell Precision", STAC_9205_DELL_M43),
2110 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2111 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002112 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2113 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002114 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2115 "Dell Vostro 1500", STAC_9205_DELL_M42),
Matt Porterf3302a52006-07-31 12:49:34 +02002116 {} /* terminator */
2117};
2118
Richard Fish11b44bb2006-08-23 18:31:34 +02002119static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2120{
2121 int i;
2122 struct sigmatel_spec *spec = codec->spec;
2123
2124 if (! spec->bios_pin_configs) {
2125 spec->bios_pin_configs = kcalloc(spec->num_pins,
2126 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
2127 if (! spec->bios_pin_configs)
2128 return -ENOMEM;
2129 }
2130
2131 for (i = 0; i < spec->num_pins; i++) {
2132 hda_nid_t nid = spec->pin_nids[i];
2133 unsigned int pin_cfg;
2134
2135 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2136 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2137 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2138 nid, pin_cfg);
2139 spec->bios_pin_configs[i] = pin_cfg;
2140 }
2141
2142 return 0;
2143}
2144
Matthew Ranostay87d48362007-07-17 11:52:24 +02002145static void stac92xx_set_config_reg(struct hda_codec *codec,
2146 hda_nid_t pin_nid, unsigned int pin_config)
2147{
2148 int i;
2149 snd_hda_codec_write(codec, pin_nid, 0,
2150 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2151 pin_config & 0x000000ff);
2152 snd_hda_codec_write(codec, pin_nid, 0,
2153 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2154 (pin_config & 0x0000ff00) >> 8);
2155 snd_hda_codec_write(codec, pin_nid, 0,
2156 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2157 (pin_config & 0x00ff0000) >> 16);
2158 snd_hda_codec_write(codec, pin_nid, 0,
2159 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2160 pin_config >> 24);
2161 i = snd_hda_codec_read(codec, pin_nid, 0,
2162 AC_VERB_GET_CONFIG_DEFAULT,
2163 0x00);
2164 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2165 pin_nid, i);
2166}
2167
Matt2f2f4252005-04-13 14:45:30 +02002168static void stac92xx_set_config_regs(struct hda_codec *codec)
2169{
2170 int i;
2171 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002172
Matthew Ranostay87d48362007-07-17 11:52:24 +02002173 if (!spec->pin_configs)
2174 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002175
Matthew Ranostay87d48362007-07-17 11:52:24 +02002176 for (i = 0; i < spec->num_pins; i++)
2177 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2178 spec->pin_configs[i]);
Matt2f2f4252005-04-13 14:45:30 +02002179}
Matt2f2f4252005-04-13 14:45:30 +02002180
Matt2f2f4252005-04-13 14:45:30 +02002181/*
2182 * Analog playback callbacks
2183 */
2184static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2185 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002186 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002187{
2188 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002189 if (spec->stream_delay)
2190 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002191 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2192 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002193}
2194
2195static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2196 struct hda_codec *codec,
2197 unsigned int stream_tag,
2198 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002199 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002200{
2201 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002202 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002203}
2204
2205static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2206 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002207 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002208{
2209 struct sigmatel_spec *spec = codec->spec;
2210 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2211}
2212
2213/*
Mattdabbed62005-06-14 10:19:34 +02002214 * Digital playback callbacks
2215 */
2216static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2217 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002218 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002219{
2220 struct sigmatel_spec *spec = codec->spec;
2221 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2222}
2223
2224static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2225 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002226 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002227{
2228 struct sigmatel_spec *spec = codec->spec;
2229 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2230}
2231
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002232static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2233 struct hda_codec *codec,
2234 unsigned int stream_tag,
2235 unsigned int format,
2236 struct snd_pcm_substream *substream)
2237{
2238 struct sigmatel_spec *spec = codec->spec;
2239 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2240 stream_tag, format, substream);
2241}
2242
Mattdabbed62005-06-14 10:19:34 +02002243
2244/*
Matt2f2f4252005-04-13 14:45:30 +02002245 * Analog capture callbacks
2246 */
2247static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2248 struct hda_codec *codec,
2249 unsigned int stream_tag,
2250 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002251 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002252{
2253 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002254 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002255
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002256 if (spec->powerdown_adcs) {
2257 msleep(40);
2258 snd_hda_codec_write_cache(codec, nid, 0,
2259 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2260 }
2261 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002262 return 0;
2263}
2264
2265static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2266 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002267 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002268{
2269 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002270 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002271
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002272 snd_hda_codec_cleanup_stream(codec, nid);
2273 if (spec->powerdown_adcs)
2274 snd_hda_codec_write_cache(codec, nid, 0,
2275 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002276 return 0;
2277}
2278
Mattdabbed62005-06-14 10:19:34 +02002279static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2280 .substreams = 1,
2281 .channels_min = 2,
2282 .channels_max = 2,
2283 /* NID is set in stac92xx_build_pcms */
2284 .ops = {
2285 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002286 .close = stac92xx_dig_playback_pcm_close,
2287 .prepare = stac92xx_dig_playback_pcm_prepare
Mattdabbed62005-06-14 10:19:34 +02002288 },
2289};
2290
2291static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2292 .substreams = 1,
2293 .channels_min = 2,
2294 .channels_max = 2,
2295 /* NID is set in stac92xx_build_pcms */
2296};
2297
Matt2f2f4252005-04-13 14:45:30 +02002298static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2299 .substreams = 1,
2300 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002301 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002302 .nid = 0x02, /* NID to query formats and rates */
2303 .ops = {
2304 .open = stac92xx_playback_pcm_open,
2305 .prepare = stac92xx_playback_pcm_prepare,
2306 .cleanup = stac92xx_playback_pcm_cleanup
2307 },
2308};
2309
Matt Porter3cc08dc2006-01-23 15:27:49 +01002310static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2311 .substreams = 1,
2312 .channels_min = 2,
2313 .channels_max = 2,
2314 .nid = 0x06, /* NID to query formats and rates */
2315 .ops = {
2316 .open = stac92xx_playback_pcm_open,
2317 .prepare = stac92xx_playback_pcm_prepare,
2318 .cleanup = stac92xx_playback_pcm_cleanup
2319 },
2320};
2321
Matt2f2f4252005-04-13 14:45:30 +02002322static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002323 .channels_min = 2,
2324 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002325 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002326 .ops = {
2327 .prepare = stac92xx_capture_pcm_prepare,
2328 .cleanup = stac92xx_capture_pcm_cleanup
2329 },
2330};
2331
2332static int stac92xx_build_pcms(struct hda_codec *codec)
2333{
2334 struct sigmatel_spec *spec = codec->spec;
2335 struct hda_pcm *info = spec->pcm_rec;
2336
2337 codec->num_pcms = 1;
2338 codec->pcm_info = info;
2339
Mattc7d4b2f2005-06-27 14:59:41 +02002340 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002341 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Matt2f2f4252005-04-13 14:45:30 +02002342 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002343 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002344 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002345
2346 if (spec->alt_switch) {
2347 codec->num_pcms++;
2348 info++;
2349 info->name = "STAC92xx Analog Alt";
2350 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2351 }
Matt2f2f4252005-04-13 14:45:30 +02002352
Mattdabbed62005-06-14 10:19:34 +02002353 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2354 codec->num_pcms++;
2355 info++;
2356 info->name = "STAC92xx Digital";
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002357 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Mattdabbed62005-06-14 10:19:34 +02002358 if (spec->multiout.dig_out_nid) {
2359 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2360 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2361 }
2362 if (spec->dig_in_nid) {
2363 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2364 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2365 }
2366 }
2367
Matt2f2f4252005-04-13 14:45:30 +02002368 return 0;
2369}
2370
Takashi Iwaic960a032006-03-23 17:06:28 +01002371static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2372{
2373 unsigned int pincap = snd_hda_param_read(codec, nid,
2374 AC_PAR_PIN_CAP);
2375 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2376 if (pincap & AC_PINCAP_VREF_100)
2377 return AC_PINCTL_VREF_100;
2378 if (pincap & AC_PINCAP_VREF_80)
2379 return AC_PINCTL_VREF_80;
2380 if (pincap & AC_PINCAP_VREF_50)
2381 return AC_PINCTL_VREF_50;
2382 if (pincap & AC_PINCAP_VREF_GRD)
2383 return AC_PINCTL_VREF_GRD;
2384 return 0;
2385}
2386
Matt Porter403d1942005-11-29 15:00:51 +01002387static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2388
2389{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002390 snd_hda_codec_write_cache(codec, nid, 0,
2391 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002392}
2393
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002394#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2395
2396static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2397 struct snd_ctl_elem_value *ucontrol)
2398{
2399 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2400 struct sigmatel_spec *spec = codec->spec;
2401
2402 ucontrol->value.integer.value[0] = spec->hp_switch;
2403 return 0;
2404}
2405
2406static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2407 struct snd_ctl_elem_value *ucontrol)
2408{
2409 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2410 struct sigmatel_spec *spec = codec->spec;
2411
2412 spec->hp_switch = ucontrol->value.integer.value[0];
2413
2414 /* check to be sure that the ports are upto date with
2415 * switch changes
2416 */
2417 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2418
2419 return 1;
2420}
2421
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002422#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002423
2424static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2425{
2426 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2427 struct sigmatel_spec *spec = codec->spec;
2428 int io_idx = kcontrol-> private_value & 0xff;
2429
2430 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2431 return 0;
2432}
2433
2434static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2435{
2436 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2437 struct sigmatel_spec *spec = codec->spec;
2438 hda_nid_t nid = kcontrol->private_value >> 8;
2439 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002440 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002441
2442 spec->io_switch[io_idx] = val;
2443
2444 if (val)
2445 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002446 else {
2447 unsigned int pinctl = AC_PINCTL_IN_EN;
2448 if (io_idx) /* set VREF for mic */
2449 pinctl |= stac92xx_get_vref(codec, nid);
2450 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2451 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002452
2453 /* check the auto-mute again: we need to mute/unmute the speaker
2454 * appropriately according to the pin direction
2455 */
2456 if (spec->hp_detect)
2457 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2458
Matt Porter403d1942005-11-29 15:00:51 +01002459 return 1;
2460}
2461
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002462#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2463
2464static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2465 struct snd_ctl_elem_value *ucontrol)
2466{
2467 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2468 struct sigmatel_spec *spec = codec->spec;
2469
2470 ucontrol->value.integer.value[0] = spec->clfe_swap;
2471 return 0;
2472}
2473
2474static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2475 struct snd_ctl_elem_value *ucontrol)
2476{
2477 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2478 struct sigmatel_spec *spec = codec->spec;
2479 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002480 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002481
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002482 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002483 return 0;
2484
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002485 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002486
2487 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2488 spec->clfe_swap ? 0x4 : 0x0);
2489
2490 return 1;
2491}
2492
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002493#define STAC_CODEC_HP_SWITCH(xname) \
2494 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2495 .name = xname, \
2496 .index = 0, \
2497 .info = stac92xx_hp_switch_info, \
2498 .get = stac92xx_hp_switch_get, \
2499 .put = stac92xx_hp_switch_put, \
2500 }
2501
Matt Porter403d1942005-11-29 15:00:51 +01002502#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2503 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2504 .name = xname, \
2505 .index = 0, \
2506 .info = stac92xx_io_switch_info, \
2507 .get = stac92xx_io_switch_get, \
2508 .put = stac92xx_io_switch_put, \
2509 .private_value = xpval, \
2510 }
2511
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002512#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2513 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2514 .name = xname, \
2515 .index = 0, \
2516 .info = stac92xx_clfe_switch_info, \
2517 .get = stac92xx_clfe_switch_get, \
2518 .put = stac92xx_clfe_switch_put, \
2519 .private_value = xpval, \
2520 }
Matt Porter403d1942005-11-29 15:00:51 +01002521
Mattc7d4b2f2005-06-27 14:59:41 +02002522enum {
2523 STAC_CTL_WIDGET_VOL,
2524 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002525 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002526 STAC_CTL_WIDGET_AMP_MUX,
2527 STAC_CTL_WIDGET_AMP_VOL,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002528 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002529 STAC_CTL_WIDGET_IO_SWITCH,
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002530 STAC_CTL_WIDGET_CLFE_SWITCH
Mattc7d4b2f2005-06-27 14:59:41 +02002531};
2532
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002533static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002534 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2535 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002536 STAC_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002537 STAC_AMP_MUX,
2538 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002539 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002540 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002541 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002542};
2543
2544/* add dynamic controls */
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002545static int stac92xx_add_control_idx(struct sigmatel_spec *spec, int type,
2546 int idx, const char *name, unsigned long val)
Mattc7d4b2f2005-06-27 14:59:41 +02002547{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002548 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002549
2550 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2551 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2552
2553 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2554 if (! knew)
2555 return -ENOMEM;
2556 if (spec->kctl_alloc) {
2557 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2558 kfree(spec->kctl_alloc);
2559 }
2560 spec->kctl_alloc = knew;
2561 spec->num_kctl_alloc = num;
2562 }
2563
2564 knew = &spec->kctl_alloc[spec->num_kctl_used];
2565 *knew = stac92xx_control_templates[type];
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002566 knew->index = idx;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002567 knew->name = kstrdup(name, GFP_KERNEL);
Mattc7d4b2f2005-06-27 14:59:41 +02002568 if (! knew->name)
2569 return -ENOMEM;
2570 knew->private_value = val;
2571 spec->num_kctl_used++;
2572 return 0;
2573}
2574
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002575
2576/* add dynamic controls */
2577static int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2578 const char *name, unsigned long val)
2579{
2580 return stac92xx_add_control_idx(spec, type, 0, name, val);
2581}
2582
Matt Porter403d1942005-11-29 15:00:51 +01002583/* flag inputs as additional dynamic lineouts */
2584static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2585{
2586 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002587 unsigned int wcaps, wtype;
2588 int i, num_dacs = 0;
2589
2590 /* use the wcaps cache to count all DACs available for line-outs */
2591 for (i = 0; i < codec->num_nodes; i++) {
2592 wcaps = codec->wcaps[i];
2593 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002594
Steve Longerbeam7b043892007-05-03 20:50:03 +02002595 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2596 num_dacs++;
2597 }
Matt Porter403d1942005-11-29 15:00:51 +01002598
Steve Longerbeam7b043892007-05-03 20:50:03 +02002599 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2600
Matt Porter403d1942005-11-29 15:00:51 +01002601 switch (cfg->line_outs) {
2602 case 3:
2603 /* add line-in as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002604 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002605 cfg->line_out_pins[cfg->line_outs] =
2606 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002607 spec->line_switch = 1;
2608 cfg->line_outs++;
2609 }
2610 break;
2611 case 2:
2612 /* add line-in as clfe and mic as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002613 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002614 cfg->line_out_pins[cfg->line_outs] =
2615 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002616 spec->line_switch = 1;
2617 cfg->line_outs++;
2618 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002619 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002620 cfg->line_out_pins[cfg->line_outs] =
2621 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002622 spec->mic_switch = 1;
2623 cfg->line_outs++;
2624 }
2625 break;
2626 case 1:
2627 /* add line-in as surr and mic as clfe */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002628 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002629 cfg->line_out_pins[cfg->line_outs] =
2630 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002631 spec->line_switch = 1;
2632 cfg->line_outs++;
2633 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002634 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002635 cfg->line_out_pins[cfg->line_outs] =
2636 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002637 spec->mic_switch = 1;
2638 cfg->line_outs++;
2639 }
2640 break;
2641 }
2642
2643 return 0;
2644}
2645
Steve Longerbeam7b043892007-05-03 20:50:03 +02002646
2647static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2648{
2649 int i;
2650
2651 for (i = 0; i < spec->multiout.num_dacs; i++) {
2652 if (spec->multiout.dac_nids[i] == nid)
2653 return 1;
2654 }
2655
2656 return 0;
2657}
2658
Matt Porter3cc08dc2006-01-23 15:27:49 +01002659/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02002660 * Fill in the dac_nids table from the parsed pin configuration
2661 * This function only works when every pin in line_out_pins[]
2662 * contains atleast one DAC in its connection list. Some 92xx
2663 * codecs are not connected directly to a DAC, such as the 9200
2664 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002665 */
Takashi Iwai19039bd2006-06-28 15:52:16 +02002666static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaidf802952007-07-02 19:18:00 +02002667 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002668{
2669 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002670 int i, j, conn_len = 0;
2671 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2672 unsigned int wcaps, wtype;
2673
Mattc7d4b2f2005-06-27 14:59:41 +02002674 for (i = 0; i < cfg->line_outs; i++) {
2675 nid = cfg->line_out_pins[i];
Steve Longerbeam7b043892007-05-03 20:50:03 +02002676 conn_len = snd_hda_get_connections(codec, nid, conn,
2677 HDA_MAX_CONNECTIONS);
2678 for (j = 0; j < conn_len; j++) {
2679 wcaps = snd_hda_param_read(codec, conn[j],
2680 AC_PAR_AUDIO_WIDGET_CAP);
2681 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002682 if (wtype != AC_WID_AUD_OUT ||
2683 (wcaps & AC_WCAP_DIGITAL))
2684 continue;
2685 /* conn[j] is a DAC routed to this line-out */
2686 if (!is_in_dac_nids(spec, conn[j]))
2687 break;
2688 }
2689
2690 if (j == conn_len) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002691 if (spec->multiout.num_dacs > 0) {
2692 /* we have already working output pins,
2693 * so let's drop the broken ones again
2694 */
2695 cfg->line_outs = spec->multiout.num_dacs;
2696 break;
2697 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002698 /* error out, no available DAC found */
2699 snd_printk(KERN_ERR
2700 "%s: No available DAC for pin 0x%x\n",
2701 __func__, nid);
2702 return -ENODEV;
2703 }
2704
2705 spec->multiout.dac_nids[i] = conn[j];
2706 spec->multiout.num_dacs++;
2707 if (conn_len > 1) {
2708 /* select this DAC in the pin's input mux */
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002709 snd_hda_codec_write_cache(codec, nid, 0,
2710 AC_VERB_SET_CONNECT_SEL, j);
Steve Longerbeam7b043892007-05-03 20:50:03 +02002711
2712 }
Mattc7d4b2f2005-06-27 14:59:41 +02002713 }
2714
Steve Longerbeam7b043892007-05-03 20:50:03 +02002715 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2716 spec->multiout.num_dacs,
2717 spec->multiout.dac_nids[0],
2718 spec->multiout.dac_nids[1],
2719 spec->multiout.dac_nids[2],
2720 spec->multiout.dac_nids[3],
2721 spec->multiout.dac_nids[4]);
Mattc7d4b2f2005-06-27 14:59:41 +02002722 return 0;
2723}
2724
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002725/* create volume control/switch for the given prefx type */
2726static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2727{
2728 char name[32];
2729 int err;
2730
2731 sprintf(name, "%s Playback Volume", pfx);
2732 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2733 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2734 if (err < 0)
2735 return err;
2736 sprintf(name, "%s Playback Switch", pfx);
2737 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2738 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2739 if (err < 0)
2740 return err;
2741 return 0;
2742}
2743
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002744static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2745{
2746 if (!spec->multiout.hp_nid)
2747 spec->multiout.hp_nid = nid;
2748 else if (spec->multiout.num_dacs > 4) {
2749 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2750 return 1;
2751 } else {
2752 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2753 spec->multiout.num_dacs++;
2754 }
2755 return 0;
2756}
2757
2758static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2759{
2760 if (is_in_dac_nids(spec, nid))
2761 return 1;
2762 if (spec->multiout.hp_nid == nid)
2763 return 1;
2764 return 0;
2765}
2766
Mattc7d4b2f2005-06-27 14:59:41 +02002767/* add playback controls from the parsed DAC table */
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002768static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
Takashi Iwai19039bd2006-06-28 15:52:16 +02002769 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002770{
Takashi Iwai19039bd2006-06-28 15:52:16 +02002771 static const char *chname[4] = {
2772 "Front", "Surround", NULL /*CLFE*/, "Side"
2773 };
Mattc7d4b2f2005-06-27 14:59:41 +02002774 hda_nid_t nid;
2775 int i, err;
2776
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002777 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002778 unsigned int wid_caps, pincap;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002779
2780
Takashi Iwai40ac8c42008-02-29 14:16:17 +01002781 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
Matt Porter403d1942005-11-29 15:00:51 +01002782 if (!spec->multiout.dac_nids[i])
Mattc7d4b2f2005-06-27 14:59:41 +02002783 continue;
2784
2785 nid = spec->multiout.dac_nids[i];
2786
2787 if (i == 2) {
2788 /* Center/LFE */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002789 err = create_controls(spec, "Center", nid, 1);
2790 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002791 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002792 err = create_controls(spec, "LFE", nid, 2);
2793 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002794 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002795
2796 wid_caps = get_wcaps(codec, nid);
2797
2798 if (wid_caps & AC_WCAP_LR_SWAP) {
2799 err = stac92xx_add_control(spec,
2800 STAC_CTL_WIDGET_CLFE_SWITCH,
2801 "Swap Center/LFE Playback Switch", nid);
2802
2803 if (err < 0)
2804 return err;
2805 }
2806
Mattc7d4b2f2005-06-27 14:59:41 +02002807 } else {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002808 err = create_controls(spec, chname[i], nid, 3);
2809 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002810 return err;
2811 }
2812 }
2813
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002814 if (cfg->hp_outs > 1) {
2815 err = stac92xx_add_control(spec,
2816 STAC_CTL_WIDGET_HP_SWITCH,
2817 "Headphone as Line Out Switch", 0);
2818 if (err < 0)
2819 return err;
2820 }
2821
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002822 if (spec->line_switch) {
2823 nid = cfg->input_pins[AUTO_PIN_LINE];
2824 pincap = snd_hda_param_read(codec, nid,
2825 AC_PAR_PIN_CAP);
2826 if (pincap & AC_PINCAP_OUT) {
2827 err = stac92xx_add_control(spec,
2828 STAC_CTL_WIDGET_IO_SWITCH,
2829 "Line In as Output Switch", nid << 8);
2830 if (err < 0)
2831 return err;
2832 }
2833 }
Matt Porter403d1942005-11-29 15:00:51 +01002834
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002835 if (spec->mic_switch) {
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002836 unsigned int def_conf;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002837 unsigned int mic_pin = AUTO_PIN_MIC;
2838again:
2839 nid = cfg->input_pins[mic_pin];
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002840 def_conf = snd_hda_codec_read(codec, nid, 0,
2841 AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002842 /* some laptops have an internal analog microphone
2843 * which can't be used as a output */
2844 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2845 pincap = snd_hda_param_read(codec, nid,
2846 AC_PAR_PIN_CAP);
2847 if (pincap & AC_PINCAP_OUT) {
2848 err = stac92xx_add_control(spec,
2849 STAC_CTL_WIDGET_IO_SWITCH,
2850 "Mic as Output Switch", (nid << 8) | 1);
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002851 nid = snd_hda_codec_read(codec, nid, 0,
2852 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2853 if (!check_in_dac_nids(spec, nid))
2854 add_spec_dacs(spec, nid);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002855 if (err < 0)
2856 return err;
2857 }
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002858 } else if (mic_pin == AUTO_PIN_MIC) {
2859 mic_pin = AUTO_PIN_FRONT_MIC;
2860 goto again;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002861 }
2862 }
Matt Porter403d1942005-11-29 15:00:51 +01002863
Mattc7d4b2f2005-06-27 14:59:41 +02002864 return 0;
2865}
2866
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002867/* add playback controls for Speaker and HP outputs */
2868static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2869 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002870{
2871 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02002872 hda_nid_t nid;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002873 int i, old_num_dacs, err;
Mattc7d4b2f2005-06-27 14:59:41 +02002874
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002875 old_num_dacs = spec->multiout.num_dacs;
2876 for (i = 0; i < cfg->hp_outs; i++) {
2877 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2878 if (wid_caps & AC_WCAP_UNSOL_CAP)
2879 spec->hp_detect = 1;
2880 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2881 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2882 if (check_in_dac_nids(spec, nid))
2883 nid = 0;
2884 if (! nid)
Mattc7d4b2f2005-06-27 14:59:41 +02002885 continue;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002886 add_spec_dacs(spec, nid);
2887 }
2888 for (i = 0; i < cfg->speaker_outs; i++) {
Steve Longerbeam7b043892007-05-03 20:50:03 +02002889 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002890 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2891 if (check_in_dac_nids(spec, nid))
2892 nid = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002893 if (! nid)
2894 continue;
2895 add_spec_dacs(spec, nid);
Mattc7d4b2f2005-06-27 14:59:41 +02002896 }
Matthew Ranostay1b290a52007-07-12 15:17:34 +02002897 for (i = 0; i < cfg->line_outs; i++) {
2898 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2899 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2900 if (check_in_dac_nids(spec, nid))
2901 nid = 0;
2902 if (! nid)
2903 continue;
2904 add_spec_dacs(spec, nid);
2905 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002906 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2907 static const char *pfxs[] = {
2908 "Speaker", "External Speaker", "Speaker2",
2909 };
2910 err = create_controls(spec, pfxs[i - old_num_dacs],
2911 spec->multiout.dac_nids[i], 3);
2912 if (err < 0)
2913 return err;
2914 }
2915 if (spec->multiout.hp_nid) {
Takashi Iwai2626a262008-03-14 09:18:32 +01002916 err = create_controls(spec, "Headphone",
2917 spec->multiout.hp_nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002918 if (err < 0)
2919 return err;
2920 }
Mattc7d4b2f2005-06-27 14:59:41 +02002921
2922 return 0;
2923}
2924
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002925/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002926static const char *stac92xx_mono_labels[4] = {
2927 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002928};
2929
2930/* create mono mux for mono out on capable codecs */
2931static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
2932{
2933 struct sigmatel_spec *spec = codec->spec;
2934 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
2935 int i, num_cons;
2936 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
2937
2938 num_cons = snd_hda_get_connections(codec,
2939 spec->mono_nid,
2940 con_lst,
2941 HDA_MAX_NUM_INPUTS);
2942 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
2943 return -EINVAL;
2944
2945 for (i = 0; i < num_cons; i++) {
2946 mono_mux->items[mono_mux->num_items].label =
2947 stac92xx_mono_labels[i];
2948 mono_mux->items[mono_mux->num_items].index = i;
2949 mono_mux->num_items++;
2950 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01002951
2952 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
2953 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002954}
2955
Matthew Ranostay89385032008-09-11 09:49:39 -04002956/* labels for amp mux outputs */
2957static const char *stac92xx_amp_labels[3] = {
2958 "Front Microphone", "Microphone", "Line In"
2959};
2960
2961/* create amp out controls mux on capable codecs */
2962static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
2963{
2964 struct sigmatel_spec *spec = codec->spec;
2965 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
2966 int i, err;
2967
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04002968 for (i = 0; i < spec->num_amps; i++) {
Matthew Ranostay89385032008-09-11 09:49:39 -04002969 amp_mux->items[amp_mux->num_items].label =
2970 stac92xx_amp_labels[i];
2971 amp_mux->items[amp_mux->num_items].index = i;
2972 amp_mux->num_items++;
2973 }
2974
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04002975 if (spec->num_amps > 1) {
2976 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
2977 "Amp Selector Capture Switch", 0);
2978 if (err < 0)
2979 return err;
2980 }
Matthew Ranostay89385032008-09-11 09:49:39 -04002981 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
2982 "Amp Capture Volume",
2983 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
2984}
2985
2986
Matthew Ranostay1cd22242008-07-18 18:20:52 +02002987/* create PC beep volume controls */
2988static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
2989 hda_nid_t nid)
2990{
2991 struct sigmatel_spec *spec = codec->spec;
2992 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
2993 int err;
2994
2995 /* check for mute support for the the amp */
2996 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
2997 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
2998 "PC Beep Playback Switch",
2999 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3000 if (err < 0)
3001 return err;
3002 }
3003
3004 /* check to see if there is volume support for the amp */
3005 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3006 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3007 "PC Beep Playback Volume",
3008 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3009 if (err < 0)
3010 return err;
3011 }
3012 return 0;
3013}
3014
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003015static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3016{
3017 struct sigmatel_spec *spec = codec->spec;
3018 int wcaps, nid, i, err = 0;
3019
3020 for (i = 0; i < spec->num_muxes; i++) {
3021 nid = spec->mux_nids[i];
3022 wcaps = get_wcaps(codec, nid);
3023
3024 if (wcaps & AC_WCAP_OUT_AMP) {
3025 err = stac92xx_add_control_idx(spec,
3026 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3027 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3028 if (err < 0)
3029 return err;
3030 }
3031 }
3032 return 0;
3033};
3034
Matthew Ranostayd9737752008-09-07 12:03:41 +02003035static const char *stac92xx_spdif_labels[3] = {
3036 "Digital Playback", "Analog Mux 1", "Analog Mux 2"
3037};
3038
3039static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3040{
3041 struct sigmatel_spec *spec = codec->spec;
3042 struct hda_input_mux *spdif_mux = &spec->private_smux;
3043 int i, num_cons;
3044 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_spdif_labels)];
3045
3046 num_cons = snd_hda_get_connections(codec,
3047 spec->smux_nids[0],
3048 con_lst,
3049 HDA_MAX_NUM_INPUTS);
3050 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_spdif_labels))
3051 return -EINVAL;
3052
3053 for (i = 0; i < num_cons; i++) {
3054 spdif_mux->items[spdif_mux->num_items].label =
3055 stac92xx_spdif_labels[i];
3056 spdif_mux->items[spdif_mux->num_items].index = i;
3057 spdif_mux->num_items++;
3058 }
3059
3060 return 0;
3061}
3062
Matt Porter8b657272006-10-26 17:12:59 +02003063/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003064static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003065 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3066 "Digital Mic 3", "Digital Mic 4"
3067};
3068
3069/* create playback/capture controls for input pins on dmic capable codecs */
3070static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3071 const struct auto_pin_cfg *cfg)
3072{
3073 struct sigmatel_spec *spec = codec->spec;
3074 struct hda_input_mux *dimux = &spec->private_dimux;
3075 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003076 int err, i, j;
3077 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02003078
3079 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3080 dimux->items[dimux->num_items].index = 0;
3081 dimux->num_items++;
3082
3083 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003084 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003085 int index;
3086 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003087 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02003088 unsigned int def_conf;
3089
3090 def_conf = snd_hda_codec_read(codec,
3091 spec->dmic_nids[i],
3092 0,
3093 AC_VERB_GET_CONFIG_DEFAULT,
3094 0);
3095 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3096 continue;
3097
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003098 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02003099 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003100 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02003101 con_lst,
3102 HDA_MAX_NUM_INPUTS);
3103 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003104 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02003105 index = j;
3106 goto found;
3107 }
3108 continue;
3109found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003110 wcaps = get_wcaps(codec, nid) &
3111 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003112
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003113 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003114 sprintf(name, "%s Capture Volume",
3115 stac92xx_dmic_labels[dimux->num_items]);
3116
3117 err = stac92xx_add_control(spec,
3118 STAC_CTL_WIDGET_VOL,
3119 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003120 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3121 (wcaps & AC_WCAP_OUT_AMP) ?
3122 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003123 if (err < 0)
3124 return err;
3125 }
3126
Matt Porter8b657272006-10-26 17:12:59 +02003127 dimux->items[dimux->num_items].label =
3128 stac92xx_dmic_labels[dimux->num_items];
3129 dimux->items[dimux->num_items].index = index;
3130 dimux->num_items++;
3131 }
3132
3133 return 0;
3134}
3135
Mattc7d4b2f2005-06-27 14:59:41 +02003136/* create playback/capture controls for input pins */
3137static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3138{
3139 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003140 struct hda_input_mux *imux = &spec->private_imux;
3141 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3142 int i, j, k;
3143
3144 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003145 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02003146
Takashi Iwai314634b2006-09-21 11:56:18 +02003147 if (!cfg->input_pins[i])
3148 continue;
3149 index = -1;
3150 for (j = 0; j < spec->num_muxes; j++) {
3151 int num_cons;
3152 num_cons = snd_hda_get_connections(codec,
3153 spec->mux_nids[j],
3154 con_lst,
3155 HDA_MAX_NUM_INPUTS);
3156 for (k = 0; k < num_cons; k++)
3157 if (con_lst[k] == cfg->input_pins[i]) {
3158 index = k;
3159 goto found;
3160 }
Mattc7d4b2f2005-06-27 14:59:41 +02003161 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003162 continue;
3163 found:
3164 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3165 imux->items[imux->num_items].index = index;
3166 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003167 }
3168
Steve Longerbeam7b043892007-05-03 20:50:03 +02003169 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003170 /*
3171 * Set the current input for the muxes.
3172 * The STAC9221 has two input muxes with identical source
3173 * NID lists. Hopefully this won't get confused.
3174 */
3175 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003176 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3177 AC_VERB_SET_CONNECT_SEL,
3178 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003179 }
3180 }
3181
Mattc7d4b2f2005-06-27 14:59:41 +02003182 return 0;
3183}
3184
Mattc7d4b2f2005-06-27 14:59:41 +02003185static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3186{
3187 struct sigmatel_spec *spec = codec->spec;
3188 int i;
3189
3190 for (i = 0; i < spec->autocfg.line_outs; i++) {
3191 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3192 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3193 }
3194}
3195
3196static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3197{
3198 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003199 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003200
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003201 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3202 hda_nid_t pin;
3203 pin = spec->autocfg.hp_pins[i];
3204 if (pin) /* connect to front */
3205 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3206 }
3207 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3208 hda_nid_t pin;
3209 pin = spec->autocfg.speaker_pins[i];
3210 if (pin) /* connect to front */
3211 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3212 }
Mattc7d4b2f2005-06-27 14:59:41 +02003213}
3214
Matt Porter3cc08dc2006-01-23 15:27:49 +01003215static 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 +02003216{
3217 struct sigmatel_spec *spec = codec->spec;
3218 int err;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003219 int hp_speaker_swap = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003220
Matt Porter8b657272006-10-26 17:12:59 +02003221 if ((err = snd_hda_parse_pin_def_config(codec,
3222 &spec->autocfg,
3223 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003224 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003225 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003226 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003227
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003228 /* If we have no real line-out pin and multiple hp-outs, HPs should
3229 * be set up as multi-channel outputs.
3230 */
3231 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3232 spec->autocfg.hp_outs > 1) {
3233 /* Copy hp_outs to line_outs, backup line_outs in
3234 * speaker_outs so that the following routines can handle
3235 * HP pins as primary outputs.
3236 */
3237 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3238 sizeof(spec->autocfg.line_out_pins));
3239 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3240 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3241 sizeof(spec->autocfg.hp_pins));
3242 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3243 hp_speaker_swap = 1;
3244 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003245 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003246 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3247 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003248 u32 caps = query_amp_caps(codec,
3249 spec->autocfg.mono_out_pin, dir);
3250 hda_nid_t conn_list[1];
3251
3252 /* get the mixer node and then the mono mux if it exists */
3253 if (snd_hda_get_connections(codec,
3254 spec->autocfg.mono_out_pin, conn_list, 1) &&
3255 snd_hda_get_connections(codec, conn_list[0],
3256 conn_list, 1)) {
3257
3258 int wcaps = get_wcaps(codec, conn_list[0]);
3259 int wid_type = (wcaps & AC_WCAP_TYPE)
3260 >> AC_WCAP_TYPE_SHIFT;
3261 /* LR swap check, some stac925x have a mux that
3262 * changes the DACs output path instead of the
3263 * mono-mux path.
3264 */
3265 if (wid_type == AC_WID_AUD_SEL &&
3266 !(wcaps & AC_WCAP_LR_SWAP))
3267 spec->mono_nid = conn_list[0];
3268 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003269 if (dir) {
3270 hda_nid_t nid = spec->autocfg.mono_out_pin;
3271
3272 /* most mono outs have a least a mute/unmute switch */
3273 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3274 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3275 "Mono Playback Switch",
3276 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003277 if (err < 0)
3278 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003279 /* check for volume support for the amp */
3280 if ((caps & AC_AMPCAP_NUM_STEPS)
3281 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3282 err = stac92xx_add_control(spec,
3283 STAC_CTL_WIDGET_VOL,
3284 "Mono Playback Volume",
3285 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3286 if (err < 0)
3287 return err;
3288 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003289 }
3290
3291 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3292 AC_PINCTL_OUT_EN);
3293 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003294
Matt Porter403d1942005-11-29 15:00:51 +01003295 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
3296 return err;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003297 if (spec->multiout.num_dacs == 0)
3298 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
3299 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003300
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003301 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
3302
3303 if (err < 0)
3304 return err;
3305
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003306 /* setup analog beep controls */
3307 if (spec->anabeep_nid > 0) {
3308 err = stac92xx_auto_create_beep_ctls(codec,
3309 spec->anabeep_nid);
3310 if (err < 0)
3311 return err;
3312 }
3313
3314 /* setup digital beep controls and input device */
3315#ifdef CONFIG_SND_HDA_INPUT_BEEP
3316 if (spec->digbeep_nid > 0) {
3317 hda_nid_t nid = spec->digbeep_nid;
3318
3319 err = stac92xx_auto_create_beep_ctls(codec, nid);
3320 if (err < 0)
3321 return err;
3322 err = snd_hda_attach_beep_device(codec, nid);
3323 if (err < 0)
3324 return err;
3325 }
3326#endif
3327
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003328 if (hp_speaker_swap == 1) {
3329 /* Restore the hp_outs and line_outs */
3330 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3331 sizeof(spec->autocfg.line_out_pins));
3332 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3333 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
3334 sizeof(spec->autocfg.speaker_pins));
3335 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
3336 memset(spec->autocfg.speaker_pins, 0,
3337 sizeof(spec->autocfg.speaker_pins));
3338 spec->autocfg.speaker_outs = 0;
3339 }
3340
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003341 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3342
3343 if (err < 0)
3344 return err;
3345
3346 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3347
3348 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003349 return err;
3350
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003351 if (spec->mono_nid > 0) {
3352 err = stac92xx_auto_create_mono_output_ctls(codec);
3353 if (err < 0)
3354 return err;
3355 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003356 if (spec->num_amps > 0) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003357 err = stac92xx_auto_create_amp_output_ctls(codec);
3358 if (err < 0)
3359 return err;
3360 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003361 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003362 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3363 &spec->autocfg)) < 0)
3364 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003365 if (spec->num_muxes > 0) {
3366 err = stac92xx_auto_create_mux_input_ctls(codec);
3367 if (err < 0)
3368 return err;
3369 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003370 if (spec->num_smuxes > 0) {
3371 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3372 if (err < 0)
3373 return err;
3374 }
Matt Porter8b657272006-10-26 17:12:59 +02003375
Mattc7d4b2f2005-06-27 14:59:41 +02003376 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003377 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003378 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003379
Takashi Iwai82bc9552006-03-21 11:24:42 +01003380 if (spec->autocfg.dig_out_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003381 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003382 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003383 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003384
3385 if (spec->kctl_alloc)
3386 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3387
3388 spec->input_mux = &spec->private_imux;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003389 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003390 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003391 spec->mono_mux = &spec->private_mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -04003392 spec->amp_mux = &spec->private_amp_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003393 return 1;
3394}
3395
Takashi Iwai82bc9552006-03-21 11:24:42 +01003396/* add playback controls for HP output */
3397static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3398 struct auto_pin_cfg *cfg)
3399{
3400 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003401 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003402 unsigned int wid_caps;
3403
3404 if (! pin)
3405 return 0;
3406
3407 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003408 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003409 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003410
3411 return 0;
3412}
3413
Richard Fish160ea0d2006-09-06 13:58:25 +02003414/* add playback controls for LFE output */
3415static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3416 struct auto_pin_cfg *cfg)
3417{
3418 struct sigmatel_spec *spec = codec->spec;
3419 int err;
3420 hda_nid_t lfe_pin = 0x0;
3421 int i;
3422
3423 /*
3424 * search speaker outs and line outs for a mono speaker pin
3425 * with an amp. If one is found, add LFE controls
3426 * for it.
3427 */
3428 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3429 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003430 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003431 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3432 if (wcaps == AC_WCAP_OUT_AMP)
3433 /* found a mono speaker with an amp, must be lfe */
3434 lfe_pin = pin;
3435 }
3436
3437 /* if speaker_outs is 0, then speakers may be in line_outs */
3438 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3439 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3440 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003441 unsigned int defcfg;
Harvey Harrison8b551782008-02-29 11:56:48 +01003442 defcfg = snd_hda_codec_read(codec, pin, 0,
Richard Fish160ea0d2006-09-06 13:58:25 +02003443 AC_VERB_GET_CONFIG_DEFAULT,
3444 0x00);
Harvey Harrison8b551782008-02-29 11:56:48 +01003445 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003446 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003447 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3448 if (wcaps == AC_WCAP_OUT_AMP)
3449 /* found a mono speaker with an amp,
3450 must be lfe */
3451 lfe_pin = pin;
3452 }
3453 }
3454 }
3455
3456 if (lfe_pin) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003457 err = create_controls(spec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003458 if (err < 0)
3459 return err;
3460 }
3461
3462 return 0;
3463}
3464
Mattc7d4b2f2005-06-27 14:59:41 +02003465static int stac9200_parse_auto_config(struct hda_codec *codec)
3466{
3467 struct sigmatel_spec *spec = codec->spec;
3468 int err;
3469
Kailang Yangdf694da2005-12-05 19:42:22 +01003470 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003471 return err;
3472
3473 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3474 return err;
3475
Takashi Iwai82bc9552006-03-21 11:24:42 +01003476 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3477 return err;
3478
Richard Fish160ea0d2006-09-06 13:58:25 +02003479 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3480 return err;
3481
Takashi Iwai82bc9552006-03-21 11:24:42 +01003482 if (spec->autocfg.dig_out_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003483 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003484 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003485 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003486
3487 if (spec->kctl_alloc)
3488 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3489
3490 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003491 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003492
3493 return 1;
3494}
3495
Sam Revitch62fe78e2006-05-10 15:09:17 +02003496/*
3497 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3498 * funky external mute control using GPIO pins.
3499 */
3500
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003501static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003502 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003503{
3504 unsigned int gpiostate, gpiomask, gpiodir;
3505
3506 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3507 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003508 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003509
3510 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3511 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003512 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003513
3514 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3515 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003516 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003517
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003518 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003519 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3520
3521 snd_hda_codec_write(codec, codec->afg, 0,
3522 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003523 snd_hda_codec_read(codec, codec->afg, 0,
3524 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003525
3526 msleep(1);
3527
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003528 snd_hda_codec_read(codec, codec->afg, 0,
3529 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003530}
3531
Takashi Iwai314634b2006-09-21 11:56:18 +02003532static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3533 unsigned int event)
3534{
3535 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003536 snd_hda_codec_write_cache(codec, nid, 0,
3537 AC_VERB_SET_UNSOLICITED_ENABLE,
3538 (AC_USRSP_EN | event));
Takashi Iwai314634b2006-09-21 11:56:18 +02003539}
3540
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003541static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3542{
3543 int i;
3544 for (i = 0; i < cfg->hp_outs; i++)
3545 if (cfg->hp_pins[i] == nid)
3546 return 1; /* nid is a HP-Out */
3547
3548 return 0; /* nid is not a HP-Out */
3549};
3550
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003551static void stac92xx_power_down(struct hda_codec *codec)
3552{
3553 struct sigmatel_spec *spec = codec->spec;
3554
3555 /* power down inactive DACs */
3556 hda_nid_t *dac;
3557 for (dac = spec->dac_list; *dac; dac++)
Matthew Ranostay44510892008-02-21 07:49:31 +01003558 if (!is_in_dac_nids(spec, *dac) &&
3559 spec->multiout.hp_nid != *dac)
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003560 snd_hda_codec_write_cache(codec, *dac, 0,
3561 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3562}
3563
Mattc7d4b2f2005-06-27 14:59:41 +02003564static int stac92xx_init(struct hda_codec *codec)
3565{
3566 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003567 struct auto_pin_cfg *cfg = &spec->autocfg;
3568 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003569
Mattc7d4b2f2005-06-27 14:59:41 +02003570 snd_hda_sequence_write(codec, spec->init);
3571
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003572 /* power down adcs initially */
3573 if (spec->powerdown_adcs)
3574 for (i = 0; i < spec->num_adcs; i++)
3575 snd_hda_codec_write_cache(codec,
3576 spec->adc_nids[i], 0,
3577 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003578 /* set up pins */
3579 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02003580 /* Enable unsolicited responses on the HP widget */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003581 for (i = 0; i < cfg->hp_outs; i++)
Takashi Iwai314634b2006-09-21 11:56:18 +02003582 enable_pin_detect(codec, cfg->hp_pins[i],
3583 STAC_HP_EVENT);
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01003584 /* force to enable the first line-out; the others are set up
3585 * in unsol_event
3586 */
3587 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3588 AC_PINCTL_OUT_EN);
Takashi Iwaieb995a82006-09-21 14:28:21 +02003589 stac92xx_auto_init_hp_out(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003590 /* fake event to set up pins */
3591 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3592 } else {
3593 stac92xx_auto_init_multi_out(codec);
3594 stac92xx_auto_init_hp_out(codec);
3595 }
3596 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01003597 hda_nid_t nid = cfg->input_pins[i];
3598 if (nid) {
3599 unsigned int pinctl = AC_PINCTL_IN_EN;
3600 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
3601 pinctl |= stac92xx_get_vref(codec, nid);
3602 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3603 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01003604 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003605 for (i = 0; i < spec->num_dmics; i++)
3606 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3607 AC_PINCTL_IN_EN);
3608 for (i = 0; i < spec->num_pwrs; i++) {
3609 int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
3610 ? STAC_HP_EVENT : STAC_PWR_EVENT;
3611 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
3612 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003613 int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
3614 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003615 def_conf = get_defcfg_connect(def_conf);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003616 /* outputs are only ports capable of power management
3617 * any attempts on powering down a input port cause the
3618 * referenced VREF to act quirky.
3619 */
3620 if (pinctl & AC_PINCTL_IN_EN)
3621 continue;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003622 /* skip any ports that don't have jacks since presence
3623 * detection is useless */
3624 if (def_conf && def_conf != AC_JACK_PORT_FIXED)
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003625 continue;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003626 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3627 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3628 }
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003629 if (spec->dac_list)
3630 stac92xx_power_down(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003631 if (cfg->dig_out_pin)
3632 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3633 AC_PINCTL_OUT_EN);
3634 if (cfg->dig_in_pin)
3635 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3636 AC_PINCTL_IN_EN);
3637
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003638 stac_gpio_set(codec, spec->gpio_mask,
3639 spec->gpio_dir, spec->gpio_data);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003640
Mattc7d4b2f2005-06-27 14:59:41 +02003641 return 0;
3642}
3643
Matt2f2f4252005-04-13 14:45:30 +02003644static void stac92xx_free(struct hda_codec *codec)
3645{
Mattc7d4b2f2005-06-27 14:59:41 +02003646 struct sigmatel_spec *spec = codec->spec;
3647 int i;
3648
3649 if (! spec)
3650 return;
3651
3652 if (spec->kctl_alloc) {
3653 for (i = 0; i < spec->num_kctl_used; i++)
3654 kfree(spec->kctl_alloc[i].name);
3655 kfree(spec->kctl_alloc);
3656 }
3657
Richard Fish11b44bb2006-08-23 18:31:34 +02003658 if (spec->bios_pin_configs)
3659 kfree(spec->bios_pin_configs);
3660
Mattc7d4b2f2005-06-27 14:59:41 +02003661 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003662 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02003663}
3664
Matt4e550962005-07-04 17:51:39 +02003665static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3666 unsigned int flag)
3667{
3668 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3669 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02003670
Takashi Iwaif9acba42007-05-29 18:01:06 +02003671 if (pin_ctl & AC_PINCTL_IN_EN) {
3672 /*
3673 * we need to check the current set-up direction of
3674 * shared input pins since they can be switched via
3675 * "xxx as Output" mixer switch
3676 */
3677 struct sigmatel_spec *spec = codec->spec;
3678 struct auto_pin_cfg *cfg = &spec->autocfg;
3679 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3680 spec->line_switch) ||
3681 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3682 spec->mic_switch))
3683 return;
3684 }
3685
Steve Longerbeam7b043892007-05-03 20:50:03 +02003686 /* if setting pin direction bits, clear the current
3687 direction bits first */
3688 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3689 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3690
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003691 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003692 AC_VERB_SET_PIN_WIDGET_CONTROL,
3693 pin_ctl | flag);
3694}
3695
3696static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3697 unsigned int flag)
3698{
3699 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3700 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003701 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003702 AC_VERB_SET_PIN_WIDGET_CONTROL,
3703 pin_ctl & ~flag);
3704}
3705
Jiang Zhe40c1d302007-11-12 13:05:16 +01003706static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02003707{
3708 if (!nid)
3709 return 0;
3710 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Jiang Zhe40c1d302007-11-12 13:05:16 +01003711 & (1 << 31)) {
3712 unsigned int pinctl;
3713 pinctl = snd_hda_codec_read(codec, nid, 0,
3714 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3715 if (pinctl & AC_PINCTL_IN_EN)
3716 return 0; /* mic- or line-input */
3717 else
3718 return 1; /* HP-output */
3719 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003720 return 0;
3721}
3722
3723static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
Matt4e550962005-07-04 17:51:39 +02003724{
3725 struct sigmatel_spec *spec = codec->spec;
3726 struct auto_pin_cfg *cfg = &spec->autocfg;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003727 int nid = cfg->hp_pins[cfg->hp_outs - 1];
Matt4e550962005-07-04 17:51:39 +02003728 int i, presence;
3729
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003730 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003731 if (spec->gpio_mute)
3732 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3733 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3734
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003735 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003736 if (presence)
3737 break;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003738 if (spec->hp_switch && cfg->hp_pins[i] == nid)
3739 break;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003740 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003741 }
Matt4e550962005-07-04 17:51:39 +02003742
3743 if (presence) {
3744 /* disable lineouts, enable hp */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003745 if (spec->hp_switch)
3746 stac92xx_reset_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003747 for (i = 0; i < cfg->line_outs; i++)
3748 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3749 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003750 for (i = 0; i < cfg->speaker_outs; i++)
3751 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3752 AC_PINCTL_OUT_EN);
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003753 if (spec->eapd_mask)
3754 stac_gpio_set(codec, spec->gpio_mask,
3755 spec->gpio_dir, spec->gpio_data &
3756 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003757 } else {
3758 /* enable lineouts, disable hp */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003759 if (spec->hp_switch)
3760 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003761 for (i = 0; i < cfg->line_outs; i++)
3762 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3763 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003764 for (i = 0; i < cfg->speaker_outs; i++)
3765 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3766 AC_PINCTL_OUT_EN);
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003767 if (spec->eapd_mask)
3768 stac_gpio_set(codec, spec->gpio_mask,
3769 spec->gpio_dir, spec->gpio_data |
3770 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003771 }
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003772 if (!spec->hp_switch && cfg->hp_outs > 1 && presence)
3773 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003774}
3775
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003776static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
3777{
3778 struct sigmatel_spec *spec = codec->spec;
3779 hda_nid_t nid = spec->pwr_nids[idx];
3780 int presence, val;
3781 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
3782 & 0x000000ff;
3783 presence = get_hp_pin_presence(codec, nid);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003784
3785 /* several codecs have two power down bits */
3786 if (spec->pwr_mapping)
3787 idx = spec->pwr_mapping[idx];
3788 else
3789 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003790
3791 if (presence)
3792 val &= ~idx;
3793 else
3794 val |= idx;
3795
3796 /* power down unused output ports */
3797 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
3798};
3799
Takashi Iwai314634b2006-09-21 11:56:18 +02003800static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
3801{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003802 struct sigmatel_spec *spec = codec->spec;
3803 int idx = res >> 26 & 0x0f;
3804
3805 switch ((res >> 26) & 0x30) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003806 case STAC_HP_EVENT:
3807 stac92xx_hp_detect(codec, res);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003808 /* fallthru */
3809 case STAC_PWR_EVENT:
3810 if (spec->num_pwrs > 0)
3811 stac92xx_pin_sense(codec, idx);
Takashi Iwai314634b2006-09-21 11:56:18 +02003812 }
3813}
3814
Takashi Iwaicb53c622007-08-10 17:21:45 +02003815#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02003816static int stac92xx_resume(struct hda_codec *codec)
3817{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003818 struct sigmatel_spec *spec = codec->spec;
3819
Richard Fish11b44bb2006-08-23 18:31:34 +02003820 stac92xx_set_config_regs(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003821 snd_hda_sequence_write(codec, spec->init);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003822 stac_gpio_set(codec, spec->gpio_mask,
3823 spec->gpio_dir, spec->gpio_data);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003824 snd_hda_codec_resume_amp(codec);
3825 snd_hda_codec_resume_cache(codec);
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003826 /* power down inactive DACs */
3827 if (spec->dac_list)
3828 stac92xx_power_down(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003829 /* invoke unsolicited event to reset the HP state */
3830 if (spec->hp_detect)
3831 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
Mattff6fdc32005-06-27 15:06:52 +02003832 return 0;
3833}
3834#endif
3835
Matt2f2f4252005-04-13 14:45:30 +02003836static struct hda_codec_ops stac92xx_patch_ops = {
3837 .build_controls = stac92xx_build_controls,
3838 .build_pcms = stac92xx_build_pcms,
3839 .init = stac92xx_init,
3840 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02003841 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003842#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02003843 .resume = stac92xx_resume,
3844#endif
Matt2f2f4252005-04-13 14:45:30 +02003845};
3846
3847static int patch_stac9200(struct hda_codec *codec)
3848{
3849 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003850 int err;
Matt2f2f4252005-04-13 14:45:30 +02003851
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003852 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02003853 if (spec == NULL)
3854 return -ENOMEM;
3855
3856 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003857 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02003858 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003859 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
3860 stac9200_models,
3861 stac9200_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02003862 if (spec->board_config < 0) {
3863 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
3864 err = stac92xx_save_bios_config_regs(codec);
3865 if (err < 0) {
3866 stac92xx_free(codec);
3867 return err;
3868 }
3869 spec->pin_configs = spec->bios_pin_configs;
3870 } else {
Matt Porter403d1942005-11-29 15:00:51 +01003871 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
3872 stac92xx_set_config_regs(codec);
3873 }
Matt2f2f4252005-04-13 14:45:30 +02003874
3875 spec->multiout.max_channels = 2;
3876 spec->multiout.num_dacs = 1;
3877 spec->multiout.dac_nids = stac9200_dac_nids;
3878 spec->adc_nids = stac9200_adc_nids;
3879 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02003880 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02003881 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003882 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003883 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003884
Tobin Davisbf277782008-02-03 20:31:47 +01003885 if (spec->board_config == STAC_9200_GATEWAY ||
3886 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02003887 spec->init = stac9200_eapd_init;
3888 else
3889 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02003890 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02003891
Takashi Iwai117f2572008-03-18 09:53:23 +01003892 if (spec->board_config == STAC_9200_PANASONIC) {
3893 spec->gpio_mask = spec->gpio_dir = 0x09;
3894 spec->gpio_data = 0x00;
3895 }
3896
Mattc7d4b2f2005-06-27 14:59:41 +02003897 err = stac9200_parse_auto_config(codec);
3898 if (err < 0) {
3899 stac92xx_free(codec);
3900 return err;
3901 }
Matt2f2f4252005-04-13 14:45:30 +02003902
3903 codec->patch_ops = stac92xx_patch_ops;
3904
3905 return 0;
3906}
3907
Tobin Davis8e21c342007-01-08 11:04:17 +01003908static int patch_stac925x(struct hda_codec *codec)
3909{
3910 struct sigmatel_spec *spec;
3911 int err;
3912
3913 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3914 if (spec == NULL)
3915 return -ENOMEM;
3916
3917 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003918 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01003919 spec->pin_nids = stac925x_pin_nids;
3920 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
3921 stac925x_models,
3922 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01003923 again:
Tobin Davis8e21c342007-01-08 11:04:17 +01003924 if (spec->board_config < 0) {
Tobin Davis2c11f952007-05-17 09:36:34 +02003925 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
3926 "using BIOS defaults\n");
Tobin Davis8e21c342007-01-08 11:04:17 +01003927 err = stac92xx_save_bios_config_regs(codec);
3928 if (err < 0) {
3929 stac92xx_free(codec);
3930 return err;
3931 }
3932 spec->pin_configs = spec->bios_pin_configs;
3933 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
3934 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
3935 stac92xx_set_config_regs(codec);
3936 }
3937
3938 spec->multiout.max_channels = 2;
3939 spec->multiout.num_dacs = 1;
3940 spec->multiout.dac_nids = stac925x_dac_nids;
3941 spec->adc_nids = stac925x_adc_nids;
3942 spec->mux_nids = stac925x_mux_nids;
3943 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003944 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003945 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02003946 switch (codec->vendor_id) {
3947 case 0x83847632: /* STAC9202 */
3948 case 0x83847633: /* STAC9202D */
3949 case 0x83847636: /* STAC9251 */
3950 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02003951 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02003952 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01003953 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
3954 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02003955 break;
3956 default:
3957 spec->num_dmics = 0;
3958 break;
3959 }
Tobin Davis8e21c342007-01-08 11:04:17 +01003960
3961 spec->init = stac925x_core_init;
3962 spec->mixer = stac925x_mixer;
3963
3964 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01003965 if (!err) {
3966 if (spec->board_config < 0) {
3967 printk(KERN_WARNING "hda_codec: No auto-config is "
3968 "available, default to model=ref\n");
3969 spec->board_config = STAC_925x_REF;
3970 goto again;
3971 }
3972 err = -EINVAL;
3973 }
Tobin Davis8e21c342007-01-08 11:04:17 +01003974 if (err < 0) {
3975 stac92xx_free(codec);
3976 return err;
3977 }
3978
3979 codec->patch_ops = stac92xx_patch_ops;
3980
3981 return 0;
3982}
3983
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003984static struct hda_input_mux stac92hd73xx_dmux = {
3985 .num_items = 4,
3986 .items = {
3987 { "Analog Inputs", 0x0b },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003988 { "Digital Mic 1", 0x09 },
3989 { "Digital Mic 2", 0x0a },
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003990 { "CD", 0x08 },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003991 }
3992};
3993
3994static int patch_stac92hd73xx(struct hda_codec *codec)
3995{
3996 struct sigmatel_spec *spec;
3997 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
3998 int err = 0;
3999
4000 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4001 if (spec == NULL)
4002 return -ENOMEM;
4003
4004 codec->spec = spec;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02004005 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004006 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4007 spec->pin_nids = stac92hd73xx_pin_nids;
4008 spec->board_config = snd_hda_check_board_config(codec,
4009 STAC_92HD73XX_MODELS,
4010 stac92hd73xx_models,
4011 stac92hd73xx_cfg_tbl);
4012again:
4013 if (spec->board_config < 0) {
4014 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4015 " STAC92HD73XX, using BIOS defaults\n");
4016 err = stac92xx_save_bios_config_regs(codec);
4017 if (err < 0) {
4018 stac92xx_free(codec);
4019 return err;
4020 }
4021 spec->pin_configs = spec->bios_pin_configs;
4022 } else {
4023 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
4024 stac92xx_set_config_regs(codec);
4025 }
4026
4027 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
4028 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4029
4030 if (spec->multiout.num_dacs < 0) {
4031 printk(KERN_WARNING "hda_codec: Could not determine "
4032 "number of channels defaulting to DAC count\n");
4033 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
4034 }
4035
4036 switch (spec->multiout.num_dacs) {
4037 case 0x3: /* 6 Channel */
4038 spec->mixer = stac92hd73xx_6ch_mixer;
4039 spec->init = stac92hd73xx_6ch_core_init;
4040 break;
4041 case 0x4: /* 8 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004042 spec->mixer = stac92hd73xx_8ch_mixer;
4043 spec->init = stac92hd73xx_8ch_core_init;
4044 break;
4045 case 0x5: /* 10 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004046 spec->mixer = stac92hd73xx_10ch_mixer;
4047 spec->init = stac92hd73xx_10ch_core_init;
4048 };
4049
4050 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
4051 spec->aloopback_mask = 0x01;
4052 spec->aloopback_shift = 8;
4053
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004054 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004055 spec->mux_nids = stac92hd73xx_mux_nids;
4056 spec->adc_nids = stac92hd73xx_adc_nids;
4057 spec->dmic_nids = stac92hd73xx_dmic_nids;
4058 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004059 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostay89385032008-09-11 09:49:39 -04004060 spec->amp_nids = stac92hd73xx_amp_nids;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004061 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004062
4063 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4064 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01004065 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004066 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4067 sizeof(stac92hd73xx_dmux));
4068
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004069 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004070 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004071 spec->gpio_data = 0x01;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004072
Matthew Ranostaya7662642008-02-21 07:51:14 +01004073 switch (spec->board_config) {
4074 case STAC_DELL_M6:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004075 spec->init = dell_eq_core_init;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004076 spec->num_smuxes = 0;
4077 spec->multiout.hp_nid =
4078 spec->multiout.dac_nids[spec->multiout.num_dacs - 1];
4079 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4080 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
4081 spec->num_amps = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004082 switch (codec->subsystem_id) {
4083 case 0x1028025e: /* Analog Mics */
4084 case 0x1028025f:
4085 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4086 spec->num_dmics = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004087 spec->private_dimux.num_items = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004088 break;
Matthew Ranostayd654a662008-03-14 08:46:51 +01004089 case 0x10280271: /* Digital Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004090 case 0x10280272:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004091 spec->init = dell_m6_core_init;
4092 /* fall-through */
4093 case 0x10280254:
4094 case 0x10280255:
Matthew Ranostaya7662642008-02-21 07:51:14 +01004095 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4096 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004097 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004098 break;
4099 case 0x10280256: /* Both */
4100 case 0x10280057:
4101 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4102 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4103 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004104 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004105 break;
4106 }
4107 break;
4108 default:
4109 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004110 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostaya7662642008-02-21 07:51:14 +01004111 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004112 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004113
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004114 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4115 spec->pwr_nids = stac92hd73xx_pwr_nids;
4116
Matthew Ranostayd9737752008-09-07 12:03:41 +02004117 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004118
4119 if (!err) {
4120 if (spec->board_config < 0) {
4121 printk(KERN_WARNING "hda_codec: No auto-config is "
4122 "available, default to model=ref\n");
4123 spec->board_config = STAC_92HD73XX_REF;
4124 goto again;
4125 }
4126 err = -EINVAL;
4127 }
4128
4129 if (err < 0) {
4130 stac92xx_free(codec);
4131 return err;
4132 }
4133
4134 codec->patch_ops = stac92xx_patch_ops;
4135
4136 return 0;
4137}
4138
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004139static struct hda_input_mux stac92hd83xxx_dmux = {
4140 .num_items = 3,
4141 .items = {
4142 { "Analog Inputs", 0x03 },
4143 { "Digital Mic 1", 0x04 },
4144 { "Digital Mic 2", 0x05 },
4145 }
4146};
4147
4148static int patch_stac92hd83xxx(struct hda_codec *codec)
4149{
4150 struct sigmatel_spec *spec;
4151 int err;
4152
4153 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4154 if (spec == NULL)
4155 return -ENOMEM;
4156
4157 codec->spec = spec;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004158 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004159 spec->mono_nid = 0x19;
4160 spec->digbeep_nid = 0x21;
4161 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4162 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4163 spec->adc_nids = stac92hd83xxx_adc_nids;
4164 spec->pwr_nids = stac92hd83xxx_pwr_nids;
4165 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4166 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
4167 spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
4168
4169 spec->init = stac92hd83xxx_core_init;
4170 switch (codec->vendor_id) {
4171 case 0x111d7605:
4172 spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
4173 break;
4174 default:
4175 spec->num_pwrs--;
4176 spec->init++; /* switch to config #2 */
4177 spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
4178 }
4179
4180 spec->mixer = stac92hd83xxx_mixer;
4181 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4182 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4183 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
4184 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4185 spec->dinput_mux = &stac92hd83xxx_dmux;
4186 spec->pin_nids = stac92hd83xxx_pin_nids;
4187 spec->board_config = snd_hda_check_board_config(codec,
4188 STAC_92HD83XXX_MODELS,
4189 stac92hd83xxx_models,
4190 stac92hd83xxx_cfg_tbl);
4191again:
4192 if (spec->board_config < 0) {
4193 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4194 " STAC92HD83XXX, using BIOS defaults\n");
4195 err = stac92xx_save_bios_config_regs(codec);
4196 if (err < 0) {
4197 stac92xx_free(codec);
4198 return err;
4199 }
4200 spec->pin_configs = spec->bios_pin_configs;
4201 } else {
4202 spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config];
4203 stac92xx_set_config_regs(codec);
4204 }
4205
4206 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4207 if (!err) {
4208 if (spec->board_config < 0) {
4209 printk(KERN_WARNING "hda_codec: No auto-config is "
4210 "available, default to model=ref\n");
4211 spec->board_config = STAC_92HD83XXX_REF;
4212 goto again;
4213 }
4214 err = -EINVAL;
4215 }
4216
4217 if (err < 0) {
4218 stac92xx_free(codec);
4219 return err;
4220 }
4221
4222 codec->patch_ops = stac92xx_patch_ops;
4223
4224 return 0;
4225}
4226
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004227#ifdef SND_HDA_NEEDS_RESUME
4228static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr)
4229{
4230 struct sigmatel_spec *spec = codec->spec;
4231 int i;
4232 snd_hda_codec_write_cache(codec, codec->afg, 0,
4233 AC_VERB_SET_POWER_STATE, pwr);
4234
4235 msleep(1);
4236 for (i = 0; i < spec->num_adcs; i++) {
4237 snd_hda_codec_write_cache(codec,
4238 spec->adc_nids[i], 0,
4239 AC_VERB_SET_POWER_STATE, pwr);
4240 }
4241};
4242
4243static int stac92hd71xx_resume(struct hda_codec *codec)
4244{
4245 stac92hd71xx_set_power_state(codec, AC_PWRST_D0);
4246 return stac92xx_resume(codec);
4247}
4248
4249static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state)
4250{
4251 stac92hd71xx_set_power_state(codec, AC_PWRST_D3);
4252 return 0;
4253};
4254
4255#endif
4256
4257static struct hda_codec_ops stac92hd71bxx_patch_ops = {
4258 .build_controls = stac92xx_build_controls,
4259 .build_pcms = stac92xx_build_pcms,
4260 .init = stac92xx_init,
4261 .free = stac92xx_free,
4262 .unsol_event = stac92xx_unsol_event,
4263#ifdef SND_HDA_NEEDS_RESUME
4264 .resume = stac92hd71xx_resume,
4265 .suspend = stac92hd71xx_suspend,
4266#endif
4267};
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004268
Matthew Ranostaye035b842007-11-06 11:53:55 +01004269static int patch_stac92hd71bxx(struct hda_codec *codec)
4270{
4271 struct sigmatel_spec *spec;
4272 int err = 0;
4273
4274 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4275 if (spec == NULL)
4276 return -ENOMEM;
4277
4278 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004279 codec->patch_ops = stac92xx_patch_ops;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004280 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004281 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004282 spec->pin_nids = stac92hd71bxx_pin_nids;
4283 spec->board_config = snd_hda_check_board_config(codec,
4284 STAC_92HD71BXX_MODELS,
4285 stac92hd71bxx_models,
4286 stac92hd71bxx_cfg_tbl);
4287again:
4288 if (spec->board_config < 0) {
4289 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4290 " STAC92HD71BXX, using BIOS defaults\n");
4291 err = stac92xx_save_bios_config_regs(codec);
4292 if (err < 0) {
4293 stac92xx_free(codec);
4294 return err;
4295 }
4296 spec->pin_configs = spec->bios_pin_configs;
4297 } else {
4298 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
4299 stac92xx_set_config_regs(codec);
4300 }
4301
Matthew Ranostay541eee82007-12-14 12:08:04 +01004302 switch (codec->vendor_id) {
4303 case 0x111d76b6: /* 4 Port without Analog Mixer */
4304 case 0x111d76b7:
4305 case 0x111d76b4: /* 6 Port without Analog Mixer */
4306 case 0x111d76b5:
4307 spec->mixer = stac92hd71bxx_mixer;
4308 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004309 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004310 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004311 case 0x111d7608: /* 5 Port with Analog Mixer */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004312 if ((codec->revision_id & 0xf) == 0 ||
4313 (codec->revision_id & 0xf) == 1) {
4314#ifdef SND_HDA_NEEDS_RESUME
4315 codec->patch_ops = stac92hd71bxx_patch_ops;
4316#endif
4317 spec->stream_delay = 40; /* 40 milliseconds */
4318 }
4319
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004320 /* no output amps */
4321 spec->num_pwrs = 0;
4322 spec->mixer = stac92hd71bxx_analog_mixer;
4323
4324 /* disable VSW */
4325 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
4326 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
4327 break;
4328 case 0x111d7603: /* 6 Port with Analog Mixer */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004329 if ((codec->revision_id & 0xf) == 1) {
4330#ifdef SND_HDA_NEEDS_RESUME
4331 codec->patch_ops = stac92hd71bxx_patch_ops;
4332#endif
4333 spec->stream_delay = 40; /* 40 milliseconds */
4334 }
4335
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004336 /* no output amps */
4337 spec->num_pwrs = 0;
4338 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01004339 default:
4340 spec->mixer = stac92hd71bxx_analog_mixer;
4341 spec->init = stac92hd71bxx_analog_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004342 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004343 }
4344
4345 spec->aloopback_mask = 0x20;
4346 spec->aloopback_shift = 0;
4347
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004348 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004349 spec->gpio_mask = 0x01;
4350 spec->gpio_dir = 0x01;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004351 spec->gpio_data = 0x01;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004352
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004353 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004354 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004355 spec->mux_nids = stac92hd71bxx_mux_nids;
4356 spec->adc_nids = stac92hd71bxx_adc_nids;
4357 spec->dmic_nids = stac92hd71bxx_dmic_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004358 spec->dmux_nids = stac92hd71bxx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004359 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004360 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004361
4362 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
4363 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01004364 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004365
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004366 switch (spec->board_config) {
4367 case STAC_HP_M4:
4368 spec->num_dmics = 0;
4369 spec->num_smuxes = 1;
4370 spec->num_dmuxes = 0;
4371
4372 /* enable internal microphone */
4373 snd_hda_codec_write_cache(codec, 0x0e, 0,
4374 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80);
4375 break;
4376 default:
4377 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
4378 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
4379 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4380 };
4381
Takashi Iwaiaea7bb02008-02-25 18:26:41 +01004382 spec->multiout.num_dacs = 1;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004383 spec->multiout.hp_nid = 0x11;
4384 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
4385
4386 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
4387 if (!err) {
4388 if (spec->board_config < 0) {
4389 printk(KERN_WARNING "hda_codec: No auto-config is "
4390 "available, default to model=ref\n");
4391 spec->board_config = STAC_92HD71BXX_REF;
4392 goto again;
4393 }
4394 err = -EINVAL;
4395 }
4396
4397 if (err < 0) {
4398 stac92xx_free(codec);
4399 return err;
4400 }
4401
Matthew Ranostaye035b842007-11-06 11:53:55 +01004402 return 0;
4403};
4404
Matt2f2f4252005-04-13 14:45:30 +02004405static int patch_stac922x(struct hda_codec *codec)
4406{
4407 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004408 int err;
Matt2f2f4252005-04-13 14:45:30 +02004409
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004410 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004411 if (spec == NULL)
4412 return -ENOMEM;
4413
4414 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004415 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004416 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004417 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
4418 stac922x_models,
4419 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08004420 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004421 spec->gpio_mask = spec->gpio_dir = 0x03;
4422 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004423 /* Intel Macs have all same PCI SSID, so we need to check
4424 * codec SSID to distinguish the exact models
4425 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004426 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004427 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004428
4429 case 0x106b0800:
4430 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02004431 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004432 case 0x106b0600:
4433 case 0x106b0700:
4434 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004435 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004436 case 0x106b0e00:
4437 case 0x106b0f00:
4438 case 0x106b1600:
4439 case 0x106b1700:
4440 case 0x106b0200:
4441 case 0x106b1e00:
4442 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004443 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004444 case 0x106b1a00:
4445 case 0x00000100:
4446 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02004447 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004448 case 0x106b0a00:
4449 case 0x106b2200:
4450 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02004451 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08004452 default:
4453 spec->board_config = STAC_INTEL_MAC_V3;
4454 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004455 }
4456 }
4457
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004458 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004459 if (spec->board_config < 0) {
4460 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
4461 "using BIOS defaults\n");
4462 err = stac92xx_save_bios_config_regs(codec);
4463 if (err < 0) {
4464 stac92xx_free(codec);
4465 return err;
4466 }
4467 spec->pin_configs = spec->bios_pin_configs;
4468 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
Matt Porter403d1942005-11-29 15:00:51 +01004469 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
4470 stac92xx_set_config_regs(codec);
4471 }
Matt2f2f4252005-04-13 14:45:30 +02004472
Matt2f2f4252005-04-13 14:45:30 +02004473 spec->adc_nids = stac922x_adc_nids;
4474 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004475 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004476 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004477 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004478 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004479
4480 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004481 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004482
4483 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02004484
Matt Porter3cc08dc2006-01-23 15:27:49 +01004485 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004486 if (!err) {
4487 if (spec->board_config < 0) {
4488 printk(KERN_WARNING "hda_codec: No auto-config is "
4489 "available, default to model=ref\n");
4490 spec->board_config = STAC_D945_REF;
4491 goto again;
4492 }
4493 err = -EINVAL;
4494 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004495 if (err < 0) {
4496 stac92xx_free(codec);
4497 return err;
4498 }
4499
4500 codec->patch_ops = stac92xx_patch_ops;
4501
Takashi Iwai807a46362007-05-29 19:01:37 +02004502 /* Fix Mux capture level; max to 2 */
4503 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
4504 (0 << AC_AMPCAP_OFFSET_SHIFT) |
4505 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4506 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4507 (0 << AC_AMPCAP_MUTE_SHIFT));
4508
Matt Porter3cc08dc2006-01-23 15:27:49 +01004509 return 0;
4510}
4511
4512static int patch_stac927x(struct hda_codec *codec)
4513{
4514 struct sigmatel_spec *spec;
4515 int err;
4516
4517 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4518 if (spec == NULL)
4519 return -ENOMEM;
4520
4521 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004522 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004523 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004524 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
4525 stac927x_models,
4526 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004527 again:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004528 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
4529 if (spec->board_config < 0)
4530 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4531 "STAC927x, using BIOS defaults\n");
Richard Fish11b44bb2006-08-23 18:31:34 +02004532 err = stac92xx_save_bios_config_regs(codec);
4533 if (err < 0) {
4534 stac92xx_free(codec);
4535 return err;
4536 }
4537 spec->pin_configs = spec->bios_pin_configs;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004538 } else {
Matt Porter3cc08dc2006-01-23 15:27:49 +01004539 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
4540 stac92xx_set_config_regs(codec);
4541 }
4542
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004543 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004544 spec->adc_nids = stac927x_adc_nids;
4545 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
4546 spec->mux_nids = stac927x_mux_nids;
4547 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004548 spec->smux_nids = stac927x_smux_nids;
4549 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004550 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004551 spec->multiout.dac_nids = spec->dac_nids;
4552
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004553 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02004554 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004555 case STAC_D965_5ST:
4556 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004557 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004558 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004559 spec->num_dmics = 0;
4560
Tobin Davis93ed1502006-09-01 21:03:12 +02004561 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004562 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004563 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004564 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02004565 switch (codec->subsystem_id) {
4566 case 0x10280209:
4567 case 0x1028022e:
4568 /* correct the device field to SPDIF out */
4569 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
4570 break;
4571 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01004572 /* configure the analog microphone on some laptops */
4573 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01004574 /* correct the front output jack as a hp out */
Matthew Ranostay7989fba2008-02-21 07:50:12 +01004575 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01004576 /* correct the front input jack as a mic */
4577 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
4578 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004579 case STAC_DELL_3ST:
4580 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004581 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004582 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004583 spec->dmic_nids = stac927x_dmic_nids;
4584 spec->num_dmics = STAC927X_NUM_DMICS;
4585
Tobin Davis93ed1502006-09-01 21:03:12 +02004586 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004587 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004588 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004589 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004590 break;
4591 default:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004592 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004593 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004594 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004595 spec->num_dmics = 0;
4596
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004597 spec->init = stac927x_core_init;
4598 spec->mixer = stac927x_mixer;
4599 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004600
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004601 spec->num_pwrs = 0;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004602 spec->aloopback_mask = 0x40;
4603 spec->aloopback_shift = 0;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004604
Matt Porter3cc08dc2006-01-23 15:27:49 +01004605 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004606 if (!err) {
4607 if (spec->board_config < 0) {
4608 printk(KERN_WARNING "hda_codec: No auto-config is "
4609 "available, default to model=ref\n");
4610 spec->board_config = STAC_D965_REF;
4611 goto again;
4612 }
4613 err = -EINVAL;
4614 }
Mattc7d4b2f2005-06-27 14:59:41 +02004615 if (err < 0) {
4616 stac92xx_free(codec);
4617 return err;
4618 }
Matt2f2f4252005-04-13 14:45:30 +02004619
4620 codec->patch_ops = stac92xx_patch_ops;
4621
Takashi Iwai52987652008-01-16 16:09:47 +01004622 /*
4623 * !!FIXME!!
4624 * The STAC927x seem to require fairly long delays for certain
4625 * command sequences. With too short delays (even if the answer
4626 * is set to RIRB properly), it results in the silence output
4627 * on some hardwares like Dell.
4628 *
4629 * The below flag enables the longer delay (see get_response
4630 * in hda_intel.c).
4631 */
4632 codec->bus->needs_damn_long_delay = 1;
4633
Matt2f2f4252005-04-13 14:45:30 +02004634 return 0;
4635}
4636
Matt Porterf3302a52006-07-31 12:49:34 +02004637static int patch_stac9205(struct hda_codec *codec)
4638{
4639 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02004640 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02004641
4642 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4643 if (spec == NULL)
4644 return -ENOMEM;
4645
4646 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004647 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004648 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004649 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
4650 stac9205_models,
4651 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004652 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004653 if (spec->board_config < 0) {
4654 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
4655 err = stac92xx_save_bios_config_regs(codec);
4656 if (err < 0) {
4657 stac92xx_free(codec);
4658 return err;
4659 }
4660 spec->pin_configs = spec->bios_pin_configs;
4661 } else {
Matt Porterf3302a52006-07-31 12:49:34 +02004662 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
4663 stac92xx_set_config_regs(codec);
4664 }
4665
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004666 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02004667 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004668 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02004669 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004670 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004671 spec->smux_nids = stac9205_smux_nids;
4672 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004673 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02004674 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004675 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004676 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004677 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02004678
4679 spec->init = stac9205_core_init;
4680 spec->mixer = stac9205_mixer;
4681
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004682 spec->aloopback_mask = 0x40;
4683 spec->aloopback_shift = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02004684 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02004685
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004686 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004687 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02004688 /* Enable SPDIF in/out */
4689 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
4690 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01004691
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004692 /* Enable unsol response for GPIO4/Dock HP connection */
4693 snd_hda_codec_write(codec, codec->afg, 0,
4694 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4695 snd_hda_codec_write_cache(codec, codec->afg, 0,
4696 AC_VERB_SET_UNSOLICITED_ENABLE,
4697 (AC_USRSP_EN | STAC_HP_EVENT));
4698
4699 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004700 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004701 spec->gpio_mask = 0x1b;
4702 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01004703 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004704 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02004705 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004706 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004707 break;
4708 default:
4709 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004710 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004711 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004712 break;
4713 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02004714
Matt Porterf3302a52006-07-31 12:49:34 +02004715 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004716 if (!err) {
4717 if (spec->board_config < 0) {
4718 printk(KERN_WARNING "hda_codec: No auto-config is "
4719 "available, default to model=ref\n");
4720 spec->board_config = STAC_9205_REF;
4721 goto again;
4722 }
4723 err = -EINVAL;
4724 }
Matt Porterf3302a52006-07-31 12:49:34 +02004725 if (err < 0) {
4726 stac92xx_free(codec);
4727 return err;
4728 }
4729
4730 codec->patch_ops = stac92xx_patch_ops;
4731
4732 return 0;
4733}
4734
Matt2f2f4252005-04-13 14:45:30 +02004735/*
Guillaume Munch6d859062006-08-22 17:15:47 +02004736 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01004737 */
4738
Guillaume Munch99ccc562006-08-16 19:35:12 +02004739/* static config for Sony VAIO FE550G and Sony VAIO AR */
Takashi Iwaidb064e52006-03-16 16:04:58 +01004740static hda_nid_t vaio_dacs[] = { 0x2 };
4741#define VAIO_HP_DAC 0x5
4742static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
4743static hda_nid_t vaio_mux_nids[] = { 0x15 };
4744
4745static struct hda_input_mux vaio_mux = {
Takashi Iwaia3a2f422007-10-11 11:21:21 +02004746 .num_items = 3,
Takashi Iwaidb064e52006-03-16 16:04:58 +01004747 .items = {
Takashi Iwaid7737812006-04-25 13:05:43 +02004748 /* { "HP", 0x0 }, */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004749 { "Mic Jack", 0x1 },
4750 { "Internal Mic", 0x2 },
Takashi Iwaidb064e52006-03-16 16:04:58 +01004751 { "PCM", 0x3 },
4752 }
4753};
4754
4755static struct hda_verb vaio_init[] = {
4756 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004757 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
Takashi Iwaidb064e52006-03-16 16:04:58 +01004758 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4759 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4760 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4761 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004762 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01004763 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4764 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4765 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4766 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4767 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4768 {}
4769};
4770
Guillaume Munch6d859062006-08-22 17:15:47 +02004771static struct hda_verb vaio_ar_init[] = {
4772 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
4773 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4774 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4775 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4776/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
4777 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004778 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Guillaume Munch6d859062006-08-22 17:15:47 +02004779 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4780 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4781/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
4782 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4783 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4784 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4785 {}
4786};
4787
Takashi Iwaidb064e52006-03-16 16:04:58 +01004788/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02004789static struct hda_bind_ctls vaio_bind_master_vol = {
4790 .ops = &snd_hda_bind_vol,
4791 .values = {
4792 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4793 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4794 0
4795 },
4796};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004797
4798/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02004799static struct hda_bind_ctls vaio_bind_master_sw = {
4800 .ops = &snd_hda_bind_sw,
4801 .values = {
4802 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4803 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4804 0,
4805 },
4806};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004807
4808static struct snd_kcontrol_new vaio_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02004809 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4810 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Takashi Iwaidb064e52006-03-16 16:04:58 +01004811 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4812 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4813 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4814 {
4815 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4816 .name = "Capture Source",
4817 .count = 1,
4818 .info = stac92xx_mux_enum_info,
4819 .get = stac92xx_mux_enum_get,
4820 .put = stac92xx_mux_enum_put,
4821 },
4822 {}
4823};
4824
Guillaume Munch6d859062006-08-22 17:15:47 +02004825static struct snd_kcontrol_new vaio_ar_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02004826 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4827 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Guillaume Munch6d859062006-08-22 17:15:47 +02004828 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4829 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4830 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4831 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
4832 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
4833 {
4834 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4835 .name = "Capture Source",
4836 .count = 1,
4837 .info = stac92xx_mux_enum_info,
4838 .get = stac92xx_mux_enum_get,
4839 .put = stac92xx_mux_enum_put,
4840 },
4841 {}
4842};
4843
4844static struct hda_codec_ops stac9872_patch_ops = {
Takashi Iwaidb064e52006-03-16 16:04:58 +01004845 .build_controls = stac92xx_build_controls,
4846 .build_pcms = stac92xx_build_pcms,
4847 .init = stac92xx_init,
4848 .free = stac92xx_free,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004849#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaidb064e52006-03-16 16:04:58 +01004850 .resume = stac92xx_resume,
4851#endif
4852};
4853
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004854static int stac9872_vaio_init(struct hda_codec *codec)
4855{
4856 int err;
4857
4858 err = stac92xx_init(codec);
4859 if (err < 0)
4860 return err;
4861 if (codec->patch_ops.unsol_event)
4862 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
4863 return 0;
4864}
4865
4866static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
4867{
Jiang Zhe40c1d302007-11-12 13:05:16 +01004868 if (get_hp_pin_presence(codec, 0x0a)) {
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004869 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4870 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4871 } else {
4872 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4873 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4874 }
4875}
4876
4877static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
4878{
4879 switch (res >> 26) {
4880 case STAC_HP_EVENT:
4881 stac9872_vaio_hp_detect(codec, res);
4882 break;
4883 }
4884}
4885
4886static struct hda_codec_ops stac9872_vaio_patch_ops = {
4887 .build_controls = stac92xx_build_controls,
4888 .build_pcms = stac92xx_build_pcms,
4889 .init = stac9872_vaio_init,
4890 .free = stac92xx_free,
4891 .unsol_event = stac9872_vaio_unsol_event,
4892#ifdef CONFIG_PM
4893 .resume = stac92xx_resume,
4894#endif
4895};
4896
Guillaume Munch6d859062006-08-22 17:15:47 +02004897enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
4898 CXD9872RD_VAIO,
4899 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
4900 STAC9872AK_VAIO,
4901 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
4902 STAC9872K_VAIO,
4903 /* AR Series. id=0x83847664 and subsys=104D1300 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004904 CXD9872AKD_VAIO,
4905 STAC_9872_MODELS,
4906};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004907
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004908static const char *stac9872_models[STAC_9872_MODELS] = {
4909 [CXD9872RD_VAIO] = "vaio",
4910 [CXD9872AKD_VAIO] = "vaio-ar",
4911};
4912
4913static struct snd_pci_quirk stac9872_cfg_tbl[] = {
4914 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
4915 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
4916 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
Tobin Davis68e22542007-03-12 11:36:39 +01004917 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
Takashi Iwaidb064e52006-03-16 16:04:58 +01004918 {}
4919};
4920
Guillaume Munch6d859062006-08-22 17:15:47 +02004921static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01004922{
4923 struct sigmatel_spec *spec;
4924 int board_config;
4925
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004926 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
4927 stac9872_models,
4928 stac9872_cfg_tbl);
Takashi Iwaidb064e52006-03-16 16:04:58 +01004929 if (board_config < 0)
4930 /* unknown config, let generic-parser do its job... */
4931 return snd_hda_parse_generic_codec(codec);
4932
4933 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4934 if (spec == NULL)
4935 return -ENOMEM;
4936
4937 codec->spec = spec;
4938 switch (board_config) {
Guillaume Munch6d859062006-08-22 17:15:47 +02004939 case CXD9872RD_VAIO:
4940 case STAC9872AK_VAIO:
4941 case STAC9872K_VAIO:
Takashi Iwaidb064e52006-03-16 16:04:58 +01004942 spec->mixer = vaio_mixer;
4943 spec->init = vaio_init;
4944 spec->multiout.max_channels = 2;
4945 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
4946 spec->multiout.dac_nids = vaio_dacs;
4947 spec->multiout.hp_nid = VAIO_HP_DAC;
4948 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
4949 spec->adc_nids = vaio_adcs;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004950 spec->num_pwrs = 0;
Takashi Iwaidb064e52006-03-16 16:04:58 +01004951 spec->input_mux = &vaio_mux;
4952 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004953 codec->patch_ops = stac9872_vaio_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01004954 break;
Guillaume Munch6d859062006-08-22 17:15:47 +02004955
4956 case CXD9872AKD_VAIO:
4957 spec->mixer = vaio_ar_mixer;
4958 spec->init = vaio_ar_init;
4959 spec->multiout.max_channels = 2;
4960 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
4961 spec->multiout.dac_nids = vaio_dacs;
4962 spec->multiout.hp_nid = VAIO_HP_DAC;
4963 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004964 spec->num_pwrs = 0;
Guillaume Munch6d859062006-08-22 17:15:47 +02004965 spec->adc_nids = vaio_adcs;
4966 spec->input_mux = &vaio_mux;
4967 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004968 codec->patch_ops = stac9872_patch_ops;
Guillaume Munch6d859062006-08-22 17:15:47 +02004969 break;
Takashi Iwaidb064e52006-03-16 16:04:58 +01004970 }
4971
Takashi Iwaidb064e52006-03-16 16:04:58 +01004972 return 0;
4973}
4974
4975
4976/*
Matt2f2f4252005-04-13 14:45:30 +02004977 * patch entries
4978 */
4979struct hda_codec_preset snd_hda_preset_sigmatel[] = {
4980 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
4981 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
4982 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
4983 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
4984 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
4985 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
4986 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02004987 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
4988 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
4989 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
4990 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
4991 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
4992 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01004993 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
4994 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
4995 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
4996 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
4997 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
4998 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
4999 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5000 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5001 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5002 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01005003 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5004 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5005 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5006 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5007 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5008 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02005009 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5010 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02005011 /* The following does not take into account .id=0x83847661 when subsys =
5012 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5013 * currently not fully supported.
5014 */
5015 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5016 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5017 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02005018 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5019 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5020 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5021 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5022 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5023 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5024 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5025 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005026 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005027 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5028 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005029 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01005030 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5031 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005032 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01005033 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5034 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5035 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5036 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5037 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5038 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5039 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5040 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02005041 {} /* terminator */
5042};