blob: f9b25638892110d35a83ec6a30506533f1201e0a [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;
Matthew Ranostay65973632008-09-16 10:39:37 -0400180 const char **spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200181
Mattdabbed62005-06-14 10:19:34 +0200182 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100183 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200184 hda_nid_t anabeep_nid;
185 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200186
Matt2f2f4252005-04-13 14:45:30 +0200187 /* pin widgets */
188 hda_nid_t *pin_nids;
189 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200190 unsigned int *pin_configs;
Richard Fish11b44bb2006-08-23 18:31:34 +0200191 unsigned int *bios_pin_configs;
Matt2f2f4252005-04-13 14:45:30 +0200192
193 /* codec specific stuff */
194 struct hda_verb *init;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100195 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200196
197 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200198 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100199 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200200 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100201 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200202 struct hda_input_mux *sinput_mux;
203 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400204 unsigned int cur_amux;
205 hda_nid_t *amp_nids;
206 unsigned int num_amps;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200207 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200208
Matt Porter403d1942005-11-29 15:00:51 +0100209 /* i/o switches */
210 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200211 unsigned int clfe_swap;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +0200212 unsigned int hp_switch;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200213 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200214
Mattc7d4b2f2005-06-27 14:59:41 +0200215 struct hda_pcm pcm_rec[2]; /* PCM information */
216
217 /* dynamic controls and input_mux */
218 struct auto_pin_cfg autocfg;
219 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100220 struct snd_kcontrol_new *kctl_alloc;
Matt Porter8b657272006-10-26 17:12:59 +0200221 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200222 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200223 struct hda_input_mux private_smux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400224 struct hda_input_mux private_amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100225 struct hda_input_mux private_mono_mux;
Matt2f2f4252005-04-13 14:45:30 +0200226};
227
228static hda_nid_t stac9200_adc_nids[1] = {
229 0x03,
230};
231
232static hda_nid_t stac9200_mux_nids[1] = {
233 0x0c,
234};
235
236static hda_nid_t stac9200_dac_nids[1] = {
237 0x02,
238};
239
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100240static hda_nid_t stac92hd73xx_pwr_nids[8] = {
241 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
242 0x0f, 0x10, 0x11
243};
244
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400245static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
246 0x26, 0,
247};
248
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100249static hda_nid_t stac92hd73xx_adc_nids[2] = {
250 0x1a, 0x1b
251};
252
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400253#define DELL_M6_AMP 2
254static hda_nid_t stac92hd73xx_amp_nids[3] = {
255 0x0b, 0x0c, 0x0e
Matthew Ranostay89385032008-09-11 09:49:39 -0400256};
257
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100258#define STAC92HD73XX_NUM_DMICS 2
259static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
260 0x13, 0x14, 0
261};
262
263#define STAC92HD73_DAC_COUNT 5
264static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
265 0x15, 0x16, 0x17, 0x18, 0x19,
266};
267
268static hda_nid_t stac92hd73xx_mux_nids[4] = {
269 0x28, 0x29, 0x2a, 0x2b,
270};
271
272static hda_nid_t stac92hd73xx_dmux_nids[2] = {
273 0x20, 0x21,
274};
275
Matthew Ranostayd9737752008-09-07 12:03:41 +0200276static hda_nid_t stac92hd73xx_smux_nids[2] = {
277 0x22, 0x23,
278};
279
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200280#define STAC92HD83XXX_NUM_DMICS 2
281static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
282 0x11, 0x12, 0
283};
284
285#define STAC92HD81_DAC_COUNT 2
286#define STAC92HD83_DAC_COUNT 3
287static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = {
288 0x13, 0x14, 0x22,
289};
290
291static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
292 0x17, 0x18,
293};
294
295static hda_nid_t stac92hd83xxx_adc_nids[2] = {
296 0x15, 0x16,
297};
298
299static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
300 0xa, 0xb, 0xd, 0xe,
301};
302
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400303static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
304 0x1e, 0,
305};
306
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200307static unsigned int stac92hd83xxx_pwr_mapping[4] = {
308 0x03, 0x0c, 0x10, 0x40,
309};
310
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100311static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
312 0x0a, 0x0d, 0x0f
313};
314
Matthew Ranostaye035b842007-11-06 11:53:55 +0100315static hda_nid_t stac92hd71bxx_adc_nids[2] = {
316 0x12, 0x13,
317};
318
319static hda_nid_t stac92hd71bxx_mux_nids[2] = {
320 0x1a, 0x1b
321};
322
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100323static hda_nid_t stac92hd71bxx_dmux_nids[1] = {
324 0x1c,
325};
326
Matthew Ranostayd9737752008-09-07 12:03:41 +0200327static hda_nid_t stac92hd71bxx_smux_nids[2] = {
328 0x24, 0x25,
329};
330
Takashi Iwaiaea7bb02008-02-25 18:26:41 +0100331static hda_nid_t stac92hd71bxx_dac_nids[1] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100332 0x10, /*0x11, */
333};
334
335#define STAC92HD71BXX_NUM_DMICS 2
336static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
337 0x18, 0x19, 0
338};
339
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400340static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
341 0x22, 0
342};
343
Tobin Davis8e21c342007-01-08 11:04:17 +0100344static hda_nid_t stac925x_adc_nids[1] = {
345 0x03,
346};
347
348static hda_nid_t stac925x_mux_nids[1] = {
349 0x0f,
350};
351
352static hda_nid_t stac925x_dac_nids[1] = {
353 0x02,
354};
355
Takashi Iwaif6e98522007-10-16 14:27:04 +0200356#define STAC925X_NUM_DMICS 1
357static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
358 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200359};
360
Takashi Iwai1697055e2007-12-18 18:05:52 +0100361static hda_nid_t stac925x_dmux_nids[1] = {
362 0x14,
363};
364
Matt2f2f4252005-04-13 14:45:30 +0200365static hda_nid_t stac922x_adc_nids[2] = {
366 0x06, 0x07,
367};
368
369static hda_nid_t stac922x_mux_nids[2] = {
370 0x12, 0x13,
371};
372
Matt Porter3cc08dc2006-01-23 15:27:49 +0100373static hda_nid_t stac927x_adc_nids[3] = {
374 0x07, 0x08, 0x09
375};
376
377static hda_nid_t stac927x_mux_nids[3] = {
378 0x15, 0x16, 0x17
379};
380
Matthew Ranostayd9737752008-09-07 12:03:41 +0200381static hda_nid_t stac927x_smux_nids[1] = {
382 0x21,
383};
384
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100385static hda_nid_t stac927x_dac_nids[6] = {
386 0x02, 0x03, 0x04, 0x05, 0x06, 0
387};
388
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100389static hda_nid_t stac927x_dmux_nids[1] = {
390 0x1b,
391};
392
Matthew Ranostay7f168592007-10-18 17:38:17 +0200393#define STAC927X_NUM_DMICS 2
394static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
395 0x13, 0x14, 0
396};
397
Matthew Ranostay65973632008-09-16 10:39:37 -0400398static const char *stac927x_spdif_labels[5] = {
399 "Digital Playback", "ADAT", "Analog Mux 1",
400 "Analog Mux 2", "Analog Mux 3"
401};
402
Matt Porterf3302a52006-07-31 12:49:34 +0200403static hda_nid_t stac9205_adc_nids[2] = {
404 0x12, 0x13
405};
406
407static hda_nid_t stac9205_mux_nids[2] = {
408 0x19, 0x1a
409};
410
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100411static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100412 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100413};
414
Matthew Ranostayd9737752008-09-07 12:03:41 +0200415static hda_nid_t stac9205_smux_nids[1] = {
416 0x21,
417};
418
Takashi Iwaif6e98522007-10-16 14:27:04 +0200419#define STAC9205_NUM_DMICS 2
420static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
421 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200422};
423
Mattc7d4b2f2005-06-27 14:59:41 +0200424static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200425 0x08, 0x09, 0x0d, 0x0e,
426 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200427};
428
Tobin Davis8e21c342007-01-08 11:04:17 +0100429static hda_nid_t stac925x_pin_nids[8] = {
430 0x07, 0x08, 0x0a, 0x0b,
431 0x0c, 0x0d, 0x10, 0x11,
432};
433
Matt2f2f4252005-04-13 14:45:30 +0200434static hda_nid_t stac922x_pin_nids[10] = {
435 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
436 0x0f, 0x10, 0x11, 0x15, 0x1b,
437};
438
Matthew Ranostaya7662642008-02-21 07:51:14 +0100439static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100440 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
441 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200442 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100443};
444
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200445static hda_nid_t stac92hd83xxx_pin_nids[14] = {
446 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
447 0x0f, 0x10, 0x11, 0x12, 0x13,
448 0x1d, 0x1e, 0x1f, 0x20
449};
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400450static hda_nid_t stac92hd71bxx_pin_nids[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100451 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
452 0x0f, 0x14, 0x18, 0x19, 0x1e,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400453 0x1f,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100454};
455
Matt Porter3cc08dc2006-01-23 15:27:49 +0100456static hda_nid_t stac927x_pin_nids[14] = {
457 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
458 0x0f, 0x10, 0x11, 0x12, 0x13,
459 0x14, 0x21, 0x22, 0x23,
460};
461
Matt Porterf3302a52006-07-31 12:49:34 +0200462static hda_nid_t stac9205_pin_nids[12] = {
463 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
464 0x0f, 0x14, 0x16, 0x17, 0x18,
465 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200466};
467
Matthew Ranostay89385032008-09-11 09:49:39 -0400468#define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
469
470static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
471 struct snd_ctl_elem_value *ucontrol)
472{
473 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
474 struct sigmatel_spec *spec = codec->spec;
475 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
476
477 kcontrol->private_value ^= get_amp_nid(kcontrol);
478 kcontrol->private_value |= nid;
479
480 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
481}
482
483static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
484 struct snd_ctl_elem_value *ucontrol)
485{
486 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
487 struct sigmatel_spec *spec = codec->spec;
488 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
489
490 kcontrol->private_value ^= get_amp_nid(kcontrol);
491 kcontrol->private_value |= nid;
492
493 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
494}
495
Matt Porter8b657272006-10-26 17:12:59 +0200496static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
497 struct snd_ctl_elem_info *uinfo)
498{
499 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
500 struct sigmatel_spec *spec = codec->spec;
501 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
502}
503
504static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
505 struct snd_ctl_elem_value *ucontrol)
506{
507 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
508 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100509 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200510
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100511 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200512 return 0;
513}
514
515static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
516 struct snd_ctl_elem_value *ucontrol)
517{
518 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
519 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100520 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200521
522 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100523 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200524}
525
Matthew Ranostayd9737752008-09-07 12:03:41 +0200526static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
527 struct snd_ctl_elem_info *uinfo)
528{
529 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
530 struct sigmatel_spec *spec = codec->spec;
531 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
532}
533
534static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
535 struct snd_ctl_elem_value *ucontrol)
536{
537 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
538 struct sigmatel_spec *spec = codec->spec;
539 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
540
541 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
542 return 0;
543}
544
545static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
546 struct snd_ctl_elem_value *ucontrol)
547{
548 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
549 struct sigmatel_spec *spec = codec->spec;
550 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
551
552 return snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
553 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
554}
555
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100556static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200557{
558 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
559 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200560 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200561}
562
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100563static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200564{
565 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
566 struct sigmatel_spec *spec = codec->spec;
567 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
568
569 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
570 return 0;
571}
572
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100573static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200574{
575 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
576 struct sigmatel_spec *spec = codec->spec;
577 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
578
Mattc7d4b2f2005-06-27 14:59:41 +0200579 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200580 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
581}
582
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100583static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
584 struct snd_ctl_elem_info *uinfo)
585{
586 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
587 struct sigmatel_spec *spec = codec->spec;
588 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
589}
590
591static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
592 struct snd_ctl_elem_value *ucontrol)
593{
594 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
595 struct sigmatel_spec *spec = codec->spec;
596
597 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
598 return 0;
599}
600
601static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
602 struct snd_ctl_elem_value *ucontrol)
603{
604 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
605 struct sigmatel_spec *spec = codec->spec;
606
607 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
608 spec->mono_nid, &spec->cur_mmux);
609}
610
Matthew Ranostay89385032008-09-11 09:49:39 -0400611static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
612 struct snd_ctl_elem_info *uinfo)
613{
614 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
615 struct sigmatel_spec *spec = codec->spec;
616 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
617}
618
619static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
620 struct snd_ctl_elem_value *ucontrol)
621{
622 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
623 struct sigmatel_spec *spec = codec->spec;
624
625 ucontrol->value.enumerated.item[0] = spec->cur_amux;
626 return 0;
627}
628
629static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
630 struct snd_ctl_elem_value *ucontrol)
631{
632 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
633 struct sigmatel_spec *spec = codec->spec;
634 struct snd_kcontrol *ctl =
635 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
636 if (!ctl)
637 return -EINVAL;
638
639 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
640 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
641
642 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
643 0, &spec->cur_amux);
644}
645
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200646#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
647
648static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
649 struct snd_ctl_elem_value *ucontrol)
650{
651 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100652 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200653 struct sigmatel_spec *spec = codec->spec;
654
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100655 ucontrol->value.integer.value[0] = !!(spec->aloopback &
656 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200657 return 0;
658}
659
660static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
661 struct snd_ctl_elem_value *ucontrol)
662{
663 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
664 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100665 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200666 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100667 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200668
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100669 idx_val = spec->aloopback_mask << idx;
670 if (ucontrol->value.integer.value[0])
671 val = spec->aloopback | idx_val;
672 else
673 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100674 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200675 return 0;
676
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100677 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200678
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100679 /* Only return the bits defined by the shift value of the
680 * first two bytes of the mask
681 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200682 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100683 kcontrol->private_value & 0xFFFF, 0x0);
684 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200685
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100686 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200687 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100688 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200689 } else {
690 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100691 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200692 }
693
694 snd_hda_codec_write_cache(codec, codec->afg, 0,
695 kcontrol->private_value >> 16, dac_mode);
696
697 return 1;
698}
699
Mattc7d4b2f2005-06-27 14:59:41 +0200700static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200701 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200702 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200703 {}
704};
705
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200706static struct hda_verb stac9200_eapd_init[] = {
707 /* set dac0mux for dac converter */
708 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
709 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
710 {}
711};
712
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100713static struct hda_verb stac92hd73xx_6ch_core_init[] = {
714 /* set master volume and direct control */
715 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
716 /* setup audio connections */
717 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
718 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
719 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
720 /* setup adcs to point to mixer */
721 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
722 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100723 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
724 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
725 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
726 /* setup import muxs */
727 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
728 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
729 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
730 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
731 {}
732};
733
Matthew Ranostayd654a662008-03-14 08:46:51 +0100734static struct hda_verb dell_eq_core_init[] = {
735 /* set master volume to max value without distortion
736 * and direct control */
737 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
738 /* setup audio connections */
739 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
Matthew Ranostayf7cf0a72008-09-13 10:36:58 -0400740 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x02},
741 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100742 /* setup adcs to point to mixer */
743 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
744 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
745 /* setup import muxs */
746 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
747 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
748 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
749 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
750 {}
751};
752
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100753static struct hda_verb dell_m6_core_init[] = {
Matthew Ranostay20f5f952008-09-01 08:17:56 +0200754 /* set master volume to max value without distortion
755 * and direct control */
756 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100757 /* setup audio connections */
Matthew Ranostay7747ecc2008-03-10 11:30:04 +0100758 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
759 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100760 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
761 /* setup adcs to point to mixer */
762 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
763 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
764 /* setup import muxs */
765 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
766 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
767 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
768 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
769 {}
770};
771
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100772static struct hda_verb stac92hd73xx_8ch_core_init[] = {
773 /* set master volume and direct control */
774 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
775 /* setup audio connections */
776 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
777 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
778 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
779 /* connect hp ports to dac3 */
780 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
781 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
782 /* setup adcs to point to mixer */
783 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
784 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100785 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
786 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
787 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
788 /* setup import muxs */
789 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
790 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
791 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
792 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
793 {}
794};
795
796static struct hda_verb stac92hd73xx_10ch_core_init[] = {
797 /* set master volume and direct control */
798 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
799 /* setup audio connections */
800 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
801 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
802 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
803 /* dac3 is connected to import3 mux */
804 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
805 /* connect hp ports to dac4 */
806 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
807 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
808 /* setup adcs to point to mixer */
809 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
810 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100811 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
812 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
813 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
814 /* setup import muxs */
815 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
816 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
817 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
818 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
819 {}
820};
821
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200822static struct hda_verb stac92hd83xxx_core_init[] = {
823 /* start of config #1 */
824 { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3},
825
826 /* start of config #2 */
827 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
828 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
829 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
830
831 /* power state controls amps */
832 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
833};
834
Matthew Ranostaye035b842007-11-06 11:53:55 +0100835static struct hda_verb stac92hd71bxx_core_init[] = {
836 /* set master volume and direct control */
837 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
838 /* connect headphone jack to dac1 */
839 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100840 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
841 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
842 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
843 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
844 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100845};
846
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200847#define HD_DISABLE_PORTF 3
Matthew Ranostay541eee82007-12-14 12:08:04 +0100848static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200849 /* start of config #1 */
850
851 /* connect port 0f to audio mixer */
852 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
853 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
854 /* unmute right and left channels for node 0x0f */
855 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
856 /* start of config #2 */
857
Matthew Ranostay541eee82007-12-14 12:08:04 +0100858 /* set master volume and direct control */
859 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
860 /* connect headphone jack to dac1 */
861 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200862 /* connect port 0d to audio mixer */
Matthew Ranostay9b359472007-11-07 13:03:12 +0100863 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostay9b359472007-11-07 13:03:12 +0100864 /* unmute dac0 input in audio mixer */
865 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200866 /* unmute right and left channels for nodes 0x0a, 0xd */
Matthew Ranostaye035b842007-11-06 11:53:55 +0100867 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
868 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100869 {}
870};
871
Tobin Davis8e21c342007-01-08 11:04:17 +0100872static struct hda_verb stac925x_core_init[] = {
873 /* set dac0mux for dac converter */
874 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
875 {}
876};
877
Mattc7d4b2f2005-06-27 14:59:41 +0200878static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200879 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200880 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200881 {}
882};
883
Tobin Davis93ed1502006-09-01 21:03:12 +0200884static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200885 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200886 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200887 /* unmute node 0x1b */
888 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
889 /* select node 0x03 as DAC */
890 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
891 {}
892};
893
Matt Porter3cc08dc2006-01-23 15:27:49 +0100894static struct hda_verb stac927x_core_init[] = {
895 /* set master volume and direct control */
896 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200897 /* enable analog pc beep path */
898 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100899 {}
900};
901
Matt Porterf3302a52006-07-31 12:49:34 +0200902static struct hda_verb stac9205_core_init[] = {
903 /* set master volume and direct control */
904 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200905 /* enable analog pc beep path */
906 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200907 {}
908};
909
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100910#define STAC_MONO_MUX \
911 { \
912 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
913 .name = "Mono Mux", \
914 .count = 1, \
915 .info = stac92xx_mono_mux_enum_info, \
916 .get = stac92xx_mono_mux_enum_get, \
917 .put = stac92xx_mono_mux_enum_put, \
918 }
919
Matthew Ranostay89385032008-09-11 09:49:39 -0400920#define STAC_AMP_MUX \
921 { \
922 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
923 .name = "Amp Selector Capture Switch", \
924 .count = 1, \
925 .info = stac92xx_amp_mux_enum_info, \
926 .get = stac92xx_amp_mux_enum_get, \
927 .put = stac92xx_amp_mux_enum_put, \
928 }
929
930#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
931 { \
932 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
933 .name = xname, \
934 .index = 0, \
935 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
936 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
937 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
938 .info = stac92xx_amp_volume_info, \
939 .get = stac92xx_amp_volume_get, \
940 .put = stac92xx_amp_volume_put, \
941 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
942 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
943 }
944
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200945#define STAC_INPUT_SOURCE(cnt) \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200946 { \
947 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
948 .name = "Input Source", \
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200949 .count = cnt, \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200950 .info = stac92xx_mux_enum_info, \
951 .get = stac92xx_mux_enum_get, \
952 .put = stac92xx_mux_enum_put, \
953 }
954
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100955#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200956 { \
957 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
958 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100959 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200960 .info = stac92xx_aloopback_info, \
961 .get = stac92xx_aloopback_get, \
962 .put = stac92xx_aloopback_put, \
963 .private_value = verb_read | (verb_write << 16), \
964 }
965
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100966static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200967 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
968 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200969 STAC_INPUT_SOURCE(1),
Matt2f2f4252005-04-13 14:45:30 +0200970 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
971 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200972 { } /* end */
973};
974
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400975#define DELL_M6_MIXER 6
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100976static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400977 /* start of config #1 */
978 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
979 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
980
981 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
982 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
983
984 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
985 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
986
987 /* start of config #2 */
988 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
989 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
990
991 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
992 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
993
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100994 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
995
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100996 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
997 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
998
999 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1000 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1001
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001002 { } /* end */
1003};
1004
1005static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001006 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1007
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001008 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1009 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1010
1011 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1012 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1013
1014 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1015 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1016
1017 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1018 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1019
1020 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1021 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1022
1023 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1024 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1025
1026 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1027 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1028 { } /* end */
1029};
1030
1031static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001032 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1033
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001034 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1035 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1036
1037 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1038 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1039
1040 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1041 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1042
1043 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1044 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1045
1046 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1047 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1048
1049 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1050 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1051
1052 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1053 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1054 { } /* end */
1055};
1056
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001057
1058static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1059 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1060 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1061
1062 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1063 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1064
1065 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT),
1066 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
1067
1068 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
1069 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
1070
1071 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
1072 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
1073
1074 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
1075 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
1076
1077 /*
1078 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
1079 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
1080 */
1081 { } /* end */
1082};
1083
Matthew Ranostay541eee82007-12-14 12:08:04 +01001084static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001085 STAC_INPUT_SOURCE(2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001086
Matthew Ranostay9b359472007-11-07 13:03:12 +01001087 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1088 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay9b359472007-11-07 13:03:12 +01001089
1090 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1091 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001092 /* analog pc-beep replaced with digital beep support */
1093 /*
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001094 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1095 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001096 */
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001097
Matthew Ranostay9b359472007-11-07 13:03:12 +01001098 HDA_CODEC_MUTE("Analog Loopback 1", 0x17, 0x3, HDA_INPUT),
1099 HDA_CODEC_MUTE("Analog Loopback 2", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001100 { } /* end */
1101};
1102
Matthew Ranostay541eee82007-12-14 12:08:04 +01001103static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +01001104 STAC_INPUT_SOURCE(2),
1105 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1106
Matthew Ranostay541eee82007-12-14 12:08:04 +01001107 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1108 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001109
1110 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1111 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001112 { } /* end */
1113};
1114
Tobin Davis8e21c342007-01-08 11:04:17 +01001115static struct snd_kcontrol_new stac925x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001116 STAC_INPUT_SOURCE(1),
Tobin Davis8e21c342007-01-08 11:04:17 +01001117 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +02001118 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001119 { } /* end */
1120};
1121
Takashi Iwaid1d985f2006-11-23 19:27:12 +01001122static struct snd_kcontrol_new stac9205_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001123 STAC_INPUT_SOURCE(2),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001124 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001125
1126 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1127 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001128
1129 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1130 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001131 { } /* end */
1132};
1133
1134/* This needs to be generated dynamically based on sequence */
1135static struct snd_kcontrol_new stac922x_mixer[] = {
1136 STAC_INPUT_SOURCE(2),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001137 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1138 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001139
1140 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1141 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001142 { } /* end */
1143};
1144
1145
1146static struct snd_kcontrol_new stac927x_mixer[] = {
1147 STAC_INPUT_SOURCE(3),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001148 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001149
1150 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1151 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001152
1153 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1154 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001155
1156 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1157 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
Matt Porterf3302a52006-07-31 12:49:34 +02001158 { } /* end */
1159};
1160
Takashi Iwai1697055e2007-12-18 18:05:52 +01001161static struct snd_kcontrol_new stac_dmux_mixer = {
1162 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1163 .name = "Digital Input Source",
1164 /* count set later */
1165 .info = stac92xx_dmux_enum_info,
1166 .get = stac92xx_dmux_enum_get,
1167 .put = stac92xx_dmux_enum_put,
1168};
1169
Matthew Ranostayd9737752008-09-07 12:03:41 +02001170static struct snd_kcontrol_new stac_smux_mixer = {
1171 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001172 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001173 /* count set later */
1174 .info = stac92xx_smux_enum_info,
1175 .get = stac92xx_smux_enum_get,
1176 .put = stac92xx_smux_enum_put,
1177};
1178
Takashi Iwai2134ea42008-01-10 16:53:55 +01001179static const char *slave_vols[] = {
1180 "Front Playback Volume",
1181 "Surround Playback Volume",
1182 "Center Playback Volume",
1183 "LFE Playback Volume",
1184 "Side Playback Volume",
1185 "Headphone Playback Volume",
1186 "Headphone Playback Volume",
1187 "Speaker Playback Volume",
1188 "External Speaker Playback Volume",
1189 "Speaker2 Playback Volume",
1190 NULL
1191};
1192
1193static const char *slave_sws[] = {
1194 "Front Playback Switch",
1195 "Surround Playback Switch",
1196 "Center Playback Switch",
1197 "LFE Playback Switch",
1198 "Side Playback Switch",
1199 "Headphone Playback Switch",
1200 "Headphone Playback Switch",
1201 "Speaker Playback Switch",
1202 "External Speaker Playback Switch",
1203 "Speaker2 Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001204 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001205 NULL
1206};
1207
Matt2f2f4252005-04-13 14:45:30 +02001208static int stac92xx_build_controls(struct hda_codec *codec)
1209{
1210 struct sigmatel_spec *spec = codec->spec;
1211 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001212 int i;
Matt2f2f4252005-04-13 14:45:30 +02001213
1214 err = snd_hda_add_new_ctls(codec, spec->mixer);
1215 if (err < 0)
1216 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001217
1218 for (i = 0; i < spec->num_mixers; i++) {
1219 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1220 if (err < 0)
1221 return err;
1222 }
Takashi Iwai1697055e2007-12-18 18:05:52 +01001223 if (spec->num_dmuxes > 0) {
1224 stac_dmux_mixer.count = spec->num_dmuxes;
1225 err = snd_ctl_add(codec->bus->card,
1226 snd_ctl_new1(&stac_dmux_mixer, codec));
1227 if (err < 0)
1228 return err;
1229 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001230 if (spec->num_smuxes > 0) {
1231 stac_smux_mixer.count = spec->num_smuxes;
1232 err = snd_ctl_add(codec->bus->card,
1233 snd_ctl_new1(&stac_smux_mixer, codec));
1234 if (err < 0)
1235 return err;
1236 }
Mattc7d4b2f2005-06-27 14:59:41 +02001237
Mattdabbed62005-06-14 10:19:34 +02001238 if (spec->multiout.dig_out_nid) {
1239 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1240 if (err < 0)
1241 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001242 err = snd_hda_create_spdif_share_sw(codec,
1243 &spec->multiout);
1244 if (err < 0)
1245 return err;
1246 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001247 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04001248 if (spec->dig_in_nid && (!spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001249 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1250 if (err < 0)
1251 return err;
1252 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001253
1254 /* if we have no master control, let's create it */
1255 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001256 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001257 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001258 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001259 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001260 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001261 if (err < 0)
1262 return err;
1263 }
1264 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1265 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1266 NULL, slave_sws);
1267 if (err < 0)
1268 return err;
1269 }
1270
Mattdabbed62005-06-14 10:19:34 +02001271 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001272}
1273
Matt Porter403d1942005-11-29 15:00:51 +01001274static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001275 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001276 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1277};
1278
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001279/*
1280 STAC 9200 pin configs for
1281 102801A8
1282 102801DE
1283 102801E8
1284*/
1285static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001286 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1287 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001288};
1289
1290/*
1291 STAC 9200 pin configs for
1292 102801C0
1293 102801C1
1294*/
1295static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001296 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1297 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001298};
1299
1300/*
1301 STAC 9200 pin configs for
1302 102801C4 (Dell Dimension E310)
1303 102801C5
1304 102801C7
1305 102801D9
1306 102801DA
1307 102801E3
1308*/
1309static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001310 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1311 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001312};
1313
1314
1315/*
1316 STAC 9200-32 pin configs for
1317 102801B5 (Dell Inspiron 630m)
1318 102801D8 (Dell Inspiron 640m)
1319*/
1320static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001321 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1322 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001323};
1324
1325/*
1326 STAC 9200-32 pin configs for
1327 102801C2 (Dell Latitude D620)
1328 102801C8
1329 102801CC (Dell Latitude D820)
1330 102801D4
1331 102801D6
1332*/
1333static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001334 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1335 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001336};
1337
1338/*
1339 STAC 9200-32 pin configs for
1340 102801CE (Dell XPS M1710)
1341 102801CF (Dell Precision M90)
1342*/
1343static unsigned int dell9200_m23_pin_configs[8] = {
1344 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1345 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1346};
1347
1348/*
1349 STAC 9200-32 pin configs for
1350 102801C9
1351 102801CA
1352 102801CB (Dell Latitude 120L)
1353 102801D3
1354*/
1355static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001356 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1357 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001358};
1359
1360/*
1361 STAC 9200-32 pin configs for
1362 102801BD (Dell Inspiron E1505n)
1363 102801EE
1364 102801EF
1365*/
1366static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001367 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1368 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001369};
1370
1371/*
1372 STAC 9200-32 pin configs for
1373 102801F5 (Dell Inspiron 1501)
1374 102801F6
1375*/
1376static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001377 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1378 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001379};
1380
1381/*
1382 STAC 9200-32
1383 102801CD (Dell Inspiron E1705/9400)
1384*/
1385static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001386 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1387 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001388};
1389
Tobin Davisbf277782008-02-03 20:31:47 +01001390static unsigned int oqo9200_pin_configs[8] = {
1391 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1392 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1393};
1394
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001395
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001396static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1397 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001398 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001399 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1400 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1401 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1402 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1403 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1404 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1405 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1406 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1407 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1408 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001409 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001410};
1411
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001412static const char *stac9200_models[STAC_9200_MODELS] = {
1413 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001414 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001415 [STAC_9200_DELL_D21] = "dell-d21",
1416 [STAC_9200_DELL_D22] = "dell-d22",
1417 [STAC_9200_DELL_D23] = "dell-d23",
1418 [STAC_9200_DELL_M21] = "dell-m21",
1419 [STAC_9200_DELL_M22] = "dell-m22",
1420 [STAC_9200_DELL_M23] = "dell-m23",
1421 [STAC_9200_DELL_M24] = "dell-m24",
1422 [STAC_9200_DELL_M25] = "dell-m25",
1423 [STAC_9200_DELL_M26] = "dell-m26",
1424 [STAC_9200_DELL_M27] = "dell-m27",
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001425 [STAC_9200_GATEWAY] = "gateway",
Takashi Iwai117f2572008-03-18 09:53:23 +01001426 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001427};
1428
1429static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1430 /* SigmaTel reference board */
1431 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1432 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001433 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001434 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1435 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001436 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001437 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1438 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1439 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1440 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1441 "unknown Dell", STAC_9200_DELL_D22),
1442 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1443 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001444 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001445 "Dell Latitude D620", STAC_9200_DELL_M22),
1446 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1447 "unknown Dell", STAC_9200_DELL_D23),
1448 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1449 "unknown Dell", STAC_9200_DELL_D23),
1450 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1451 "unknown Dell", STAC_9200_DELL_M22),
1452 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1453 "unknown Dell", STAC_9200_DELL_M24),
1454 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1455 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001456 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001457 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001458 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001459 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001460 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001461 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001462 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001463 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001464 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001465 "Dell Precision M90", STAC_9200_DELL_M23),
1466 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1467 "unknown Dell", STAC_9200_DELL_M22),
1468 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1469 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001470 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001471 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001472 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001473 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1474 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1475 "unknown Dell", STAC_9200_DELL_D23),
1476 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1477 "unknown Dell", STAC_9200_DELL_D23),
1478 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1479 "unknown Dell", STAC_9200_DELL_D21),
1480 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1481 "unknown Dell", STAC_9200_DELL_D23),
1482 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1483 "unknown Dell", STAC_9200_DELL_D21),
1484 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1485 "unknown Dell", STAC_9200_DELL_M25),
1486 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1487 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001488 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001489 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1490 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1491 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001492 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001493 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001494 /* Gateway machines needs EAPD to be set on resume */
1495 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1496 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1497 STAC_9200_GATEWAY),
1498 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1499 STAC_9200_GATEWAY),
Tobin Davisbf277782008-02-03 20:31:47 +01001500 /* OQO Mobile */
1501 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001502 {} /* terminator */
1503};
1504
Tobin Davis8e21c342007-01-08 11:04:17 +01001505static unsigned int ref925x_pin_configs[8] = {
1506 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001507 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001508};
1509
1510static unsigned int stac925x_MA6_pin_configs[8] = {
1511 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1512 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1513};
1514
Tobin Davis2c11f952007-05-17 09:36:34 +02001515static unsigned int stac925x_PA6_pin_configs[8] = {
1516 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1517 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1518};
1519
Tobin Davis8e21c342007-01-08 11:04:17 +01001520static unsigned int stac925xM2_2_pin_configs[8] = {
Steve Longerbeam7353e142007-05-29 14:36:17 +02001521 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1522 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001523};
1524
1525static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1526 [STAC_REF] = ref925x_pin_configs,
1527 [STAC_M2_2] = stac925xM2_2_pin_configs,
1528 [STAC_MA6] = stac925x_MA6_pin_configs,
Tobin Davis2c11f952007-05-17 09:36:34 +02001529 [STAC_PA6] = stac925x_PA6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001530};
1531
1532static const char *stac925x_models[STAC_925x_MODELS] = {
1533 [STAC_REF] = "ref",
1534 [STAC_M2_2] = "m2-2",
1535 [STAC_MA6] = "m6",
Tobin Davis2c11f952007-05-17 09:36:34 +02001536 [STAC_PA6] = "pa6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001537};
1538
1539static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1540 /* SigmaTel reference board */
1541 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001542 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Tobin Davis8e21c342007-01-08 11:04:17 +01001543 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1544 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1545 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
Tobin Davis2c11f952007-05-17 09:36:34 +02001546 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
Tobin Davis8e21c342007-01-08 11:04:17 +01001547 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1548 {} /* terminator */
1549};
1550
Matthew Ranostaya7662642008-02-21 07:51:14 +01001551static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001552 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1553 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1554 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001555 0x01452050,
1556};
1557
1558static unsigned int dell_m6_pin_configs[13] = {
1559 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001560 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001561 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1562 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001563};
1564
1565static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001566 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1567 [STAC_DELL_M6] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001568};
1569
1570static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1571 [STAC_92HD73XX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001572 [STAC_DELL_M6] = "dell-m6",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001573};
1574
1575static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1576 /* SigmaTel reference board */
1577 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001578 "DFI LanParty", STAC_92HD73XX_REF),
1579 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1580 "unknown Dell", STAC_DELL_M6),
1581 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1582 "unknown Dell", STAC_DELL_M6),
1583 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1584 "unknown Dell", STAC_DELL_M6),
1585 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1586 "unknown Dell", STAC_DELL_M6),
1587 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1588 "unknown Dell", STAC_DELL_M6),
1589 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1590 "unknown Dell", STAC_DELL_M6),
1591 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1592 "unknown Dell", STAC_DELL_M6),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001593 {} /* terminator */
1594};
1595
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001596static unsigned int ref92hd83xxx_pin_configs[14] = {
1597 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1598 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1599 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1600 0x01451160, 0x98560170,
1601};
1602
1603static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1604 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1605};
1606
1607static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1608 [STAC_92HD83XXX_REF] = "ref",
1609};
1610
1611static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1612 /* SigmaTel reference board */
1613 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1614 "DFI LanParty", STAC_92HD71BXX_REF),
1615};
1616
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001617static unsigned int ref92hd71bxx_pin_configs[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001618 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostayb22b4822008-01-22 12:32:30 +01001619 0x0181302e, 0x01114010, 0x01019020, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001620 0x90a000f0, 0x01452050, 0x01452050,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001621};
1622
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001623static unsigned int dell_m4_1_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001624 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001625 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001626 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001627};
1628
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001629static unsigned int dell_m4_2_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001630 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1631 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001632 0x40f000f0, 0x044413b0, 0x044413b0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001633};
1634
Matthew Ranostaye035b842007-11-06 11:53:55 +01001635static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1636 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001637 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1638 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001639 [STAC_HP_M4] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001640};
1641
1642static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1643 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001644 [STAC_DELL_M4_1] = "dell-m4-1",
1645 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001646 [STAC_HP_M4] = "hp-m4",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001647};
1648
1649static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1650 /* SigmaTel reference board */
1651 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1652 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001653 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1654 "unknown HP", STAC_HP_M4),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001655 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1656 "unknown Dell", STAC_DELL_M4_1),
1657 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1658 "unknown Dell", STAC_DELL_M4_1),
1659 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1660 "unknown Dell", STAC_DELL_M4_1),
1661 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1662 "unknown Dell", STAC_DELL_M4_1),
1663 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1664 "unknown Dell", STAC_DELL_M4_1),
1665 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1666 "unknown Dell", STAC_DELL_M4_1),
1667 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1668 "unknown Dell", STAC_DELL_M4_1),
1669 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1670 "unknown Dell", STAC_DELL_M4_2),
1671 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1672 "unknown Dell", STAC_DELL_M4_2),
1673 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1674 "unknown Dell", STAC_DELL_M4_2),
1675 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1676 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001677 {} /* terminator */
1678};
1679
Matt Porter403d1942005-11-29 15:00:51 +01001680static unsigned int ref922x_pin_configs[10] = {
1681 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1682 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001683 0x40000100, 0x40000100,
1684};
1685
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001686/*
1687 STAC 922X pin configs for
1688 102801A7
1689 102801AB
1690 102801A9
1691 102801D1
1692 102801D2
1693*/
1694static unsigned int dell_922x_d81_pin_configs[10] = {
1695 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1696 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1697 0x01813122, 0x400001f2,
1698};
1699
1700/*
1701 STAC 922X pin configs for
1702 102801AC
1703 102801D0
1704*/
1705static unsigned int dell_922x_d82_pin_configs[10] = {
1706 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1707 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1708 0x01813122, 0x400001f1,
1709};
1710
1711/*
1712 STAC 922X pin configs for
1713 102801BF
1714*/
1715static unsigned int dell_922x_m81_pin_configs[10] = {
1716 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1717 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1718 0x40C003f1, 0x405003f0,
1719};
1720
1721/*
1722 STAC 9221 A1 pin configs for
1723 102801D7 (Dell XPS M1210)
1724*/
1725static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001726 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1727 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001728 0x508003f3, 0x405003f4,
1729};
1730
Matt Porter403d1942005-11-29 15:00:51 +01001731static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001732 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001733 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1734 0x02a19120, 0x40000100,
1735};
1736
1737static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001738 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1739 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001740 0x02a19320, 0x40000100,
1741};
1742
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001743static unsigned int intel_mac_v1_pin_configs[10] = {
1744 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1745 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001746 0x400000fc, 0x400000fb,
1747};
1748
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001749static unsigned int intel_mac_v2_pin_configs[10] = {
1750 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1751 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001752 0x400000fc, 0x400000fb,
1753};
1754
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001755static unsigned int intel_mac_v3_pin_configs[10] = {
1756 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1757 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1758 0x400000fc, 0x400000fb,
1759};
1760
1761static unsigned int intel_mac_v4_pin_configs[10] = {
1762 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1763 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1764 0x400000fc, 0x400000fb,
1765};
1766
1767static unsigned int intel_mac_v5_pin_configs[10] = {
1768 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1769 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1770 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001771};
1772
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001773static unsigned int ecs202_pin_configs[10] = {
1774 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1775 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1776 0x9037012e, 0x40e000f2,
1777};
Takashi Iwai76c08822007-06-19 12:17:42 +02001778
Takashi Iwai19039bd2006-06-28 15:52:16 +02001779static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001780 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001781 [STAC_D945GTP3] = d945gtp3_pin_configs,
1782 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001783 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1784 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1785 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1786 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1787 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001788 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001789 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001790 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1791 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1792 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1793 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1794 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1795 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001796 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001797 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1798 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1799 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1800 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001801};
1802
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001803static const char *stac922x_models[STAC_922X_MODELS] = {
1804 [STAC_D945_REF] = "ref",
1805 [STAC_D945GTP5] = "5stack",
1806 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001807 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1808 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1809 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1810 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1811 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001812 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001813 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001814 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001815 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001816 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1817 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001818 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001819 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001820 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001821 [STAC_922X_DELL_D81] = "dell-d81",
1822 [STAC_922X_DELL_D82] = "dell-d82",
1823 [STAC_922X_DELL_M81] = "dell-m81",
1824 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001825};
1826
1827static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1828 /* SigmaTel reference board */
1829 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1830 "DFI LanParty", STAC_D945_REF),
1831 /* Intel 945G based systems */
1832 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1833 "Intel D945G", STAC_D945GTP3),
1834 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1835 "Intel D945G", STAC_D945GTP3),
1836 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1837 "Intel D945G", STAC_D945GTP3),
1838 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1839 "Intel D945G", STAC_D945GTP3),
1840 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1841 "Intel D945G", STAC_D945GTP3),
1842 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1843 "Intel D945G", STAC_D945GTP3),
1844 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1845 "Intel D945G", STAC_D945GTP3),
1846 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1847 "Intel D945G", STAC_D945GTP3),
1848 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1849 "Intel D945G", STAC_D945GTP3),
1850 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1851 "Intel D945G", STAC_D945GTP3),
1852 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1853 "Intel D945G", STAC_D945GTP3),
1854 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1855 "Intel D945G", STAC_D945GTP3),
1856 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1857 "Intel D945G", STAC_D945GTP3),
1858 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1859 "Intel D945G", STAC_D945GTP3),
1860 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1861 "Intel D945G", STAC_D945GTP3),
1862 /* Intel D945G 5-stack systems */
1863 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1864 "Intel D945G", STAC_D945GTP5),
1865 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1866 "Intel D945G", STAC_D945GTP5),
1867 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1868 "Intel D945G", STAC_D945GTP5),
1869 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1870 "Intel D945G", STAC_D945GTP5),
1871 /* Intel 945P based systems */
1872 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1873 "Intel D945P", STAC_D945GTP3),
1874 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1875 "Intel D945P", STAC_D945GTP3),
1876 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1877 "Intel D945P", STAC_D945GTP3),
1878 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1879 "Intel D945P", STAC_D945GTP3),
1880 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1881 "Intel D945P", STAC_D945GTP3),
1882 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1883 "Intel D945P", STAC_D945GTP5),
1884 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08001885 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001886 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001887 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001888 /* Dell systems */
1889 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1890 "unknown Dell", STAC_922X_DELL_D81),
1891 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1892 "unknown Dell", STAC_922X_DELL_D81),
1893 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1894 "unknown Dell", STAC_922X_DELL_D81),
1895 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1896 "unknown Dell", STAC_922X_DELL_D82),
1897 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1898 "unknown Dell", STAC_922X_DELL_M81),
1899 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1900 "unknown Dell", STAC_922X_DELL_D82),
1901 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1902 "unknown Dell", STAC_922X_DELL_D81),
1903 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1904 "unknown Dell", STAC_922X_DELL_D81),
1905 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1906 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001907 /* ECS/PC Chips boards */
1908 SND_PCI_QUIRK(0x1019, 0x2144,
1909 "ECS/PC chips", STAC_ECS_202),
1910 SND_PCI_QUIRK(0x1019, 0x2608,
1911 "ECS/PC chips", STAC_ECS_202),
1912 SND_PCI_QUIRK(0x1019, 0x2633,
1913 "ECS/PC chips P17G/1333", STAC_ECS_202),
1914 SND_PCI_QUIRK(0x1019, 0x2811,
1915 "ECS/PC chips", STAC_ECS_202),
1916 SND_PCI_QUIRK(0x1019, 0x2812,
1917 "ECS/PC chips", STAC_ECS_202),
1918 SND_PCI_QUIRK(0x1019, 0x2813,
1919 "ECS/PC chips", STAC_ECS_202),
1920 SND_PCI_QUIRK(0x1019, 0x2814,
1921 "ECS/PC chips", STAC_ECS_202),
1922 SND_PCI_QUIRK(0x1019, 0x2815,
1923 "ECS/PC chips", STAC_ECS_202),
1924 SND_PCI_QUIRK(0x1019, 0x2816,
1925 "ECS/PC chips", STAC_ECS_202),
1926 SND_PCI_QUIRK(0x1019, 0x2817,
1927 "ECS/PC chips", STAC_ECS_202),
1928 SND_PCI_QUIRK(0x1019, 0x2818,
1929 "ECS/PC chips", STAC_ECS_202),
1930 SND_PCI_QUIRK(0x1019, 0x2819,
1931 "ECS/PC chips", STAC_ECS_202),
1932 SND_PCI_QUIRK(0x1019, 0x2820,
1933 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01001934 {} /* terminator */
1935};
1936
Matt Porter3cc08dc2006-01-23 15:27:49 +01001937static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02001938 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1939 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1940 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1941 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01001942};
1943
Tobin Davis93ed1502006-09-01 21:03:12 +02001944static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02001945 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1946 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1947 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1948 0x40000100, 0x40000100
1949};
1950
Tobin Davis93ed1502006-09-01 21:03:12 +02001951static unsigned int d965_5st_pin_configs[14] = {
1952 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1953 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1954 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1955 0x40000100, 0x40000100
1956};
1957
Tobin Davis4ff076e2007-08-07 11:48:12 +02001958static unsigned int dell_3st_pin_configs[14] = {
1959 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1960 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001961 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02001962 0x40c003fc, 0x40000100
1963};
1964
Tobin Davis93ed1502006-09-01 21:03:12 +02001965static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001966 [STAC_D965_REF] = ref927x_pin_configs,
1967 [STAC_D965_3ST] = d965_3st_pin_configs,
1968 [STAC_D965_5ST] = d965_5st_pin_configs,
1969 [STAC_DELL_3ST] = dell_3st_pin_configs,
1970 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01001971};
1972
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001973static const char *stac927x_models[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001974 [STAC_D965_REF] = "ref",
1975 [STAC_D965_3ST] = "3stack",
1976 [STAC_D965_5ST] = "5stack",
1977 [STAC_DELL_3ST] = "dell-3stack",
1978 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001979};
1980
1981static struct snd_pci_quirk stac927x_cfg_tbl[] = {
1982 /* SigmaTel reference board */
1983 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1984 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02001985 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001986 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
1987 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02001988 /* 965 based 3 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001989 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
1990 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
1991 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
1992 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
1993 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
1994 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
1995 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
1996 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
1997 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
1998 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
1999 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
2000 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
2001 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
2002 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
2003 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
2004 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002005 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002006 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002007 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002008 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2009 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002010 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002011 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2012 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002013 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02002014 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002015 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2016 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2017 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2018 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002019 /* 965 based 5 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002020 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2021 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2022 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2023 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2024 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2025 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2026 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2027 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2028 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002029 {} /* terminator */
2030};
2031
Matt Porterf3302a52006-07-31 12:49:34 +02002032static unsigned int ref9205_pin_configs[12] = {
2033 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002034 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002035 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002036};
2037
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002038/*
2039 STAC 9205 pin configs for
2040 102801F1
2041 102801F2
2042 102801FC
2043 102801FD
2044 10280204
2045 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002046 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002047*/
2048static unsigned int dell_9205_m42_pin_configs[12] = {
2049 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2050 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2051 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2052};
2053
2054/*
2055 STAC 9205 pin configs for
2056 102801F9
2057 102801FA
2058 102801FE
2059 102801FF (Dell Precision M4300)
2060 10280206
2061 10280200
2062 10280201
2063*/
2064static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002065 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2066 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2067 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2068};
2069
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002070static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002071 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2072 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2073 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2074};
2075
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002076static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002077 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002078 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2079 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2080 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Matt Porterf3302a52006-07-31 12:49:34 +02002081};
2082
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002083static const char *stac9205_models[STAC_9205_MODELS] = {
2084 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002085 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002086 [STAC_9205_DELL_M43] = "dell-m43",
2087 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002088};
2089
2090static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2091 /* SigmaTel reference board */
2092 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2093 "DFI LanParty", STAC_9205_REF),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002094 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2095 "unknown Dell", STAC_9205_DELL_M42),
2096 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2097 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002098 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002099 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002100 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2101 "Dell Precision", STAC_9205_DELL_M43),
2102 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2103 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002104 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2105 "unknown Dell", STAC_9205_DELL_M42),
2106 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2107 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002108 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2109 "Dell Precision", STAC_9205_DELL_M43),
2110 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002111 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002112 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2113 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002114 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2115 "Dell Precision", STAC_9205_DELL_M43),
2116 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2117 "Dell Precision", STAC_9205_DELL_M43),
2118 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2119 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002120 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2121 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002122 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2123 "Dell Vostro 1500", STAC_9205_DELL_M42),
Matt Porterf3302a52006-07-31 12:49:34 +02002124 {} /* terminator */
2125};
2126
Richard Fish11b44bb2006-08-23 18:31:34 +02002127static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2128{
2129 int i;
2130 struct sigmatel_spec *spec = codec->spec;
2131
2132 if (! spec->bios_pin_configs) {
2133 spec->bios_pin_configs = kcalloc(spec->num_pins,
2134 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
2135 if (! spec->bios_pin_configs)
2136 return -ENOMEM;
2137 }
2138
2139 for (i = 0; i < spec->num_pins; i++) {
2140 hda_nid_t nid = spec->pin_nids[i];
2141 unsigned int pin_cfg;
2142
2143 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2144 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2145 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2146 nid, pin_cfg);
2147 spec->bios_pin_configs[i] = pin_cfg;
2148 }
2149
2150 return 0;
2151}
2152
Matthew Ranostay87d48362007-07-17 11:52:24 +02002153static void stac92xx_set_config_reg(struct hda_codec *codec,
2154 hda_nid_t pin_nid, unsigned int pin_config)
2155{
2156 int i;
2157 snd_hda_codec_write(codec, pin_nid, 0,
2158 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2159 pin_config & 0x000000ff);
2160 snd_hda_codec_write(codec, pin_nid, 0,
2161 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2162 (pin_config & 0x0000ff00) >> 8);
2163 snd_hda_codec_write(codec, pin_nid, 0,
2164 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2165 (pin_config & 0x00ff0000) >> 16);
2166 snd_hda_codec_write(codec, pin_nid, 0,
2167 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2168 pin_config >> 24);
2169 i = snd_hda_codec_read(codec, pin_nid, 0,
2170 AC_VERB_GET_CONFIG_DEFAULT,
2171 0x00);
2172 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2173 pin_nid, i);
2174}
2175
Matt2f2f4252005-04-13 14:45:30 +02002176static void stac92xx_set_config_regs(struct hda_codec *codec)
2177{
2178 int i;
2179 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002180
Matthew Ranostay87d48362007-07-17 11:52:24 +02002181 if (!spec->pin_configs)
2182 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002183
Matthew Ranostay87d48362007-07-17 11:52:24 +02002184 for (i = 0; i < spec->num_pins; i++)
2185 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2186 spec->pin_configs[i]);
Matt2f2f4252005-04-13 14:45:30 +02002187}
Matt2f2f4252005-04-13 14:45:30 +02002188
Matt2f2f4252005-04-13 14:45:30 +02002189/*
2190 * Analog playback callbacks
2191 */
2192static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2193 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002194 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002195{
2196 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002197 if (spec->stream_delay)
2198 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002199 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2200 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002201}
2202
2203static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2204 struct hda_codec *codec,
2205 unsigned int stream_tag,
2206 unsigned int format,
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;
Matt Porter403d1942005-11-29 15:00:51 +01002210 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002211}
2212
2213static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2214 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002215 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002216{
2217 struct sigmatel_spec *spec = codec->spec;
2218 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2219}
2220
2221/*
Mattdabbed62005-06-14 10:19:34 +02002222 * Digital playback callbacks
2223 */
2224static int stac92xx_dig_playback_pcm_open(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_open(codec, &spec->multiout);
2230}
2231
2232static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2233 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002234 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002235{
2236 struct sigmatel_spec *spec = codec->spec;
2237 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2238}
2239
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002240static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2241 struct hda_codec *codec,
2242 unsigned int stream_tag,
2243 unsigned int format,
2244 struct snd_pcm_substream *substream)
2245{
2246 struct sigmatel_spec *spec = codec->spec;
2247 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2248 stream_tag, format, substream);
2249}
2250
Mattdabbed62005-06-14 10:19:34 +02002251
2252/*
Matt2f2f4252005-04-13 14:45:30 +02002253 * Analog capture callbacks
2254 */
2255static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2256 struct hda_codec *codec,
2257 unsigned int stream_tag,
2258 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002259 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002260{
2261 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002262 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002263
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002264 if (spec->powerdown_adcs) {
2265 msleep(40);
2266 snd_hda_codec_write_cache(codec, nid, 0,
2267 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2268 }
2269 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002270 return 0;
2271}
2272
2273static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2274 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002275 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002276{
2277 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002278 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002279
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002280 snd_hda_codec_cleanup_stream(codec, nid);
2281 if (spec->powerdown_adcs)
2282 snd_hda_codec_write_cache(codec, nid, 0,
2283 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002284 return 0;
2285}
2286
Mattdabbed62005-06-14 10:19:34 +02002287static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2288 .substreams = 1,
2289 .channels_min = 2,
2290 .channels_max = 2,
2291 /* NID is set in stac92xx_build_pcms */
2292 .ops = {
2293 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002294 .close = stac92xx_dig_playback_pcm_close,
2295 .prepare = stac92xx_dig_playback_pcm_prepare
Mattdabbed62005-06-14 10:19:34 +02002296 },
2297};
2298
2299static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2300 .substreams = 1,
2301 .channels_min = 2,
2302 .channels_max = 2,
2303 /* NID is set in stac92xx_build_pcms */
2304};
2305
Matt2f2f4252005-04-13 14:45:30 +02002306static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2307 .substreams = 1,
2308 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002309 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002310 .nid = 0x02, /* NID to query formats and rates */
2311 .ops = {
2312 .open = stac92xx_playback_pcm_open,
2313 .prepare = stac92xx_playback_pcm_prepare,
2314 .cleanup = stac92xx_playback_pcm_cleanup
2315 },
2316};
2317
Matt Porter3cc08dc2006-01-23 15:27:49 +01002318static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2319 .substreams = 1,
2320 .channels_min = 2,
2321 .channels_max = 2,
2322 .nid = 0x06, /* NID to query formats and rates */
2323 .ops = {
2324 .open = stac92xx_playback_pcm_open,
2325 .prepare = stac92xx_playback_pcm_prepare,
2326 .cleanup = stac92xx_playback_pcm_cleanup
2327 },
2328};
2329
Matt2f2f4252005-04-13 14:45:30 +02002330static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002331 .channels_min = 2,
2332 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002333 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002334 .ops = {
2335 .prepare = stac92xx_capture_pcm_prepare,
2336 .cleanup = stac92xx_capture_pcm_cleanup
2337 },
2338};
2339
2340static int stac92xx_build_pcms(struct hda_codec *codec)
2341{
2342 struct sigmatel_spec *spec = codec->spec;
2343 struct hda_pcm *info = spec->pcm_rec;
2344
2345 codec->num_pcms = 1;
2346 codec->pcm_info = info;
2347
Mattc7d4b2f2005-06-27 14:59:41 +02002348 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002349 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Matt2f2f4252005-04-13 14:45:30 +02002350 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002351 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002352 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002353
2354 if (spec->alt_switch) {
2355 codec->num_pcms++;
2356 info++;
2357 info->name = "STAC92xx Analog Alt";
2358 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2359 }
Matt2f2f4252005-04-13 14:45:30 +02002360
Mattdabbed62005-06-14 10:19:34 +02002361 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2362 codec->num_pcms++;
2363 info++;
2364 info->name = "STAC92xx Digital";
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002365 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Mattdabbed62005-06-14 10:19:34 +02002366 if (spec->multiout.dig_out_nid) {
2367 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2368 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2369 }
2370 if (spec->dig_in_nid) {
2371 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2372 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2373 }
2374 }
2375
Matt2f2f4252005-04-13 14:45:30 +02002376 return 0;
2377}
2378
Takashi Iwaic960a032006-03-23 17:06:28 +01002379static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2380{
2381 unsigned int pincap = snd_hda_param_read(codec, nid,
2382 AC_PAR_PIN_CAP);
2383 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2384 if (pincap & AC_PINCAP_VREF_100)
2385 return AC_PINCTL_VREF_100;
2386 if (pincap & AC_PINCAP_VREF_80)
2387 return AC_PINCTL_VREF_80;
2388 if (pincap & AC_PINCAP_VREF_50)
2389 return AC_PINCTL_VREF_50;
2390 if (pincap & AC_PINCAP_VREF_GRD)
2391 return AC_PINCTL_VREF_GRD;
2392 return 0;
2393}
2394
Matt Porter403d1942005-11-29 15:00:51 +01002395static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2396
2397{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002398 snd_hda_codec_write_cache(codec, nid, 0,
2399 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002400}
2401
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002402#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2403
2404static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2405 struct snd_ctl_elem_value *ucontrol)
2406{
2407 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2408 struct sigmatel_spec *spec = codec->spec;
2409
2410 ucontrol->value.integer.value[0] = spec->hp_switch;
2411 return 0;
2412}
2413
2414static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2415 struct snd_ctl_elem_value *ucontrol)
2416{
2417 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2418 struct sigmatel_spec *spec = codec->spec;
2419
2420 spec->hp_switch = ucontrol->value.integer.value[0];
2421
2422 /* check to be sure that the ports are upto date with
2423 * switch changes
2424 */
2425 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2426
2427 return 1;
2428}
2429
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002430#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002431
2432static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2433{
2434 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2435 struct sigmatel_spec *spec = codec->spec;
2436 int io_idx = kcontrol-> private_value & 0xff;
2437
2438 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2439 return 0;
2440}
2441
2442static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2443{
2444 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2445 struct sigmatel_spec *spec = codec->spec;
2446 hda_nid_t nid = kcontrol->private_value >> 8;
2447 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002448 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002449
2450 spec->io_switch[io_idx] = val;
2451
2452 if (val)
2453 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002454 else {
2455 unsigned int pinctl = AC_PINCTL_IN_EN;
2456 if (io_idx) /* set VREF for mic */
2457 pinctl |= stac92xx_get_vref(codec, nid);
2458 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2459 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002460
2461 /* check the auto-mute again: we need to mute/unmute the speaker
2462 * appropriately according to the pin direction
2463 */
2464 if (spec->hp_detect)
2465 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2466
Matt Porter403d1942005-11-29 15:00:51 +01002467 return 1;
2468}
2469
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002470#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2471
2472static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2473 struct snd_ctl_elem_value *ucontrol)
2474{
2475 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2476 struct sigmatel_spec *spec = codec->spec;
2477
2478 ucontrol->value.integer.value[0] = spec->clfe_swap;
2479 return 0;
2480}
2481
2482static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2483 struct snd_ctl_elem_value *ucontrol)
2484{
2485 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2486 struct sigmatel_spec *spec = codec->spec;
2487 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002488 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002489
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002490 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002491 return 0;
2492
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002493 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002494
2495 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2496 spec->clfe_swap ? 0x4 : 0x0);
2497
2498 return 1;
2499}
2500
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002501#define STAC_CODEC_HP_SWITCH(xname) \
2502 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2503 .name = xname, \
2504 .index = 0, \
2505 .info = stac92xx_hp_switch_info, \
2506 .get = stac92xx_hp_switch_get, \
2507 .put = stac92xx_hp_switch_put, \
2508 }
2509
Matt Porter403d1942005-11-29 15:00:51 +01002510#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2511 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2512 .name = xname, \
2513 .index = 0, \
2514 .info = stac92xx_io_switch_info, \
2515 .get = stac92xx_io_switch_get, \
2516 .put = stac92xx_io_switch_put, \
2517 .private_value = xpval, \
2518 }
2519
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002520#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2521 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2522 .name = xname, \
2523 .index = 0, \
2524 .info = stac92xx_clfe_switch_info, \
2525 .get = stac92xx_clfe_switch_get, \
2526 .put = stac92xx_clfe_switch_put, \
2527 .private_value = xpval, \
2528 }
Matt Porter403d1942005-11-29 15:00:51 +01002529
Mattc7d4b2f2005-06-27 14:59:41 +02002530enum {
2531 STAC_CTL_WIDGET_VOL,
2532 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002533 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002534 STAC_CTL_WIDGET_AMP_MUX,
2535 STAC_CTL_WIDGET_AMP_VOL,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002536 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002537 STAC_CTL_WIDGET_IO_SWITCH,
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002538 STAC_CTL_WIDGET_CLFE_SWITCH
Mattc7d4b2f2005-06-27 14:59:41 +02002539};
2540
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002541static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002542 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2543 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002544 STAC_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002545 STAC_AMP_MUX,
2546 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002547 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002548 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002549 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002550};
2551
2552/* add dynamic controls */
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002553static int stac92xx_add_control_idx(struct sigmatel_spec *spec, int type,
2554 int idx, const char *name, unsigned long val)
Mattc7d4b2f2005-06-27 14:59:41 +02002555{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002556 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002557
2558 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2559 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2560
2561 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2562 if (! knew)
2563 return -ENOMEM;
2564 if (spec->kctl_alloc) {
2565 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2566 kfree(spec->kctl_alloc);
2567 }
2568 spec->kctl_alloc = knew;
2569 spec->num_kctl_alloc = num;
2570 }
2571
2572 knew = &spec->kctl_alloc[spec->num_kctl_used];
2573 *knew = stac92xx_control_templates[type];
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002574 knew->index = idx;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002575 knew->name = kstrdup(name, GFP_KERNEL);
Mattc7d4b2f2005-06-27 14:59:41 +02002576 if (! knew->name)
2577 return -ENOMEM;
2578 knew->private_value = val;
2579 spec->num_kctl_used++;
2580 return 0;
2581}
2582
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002583
2584/* add dynamic controls */
2585static int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2586 const char *name, unsigned long val)
2587{
2588 return stac92xx_add_control_idx(spec, type, 0, name, val);
2589}
2590
Matt Porter403d1942005-11-29 15:00:51 +01002591/* flag inputs as additional dynamic lineouts */
2592static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2593{
2594 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002595 unsigned int wcaps, wtype;
2596 int i, num_dacs = 0;
2597
2598 /* use the wcaps cache to count all DACs available for line-outs */
2599 for (i = 0; i < codec->num_nodes; i++) {
2600 wcaps = codec->wcaps[i];
2601 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002602
Steve Longerbeam7b043892007-05-03 20:50:03 +02002603 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2604 num_dacs++;
2605 }
Matt Porter403d1942005-11-29 15:00:51 +01002606
Steve Longerbeam7b043892007-05-03 20:50:03 +02002607 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2608
Matt Porter403d1942005-11-29 15:00:51 +01002609 switch (cfg->line_outs) {
2610 case 3:
2611 /* add line-in as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002612 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002613 cfg->line_out_pins[cfg->line_outs] =
2614 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002615 spec->line_switch = 1;
2616 cfg->line_outs++;
2617 }
2618 break;
2619 case 2:
2620 /* add line-in as clfe and mic as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002621 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002622 cfg->line_out_pins[cfg->line_outs] =
2623 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002624 spec->line_switch = 1;
2625 cfg->line_outs++;
2626 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002627 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002628 cfg->line_out_pins[cfg->line_outs] =
2629 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002630 spec->mic_switch = 1;
2631 cfg->line_outs++;
2632 }
2633 break;
2634 case 1:
2635 /* add line-in as surr and mic as clfe */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002636 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002637 cfg->line_out_pins[cfg->line_outs] =
2638 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002639 spec->line_switch = 1;
2640 cfg->line_outs++;
2641 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002642 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002643 cfg->line_out_pins[cfg->line_outs] =
2644 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002645 spec->mic_switch = 1;
2646 cfg->line_outs++;
2647 }
2648 break;
2649 }
2650
2651 return 0;
2652}
2653
Steve Longerbeam7b043892007-05-03 20:50:03 +02002654
2655static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2656{
2657 int i;
2658
2659 for (i = 0; i < spec->multiout.num_dacs; i++) {
2660 if (spec->multiout.dac_nids[i] == nid)
2661 return 1;
2662 }
2663
2664 return 0;
2665}
2666
Matt Porter3cc08dc2006-01-23 15:27:49 +01002667/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02002668 * Fill in the dac_nids table from the parsed pin configuration
2669 * This function only works when every pin in line_out_pins[]
2670 * contains atleast one DAC in its connection list. Some 92xx
2671 * codecs are not connected directly to a DAC, such as the 9200
2672 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002673 */
Takashi Iwai19039bd2006-06-28 15:52:16 +02002674static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaidf802952007-07-02 19:18:00 +02002675 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002676{
2677 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002678 int i, j, conn_len = 0;
2679 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2680 unsigned int wcaps, wtype;
2681
Mattc7d4b2f2005-06-27 14:59:41 +02002682 for (i = 0; i < cfg->line_outs; i++) {
2683 nid = cfg->line_out_pins[i];
Steve Longerbeam7b043892007-05-03 20:50:03 +02002684 conn_len = snd_hda_get_connections(codec, nid, conn,
2685 HDA_MAX_CONNECTIONS);
2686 for (j = 0; j < conn_len; j++) {
2687 wcaps = snd_hda_param_read(codec, conn[j],
2688 AC_PAR_AUDIO_WIDGET_CAP);
2689 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002690 if (wtype != AC_WID_AUD_OUT ||
2691 (wcaps & AC_WCAP_DIGITAL))
2692 continue;
2693 /* conn[j] is a DAC routed to this line-out */
2694 if (!is_in_dac_nids(spec, conn[j]))
2695 break;
2696 }
2697
2698 if (j == conn_len) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002699 if (spec->multiout.num_dacs > 0) {
2700 /* we have already working output pins,
2701 * so let's drop the broken ones again
2702 */
2703 cfg->line_outs = spec->multiout.num_dacs;
2704 break;
2705 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002706 /* error out, no available DAC found */
2707 snd_printk(KERN_ERR
2708 "%s: No available DAC for pin 0x%x\n",
2709 __func__, nid);
2710 return -ENODEV;
2711 }
2712
2713 spec->multiout.dac_nids[i] = conn[j];
2714 spec->multiout.num_dacs++;
2715 if (conn_len > 1) {
2716 /* select this DAC in the pin's input mux */
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002717 snd_hda_codec_write_cache(codec, nid, 0,
2718 AC_VERB_SET_CONNECT_SEL, j);
Steve Longerbeam7b043892007-05-03 20:50:03 +02002719
2720 }
Mattc7d4b2f2005-06-27 14:59:41 +02002721 }
2722
Steve Longerbeam7b043892007-05-03 20:50:03 +02002723 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2724 spec->multiout.num_dacs,
2725 spec->multiout.dac_nids[0],
2726 spec->multiout.dac_nids[1],
2727 spec->multiout.dac_nids[2],
2728 spec->multiout.dac_nids[3],
2729 spec->multiout.dac_nids[4]);
Mattc7d4b2f2005-06-27 14:59:41 +02002730 return 0;
2731}
2732
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002733/* create volume control/switch for the given prefx type */
2734static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2735{
2736 char name[32];
2737 int err;
2738
2739 sprintf(name, "%s Playback Volume", pfx);
2740 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2741 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2742 if (err < 0)
2743 return err;
2744 sprintf(name, "%s Playback Switch", pfx);
2745 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2746 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2747 if (err < 0)
2748 return err;
2749 return 0;
2750}
2751
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002752static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2753{
2754 if (!spec->multiout.hp_nid)
2755 spec->multiout.hp_nid = nid;
2756 else if (spec->multiout.num_dacs > 4) {
2757 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2758 return 1;
2759 } else {
2760 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2761 spec->multiout.num_dacs++;
2762 }
2763 return 0;
2764}
2765
2766static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2767{
2768 if (is_in_dac_nids(spec, nid))
2769 return 1;
2770 if (spec->multiout.hp_nid == nid)
2771 return 1;
2772 return 0;
2773}
2774
Mattc7d4b2f2005-06-27 14:59:41 +02002775/* add playback controls from the parsed DAC table */
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002776static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
Takashi Iwai19039bd2006-06-28 15:52:16 +02002777 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002778{
Takashi Iwai19039bd2006-06-28 15:52:16 +02002779 static const char *chname[4] = {
2780 "Front", "Surround", NULL /*CLFE*/, "Side"
2781 };
Mattc7d4b2f2005-06-27 14:59:41 +02002782 hda_nid_t nid;
2783 int i, err;
2784
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002785 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002786 unsigned int wid_caps, pincap;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002787
2788
Takashi Iwai40ac8c42008-02-29 14:16:17 +01002789 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
Matt Porter403d1942005-11-29 15:00:51 +01002790 if (!spec->multiout.dac_nids[i])
Mattc7d4b2f2005-06-27 14:59:41 +02002791 continue;
2792
2793 nid = spec->multiout.dac_nids[i];
2794
2795 if (i == 2) {
2796 /* Center/LFE */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002797 err = create_controls(spec, "Center", nid, 1);
2798 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002799 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002800 err = create_controls(spec, "LFE", nid, 2);
2801 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002802 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002803
2804 wid_caps = get_wcaps(codec, nid);
2805
2806 if (wid_caps & AC_WCAP_LR_SWAP) {
2807 err = stac92xx_add_control(spec,
2808 STAC_CTL_WIDGET_CLFE_SWITCH,
2809 "Swap Center/LFE Playback Switch", nid);
2810
2811 if (err < 0)
2812 return err;
2813 }
2814
Mattc7d4b2f2005-06-27 14:59:41 +02002815 } else {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002816 err = create_controls(spec, chname[i], nid, 3);
2817 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002818 return err;
2819 }
2820 }
2821
Matthew Ranostayfedb7562008-09-23 21:46:30 -04002822 if ((spec->multiout.num_dacs - cfg->line_outs) > 0 &&
2823 cfg->hp_outs && !spec->multiout.hp_nid)
2824 spec->multiout.hp_nid = nid;
2825
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002826 if (cfg->hp_outs > 1) {
2827 err = stac92xx_add_control(spec,
2828 STAC_CTL_WIDGET_HP_SWITCH,
2829 "Headphone as Line Out Switch", 0);
2830 if (err < 0)
2831 return err;
2832 }
2833
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002834 if (spec->line_switch) {
2835 nid = cfg->input_pins[AUTO_PIN_LINE];
2836 pincap = snd_hda_param_read(codec, nid,
2837 AC_PAR_PIN_CAP);
2838 if (pincap & AC_PINCAP_OUT) {
2839 err = stac92xx_add_control(spec,
2840 STAC_CTL_WIDGET_IO_SWITCH,
2841 "Line In as Output Switch", nid << 8);
2842 if (err < 0)
2843 return err;
2844 }
2845 }
Matt Porter403d1942005-11-29 15:00:51 +01002846
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002847 if (spec->mic_switch) {
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002848 unsigned int def_conf;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002849 unsigned int mic_pin = AUTO_PIN_MIC;
2850again:
2851 nid = cfg->input_pins[mic_pin];
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002852 def_conf = snd_hda_codec_read(codec, nid, 0,
2853 AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002854 /* some laptops have an internal analog microphone
2855 * which can't be used as a output */
2856 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2857 pincap = snd_hda_param_read(codec, nid,
2858 AC_PAR_PIN_CAP);
2859 if (pincap & AC_PINCAP_OUT) {
2860 err = stac92xx_add_control(spec,
2861 STAC_CTL_WIDGET_IO_SWITCH,
2862 "Mic as Output Switch", (nid << 8) | 1);
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002863 nid = snd_hda_codec_read(codec, nid, 0,
2864 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2865 if (!check_in_dac_nids(spec, nid))
2866 add_spec_dacs(spec, nid);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002867 if (err < 0)
2868 return err;
2869 }
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002870 } else if (mic_pin == AUTO_PIN_MIC) {
2871 mic_pin = AUTO_PIN_FRONT_MIC;
2872 goto again;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002873 }
2874 }
Matt Porter403d1942005-11-29 15:00:51 +01002875
Mattc7d4b2f2005-06-27 14:59:41 +02002876 return 0;
2877}
2878
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002879/* add playback controls for Speaker and HP outputs */
2880static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2881 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002882{
2883 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02002884 hda_nid_t nid;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002885 int i, old_num_dacs, err;
Mattc7d4b2f2005-06-27 14:59:41 +02002886
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002887 old_num_dacs = spec->multiout.num_dacs;
2888 for (i = 0; i < cfg->hp_outs; i++) {
2889 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2890 if (wid_caps & AC_WCAP_UNSOL_CAP)
2891 spec->hp_detect = 1;
2892 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2893 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2894 if (check_in_dac_nids(spec, nid))
2895 nid = 0;
2896 if (! nid)
Mattc7d4b2f2005-06-27 14:59:41 +02002897 continue;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002898 add_spec_dacs(spec, nid);
2899 }
2900 for (i = 0; i < cfg->speaker_outs; i++) {
Steve Longerbeam7b043892007-05-03 20:50:03 +02002901 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002902 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2903 if (check_in_dac_nids(spec, nid))
2904 nid = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002905 if (! nid)
2906 continue;
2907 add_spec_dacs(spec, nid);
Mattc7d4b2f2005-06-27 14:59:41 +02002908 }
Matthew Ranostay1b290a52007-07-12 15:17:34 +02002909 for (i = 0; i < cfg->line_outs; i++) {
2910 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2911 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2912 if (check_in_dac_nids(spec, nid))
2913 nid = 0;
2914 if (! nid)
2915 continue;
2916 add_spec_dacs(spec, nid);
2917 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002918 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2919 static const char *pfxs[] = {
2920 "Speaker", "External Speaker", "Speaker2",
2921 };
2922 err = create_controls(spec, pfxs[i - old_num_dacs],
2923 spec->multiout.dac_nids[i], 3);
2924 if (err < 0)
2925 return err;
2926 }
2927 if (spec->multiout.hp_nid) {
Takashi Iwai2626a262008-03-14 09:18:32 +01002928 err = create_controls(spec, "Headphone",
2929 spec->multiout.hp_nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002930 if (err < 0)
2931 return err;
2932 }
Mattc7d4b2f2005-06-27 14:59:41 +02002933
2934 return 0;
2935}
2936
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002937/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002938static const char *stac92xx_mono_labels[4] = {
2939 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002940};
2941
2942/* create mono mux for mono out on capable codecs */
2943static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
2944{
2945 struct sigmatel_spec *spec = codec->spec;
2946 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
2947 int i, num_cons;
2948 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
2949
2950 num_cons = snd_hda_get_connections(codec,
2951 spec->mono_nid,
2952 con_lst,
2953 HDA_MAX_NUM_INPUTS);
2954 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
2955 return -EINVAL;
2956
2957 for (i = 0; i < num_cons; i++) {
2958 mono_mux->items[mono_mux->num_items].label =
2959 stac92xx_mono_labels[i];
2960 mono_mux->items[mono_mux->num_items].index = i;
2961 mono_mux->num_items++;
2962 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01002963
2964 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
2965 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002966}
2967
Matthew Ranostay89385032008-09-11 09:49:39 -04002968/* labels for amp mux outputs */
2969static const char *stac92xx_amp_labels[3] = {
2970 "Front Microphone", "Microphone", "Line In"
2971};
2972
2973/* create amp out controls mux on capable codecs */
2974static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
2975{
2976 struct sigmatel_spec *spec = codec->spec;
2977 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
2978 int i, err;
2979
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04002980 for (i = 0; i < spec->num_amps; i++) {
Matthew Ranostay89385032008-09-11 09:49:39 -04002981 amp_mux->items[amp_mux->num_items].label =
2982 stac92xx_amp_labels[i];
2983 amp_mux->items[amp_mux->num_items].index = i;
2984 amp_mux->num_items++;
2985 }
2986
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04002987 if (spec->num_amps > 1) {
2988 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
2989 "Amp Selector Capture Switch", 0);
2990 if (err < 0)
2991 return err;
2992 }
Matthew Ranostay89385032008-09-11 09:49:39 -04002993 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
2994 "Amp Capture Volume",
2995 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
2996}
2997
2998
Matthew Ranostay1cd22242008-07-18 18:20:52 +02002999/* create PC beep volume controls */
3000static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3001 hda_nid_t nid)
3002{
3003 struct sigmatel_spec *spec = codec->spec;
3004 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3005 int err;
3006
3007 /* check for mute support for the the amp */
3008 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3009 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3010 "PC Beep Playback Switch",
3011 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3012 if (err < 0)
3013 return err;
3014 }
3015
3016 /* check to see if there is volume support for the amp */
3017 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3018 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3019 "PC Beep Playback Volume",
3020 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3021 if (err < 0)
3022 return err;
3023 }
3024 return 0;
3025}
3026
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003027static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3028{
3029 struct sigmatel_spec *spec = codec->spec;
3030 int wcaps, nid, i, err = 0;
3031
3032 for (i = 0; i < spec->num_muxes; i++) {
3033 nid = spec->mux_nids[i];
3034 wcaps = get_wcaps(codec, nid);
3035
3036 if (wcaps & AC_WCAP_OUT_AMP) {
3037 err = stac92xx_add_control_idx(spec,
3038 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3039 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3040 if (err < 0)
3041 return err;
3042 }
3043 }
3044 return 0;
3045};
3046
Matthew Ranostayd9737752008-09-07 12:03:41 +02003047static const char *stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003048 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003049};
3050
3051static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3052{
3053 struct sigmatel_spec *spec = codec->spec;
3054 struct hda_input_mux *spdif_mux = &spec->private_smux;
Matthew Ranostay65973632008-09-16 10:39:37 -04003055 const char **labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003056 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003057 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003058
3059 num_cons = snd_hda_get_connections(codec,
3060 spec->smux_nids[0],
3061 con_lst,
3062 HDA_MAX_NUM_INPUTS);
Matthew Ranostay65973632008-09-16 10:39:37 -04003063 if (!num_cons)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003064 return -EINVAL;
3065
Matthew Ranostay65973632008-09-16 10:39:37 -04003066 if (!labels)
3067 labels = stac92xx_spdif_labels;
3068
Matthew Ranostayd9737752008-09-07 12:03:41 +02003069 for (i = 0; i < num_cons; i++) {
Matthew Ranostay65973632008-09-16 10:39:37 -04003070 spdif_mux->items[spdif_mux->num_items].label = labels[i];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003071 spdif_mux->items[spdif_mux->num_items].index = i;
3072 spdif_mux->num_items++;
3073 }
3074
3075 return 0;
3076}
3077
Matt Porter8b657272006-10-26 17:12:59 +02003078/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003079static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003080 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3081 "Digital Mic 3", "Digital Mic 4"
3082};
3083
3084/* create playback/capture controls for input pins on dmic capable codecs */
3085static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3086 const struct auto_pin_cfg *cfg)
3087{
3088 struct sigmatel_spec *spec = codec->spec;
3089 struct hda_input_mux *dimux = &spec->private_dimux;
3090 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003091 int err, i, j;
3092 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02003093
3094 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3095 dimux->items[dimux->num_items].index = 0;
3096 dimux->num_items++;
3097
3098 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003099 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003100 int index;
3101 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003102 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02003103 unsigned int def_conf;
3104
3105 def_conf = snd_hda_codec_read(codec,
3106 spec->dmic_nids[i],
3107 0,
3108 AC_VERB_GET_CONFIG_DEFAULT,
3109 0);
3110 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3111 continue;
3112
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003113 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02003114 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003115 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02003116 con_lst,
3117 HDA_MAX_NUM_INPUTS);
3118 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003119 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02003120 index = j;
3121 goto found;
3122 }
3123 continue;
3124found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003125 wcaps = get_wcaps(codec, nid) &
3126 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003127
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003128 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003129 sprintf(name, "%s Capture Volume",
3130 stac92xx_dmic_labels[dimux->num_items]);
3131
3132 err = stac92xx_add_control(spec,
3133 STAC_CTL_WIDGET_VOL,
3134 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003135 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3136 (wcaps & AC_WCAP_OUT_AMP) ?
3137 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003138 if (err < 0)
3139 return err;
3140 }
3141
Matt Porter8b657272006-10-26 17:12:59 +02003142 dimux->items[dimux->num_items].label =
3143 stac92xx_dmic_labels[dimux->num_items];
3144 dimux->items[dimux->num_items].index = index;
3145 dimux->num_items++;
3146 }
3147
3148 return 0;
3149}
3150
Mattc7d4b2f2005-06-27 14:59:41 +02003151/* create playback/capture controls for input pins */
3152static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3153{
3154 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003155 struct hda_input_mux *imux = &spec->private_imux;
3156 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3157 int i, j, k;
3158
3159 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003160 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02003161
Takashi Iwai314634b2006-09-21 11:56:18 +02003162 if (!cfg->input_pins[i])
3163 continue;
3164 index = -1;
3165 for (j = 0; j < spec->num_muxes; j++) {
3166 int num_cons;
3167 num_cons = snd_hda_get_connections(codec,
3168 spec->mux_nids[j],
3169 con_lst,
3170 HDA_MAX_NUM_INPUTS);
3171 for (k = 0; k < num_cons; k++)
3172 if (con_lst[k] == cfg->input_pins[i]) {
3173 index = k;
3174 goto found;
3175 }
Mattc7d4b2f2005-06-27 14:59:41 +02003176 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003177 continue;
3178 found:
3179 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3180 imux->items[imux->num_items].index = index;
3181 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003182 }
3183
Steve Longerbeam7b043892007-05-03 20:50:03 +02003184 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003185 /*
3186 * Set the current input for the muxes.
3187 * The STAC9221 has two input muxes with identical source
3188 * NID lists. Hopefully this won't get confused.
3189 */
3190 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003191 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3192 AC_VERB_SET_CONNECT_SEL,
3193 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003194 }
3195 }
3196
Mattc7d4b2f2005-06-27 14:59:41 +02003197 return 0;
3198}
3199
Mattc7d4b2f2005-06-27 14:59:41 +02003200static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3201{
3202 struct sigmatel_spec *spec = codec->spec;
3203 int i;
3204
3205 for (i = 0; i < spec->autocfg.line_outs; i++) {
3206 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3207 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3208 }
3209}
3210
3211static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3212{
3213 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003214 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003215
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003216 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3217 hda_nid_t pin;
3218 pin = spec->autocfg.hp_pins[i];
3219 if (pin) /* connect to front */
3220 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3221 }
3222 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3223 hda_nid_t pin;
3224 pin = spec->autocfg.speaker_pins[i];
3225 if (pin) /* connect to front */
3226 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3227 }
Mattc7d4b2f2005-06-27 14:59:41 +02003228}
3229
Matt Porter3cc08dc2006-01-23 15:27:49 +01003230static 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 +02003231{
3232 struct sigmatel_spec *spec = codec->spec;
3233 int err;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003234 int hp_speaker_swap = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003235
Matt Porter8b657272006-10-26 17:12:59 +02003236 if ((err = snd_hda_parse_pin_def_config(codec,
3237 &spec->autocfg,
3238 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003239 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003240 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003241 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003242
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003243 /* If we have no real line-out pin and multiple hp-outs, HPs should
3244 * be set up as multi-channel outputs.
3245 */
3246 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3247 spec->autocfg.hp_outs > 1) {
3248 /* Copy hp_outs to line_outs, backup line_outs in
3249 * speaker_outs so that the following routines can handle
3250 * HP pins as primary outputs.
3251 */
3252 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3253 sizeof(spec->autocfg.line_out_pins));
3254 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3255 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3256 sizeof(spec->autocfg.hp_pins));
3257 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3258 hp_speaker_swap = 1;
3259 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003260 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003261 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3262 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003263 u32 caps = query_amp_caps(codec,
3264 spec->autocfg.mono_out_pin, dir);
3265 hda_nid_t conn_list[1];
3266
3267 /* get the mixer node and then the mono mux if it exists */
3268 if (snd_hda_get_connections(codec,
3269 spec->autocfg.mono_out_pin, conn_list, 1) &&
3270 snd_hda_get_connections(codec, conn_list[0],
3271 conn_list, 1)) {
3272
3273 int wcaps = get_wcaps(codec, conn_list[0]);
3274 int wid_type = (wcaps & AC_WCAP_TYPE)
3275 >> AC_WCAP_TYPE_SHIFT;
3276 /* LR swap check, some stac925x have a mux that
3277 * changes the DACs output path instead of the
3278 * mono-mux path.
3279 */
3280 if (wid_type == AC_WID_AUD_SEL &&
3281 !(wcaps & AC_WCAP_LR_SWAP))
3282 spec->mono_nid = conn_list[0];
3283 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003284 if (dir) {
3285 hda_nid_t nid = spec->autocfg.mono_out_pin;
3286
3287 /* most mono outs have a least a mute/unmute switch */
3288 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3289 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3290 "Mono Playback Switch",
3291 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003292 if (err < 0)
3293 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003294 /* check for volume support for the amp */
3295 if ((caps & AC_AMPCAP_NUM_STEPS)
3296 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3297 err = stac92xx_add_control(spec,
3298 STAC_CTL_WIDGET_VOL,
3299 "Mono Playback Volume",
3300 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3301 if (err < 0)
3302 return err;
3303 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003304 }
3305
3306 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3307 AC_PINCTL_OUT_EN);
3308 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003309
Matt Porter403d1942005-11-29 15:00:51 +01003310 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
3311 return err;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003312 if (spec->multiout.num_dacs == 0)
3313 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
3314 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003315
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003316 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
3317
3318 if (err < 0)
3319 return err;
3320
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003321 /* setup analog beep controls */
3322 if (spec->anabeep_nid > 0) {
3323 err = stac92xx_auto_create_beep_ctls(codec,
3324 spec->anabeep_nid);
3325 if (err < 0)
3326 return err;
3327 }
3328
3329 /* setup digital beep controls and input device */
3330#ifdef CONFIG_SND_HDA_INPUT_BEEP
3331 if (spec->digbeep_nid > 0) {
3332 hda_nid_t nid = spec->digbeep_nid;
3333
3334 err = stac92xx_auto_create_beep_ctls(codec, nid);
3335 if (err < 0)
3336 return err;
3337 err = snd_hda_attach_beep_device(codec, nid);
3338 if (err < 0)
3339 return err;
3340 }
3341#endif
3342
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003343 if (hp_speaker_swap == 1) {
3344 /* Restore the hp_outs and line_outs */
3345 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3346 sizeof(spec->autocfg.line_out_pins));
3347 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3348 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
3349 sizeof(spec->autocfg.speaker_pins));
3350 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
3351 memset(spec->autocfg.speaker_pins, 0,
3352 sizeof(spec->autocfg.speaker_pins));
3353 spec->autocfg.speaker_outs = 0;
3354 }
3355
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003356 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3357
3358 if (err < 0)
3359 return err;
3360
3361 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3362
3363 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003364 return err;
3365
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003366 if (spec->mono_nid > 0) {
3367 err = stac92xx_auto_create_mono_output_ctls(codec);
3368 if (err < 0)
3369 return err;
3370 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003371 if (spec->num_amps > 0) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003372 err = stac92xx_auto_create_amp_output_ctls(codec);
3373 if (err < 0)
3374 return err;
3375 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003376 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003377 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3378 &spec->autocfg)) < 0)
3379 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003380 if (spec->num_muxes > 0) {
3381 err = stac92xx_auto_create_mux_input_ctls(codec);
3382 if (err < 0)
3383 return err;
3384 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003385 if (spec->num_smuxes > 0) {
3386 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3387 if (err < 0)
3388 return err;
3389 }
Matt Porter8b657272006-10-26 17:12:59 +02003390
Mattc7d4b2f2005-06-27 14:59:41 +02003391 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003392 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003393 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003394
Takashi Iwai82bc9552006-03-21 11:24:42 +01003395 if (spec->autocfg.dig_out_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003396 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003397 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003398 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003399
3400 if (spec->kctl_alloc)
3401 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3402
3403 spec->input_mux = &spec->private_imux;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003404 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003405 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003406 spec->mono_mux = &spec->private_mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -04003407 spec->amp_mux = &spec->private_amp_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003408 return 1;
3409}
3410
Takashi Iwai82bc9552006-03-21 11:24:42 +01003411/* add playback controls for HP output */
3412static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3413 struct auto_pin_cfg *cfg)
3414{
3415 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003416 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003417 unsigned int wid_caps;
3418
3419 if (! pin)
3420 return 0;
3421
3422 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003423 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003424 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003425
3426 return 0;
3427}
3428
Richard Fish160ea0d2006-09-06 13:58:25 +02003429/* add playback controls for LFE output */
3430static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3431 struct auto_pin_cfg *cfg)
3432{
3433 struct sigmatel_spec *spec = codec->spec;
3434 int err;
3435 hda_nid_t lfe_pin = 0x0;
3436 int i;
3437
3438 /*
3439 * search speaker outs and line outs for a mono speaker pin
3440 * with an amp. If one is found, add LFE controls
3441 * for it.
3442 */
3443 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3444 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003445 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003446 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3447 if (wcaps == AC_WCAP_OUT_AMP)
3448 /* found a mono speaker with an amp, must be lfe */
3449 lfe_pin = pin;
3450 }
3451
3452 /* if speaker_outs is 0, then speakers may be in line_outs */
3453 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3454 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3455 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003456 unsigned int defcfg;
Harvey Harrison8b551782008-02-29 11:56:48 +01003457 defcfg = snd_hda_codec_read(codec, pin, 0,
Richard Fish160ea0d2006-09-06 13:58:25 +02003458 AC_VERB_GET_CONFIG_DEFAULT,
3459 0x00);
Harvey Harrison8b551782008-02-29 11:56:48 +01003460 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003461 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003462 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3463 if (wcaps == AC_WCAP_OUT_AMP)
3464 /* found a mono speaker with an amp,
3465 must be lfe */
3466 lfe_pin = pin;
3467 }
3468 }
3469 }
3470
3471 if (lfe_pin) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003472 err = create_controls(spec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003473 if (err < 0)
3474 return err;
3475 }
3476
3477 return 0;
3478}
3479
Mattc7d4b2f2005-06-27 14:59:41 +02003480static int stac9200_parse_auto_config(struct hda_codec *codec)
3481{
3482 struct sigmatel_spec *spec = codec->spec;
3483 int err;
3484
Kailang Yangdf694da2005-12-05 19:42:22 +01003485 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003486 return err;
3487
3488 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3489 return err;
3490
Takashi Iwai82bc9552006-03-21 11:24:42 +01003491 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3492 return err;
3493
Richard Fish160ea0d2006-09-06 13:58:25 +02003494 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3495 return err;
3496
Takashi Iwai82bc9552006-03-21 11:24:42 +01003497 if (spec->autocfg.dig_out_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003498 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003499 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003500 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003501
3502 if (spec->kctl_alloc)
3503 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3504
3505 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003506 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003507
3508 return 1;
3509}
3510
Sam Revitch62fe78e2006-05-10 15:09:17 +02003511/*
3512 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3513 * funky external mute control using GPIO pins.
3514 */
3515
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003516static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003517 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003518{
3519 unsigned int gpiostate, gpiomask, gpiodir;
3520
3521 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3522 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003523 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003524
3525 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3526 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003527 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003528
3529 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3530 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003531 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003532
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003533 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003534 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3535
3536 snd_hda_codec_write(codec, codec->afg, 0,
3537 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003538 snd_hda_codec_read(codec, codec->afg, 0,
3539 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003540
3541 msleep(1);
3542
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003543 snd_hda_codec_read(codec, codec->afg, 0,
3544 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003545}
3546
Takashi Iwai314634b2006-09-21 11:56:18 +02003547static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3548 unsigned int event)
3549{
3550 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003551 snd_hda_codec_write_cache(codec, nid, 0,
3552 AC_VERB_SET_UNSOLICITED_ENABLE,
3553 (AC_USRSP_EN | event));
Takashi Iwai314634b2006-09-21 11:56:18 +02003554}
3555
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003556static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3557{
3558 int i;
3559 for (i = 0; i < cfg->hp_outs; i++)
3560 if (cfg->hp_pins[i] == nid)
3561 return 1; /* nid is a HP-Out */
3562
3563 return 0; /* nid is not a HP-Out */
3564};
3565
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003566static void stac92xx_power_down(struct hda_codec *codec)
3567{
3568 struct sigmatel_spec *spec = codec->spec;
3569
3570 /* power down inactive DACs */
3571 hda_nid_t *dac;
3572 for (dac = spec->dac_list; *dac; dac++)
Matthew Ranostay44510892008-02-21 07:49:31 +01003573 if (!is_in_dac_nids(spec, *dac) &&
3574 spec->multiout.hp_nid != *dac)
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003575 snd_hda_codec_write_cache(codec, *dac, 0,
3576 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3577}
3578
Mattc7d4b2f2005-06-27 14:59:41 +02003579static int stac92xx_init(struct hda_codec *codec)
3580{
3581 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003582 struct auto_pin_cfg *cfg = &spec->autocfg;
3583 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003584
Mattc7d4b2f2005-06-27 14:59:41 +02003585 snd_hda_sequence_write(codec, spec->init);
3586
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003587 /* power down adcs initially */
3588 if (spec->powerdown_adcs)
3589 for (i = 0; i < spec->num_adcs; i++)
3590 snd_hda_codec_write_cache(codec,
3591 spec->adc_nids[i], 0,
3592 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003593 /* set up pins */
3594 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02003595 /* Enable unsolicited responses on the HP widget */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003596 for (i = 0; i < cfg->hp_outs; i++)
Takashi Iwai314634b2006-09-21 11:56:18 +02003597 enable_pin_detect(codec, cfg->hp_pins[i],
3598 STAC_HP_EVENT);
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01003599 /* force to enable the first line-out; the others are set up
3600 * in unsol_event
3601 */
3602 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3603 AC_PINCTL_OUT_EN);
Takashi Iwaieb995a82006-09-21 14:28:21 +02003604 stac92xx_auto_init_hp_out(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003605 /* fake event to set up pins */
3606 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3607 } else {
3608 stac92xx_auto_init_multi_out(codec);
3609 stac92xx_auto_init_hp_out(codec);
3610 }
3611 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01003612 hda_nid_t nid = cfg->input_pins[i];
3613 if (nid) {
3614 unsigned int pinctl = AC_PINCTL_IN_EN;
3615 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
3616 pinctl |= stac92xx_get_vref(codec, nid);
3617 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3618 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01003619 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003620 for (i = 0; i < spec->num_dmics; i++)
3621 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3622 AC_PINCTL_IN_EN);
3623 for (i = 0; i < spec->num_pwrs; i++) {
3624 int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
3625 ? STAC_HP_EVENT : STAC_PWR_EVENT;
3626 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
3627 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003628 int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
3629 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003630 def_conf = get_defcfg_connect(def_conf);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003631 /* outputs are only ports capable of power management
3632 * any attempts on powering down a input port cause the
3633 * referenced VREF to act quirky.
3634 */
3635 if (pinctl & AC_PINCTL_IN_EN)
3636 continue;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003637 /* skip any ports that don't have jacks since presence
3638 * detection is useless */
3639 if (def_conf && def_conf != AC_JACK_PORT_FIXED)
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003640 continue;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003641 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3642 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3643 }
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003644 if (spec->dac_list)
3645 stac92xx_power_down(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003646 if (cfg->dig_out_pin)
3647 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3648 AC_PINCTL_OUT_EN);
3649 if (cfg->dig_in_pin)
3650 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3651 AC_PINCTL_IN_EN);
3652
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003653 stac_gpio_set(codec, spec->gpio_mask,
3654 spec->gpio_dir, spec->gpio_data);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003655
Mattc7d4b2f2005-06-27 14:59:41 +02003656 return 0;
3657}
3658
Matt2f2f4252005-04-13 14:45:30 +02003659static void stac92xx_free(struct hda_codec *codec)
3660{
Mattc7d4b2f2005-06-27 14:59:41 +02003661 struct sigmatel_spec *spec = codec->spec;
3662 int i;
3663
3664 if (! spec)
3665 return;
3666
3667 if (spec->kctl_alloc) {
3668 for (i = 0; i < spec->num_kctl_used; i++)
3669 kfree(spec->kctl_alloc[i].name);
3670 kfree(spec->kctl_alloc);
3671 }
3672
Richard Fish11b44bb2006-08-23 18:31:34 +02003673 if (spec->bios_pin_configs)
3674 kfree(spec->bios_pin_configs);
3675
Mattc7d4b2f2005-06-27 14:59:41 +02003676 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003677 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02003678}
3679
Matt4e550962005-07-04 17:51:39 +02003680static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3681 unsigned int flag)
3682{
3683 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3684 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02003685
Takashi Iwaif9acba42007-05-29 18:01:06 +02003686 if (pin_ctl & AC_PINCTL_IN_EN) {
3687 /*
3688 * we need to check the current set-up direction of
3689 * shared input pins since they can be switched via
3690 * "xxx as Output" mixer switch
3691 */
3692 struct sigmatel_spec *spec = codec->spec;
3693 struct auto_pin_cfg *cfg = &spec->autocfg;
3694 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3695 spec->line_switch) ||
3696 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3697 spec->mic_switch))
3698 return;
3699 }
3700
Steve Longerbeam7b043892007-05-03 20:50:03 +02003701 /* if setting pin direction bits, clear the current
3702 direction bits first */
3703 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3704 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3705
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003706 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003707 AC_VERB_SET_PIN_WIDGET_CONTROL,
3708 pin_ctl | flag);
3709}
3710
3711static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3712 unsigned int flag)
3713{
3714 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3715 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003716 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003717 AC_VERB_SET_PIN_WIDGET_CONTROL,
3718 pin_ctl & ~flag);
3719}
3720
Jiang Zhe40c1d302007-11-12 13:05:16 +01003721static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02003722{
3723 if (!nid)
3724 return 0;
3725 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Jiang Zhe40c1d302007-11-12 13:05:16 +01003726 & (1 << 31)) {
3727 unsigned int pinctl;
3728 pinctl = snd_hda_codec_read(codec, nid, 0,
3729 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3730 if (pinctl & AC_PINCTL_IN_EN)
3731 return 0; /* mic- or line-input */
3732 else
3733 return 1; /* HP-output */
3734 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003735 return 0;
3736}
3737
3738static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
Matt4e550962005-07-04 17:51:39 +02003739{
3740 struct sigmatel_spec *spec = codec->spec;
3741 struct auto_pin_cfg *cfg = &spec->autocfg;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003742 int nid = cfg->hp_pins[cfg->hp_outs - 1];
Matt4e550962005-07-04 17:51:39 +02003743 int i, presence;
3744
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003745 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003746 if (spec->gpio_mute)
3747 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3748 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3749
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003750 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003751 if (presence)
3752 break;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003753 if (spec->hp_switch && cfg->hp_pins[i] == nid)
3754 break;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003755 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003756 }
Matt4e550962005-07-04 17:51:39 +02003757
3758 if (presence) {
3759 /* disable lineouts, enable hp */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003760 if (spec->hp_switch)
3761 stac92xx_reset_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003762 for (i = 0; i < cfg->line_outs; i++)
3763 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3764 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003765 for (i = 0; i < cfg->speaker_outs; i++)
3766 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3767 AC_PINCTL_OUT_EN);
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003768 if (spec->eapd_mask)
3769 stac_gpio_set(codec, spec->gpio_mask,
3770 spec->gpio_dir, spec->gpio_data &
3771 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003772 } else {
3773 /* enable lineouts, disable hp */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003774 if (spec->hp_switch)
3775 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003776 for (i = 0; i < cfg->line_outs; i++)
3777 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3778 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003779 for (i = 0; i < cfg->speaker_outs; i++)
3780 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3781 AC_PINCTL_OUT_EN);
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003782 if (spec->eapd_mask)
3783 stac_gpio_set(codec, spec->gpio_mask,
3784 spec->gpio_dir, spec->gpio_data |
3785 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003786 }
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003787 if (!spec->hp_switch && cfg->hp_outs > 1 && presence)
3788 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003789}
3790
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003791static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
3792{
3793 struct sigmatel_spec *spec = codec->spec;
3794 hda_nid_t nid = spec->pwr_nids[idx];
3795 int presence, val;
3796 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
3797 & 0x000000ff;
3798 presence = get_hp_pin_presence(codec, nid);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003799
3800 /* several codecs have two power down bits */
3801 if (spec->pwr_mapping)
3802 idx = spec->pwr_mapping[idx];
3803 else
3804 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003805
3806 if (presence)
3807 val &= ~idx;
3808 else
3809 val |= idx;
3810
3811 /* power down unused output ports */
3812 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
3813};
3814
Takashi Iwai314634b2006-09-21 11:56:18 +02003815static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
3816{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003817 struct sigmatel_spec *spec = codec->spec;
3818 int idx = res >> 26 & 0x0f;
3819
3820 switch ((res >> 26) & 0x30) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003821 case STAC_HP_EVENT:
3822 stac92xx_hp_detect(codec, res);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003823 /* fallthru */
3824 case STAC_PWR_EVENT:
3825 if (spec->num_pwrs > 0)
3826 stac92xx_pin_sense(codec, idx);
Takashi Iwai314634b2006-09-21 11:56:18 +02003827 }
3828}
3829
Takashi Iwaicb53c622007-08-10 17:21:45 +02003830#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02003831static int stac92xx_resume(struct hda_codec *codec)
3832{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003833 struct sigmatel_spec *spec = codec->spec;
3834
Richard Fish11b44bb2006-08-23 18:31:34 +02003835 stac92xx_set_config_regs(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003836 snd_hda_sequence_write(codec, spec->init);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003837 stac_gpio_set(codec, spec->gpio_mask,
3838 spec->gpio_dir, spec->gpio_data);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003839 snd_hda_codec_resume_amp(codec);
3840 snd_hda_codec_resume_cache(codec);
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003841 /* power down inactive DACs */
3842 if (spec->dac_list)
3843 stac92xx_power_down(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003844 /* invoke unsolicited event to reset the HP state */
3845 if (spec->hp_detect)
3846 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
Mattff6fdc32005-06-27 15:06:52 +02003847 return 0;
3848}
3849#endif
3850
Matt2f2f4252005-04-13 14:45:30 +02003851static struct hda_codec_ops stac92xx_patch_ops = {
3852 .build_controls = stac92xx_build_controls,
3853 .build_pcms = stac92xx_build_pcms,
3854 .init = stac92xx_init,
3855 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02003856 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003857#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02003858 .resume = stac92xx_resume,
3859#endif
Matt2f2f4252005-04-13 14:45:30 +02003860};
3861
3862static int patch_stac9200(struct hda_codec *codec)
3863{
3864 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003865 int err;
Matt2f2f4252005-04-13 14:45:30 +02003866
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003867 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02003868 if (spec == NULL)
3869 return -ENOMEM;
3870
3871 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003872 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02003873 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003874 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
3875 stac9200_models,
3876 stac9200_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02003877 if (spec->board_config < 0) {
3878 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
3879 err = stac92xx_save_bios_config_regs(codec);
3880 if (err < 0) {
3881 stac92xx_free(codec);
3882 return err;
3883 }
3884 spec->pin_configs = spec->bios_pin_configs;
3885 } else {
Matt Porter403d1942005-11-29 15:00:51 +01003886 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
3887 stac92xx_set_config_regs(codec);
3888 }
Matt2f2f4252005-04-13 14:45:30 +02003889
3890 spec->multiout.max_channels = 2;
3891 spec->multiout.num_dacs = 1;
3892 spec->multiout.dac_nids = stac9200_dac_nids;
3893 spec->adc_nids = stac9200_adc_nids;
3894 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02003895 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02003896 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003897 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003898 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003899
Tobin Davisbf277782008-02-03 20:31:47 +01003900 if (spec->board_config == STAC_9200_GATEWAY ||
3901 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02003902 spec->init = stac9200_eapd_init;
3903 else
3904 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02003905 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02003906
Takashi Iwai117f2572008-03-18 09:53:23 +01003907 if (spec->board_config == STAC_9200_PANASONIC) {
3908 spec->gpio_mask = spec->gpio_dir = 0x09;
3909 spec->gpio_data = 0x00;
3910 }
3911
Mattc7d4b2f2005-06-27 14:59:41 +02003912 err = stac9200_parse_auto_config(codec);
3913 if (err < 0) {
3914 stac92xx_free(codec);
3915 return err;
3916 }
Matt2f2f4252005-04-13 14:45:30 +02003917
3918 codec->patch_ops = stac92xx_patch_ops;
3919
3920 return 0;
3921}
3922
Tobin Davis8e21c342007-01-08 11:04:17 +01003923static int patch_stac925x(struct hda_codec *codec)
3924{
3925 struct sigmatel_spec *spec;
3926 int err;
3927
3928 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3929 if (spec == NULL)
3930 return -ENOMEM;
3931
3932 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003933 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01003934 spec->pin_nids = stac925x_pin_nids;
3935 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
3936 stac925x_models,
3937 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01003938 again:
Tobin Davis8e21c342007-01-08 11:04:17 +01003939 if (spec->board_config < 0) {
Tobin Davis2c11f952007-05-17 09:36:34 +02003940 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
3941 "using BIOS defaults\n");
Tobin Davis8e21c342007-01-08 11:04:17 +01003942 err = stac92xx_save_bios_config_regs(codec);
3943 if (err < 0) {
3944 stac92xx_free(codec);
3945 return err;
3946 }
3947 spec->pin_configs = spec->bios_pin_configs;
3948 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
3949 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
3950 stac92xx_set_config_regs(codec);
3951 }
3952
3953 spec->multiout.max_channels = 2;
3954 spec->multiout.num_dacs = 1;
3955 spec->multiout.dac_nids = stac925x_dac_nids;
3956 spec->adc_nids = stac925x_adc_nids;
3957 spec->mux_nids = stac925x_mux_nids;
3958 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003959 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003960 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02003961 switch (codec->vendor_id) {
3962 case 0x83847632: /* STAC9202 */
3963 case 0x83847633: /* STAC9202D */
3964 case 0x83847636: /* STAC9251 */
3965 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02003966 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02003967 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01003968 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
3969 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02003970 break;
3971 default:
3972 spec->num_dmics = 0;
3973 break;
3974 }
Tobin Davis8e21c342007-01-08 11:04:17 +01003975
3976 spec->init = stac925x_core_init;
3977 spec->mixer = stac925x_mixer;
3978
3979 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01003980 if (!err) {
3981 if (spec->board_config < 0) {
3982 printk(KERN_WARNING "hda_codec: No auto-config is "
3983 "available, default to model=ref\n");
3984 spec->board_config = STAC_925x_REF;
3985 goto again;
3986 }
3987 err = -EINVAL;
3988 }
Tobin Davis8e21c342007-01-08 11:04:17 +01003989 if (err < 0) {
3990 stac92xx_free(codec);
3991 return err;
3992 }
3993
3994 codec->patch_ops = stac92xx_patch_ops;
3995
3996 return 0;
3997}
3998
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003999static struct hda_input_mux stac92hd73xx_dmux = {
4000 .num_items = 4,
4001 .items = {
4002 { "Analog Inputs", 0x0b },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004003 { "Digital Mic 1", 0x09 },
4004 { "Digital Mic 2", 0x0a },
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004005 { "CD", 0x08 },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004006 }
4007};
4008
4009static int patch_stac92hd73xx(struct hda_codec *codec)
4010{
4011 struct sigmatel_spec *spec;
4012 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4013 int err = 0;
4014
4015 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4016 if (spec == NULL)
4017 return -ENOMEM;
4018
4019 codec->spec = spec;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02004020 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004021 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4022 spec->pin_nids = stac92hd73xx_pin_nids;
4023 spec->board_config = snd_hda_check_board_config(codec,
4024 STAC_92HD73XX_MODELS,
4025 stac92hd73xx_models,
4026 stac92hd73xx_cfg_tbl);
4027again:
4028 if (spec->board_config < 0) {
4029 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4030 " STAC92HD73XX, using BIOS defaults\n");
4031 err = stac92xx_save_bios_config_regs(codec);
4032 if (err < 0) {
4033 stac92xx_free(codec);
4034 return err;
4035 }
4036 spec->pin_configs = spec->bios_pin_configs;
4037 } else {
4038 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
4039 stac92xx_set_config_regs(codec);
4040 }
4041
4042 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
4043 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4044
4045 if (spec->multiout.num_dacs < 0) {
4046 printk(KERN_WARNING "hda_codec: Could not determine "
4047 "number of channels defaulting to DAC count\n");
4048 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
4049 }
4050
4051 switch (spec->multiout.num_dacs) {
4052 case 0x3: /* 6 Channel */
4053 spec->mixer = stac92hd73xx_6ch_mixer;
4054 spec->init = stac92hd73xx_6ch_core_init;
4055 break;
4056 case 0x4: /* 8 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004057 spec->mixer = stac92hd73xx_8ch_mixer;
4058 spec->init = stac92hd73xx_8ch_core_init;
4059 break;
4060 case 0x5: /* 10 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004061 spec->mixer = stac92hd73xx_10ch_mixer;
4062 spec->init = stac92hd73xx_10ch_core_init;
4063 };
4064
4065 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
4066 spec->aloopback_mask = 0x01;
4067 spec->aloopback_shift = 8;
4068
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004069 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004070 spec->mux_nids = stac92hd73xx_mux_nids;
4071 spec->adc_nids = stac92hd73xx_adc_nids;
4072 spec->dmic_nids = stac92hd73xx_dmic_nids;
4073 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004074 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostay89385032008-09-11 09:49:39 -04004075 spec->amp_nids = stac92hd73xx_amp_nids;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004076 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004077
4078 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4079 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01004080 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004081 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4082 sizeof(stac92hd73xx_dmux));
4083
Matthew Ranostaya7662642008-02-21 07:51:14 +01004084 switch (spec->board_config) {
4085 case STAC_DELL_M6:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004086 spec->init = dell_eq_core_init;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004087 spec->num_smuxes = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004088 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4089 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
4090 spec->num_amps = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004091 switch (codec->subsystem_id) {
4092 case 0x1028025e: /* Analog Mics */
4093 case 0x1028025f:
4094 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4095 spec->num_dmics = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004096 spec->private_dimux.num_items = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004097 break;
Matthew Ranostayd654a662008-03-14 08:46:51 +01004098 case 0x10280271: /* Digital Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004099 case 0x10280272:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004100 spec->init = dell_m6_core_init;
4101 /* fall-through */
4102 case 0x10280254:
4103 case 0x10280255:
Matthew Ranostaya7662642008-02-21 07:51:14 +01004104 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4105 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004106 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004107 break;
4108 case 0x10280256: /* Both */
4109 case 0x10280057:
4110 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4111 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4112 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004113 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004114 break;
4115 }
4116 break;
4117 default:
4118 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004119 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostaya7662642008-02-21 07:51:14 +01004120 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004121 if (spec->board_config > STAC_92HD73XX_REF) {
4122 /* GPIO0 High = Enable EAPD */
4123 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4124 spec->gpio_data = 0x01;
4125 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004126 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004127
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004128 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4129 spec->pwr_nids = stac92hd73xx_pwr_nids;
4130
Matthew Ranostayd9737752008-09-07 12:03:41 +02004131 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004132
4133 if (!err) {
4134 if (spec->board_config < 0) {
4135 printk(KERN_WARNING "hda_codec: No auto-config is "
4136 "available, default to model=ref\n");
4137 spec->board_config = STAC_92HD73XX_REF;
4138 goto again;
4139 }
4140 err = -EINVAL;
4141 }
4142
4143 if (err < 0) {
4144 stac92xx_free(codec);
4145 return err;
4146 }
4147
4148 codec->patch_ops = stac92xx_patch_ops;
4149
4150 return 0;
4151}
4152
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004153static struct hda_input_mux stac92hd83xxx_dmux = {
4154 .num_items = 3,
4155 .items = {
4156 { "Analog Inputs", 0x03 },
4157 { "Digital Mic 1", 0x04 },
4158 { "Digital Mic 2", 0x05 },
4159 }
4160};
4161
4162static int patch_stac92hd83xxx(struct hda_codec *codec)
4163{
4164 struct sigmatel_spec *spec;
4165 int err;
4166
4167 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4168 if (spec == NULL)
4169 return -ENOMEM;
4170
4171 codec->spec = spec;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004172 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004173 spec->mono_nid = 0x19;
4174 spec->digbeep_nid = 0x21;
4175 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4176 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4177 spec->adc_nids = stac92hd83xxx_adc_nids;
4178 spec->pwr_nids = stac92hd83xxx_pwr_nids;
4179 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4180 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
4181 spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
4182
4183 spec->init = stac92hd83xxx_core_init;
4184 switch (codec->vendor_id) {
4185 case 0x111d7605:
4186 spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
4187 break;
4188 default:
4189 spec->num_pwrs--;
4190 spec->init++; /* switch to config #2 */
4191 spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
4192 }
4193
4194 spec->mixer = stac92hd83xxx_mixer;
4195 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4196 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4197 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
4198 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4199 spec->dinput_mux = &stac92hd83xxx_dmux;
4200 spec->pin_nids = stac92hd83xxx_pin_nids;
4201 spec->board_config = snd_hda_check_board_config(codec,
4202 STAC_92HD83XXX_MODELS,
4203 stac92hd83xxx_models,
4204 stac92hd83xxx_cfg_tbl);
4205again:
4206 if (spec->board_config < 0) {
4207 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4208 " STAC92HD83XXX, using BIOS defaults\n");
4209 err = stac92xx_save_bios_config_regs(codec);
4210 if (err < 0) {
4211 stac92xx_free(codec);
4212 return err;
4213 }
4214 spec->pin_configs = spec->bios_pin_configs;
4215 } else {
4216 spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config];
4217 stac92xx_set_config_regs(codec);
4218 }
4219
4220 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4221 if (!err) {
4222 if (spec->board_config < 0) {
4223 printk(KERN_WARNING "hda_codec: No auto-config is "
4224 "available, default to model=ref\n");
4225 spec->board_config = STAC_92HD83XXX_REF;
4226 goto again;
4227 }
4228 err = -EINVAL;
4229 }
4230
4231 if (err < 0) {
4232 stac92xx_free(codec);
4233 return err;
4234 }
4235
4236 codec->patch_ops = stac92xx_patch_ops;
4237
4238 return 0;
4239}
4240
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004241#ifdef SND_HDA_NEEDS_RESUME
4242static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr)
4243{
4244 struct sigmatel_spec *spec = codec->spec;
4245 int i;
4246 snd_hda_codec_write_cache(codec, codec->afg, 0,
4247 AC_VERB_SET_POWER_STATE, pwr);
4248
4249 msleep(1);
4250 for (i = 0; i < spec->num_adcs; i++) {
4251 snd_hda_codec_write_cache(codec,
4252 spec->adc_nids[i], 0,
4253 AC_VERB_SET_POWER_STATE, pwr);
4254 }
4255};
4256
4257static int stac92hd71xx_resume(struct hda_codec *codec)
4258{
4259 stac92hd71xx_set_power_state(codec, AC_PWRST_D0);
4260 return stac92xx_resume(codec);
4261}
4262
4263static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state)
4264{
4265 stac92hd71xx_set_power_state(codec, AC_PWRST_D3);
4266 return 0;
4267};
4268
4269#endif
4270
4271static struct hda_codec_ops stac92hd71bxx_patch_ops = {
4272 .build_controls = stac92xx_build_controls,
4273 .build_pcms = stac92xx_build_pcms,
4274 .init = stac92xx_init,
4275 .free = stac92xx_free,
4276 .unsol_event = stac92xx_unsol_event,
4277#ifdef SND_HDA_NEEDS_RESUME
4278 .resume = stac92hd71xx_resume,
4279 .suspend = stac92hd71xx_suspend,
4280#endif
4281};
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004282
Matthew Ranostaye035b842007-11-06 11:53:55 +01004283static int patch_stac92hd71bxx(struct hda_codec *codec)
4284{
4285 struct sigmatel_spec *spec;
4286 int err = 0;
4287
4288 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4289 if (spec == NULL)
4290 return -ENOMEM;
4291
4292 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004293 codec->patch_ops = stac92xx_patch_ops;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004294 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004295 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004296 spec->pin_nids = stac92hd71bxx_pin_nids;
4297 spec->board_config = snd_hda_check_board_config(codec,
4298 STAC_92HD71BXX_MODELS,
4299 stac92hd71bxx_models,
4300 stac92hd71bxx_cfg_tbl);
4301again:
4302 if (spec->board_config < 0) {
4303 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4304 " STAC92HD71BXX, using BIOS defaults\n");
4305 err = stac92xx_save_bios_config_regs(codec);
4306 if (err < 0) {
4307 stac92xx_free(codec);
4308 return err;
4309 }
4310 spec->pin_configs = spec->bios_pin_configs;
4311 } else {
4312 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
4313 stac92xx_set_config_regs(codec);
4314 }
4315
Matthew Ranostay541eee82007-12-14 12:08:04 +01004316 switch (codec->vendor_id) {
4317 case 0x111d76b6: /* 4 Port without Analog Mixer */
4318 case 0x111d76b7:
4319 case 0x111d76b4: /* 6 Port without Analog Mixer */
4320 case 0x111d76b5:
4321 spec->mixer = stac92hd71bxx_mixer;
4322 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004323 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004324 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004325 case 0x111d7608: /* 5 Port with Analog Mixer */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004326 if ((codec->revision_id & 0xf) == 0 ||
4327 (codec->revision_id & 0xf) == 1) {
4328#ifdef SND_HDA_NEEDS_RESUME
4329 codec->patch_ops = stac92hd71bxx_patch_ops;
4330#endif
4331 spec->stream_delay = 40; /* 40 milliseconds */
4332 }
4333
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004334 /* no output amps */
4335 spec->num_pwrs = 0;
4336 spec->mixer = stac92hd71bxx_analog_mixer;
4337
4338 /* disable VSW */
4339 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
4340 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
4341 break;
4342 case 0x111d7603: /* 6 Port with Analog Mixer */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004343 if ((codec->revision_id & 0xf) == 1) {
4344#ifdef SND_HDA_NEEDS_RESUME
4345 codec->patch_ops = stac92hd71bxx_patch_ops;
4346#endif
4347 spec->stream_delay = 40; /* 40 milliseconds */
4348 }
4349
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004350 /* no output amps */
4351 spec->num_pwrs = 0;
4352 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01004353 default:
4354 spec->mixer = stac92hd71bxx_analog_mixer;
4355 spec->init = stac92hd71bxx_analog_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004356 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004357 }
4358
4359 spec->aloopback_mask = 0x20;
4360 spec->aloopback_shift = 0;
4361
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004362 if (spec->board_config > STAC_92HD71BXX_REF) {
4363 /* GPIO0 = EAPD */
4364 spec->gpio_mask = 0x01;
4365 spec->gpio_dir = 0x01;
4366 spec->gpio_data = 0x01;
4367 }
Matthew Ranostaye035b842007-11-06 11:53:55 +01004368
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004369 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004370 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004371 spec->mux_nids = stac92hd71bxx_mux_nids;
4372 spec->adc_nids = stac92hd71bxx_adc_nids;
4373 spec->dmic_nids = stac92hd71bxx_dmic_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004374 spec->dmux_nids = stac92hd71bxx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004375 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004376 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004377
4378 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
4379 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01004380 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004381
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004382 switch (spec->board_config) {
4383 case STAC_HP_M4:
4384 spec->num_dmics = 0;
4385 spec->num_smuxes = 1;
4386 spec->num_dmuxes = 0;
4387
4388 /* enable internal microphone */
4389 snd_hda_codec_write_cache(codec, 0x0e, 0,
4390 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80);
4391 break;
4392 default:
4393 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
4394 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
4395 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4396 };
4397
Takashi Iwaiaea7bb02008-02-25 18:26:41 +01004398 spec->multiout.num_dacs = 1;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004399 spec->multiout.hp_nid = 0x11;
4400 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
4401
4402 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
4403 if (!err) {
4404 if (spec->board_config < 0) {
4405 printk(KERN_WARNING "hda_codec: No auto-config is "
4406 "available, default to model=ref\n");
4407 spec->board_config = STAC_92HD71BXX_REF;
4408 goto again;
4409 }
4410 err = -EINVAL;
4411 }
4412
4413 if (err < 0) {
4414 stac92xx_free(codec);
4415 return err;
4416 }
4417
Matthew Ranostaye035b842007-11-06 11:53:55 +01004418 return 0;
4419};
4420
Matt2f2f4252005-04-13 14:45:30 +02004421static int patch_stac922x(struct hda_codec *codec)
4422{
4423 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004424 int err;
Matt2f2f4252005-04-13 14:45:30 +02004425
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004426 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004427 if (spec == NULL)
4428 return -ENOMEM;
4429
4430 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004431 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004432 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004433 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
4434 stac922x_models,
4435 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08004436 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004437 spec->gpio_mask = spec->gpio_dir = 0x03;
4438 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004439 /* Intel Macs have all same PCI SSID, so we need to check
4440 * codec SSID to distinguish the exact models
4441 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004442 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004443 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004444
4445 case 0x106b0800:
4446 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02004447 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004448 case 0x106b0600:
4449 case 0x106b0700:
4450 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004451 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004452 case 0x106b0e00:
4453 case 0x106b0f00:
4454 case 0x106b1600:
4455 case 0x106b1700:
4456 case 0x106b0200:
4457 case 0x106b1e00:
4458 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004459 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004460 case 0x106b1a00:
4461 case 0x00000100:
4462 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02004463 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004464 case 0x106b0a00:
4465 case 0x106b2200:
4466 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02004467 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08004468 default:
4469 spec->board_config = STAC_INTEL_MAC_V3;
4470 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004471 }
4472 }
4473
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004474 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004475 if (spec->board_config < 0) {
4476 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
4477 "using BIOS defaults\n");
4478 err = stac92xx_save_bios_config_regs(codec);
4479 if (err < 0) {
4480 stac92xx_free(codec);
4481 return err;
4482 }
4483 spec->pin_configs = spec->bios_pin_configs;
4484 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
Matt Porter403d1942005-11-29 15:00:51 +01004485 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
4486 stac92xx_set_config_regs(codec);
4487 }
Matt2f2f4252005-04-13 14:45:30 +02004488
Matt2f2f4252005-04-13 14:45:30 +02004489 spec->adc_nids = stac922x_adc_nids;
4490 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004491 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004492 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004493 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004494 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004495
4496 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004497 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004498
4499 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02004500
Matt Porter3cc08dc2006-01-23 15:27:49 +01004501 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004502 if (!err) {
4503 if (spec->board_config < 0) {
4504 printk(KERN_WARNING "hda_codec: No auto-config is "
4505 "available, default to model=ref\n");
4506 spec->board_config = STAC_D945_REF;
4507 goto again;
4508 }
4509 err = -EINVAL;
4510 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004511 if (err < 0) {
4512 stac92xx_free(codec);
4513 return err;
4514 }
4515
4516 codec->patch_ops = stac92xx_patch_ops;
4517
Takashi Iwai807a46362007-05-29 19:01:37 +02004518 /* Fix Mux capture level; max to 2 */
4519 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
4520 (0 << AC_AMPCAP_OFFSET_SHIFT) |
4521 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4522 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4523 (0 << AC_AMPCAP_MUTE_SHIFT));
4524
Matt Porter3cc08dc2006-01-23 15:27:49 +01004525 return 0;
4526}
4527
4528static int patch_stac927x(struct hda_codec *codec)
4529{
4530 struct sigmatel_spec *spec;
4531 int err;
4532
4533 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4534 if (spec == NULL)
4535 return -ENOMEM;
4536
4537 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004538 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004539 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004540 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
4541 stac927x_models,
4542 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004543 again:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004544 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
4545 if (spec->board_config < 0)
4546 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4547 "STAC927x, using BIOS defaults\n");
Richard Fish11b44bb2006-08-23 18:31:34 +02004548 err = stac92xx_save_bios_config_regs(codec);
4549 if (err < 0) {
4550 stac92xx_free(codec);
4551 return err;
4552 }
4553 spec->pin_configs = spec->bios_pin_configs;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004554 } else {
Matt Porter3cc08dc2006-01-23 15:27:49 +01004555 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
4556 stac92xx_set_config_regs(codec);
4557 }
4558
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004559 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004560 spec->adc_nids = stac927x_adc_nids;
4561 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
4562 spec->mux_nids = stac927x_mux_nids;
4563 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004564 spec->smux_nids = stac927x_smux_nids;
4565 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04004566 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004567 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004568 spec->multiout.dac_nids = spec->dac_nids;
4569
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004570 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02004571 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004572 case STAC_D965_5ST:
4573 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004574 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004575 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004576 spec->num_dmics = 0;
4577
Tobin Davis93ed1502006-09-01 21:03:12 +02004578 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004579 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004580 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004581 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02004582 switch (codec->subsystem_id) {
4583 case 0x10280209:
4584 case 0x1028022e:
4585 /* correct the device field to SPDIF out */
4586 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
4587 break;
4588 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01004589 /* configure the analog microphone on some laptops */
4590 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01004591 /* correct the front output jack as a hp out */
Matthew Ranostay7989fba2008-02-21 07:50:12 +01004592 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01004593 /* correct the front input jack as a mic */
4594 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
4595 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004596 case STAC_DELL_3ST:
4597 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004598 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004599 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004600 spec->dmic_nids = stac927x_dmic_nids;
4601 spec->num_dmics = STAC927X_NUM_DMICS;
4602
Tobin Davis93ed1502006-09-01 21:03:12 +02004603 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004604 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004605 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004606 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004607 break;
4608 default:
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004609 if (spec->board_config > STAC_D965_REF) {
4610 /* GPIO0 High = Enable EAPD */
4611 spec->eapd_mask = spec->gpio_mask = 0x01;
4612 spec->gpio_dir = spec->gpio_data = 0x01;
4613 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004614 spec->num_dmics = 0;
4615
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004616 spec->init = stac927x_core_init;
4617 spec->mixer = stac927x_mixer;
4618 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004619
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004620 spec->num_pwrs = 0;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004621 spec->aloopback_mask = 0x40;
4622 spec->aloopback_shift = 0;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004623
Matt Porter3cc08dc2006-01-23 15:27:49 +01004624 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004625 if (!err) {
4626 if (spec->board_config < 0) {
4627 printk(KERN_WARNING "hda_codec: No auto-config is "
4628 "available, default to model=ref\n");
4629 spec->board_config = STAC_D965_REF;
4630 goto again;
4631 }
4632 err = -EINVAL;
4633 }
Mattc7d4b2f2005-06-27 14:59:41 +02004634 if (err < 0) {
4635 stac92xx_free(codec);
4636 return err;
4637 }
Matt2f2f4252005-04-13 14:45:30 +02004638
4639 codec->patch_ops = stac92xx_patch_ops;
4640
Takashi Iwai52987652008-01-16 16:09:47 +01004641 /*
4642 * !!FIXME!!
4643 * The STAC927x seem to require fairly long delays for certain
4644 * command sequences. With too short delays (even if the answer
4645 * is set to RIRB properly), it results in the silence output
4646 * on some hardwares like Dell.
4647 *
4648 * The below flag enables the longer delay (see get_response
4649 * in hda_intel.c).
4650 */
4651 codec->bus->needs_damn_long_delay = 1;
4652
Matt2f2f4252005-04-13 14:45:30 +02004653 return 0;
4654}
4655
Matt Porterf3302a52006-07-31 12:49:34 +02004656static int patch_stac9205(struct hda_codec *codec)
4657{
4658 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02004659 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02004660
4661 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4662 if (spec == NULL)
4663 return -ENOMEM;
4664
4665 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004666 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004667 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004668 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
4669 stac9205_models,
4670 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004671 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004672 if (spec->board_config < 0) {
4673 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
4674 err = stac92xx_save_bios_config_regs(codec);
4675 if (err < 0) {
4676 stac92xx_free(codec);
4677 return err;
4678 }
4679 spec->pin_configs = spec->bios_pin_configs;
4680 } else {
Matt Porterf3302a52006-07-31 12:49:34 +02004681 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
4682 stac92xx_set_config_regs(codec);
4683 }
4684
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004685 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02004686 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004687 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02004688 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004689 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004690 spec->smux_nids = stac9205_smux_nids;
4691 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004692 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02004693 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004694 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004695 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004696 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02004697
4698 spec->init = stac9205_core_init;
4699 spec->mixer = stac9205_mixer;
4700
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004701 spec->aloopback_mask = 0x40;
4702 spec->aloopback_shift = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02004703 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02004704
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004705 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004706 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02004707 /* Enable SPDIF in/out */
4708 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
4709 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01004710
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004711 /* Enable unsol response for GPIO4/Dock HP connection */
4712 snd_hda_codec_write(codec, codec->afg, 0,
4713 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4714 snd_hda_codec_write_cache(codec, codec->afg, 0,
4715 AC_VERB_SET_UNSOLICITED_ENABLE,
4716 (AC_USRSP_EN | STAC_HP_EVENT));
4717
4718 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004719 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004720 spec->gpio_mask = 0x1b;
4721 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01004722 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004723 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02004724 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004725 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004726 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004727 case STAC_9205_REF:
4728 /* SPDIF-In enabled */
4729 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004730 default:
4731 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004732 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004733 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004734 break;
4735 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02004736
Matt Porterf3302a52006-07-31 12:49:34 +02004737 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004738 if (!err) {
4739 if (spec->board_config < 0) {
4740 printk(KERN_WARNING "hda_codec: No auto-config is "
4741 "available, default to model=ref\n");
4742 spec->board_config = STAC_9205_REF;
4743 goto again;
4744 }
4745 err = -EINVAL;
4746 }
Matt Porterf3302a52006-07-31 12:49:34 +02004747 if (err < 0) {
4748 stac92xx_free(codec);
4749 return err;
4750 }
4751
4752 codec->patch_ops = stac92xx_patch_ops;
4753
4754 return 0;
4755}
4756
Matt2f2f4252005-04-13 14:45:30 +02004757/*
Guillaume Munch6d859062006-08-22 17:15:47 +02004758 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01004759 */
4760
Guillaume Munch99ccc562006-08-16 19:35:12 +02004761/* static config for Sony VAIO FE550G and Sony VAIO AR */
Takashi Iwaidb064e52006-03-16 16:04:58 +01004762static hda_nid_t vaio_dacs[] = { 0x2 };
4763#define VAIO_HP_DAC 0x5
4764static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
4765static hda_nid_t vaio_mux_nids[] = { 0x15 };
4766
4767static struct hda_input_mux vaio_mux = {
Takashi Iwaia3a2f422007-10-11 11:21:21 +02004768 .num_items = 3,
Takashi Iwaidb064e52006-03-16 16:04:58 +01004769 .items = {
Takashi Iwaid7737812006-04-25 13:05:43 +02004770 /* { "HP", 0x0 }, */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004771 { "Mic Jack", 0x1 },
4772 { "Internal Mic", 0x2 },
Takashi Iwaidb064e52006-03-16 16:04:58 +01004773 { "PCM", 0x3 },
4774 }
4775};
4776
4777static struct hda_verb vaio_init[] = {
4778 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004779 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
Takashi Iwaidb064e52006-03-16 16:04:58 +01004780 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4781 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4782 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4783 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004784 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01004785 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4786 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4787 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4788 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4789 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4790 {}
4791};
4792
Guillaume Munch6d859062006-08-22 17:15:47 +02004793static struct hda_verb vaio_ar_init[] = {
4794 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
4795 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4796 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4797 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4798/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
4799 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004800 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Guillaume Munch6d859062006-08-22 17:15:47 +02004801 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4802 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4803/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
4804 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4805 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4806 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4807 {}
4808};
4809
Takashi Iwaidb064e52006-03-16 16:04:58 +01004810/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02004811static struct hda_bind_ctls vaio_bind_master_vol = {
4812 .ops = &snd_hda_bind_vol,
4813 .values = {
4814 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4815 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4816 0
4817 },
4818};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004819
4820/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02004821static struct hda_bind_ctls vaio_bind_master_sw = {
4822 .ops = &snd_hda_bind_sw,
4823 .values = {
4824 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4825 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4826 0,
4827 },
4828};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004829
4830static struct snd_kcontrol_new vaio_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02004831 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4832 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Takashi Iwaidb064e52006-03-16 16:04:58 +01004833 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4834 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4835 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4836 {
4837 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4838 .name = "Capture Source",
4839 .count = 1,
4840 .info = stac92xx_mux_enum_info,
4841 .get = stac92xx_mux_enum_get,
4842 .put = stac92xx_mux_enum_put,
4843 },
4844 {}
4845};
4846
Guillaume Munch6d859062006-08-22 17:15:47 +02004847static struct snd_kcontrol_new vaio_ar_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02004848 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4849 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Guillaume Munch6d859062006-08-22 17:15:47 +02004850 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4851 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4852 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4853 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
4854 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
4855 {
4856 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4857 .name = "Capture Source",
4858 .count = 1,
4859 .info = stac92xx_mux_enum_info,
4860 .get = stac92xx_mux_enum_get,
4861 .put = stac92xx_mux_enum_put,
4862 },
4863 {}
4864};
4865
4866static struct hda_codec_ops stac9872_patch_ops = {
Takashi Iwaidb064e52006-03-16 16:04:58 +01004867 .build_controls = stac92xx_build_controls,
4868 .build_pcms = stac92xx_build_pcms,
4869 .init = stac92xx_init,
4870 .free = stac92xx_free,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004871#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaidb064e52006-03-16 16:04:58 +01004872 .resume = stac92xx_resume,
4873#endif
4874};
4875
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004876static int stac9872_vaio_init(struct hda_codec *codec)
4877{
4878 int err;
4879
4880 err = stac92xx_init(codec);
4881 if (err < 0)
4882 return err;
4883 if (codec->patch_ops.unsol_event)
4884 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
4885 return 0;
4886}
4887
4888static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
4889{
Jiang Zhe40c1d302007-11-12 13:05:16 +01004890 if (get_hp_pin_presence(codec, 0x0a)) {
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004891 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4892 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4893 } else {
4894 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4895 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4896 }
4897}
4898
4899static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
4900{
4901 switch (res >> 26) {
4902 case STAC_HP_EVENT:
4903 stac9872_vaio_hp_detect(codec, res);
4904 break;
4905 }
4906}
4907
4908static struct hda_codec_ops stac9872_vaio_patch_ops = {
4909 .build_controls = stac92xx_build_controls,
4910 .build_pcms = stac92xx_build_pcms,
4911 .init = stac9872_vaio_init,
4912 .free = stac92xx_free,
4913 .unsol_event = stac9872_vaio_unsol_event,
4914#ifdef CONFIG_PM
4915 .resume = stac92xx_resume,
4916#endif
4917};
4918
Guillaume Munch6d859062006-08-22 17:15:47 +02004919enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
4920 CXD9872RD_VAIO,
4921 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
4922 STAC9872AK_VAIO,
4923 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
4924 STAC9872K_VAIO,
4925 /* AR Series. id=0x83847664 and subsys=104D1300 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004926 CXD9872AKD_VAIO,
4927 STAC_9872_MODELS,
4928};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004929
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004930static const char *stac9872_models[STAC_9872_MODELS] = {
4931 [CXD9872RD_VAIO] = "vaio",
4932 [CXD9872AKD_VAIO] = "vaio-ar",
4933};
4934
4935static struct snd_pci_quirk stac9872_cfg_tbl[] = {
4936 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
4937 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
4938 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
Tobin Davis68e22542007-03-12 11:36:39 +01004939 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
Takashi Iwaidb064e52006-03-16 16:04:58 +01004940 {}
4941};
4942
Guillaume Munch6d859062006-08-22 17:15:47 +02004943static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01004944{
4945 struct sigmatel_spec *spec;
4946 int board_config;
4947
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004948 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
4949 stac9872_models,
4950 stac9872_cfg_tbl);
Takashi Iwaidb064e52006-03-16 16:04:58 +01004951 if (board_config < 0)
4952 /* unknown config, let generic-parser do its job... */
4953 return snd_hda_parse_generic_codec(codec);
4954
4955 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4956 if (spec == NULL)
4957 return -ENOMEM;
4958
4959 codec->spec = spec;
4960 switch (board_config) {
Guillaume Munch6d859062006-08-22 17:15:47 +02004961 case CXD9872RD_VAIO:
4962 case STAC9872AK_VAIO:
4963 case STAC9872K_VAIO:
Takashi Iwaidb064e52006-03-16 16:04:58 +01004964 spec->mixer = vaio_mixer;
4965 spec->init = vaio_init;
4966 spec->multiout.max_channels = 2;
4967 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
4968 spec->multiout.dac_nids = vaio_dacs;
4969 spec->multiout.hp_nid = VAIO_HP_DAC;
4970 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
4971 spec->adc_nids = vaio_adcs;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004972 spec->num_pwrs = 0;
Takashi Iwaidb064e52006-03-16 16:04:58 +01004973 spec->input_mux = &vaio_mux;
4974 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004975 codec->patch_ops = stac9872_vaio_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01004976 break;
Guillaume Munch6d859062006-08-22 17:15:47 +02004977
4978 case CXD9872AKD_VAIO:
4979 spec->mixer = vaio_ar_mixer;
4980 spec->init = vaio_ar_init;
4981 spec->multiout.max_channels = 2;
4982 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
4983 spec->multiout.dac_nids = vaio_dacs;
4984 spec->multiout.hp_nid = VAIO_HP_DAC;
4985 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004986 spec->num_pwrs = 0;
Guillaume Munch6d859062006-08-22 17:15:47 +02004987 spec->adc_nids = vaio_adcs;
4988 spec->input_mux = &vaio_mux;
4989 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004990 codec->patch_ops = stac9872_patch_ops;
Guillaume Munch6d859062006-08-22 17:15:47 +02004991 break;
Takashi Iwaidb064e52006-03-16 16:04:58 +01004992 }
4993
Takashi Iwaidb064e52006-03-16 16:04:58 +01004994 return 0;
4995}
4996
4997
4998/*
Matt2f2f4252005-04-13 14:45:30 +02004999 * patch entries
5000 */
5001struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5002 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5003 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5004 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5005 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5006 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5007 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5008 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02005009 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5010 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5011 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5012 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5013 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5014 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01005015 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5016 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5017 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5018 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5019 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5020 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5021 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5022 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5023 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5024 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01005025 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5026 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5027 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5028 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5029 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5030 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02005031 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5032 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02005033 /* The following does not take into account .id=0x83847661 when subsys =
5034 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5035 * currently not fully supported.
5036 */
5037 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5038 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5039 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02005040 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5041 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5042 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5043 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5044 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5045 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5046 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5047 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005048 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005049 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5050 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005051 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01005052 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5053 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005054 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01005055 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5056 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5057 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5058 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5059 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5060 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5061 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5062 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02005063 {} /* terminator */
5064};