blob: 3db39adad79a6f42790e1dda2b86664d9f7a0898 [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
Matthew Ranostaya64135a2008-01-10 16:55:06 +010038#define STAC_PWR_EVENT 0x20
39#define STAC_HP_EVENT 0x30
Matthew Ranostay72474be2008-10-09 09:32:17 -040040#define STAC_VREF_EVENT 0x40
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;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400141 unsigned int spdif_mute: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200142
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100143 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200144 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100145 unsigned int gpio_mask;
146 unsigned int gpio_dir;
147 unsigned int gpio_data;
148 unsigned int gpio_mute;
149
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200150 /* stream */
151 unsigned int stream_delay;
152
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100153 /* analog loopback */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100154 unsigned char aloopback_mask;
155 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200156
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100157 /* power management */
158 unsigned int num_pwrs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200159 unsigned int *pwr_mapping;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100160 hda_nid_t *pwr_nids;
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100161 hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100162
Matt2f2f4252005-04-13 14:45:30 +0200163 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100164 struct hda_input_mux *mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400165 struct hda_input_mux *amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100166 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200167 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100168 hda_nid_t dac_nids[5];
Matt2f2f4252005-04-13 14:45:30 +0200169
170 /* capture */
171 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200172 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200173 hda_nid_t *mux_nids;
174 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200175 hda_nid_t *dmic_nids;
176 unsigned int num_dmics;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100177 hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100178 unsigned int num_dmuxes;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200179 hda_nid_t *smux_nids;
180 unsigned int num_smuxes;
Matthew Ranostay65973632008-09-16 10:39:37 -0400181 const char **spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200182
Mattdabbed62005-06-14 10:19:34 +0200183 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100184 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200185 hda_nid_t anabeep_nid;
186 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200187
Matt2f2f4252005-04-13 14:45:30 +0200188 /* pin widgets */
189 hda_nid_t *pin_nids;
190 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200191 unsigned int *pin_configs;
Richard Fish11b44bb2006-08-23 18:31:34 +0200192 unsigned int *bios_pin_configs;
Matt2f2f4252005-04-13 14:45:30 +0200193
194 /* codec specific stuff */
195 struct hda_verb *init;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100196 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200197
198 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200199 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100200 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200201 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100202 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200203 struct hda_input_mux *sinput_mux;
204 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400205 unsigned int cur_amux;
206 hda_nid_t *amp_nids;
207 unsigned int num_amps;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200208 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200209
Matt Porter403d1942005-11-29 15:00:51 +0100210 /* i/o switches */
211 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200212 unsigned int clfe_swap;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +0200213 unsigned int hp_switch;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200214 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200215
Mattc7d4b2f2005-06-27 14:59:41 +0200216 struct hda_pcm pcm_rec[2]; /* PCM information */
217
218 /* dynamic controls and input_mux */
219 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200220 struct snd_array kctls;
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 Ranostay4b33c762008-10-10 09:07:23 -0400323static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
324 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100325};
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;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400550 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200551 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400552 int err, val;
553 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200554
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400555 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200556 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400557 if (err < 0)
558 return err;
559
560 if (spec->spdif_mute) {
561 if (smux_idx == 0)
562 nid = spec->multiout.dig_out_nid;
563 else
564 nid = codec->slave_dig_outs[smux_idx - 1];
565 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
566 val = AMP_OUT_MUTE;
567 if (smux_idx == 0)
568 nid = spec->multiout.dig_out_nid;
569 else
570 nid = codec->slave_dig_outs[smux_idx - 1];
571 /* un/mute SPDIF out */
572 snd_hda_codec_write_cache(codec, nid, 0,
573 AC_VERB_SET_AMP_GAIN_MUTE, val);
574 }
575 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200576}
577
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100578static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200579{
580 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
581 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200582 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200583}
584
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100585static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200586{
587 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
588 struct sigmatel_spec *spec = codec->spec;
589 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
590
591 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
592 return 0;
593}
594
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100595static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200596{
597 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
598 struct sigmatel_spec *spec = codec->spec;
599 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
600
Mattc7d4b2f2005-06-27 14:59:41 +0200601 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200602 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
603}
604
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100605static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
606 struct snd_ctl_elem_info *uinfo)
607{
608 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
609 struct sigmatel_spec *spec = codec->spec;
610 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
611}
612
613static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
614 struct snd_ctl_elem_value *ucontrol)
615{
616 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
617 struct sigmatel_spec *spec = codec->spec;
618
619 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
620 return 0;
621}
622
623static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
624 struct snd_ctl_elem_value *ucontrol)
625{
626 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
627 struct sigmatel_spec *spec = codec->spec;
628
629 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
630 spec->mono_nid, &spec->cur_mmux);
631}
632
Matthew Ranostay89385032008-09-11 09:49:39 -0400633static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
634 struct snd_ctl_elem_info *uinfo)
635{
636 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
637 struct sigmatel_spec *spec = codec->spec;
638 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
639}
640
641static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
642 struct snd_ctl_elem_value *ucontrol)
643{
644 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
645 struct sigmatel_spec *spec = codec->spec;
646
647 ucontrol->value.enumerated.item[0] = spec->cur_amux;
648 return 0;
649}
650
651static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
652 struct snd_ctl_elem_value *ucontrol)
653{
654 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
655 struct sigmatel_spec *spec = codec->spec;
656 struct snd_kcontrol *ctl =
657 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
658 if (!ctl)
659 return -EINVAL;
660
661 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
662 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
663
664 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
665 0, &spec->cur_amux);
666}
667
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200668#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
669
670static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
671 struct snd_ctl_elem_value *ucontrol)
672{
673 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100674 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200675 struct sigmatel_spec *spec = codec->spec;
676
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100677 ucontrol->value.integer.value[0] = !!(spec->aloopback &
678 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200679 return 0;
680}
681
682static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
683 struct snd_ctl_elem_value *ucontrol)
684{
685 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
686 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100687 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200688 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100689 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200690
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100691 idx_val = spec->aloopback_mask << idx;
692 if (ucontrol->value.integer.value[0])
693 val = spec->aloopback | idx_val;
694 else
695 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100696 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200697 return 0;
698
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100699 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200700
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100701 /* Only return the bits defined by the shift value of the
702 * first two bytes of the mask
703 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200704 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100705 kcontrol->private_value & 0xFFFF, 0x0);
706 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200707
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100708 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200709 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100710 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200711 } else {
712 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100713 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200714 }
715
716 snd_hda_codec_write_cache(codec, codec->afg, 0,
717 kcontrol->private_value >> 16, dac_mode);
718
719 return 1;
720}
721
Mattc7d4b2f2005-06-27 14:59:41 +0200722static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200723 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200724 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200725 {}
726};
727
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200728static struct hda_verb stac9200_eapd_init[] = {
729 /* set dac0mux for dac converter */
730 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
731 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
732 {}
733};
734
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100735static struct hda_verb stac92hd73xx_6ch_core_init[] = {
736 /* set master volume and direct control */
737 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
738 /* setup audio connections */
739 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
740 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
741 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
742 /* setup adcs to point to mixer */
743 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
744 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100745 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
746 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
747 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
748 /* setup import muxs */
749 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
750 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
751 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
752 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
753 {}
754};
755
Matthew Ranostayd654a662008-03-14 08:46:51 +0100756static struct hda_verb dell_eq_core_init[] = {
757 /* set master volume to max value without distortion
758 * and direct control */
759 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
760 /* setup audio connections */
761 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
Matthew Ranostayf7cf0a72008-09-13 10:36:58 -0400762 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x02},
763 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100764 /* setup adcs to point to mixer */
765 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
766 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
767 /* setup import muxs */
768 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
769 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
770 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
771 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
772 {}
773};
774
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100775static struct hda_verb dell_m6_core_init[] = {
Matthew Ranostay20f5f952008-09-01 08:17:56 +0200776 /* set master volume to max value without distortion
777 * and direct control */
778 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100779 /* setup audio connections */
Matthew Ranostay7747ecc2008-03-10 11:30:04 +0100780 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
781 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100782 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
783 /* setup adcs to point to mixer */
784 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
785 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
786 /* setup import muxs */
787 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
788 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
789 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
790 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
791 {}
792};
793
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100794static struct hda_verb stac92hd73xx_8ch_core_init[] = {
795 /* set master volume and direct control */
796 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
797 /* setup audio connections */
798 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
799 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
800 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
801 /* connect hp ports to dac3 */
802 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
803 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
804 /* setup adcs to point to mixer */
805 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
806 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100807 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
808 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
809 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
810 /* setup import muxs */
811 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
812 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
813 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
814 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
815 {}
816};
817
818static struct hda_verb stac92hd73xx_10ch_core_init[] = {
819 /* set master volume and direct control */
820 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
821 /* setup audio connections */
822 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
823 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
824 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
825 /* dac3 is connected to import3 mux */
826 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
827 /* connect hp ports to dac4 */
828 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
829 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
830 /* setup adcs to point to mixer */
831 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
832 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100833 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
834 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
835 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
836 /* setup import muxs */
837 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
838 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
839 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
840 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
841 {}
842};
843
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200844static struct hda_verb stac92hd83xxx_core_init[] = {
845 /* start of config #1 */
846 { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3},
847
848 /* start of config #2 */
849 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
850 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
851 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
852
853 /* power state controls amps */
854 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
855};
856
Matthew Ranostaye035b842007-11-06 11:53:55 +0100857static struct hda_verb stac92hd71bxx_core_init[] = {
858 /* 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 Ranostay541eee82007-12-14 12:08:04 +0100862 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
863 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
864 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
865 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100866};
867
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400868#define HD_DISABLE_PORTF 2
Matthew Ranostay541eee82007-12-14 12:08:04 +0100869static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200870 /* start of config #1 */
871
872 /* connect port 0f to audio mixer */
873 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200874 /* unmute right and left channels for node 0x0f */
875 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
876 /* start of config #2 */
877
Matthew Ranostay541eee82007-12-14 12:08:04 +0100878 /* set master volume and direct control */
879 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
880 /* connect headphone jack to dac1 */
881 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200882 /* unmute right and left channels for nodes 0x0a, 0xd */
Matthew Ranostaye035b842007-11-06 11:53:55 +0100883 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
884 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100885 {}
886};
887
Tobin Davis8e21c342007-01-08 11:04:17 +0100888static struct hda_verb stac925x_core_init[] = {
889 /* set dac0mux for dac converter */
890 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
891 {}
892};
893
Mattc7d4b2f2005-06-27 14:59:41 +0200894static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200895 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200896 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200897 {}
898};
899
Tobin Davis93ed1502006-09-01 21:03:12 +0200900static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200901 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200902 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200903 /* unmute node 0x1b */
904 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
905 /* select node 0x03 as DAC */
906 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
907 {}
908};
909
Matt Porter3cc08dc2006-01-23 15:27:49 +0100910static struct hda_verb stac927x_core_init[] = {
911 /* set master volume and direct control */
912 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200913 /* enable analog pc beep path */
914 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100915 {}
916};
917
Matt Porterf3302a52006-07-31 12:49:34 +0200918static struct hda_verb stac9205_core_init[] = {
919 /* set master volume and direct control */
920 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200921 /* enable analog pc beep path */
922 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200923 {}
924};
925
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100926#define STAC_MONO_MUX \
927 { \
928 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
929 .name = "Mono Mux", \
930 .count = 1, \
931 .info = stac92xx_mono_mux_enum_info, \
932 .get = stac92xx_mono_mux_enum_get, \
933 .put = stac92xx_mono_mux_enum_put, \
934 }
935
Matthew Ranostay89385032008-09-11 09:49:39 -0400936#define STAC_AMP_MUX \
937 { \
938 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
939 .name = "Amp Selector Capture Switch", \
940 .count = 1, \
941 .info = stac92xx_amp_mux_enum_info, \
942 .get = stac92xx_amp_mux_enum_get, \
943 .put = stac92xx_amp_mux_enum_put, \
944 }
945
946#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
947 { \
948 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
949 .name = xname, \
950 .index = 0, \
951 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
952 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
953 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
954 .info = stac92xx_amp_volume_info, \
955 .get = stac92xx_amp_volume_get, \
956 .put = stac92xx_amp_volume_put, \
957 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
958 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
959 }
960
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200961#define STAC_INPUT_SOURCE(cnt) \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200962 { \
963 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
964 .name = "Input Source", \
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200965 .count = cnt, \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200966 .info = stac92xx_mux_enum_info, \
967 .get = stac92xx_mux_enum_get, \
968 .put = stac92xx_mux_enum_put, \
969 }
970
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100971#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200972 { \
973 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
974 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100975 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200976 .info = stac92xx_aloopback_info, \
977 .get = stac92xx_aloopback_get, \
978 .put = stac92xx_aloopback_put, \
979 .private_value = verb_read | (verb_write << 16), \
980 }
981
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100982static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200983 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
984 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200985 STAC_INPUT_SOURCE(1),
Matt2f2f4252005-04-13 14:45:30 +0200986 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
987 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200988 { } /* end */
989};
990
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400991#define DELL_M6_MIXER 6
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100992static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400993 /* start of config #1 */
994 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
995 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
996
997 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
998 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
999
1000 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1001 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1002
1003 /* start of config #2 */
1004 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1005 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1006
1007 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1008 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1009
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001010 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1011
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001012 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1013 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1014
1015 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1016 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1017
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001018 { } /* end */
1019};
1020
1021static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001022 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1023
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001024 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1025 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1026
1027 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1028 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1029
1030 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1031 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1032
1033 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1034 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1035
1036 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1037 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1038
1039 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1040 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1041
1042 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1043 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1044 { } /* end */
1045};
1046
1047static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001048 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1049
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001050 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1051 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1052
1053 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1054 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1055
1056 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1057 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1058
1059 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1060 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1061
1062 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1063 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1064
1065 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1066 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1067
1068 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1069 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1070 { } /* end */
1071};
1072
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001073
1074static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1075 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1076 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1077
1078 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1079 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1080
1081 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT),
1082 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
1083
1084 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
1085 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
1086
1087 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
1088 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
1089
1090 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
1091 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
1092
1093 /*
1094 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
1095 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
1096 */
1097 { } /* end */
1098};
1099
Matthew Ranostay541eee82007-12-14 12:08:04 +01001100static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001101 STAC_INPUT_SOURCE(2),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001102 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001103
Matthew Ranostay9b359472007-11-07 13:03:12 +01001104 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1105 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay9b359472007-11-07 13:03:12 +01001106
1107 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1108 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001109 /* analog pc-beep replaced with digital beep support */
1110 /*
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001111 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1112 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001113 */
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001114
Matthew Ranostay687cb982008-10-11 13:52:43 -04001115 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1116 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001117
Matthew Ranostay687cb982008-10-11 13:52:43 -04001118 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1119 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001120
1121 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1122 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1123
1124 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1125 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001126 { } /* end */
1127};
1128
Matthew Ranostay541eee82007-12-14 12:08:04 +01001129static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +01001130 STAC_INPUT_SOURCE(2),
1131 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1132
Matthew Ranostay541eee82007-12-14 12:08:04 +01001133 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1134 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001135
1136 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1137 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001138 { } /* end */
1139};
1140
Tobin Davis8e21c342007-01-08 11:04:17 +01001141static struct snd_kcontrol_new stac925x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001142 STAC_INPUT_SOURCE(1),
Tobin Davis8e21c342007-01-08 11:04:17 +01001143 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +02001144 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001145 { } /* end */
1146};
1147
Takashi Iwaid1d985f2006-11-23 19:27:12 +01001148static struct snd_kcontrol_new stac9205_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001149 STAC_INPUT_SOURCE(2),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001150 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001151
1152 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1153 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001154
1155 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1156 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001157 { } /* end */
1158};
1159
1160/* This needs to be generated dynamically based on sequence */
1161static struct snd_kcontrol_new stac922x_mixer[] = {
1162 STAC_INPUT_SOURCE(2),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001163 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1164 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001165
1166 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1167 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001168 { } /* end */
1169};
1170
1171
1172static struct snd_kcontrol_new stac927x_mixer[] = {
1173 STAC_INPUT_SOURCE(3),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001174 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001175
1176 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1177 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001178
1179 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1180 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001181
1182 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1183 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
Matt Porterf3302a52006-07-31 12:49:34 +02001184 { } /* end */
1185};
1186
Takashi Iwai1697055e2007-12-18 18:05:52 +01001187static struct snd_kcontrol_new stac_dmux_mixer = {
1188 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1189 .name = "Digital Input Source",
1190 /* count set later */
1191 .info = stac92xx_dmux_enum_info,
1192 .get = stac92xx_dmux_enum_get,
1193 .put = stac92xx_dmux_enum_put,
1194};
1195
Matthew Ranostayd9737752008-09-07 12:03:41 +02001196static struct snd_kcontrol_new stac_smux_mixer = {
1197 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001198 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001199 /* count set later */
1200 .info = stac92xx_smux_enum_info,
1201 .get = stac92xx_smux_enum_get,
1202 .put = stac92xx_smux_enum_put,
1203};
1204
Takashi Iwai2134ea42008-01-10 16:53:55 +01001205static const char *slave_vols[] = {
1206 "Front Playback Volume",
1207 "Surround Playback Volume",
1208 "Center Playback Volume",
1209 "LFE Playback Volume",
1210 "Side Playback Volume",
1211 "Headphone Playback Volume",
1212 "Headphone Playback Volume",
1213 "Speaker Playback Volume",
1214 "External Speaker Playback Volume",
1215 "Speaker2 Playback Volume",
1216 NULL
1217};
1218
1219static const char *slave_sws[] = {
1220 "Front Playback Switch",
1221 "Surround Playback Switch",
1222 "Center Playback Switch",
1223 "LFE Playback Switch",
1224 "Side Playback Switch",
1225 "Headphone Playback Switch",
1226 "Headphone Playback Switch",
1227 "Speaker Playback Switch",
1228 "External Speaker Playback Switch",
1229 "Speaker2 Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001230 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001231 NULL
1232};
1233
Takashi Iwai603c4012008-07-30 15:01:44 +02001234static void stac92xx_free_kctls(struct hda_codec *codec);
1235
Matt2f2f4252005-04-13 14:45:30 +02001236static int stac92xx_build_controls(struct hda_codec *codec)
1237{
1238 struct sigmatel_spec *spec = codec->spec;
1239 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001240 int i;
Matt2f2f4252005-04-13 14:45:30 +02001241
1242 err = snd_hda_add_new_ctls(codec, spec->mixer);
1243 if (err < 0)
1244 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001245
1246 for (i = 0; i < spec->num_mixers; i++) {
1247 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1248 if (err < 0)
1249 return err;
1250 }
Takashi Iwai1697055e2007-12-18 18:05:52 +01001251 if (spec->num_dmuxes > 0) {
1252 stac_dmux_mixer.count = spec->num_dmuxes;
1253 err = snd_ctl_add(codec->bus->card,
1254 snd_ctl_new1(&stac_dmux_mixer, codec));
1255 if (err < 0)
1256 return err;
1257 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001258 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001259 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1260 struct hda_input_mux *smux = &spec->private_smux;
1261 /* check for mute support on SPDIF out */
1262 if (wcaps & AC_WCAP_OUT_AMP) {
1263 smux->items[smux->num_items].label = "Off";
1264 smux->items[smux->num_items].index = 0;
1265 smux->num_items++;
1266 spec->spdif_mute = 1;
1267 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001268 stac_smux_mixer.count = spec->num_smuxes;
1269 err = snd_ctl_add(codec->bus->card,
1270 snd_ctl_new1(&stac_smux_mixer, codec));
1271 if (err < 0)
1272 return err;
1273 }
Mattc7d4b2f2005-06-27 14:59:41 +02001274
Mattdabbed62005-06-14 10:19:34 +02001275 if (spec->multiout.dig_out_nid) {
1276 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1277 if (err < 0)
1278 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001279 err = snd_hda_create_spdif_share_sw(codec,
1280 &spec->multiout);
1281 if (err < 0)
1282 return err;
1283 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001284 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04001285 if (spec->dig_in_nid && (!spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001286 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1287 if (err < 0)
1288 return err;
1289 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001290
1291 /* if we have no master control, let's create it */
1292 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001293 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001294 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001295 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001296 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001297 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001298 if (err < 0)
1299 return err;
1300 }
1301 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1302 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1303 NULL, slave_sws);
1304 if (err < 0)
1305 return err;
1306 }
1307
Takashi Iwai603c4012008-07-30 15:01:44 +02001308 stac92xx_free_kctls(codec); /* no longer needed */
Mattdabbed62005-06-14 10:19:34 +02001309 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001310}
1311
Matt Porter403d1942005-11-29 15:00:51 +01001312static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001313 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001314 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1315};
1316
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001317/*
1318 STAC 9200 pin configs for
1319 102801A8
1320 102801DE
1321 102801E8
1322*/
1323static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001324 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1325 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001326};
1327
1328/*
1329 STAC 9200 pin configs for
1330 102801C0
1331 102801C1
1332*/
1333static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001334 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1335 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001336};
1337
1338/*
1339 STAC 9200 pin configs for
1340 102801C4 (Dell Dimension E310)
1341 102801C5
1342 102801C7
1343 102801D9
1344 102801DA
1345 102801E3
1346*/
1347static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001348 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1349 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001350};
1351
1352
1353/*
1354 STAC 9200-32 pin configs for
1355 102801B5 (Dell Inspiron 630m)
1356 102801D8 (Dell Inspiron 640m)
1357*/
1358static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001359 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1360 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001361};
1362
1363/*
1364 STAC 9200-32 pin configs for
1365 102801C2 (Dell Latitude D620)
1366 102801C8
1367 102801CC (Dell Latitude D820)
1368 102801D4
1369 102801D6
1370*/
1371static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001372 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1373 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001374};
1375
1376/*
1377 STAC 9200-32 pin configs for
1378 102801CE (Dell XPS M1710)
1379 102801CF (Dell Precision M90)
1380*/
1381static unsigned int dell9200_m23_pin_configs[8] = {
1382 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1383 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1384};
1385
1386/*
1387 STAC 9200-32 pin configs for
1388 102801C9
1389 102801CA
1390 102801CB (Dell Latitude 120L)
1391 102801D3
1392*/
1393static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001394 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1395 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001396};
1397
1398/*
1399 STAC 9200-32 pin configs for
1400 102801BD (Dell Inspiron E1505n)
1401 102801EE
1402 102801EF
1403*/
1404static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001405 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1406 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001407};
1408
1409/*
1410 STAC 9200-32 pin configs for
1411 102801F5 (Dell Inspiron 1501)
1412 102801F6
1413*/
1414static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001415 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1416 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001417};
1418
1419/*
1420 STAC 9200-32
1421 102801CD (Dell Inspiron E1705/9400)
1422*/
1423static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001424 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1425 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001426};
1427
Tobin Davisbf277782008-02-03 20:31:47 +01001428static unsigned int oqo9200_pin_configs[8] = {
1429 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1430 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1431};
1432
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001433
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001434static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1435 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001436 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001437 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1438 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1439 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1440 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1441 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1442 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1443 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1444 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1445 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1446 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001447 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001448};
1449
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001450static const char *stac9200_models[STAC_9200_MODELS] = {
1451 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001452 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001453 [STAC_9200_DELL_D21] = "dell-d21",
1454 [STAC_9200_DELL_D22] = "dell-d22",
1455 [STAC_9200_DELL_D23] = "dell-d23",
1456 [STAC_9200_DELL_M21] = "dell-m21",
1457 [STAC_9200_DELL_M22] = "dell-m22",
1458 [STAC_9200_DELL_M23] = "dell-m23",
1459 [STAC_9200_DELL_M24] = "dell-m24",
1460 [STAC_9200_DELL_M25] = "dell-m25",
1461 [STAC_9200_DELL_M26] = "dell-m26",
1462 [STAC_9200_DELL_M27] = "dell-m27",
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001463 [STAC_9200_GATEWAY] = "gateway",
Takashi Iwai117f2572008-03-18 09:53:23 +01001464 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001465};
1466
1467static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1468 /* SigmaTel reference board */
1469 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1470 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001471 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001472 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1473 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001474 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001475 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1476 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1477 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1478 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1479 "unknown Dell", STAC_9200_DELL_D22),
1480 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1481 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001482 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001483 "Dell Latitude D620", STAC_9200_DELL_M22),
1484 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1485 "unknown Dell", STAC_9200_DELL_D23),
1486 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1487 "unknown Dell", STAC_9200_DELL_D23),
1488 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1489 "unknown Dell", STAC_9200_DELL_M22),
1490 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1491 "unknown Dell", STAC_9200_DELL_M24),
1492 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1493 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001494 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001495 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001496 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001497 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001498 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001499 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001500 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001501 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001502 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001503 "Dell Precision M90", STAC_9200_DELL_M23),
1504 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1505 "unknown Dell", STAC_9200_DELL_M22),
1506 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1507 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001508 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001509 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001510 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001511 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1512 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1513 "unknown Dell", STAC_9200_DELL_D23),
1514 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1515 "unknown Dell", STAC_9200_DELL_D23),
1516 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1517 "unknown Dell", STAC_9200_DELL_D21),
1518 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1519 "unknown Dell", STAC_9200_DELL_D23),
1520 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1521 "unknown Dell", STAC_9200_DELL_D21),
1522 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1523 "unknown Dell", STAC_9200_DELL_M25),
1524 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1525 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001526 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001527 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1528 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1529 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001530 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001531 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001532 /* Gateway machines needs EAPD to be set on resume */
1533 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1534 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1535 STAC_9200_GATEWAY),
1536 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1537 STAC_9200_GATEWAY),
Tobin Davisbf277782008-02-03 20:31:47 +01001538 /* OQO Mobile */
1539 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001540 {} /* terminator */
1541};
1542
Tobin Davis8e21c342007-01-08 11:04:17 +01001543static unsigned int ref925x_pin_configs[8] = {
1544 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001545 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001546};
1547
1548static unsigned int stac925x_MA6_pin_configs[8] = {
1549 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1550 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1551};
1552
Tobin Davis2c11f952007-05-17 09:36:34 +02001553static unsigned int stac925x_PA6_pin_configs[8] = {
1554 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1555 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1556};
1557
Tobin Davis8e21c342007-01-08 11:04:17 +01001558static unsigned int stac925xM2_2_pin_configs[8] = {
Steve Longerbeam7353e142007-05-29 14:36:17 +02001559 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1560 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001561};
1562
1563static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1564 [STAC_REF] = ref925x_pin_configs,
1565 [STAC_M2_2] = stac925xM2_2_pin_configs,
1566 [STAC_MA6] = stac925x_MA6_pin_configs,
Tobin Davis2c11f952007-05-17 09:36:34 +02001567 [STAC_PA6] = stac925x_PA6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001568};
1569
1570static const char *stac925x_models[STAC_925x_MODELS] = {
1571 [STAC_REF] = "ref",
1572 [STAC_M2_2] = "m2-2",
1573 [STAC_MA6] = "m6",
Tobin Davis2c11f952007-05-17 09:36:34 +02001574 [STAC_PA6] = "pa6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001575};
1576
1577static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1578 /* SigmaTel reference board */
1579 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001580 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Tobin Davis8e21c342007-01-08 11:04:17 +01001581 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1582 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1583 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
Tobin Davis2c11f952007-05-17 09:36:34 +02001584 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
Tobin Davis8e21c342007-01-08 11:04:17 +01001585 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1586 {} /* terminator */
1587};
1588
Matthew Ranostaya7662642008-02-21 07:51:14 +01001589static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001590 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1591 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1592 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001593 0x01452050,
1594};
1595
1596static unsigned int dell_m6_pin_configs[13] = {
1597 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001598 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001599 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1600 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001601};
1602
1603static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001604 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1605 [STAC_DELL_M6] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001606};
1607
1608static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1609 [STAC_92HD73XX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001610 [STAC_DELL_M6] = "dell-m6",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001611};
1612
1613static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1614 /* SigmaTel reference board */
1615 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001616 "DFI LanParty", STAC_92HD73XX_REF),
1617 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1618 "unknown Dell", STAC_DELL_M6),
1619 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1620 "unknown Dell", STAC_DELL_M6),
1621 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1622 "unknown Dell", STAC_DELL_M6),
1623 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1624 "unknown Dell", STAC_DELL_M6),
1625 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1626 "unknown Dell", STAC_DELL_M6),
1627 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1628 "unknown Dell", STAC_DELL_M6),
1629 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1630 "unknown Dell", STAC_DELL_M6),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001631 {} /* terminator */
1632};
1633
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001634static unsigned int ref92hd83xxx_pin_configs[14] = {
1635 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1636 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1637 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1638 0x01451160, 0x98560170,
1639};
1640
1641static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1642 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1643};
1644
1645static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1646 [STAC_92HD83XXX_REF] = "ref",
1647};
1648
1649static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1650 /* SigmaTel reference board */
1651 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1652 "DFI LanParty", STAC_92HD71BXX_REF),
1653};
1654
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001655static unsigned int ref92hd71bxx_pin_configs[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001656 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001657 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001658 0x90a000f0, 0x01452050, 0x01452050,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001659};
1660
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001661static unsigned int dell_m4_1_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001662 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001663 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001664 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001665};
1666
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001667static unsigned int dell_m4_2_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001668 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1669 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001670 0x40f000f0, 0x044413b0, 0x044413b0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001671};
1672
Matthew Ranostaye035b842007-11-06 11:53:55 +01001673static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1674 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001675 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1676 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001677 [STAC_HP_M4] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001678};
1679
1680static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1681 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001682 [STAC_DELL_M4_1] = "dell-m4-1",
1683 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001684 [STAC_HP_M4] = "hp-m4",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001685};
1686
1687static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1688 /* SigmaTel reference board */
1689 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1690 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001691 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1692 "unknown HP", STAC_HP_M4),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001693 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1694 "unknown Dell", STAC_DELL_M4_1),
1695 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1696 "unknown Dell", STAC_DELL_M4_1),
1697 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1698 "unknown Dell", STAC_DELL_M4_1),
1699 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1700 "unknown Dell", STAC_DELL_M4_1),
1701 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1702 "unknown Dell", STAC_DELL_M4_1),
1703 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1704 "unknown Dell", STAC_DELL_M4_1),
1705 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1706 "unknown Dell", STAC_DELL_M4_1),
1707 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1708 "unknown Dell", STAC_DELL_M4_2),
1709 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1710 "unknown Dell", STAC_DELL_M4_2),
1711 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1712 "unknown Dell", STAC_DELL_M4_2),
1713 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1714 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001715 {} /* terminator */
1716};
1717
Matt Porter403d1942005-11-29 15:00:51 +01001718static unsigned int ref922x_pin_configs[10] = {
1719 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1720 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001721 0x40000100, 0x40000100,
1722};
1723
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001724/*
1725 STAC 922X pin configs for
1726 102801A7
1727 102801AB
1728 102801A9
1729 102801D1
1730 102801D2
1731*/
1732static unsigned int dell_922x_d81_pin_configs[10] = {
1733 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1734 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1735 0x01813122, 0x400001f2,
1736};
1737
1738/*
1739 STAC 922X pin configs for
1740 102801AC
1741 102801D0
1742*/
1743static unsigned int dell_922x_d82_pin_configs[10] = {
1744 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1745 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1746 0x01813122, 0x400001f1,
1747};
1748
1749/*
1750 STAC 922X pin configs for
1751 102801BF
1752*/
1753static unsigned int dell_922x_m81_pin_configs[10] = {
1754 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1755 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1756 0x40C003f1, 0x405003f0,
1757};
1758
1759/*
1760 STAC 9221 A1 pin configs for
1761 102801D7 (Dell XPS M1210)
1762*/
1763static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001764 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1765 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001766 0x508003f3, 0x405003f4,
1767};
1768
Matt Porter403d1942005-11-29 15:00:51 +01001769static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001770 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001771 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1772 0x02a19120, 0x40000100,
1773};
1774
1775static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001776 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1777 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001778 0x02a19320, 0x40000100,
1779};
1780
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001781static unsigned int intel_mac_v1_pin_configs[10] = {
1782 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1783 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001784 0x400000fc, 0x400000fb,
1785};
1786
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001787static unsigned int intel_mac_v2_pin_configs[10] = {
1788 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1789 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001790 0x400000fc, 0x400000fb,
1791};
1792
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001793static unsigned int intel_mac_v3_pin_configs[10] = {
1794 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1795 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1796 0x400000fc, 0x400000fb,
1797};
1798
1799static unsigned int intel_mac_v4_pin_configs[10] = {
1800 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1801 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1802 0x400000fc, 0x400000fb,
1803};
1804
1805static unsigned int intel_mac_v5_pin_configs[10] = {
1806 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1807 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1808 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001809};
1810
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001811static unsigned int ecs202_pin_configs[10] = {
1812 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1813 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1814 0x9037012e, 0x40e000f2,
1815};
Takashi Iwai76c08822007-06-19 12:17:42 +02001816
Takashi Iwai19039bd2006-06-28 15:52:16 +02001817static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001818 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001819 [STAC_D945GTP3] = d945gtp3_pin_configs,
1820 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001821 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1822 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1823 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1824 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1825 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001826 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001827 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001828 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1829 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1830 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1831 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1832 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1833 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001834 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001835 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1836 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1837 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1838 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001839};
1840
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001841static const char *stac922x_models[STAC_922X_MODELS] = {
1842 [STAC_D945_REF] = "ref",
1843 [STAC_D945GTP5] = "5stack",
1844 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001845 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1846 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1847 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1848 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1849 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001850 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001851 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001852 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001853 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001854 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1855 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001856 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001857 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001858 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001859 [STAC_922X_DELL_D81] = "dell-d81",
1860 [STAC_922X_DELL_D82] = "dell-d82",
1861 [STAC_922X_DELL_M81] = "dell-m81",
1862 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001863};
1864
1865static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1866 /* SigmaTel reference board */
1867 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1868 "DFI LanParty", STAC_D945_REF),
1869 /* Intel 945G based systems */
1870 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1871 "Intel D945G", STAC_D945GTP3),
1872 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1873 "Intel D945G", STAC_D945GTP3),
1874 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1875 "Intel D945G", STAC_D945GTP3),
1876 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1877 "Intel D945G", STAC_D945GTP3),
1878 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1879 "Intel D945G", STAC_D945GTP3),
1880 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1881 "Intel D945G", STAC_D945GTP3),
1882 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1883 "Intel D945G", STAC_D945GTP3),
1884 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1885 "Intel D945G", STAC_D945GTP3),
1886 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1887 "Intel D945G", STAC_D945GTP3),
1888 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1889 "Intel D945G", STAC_D945GTP3),
1890 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1891 "Intel D945G", STAC_D945GTP3),
1892 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1893 "Intel D945G", STAC_D945GTP3),
1894 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1895 "Intel D945G", STAC_D945GTP3),
1896 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1897 "Intel D945G", STAC_D945GTP3),
1898 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1899 "Intel D945G", STAC_D945GTP3),
1900 /* Intel D945G 5-stack systems */
1901 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1902 "Intel D945G", STAC_D945GTP5),
1903 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1904 "Intel D945G", STAC_D945GTP5),
1905 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1906 "Intel D945G", STAC_D945GTP5),
1907 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1908 "Intel D945G", STAC_D945GTP5),
1909 /* Intel 945P based systems */
1910 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1911 "Intel D945P", STAC_D945GTP3),
1912 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1913 "Intel D945P", STAC_D945GTP3),
1914 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1915 "Intel D945P", STAC_D945GTP3),
1916 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1917 "Intel D945P", STAC_D945GTP3),
1918 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1919 "Intel D945P", STAC_D945GTP3),
1920 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1921 "Intel D945P", STAC_D945GTP5),
1922 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08001923 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001924 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001925 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001926 /* Dell systems */
1927 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1928 "unknown Dell", STAC_922X_DELL_D81),
1929 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1930 "unknown Dell", STAC_922X_DELL_D81),
1931 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1932 "unknown Dell", STAC_922X_DELL_D81),
1933 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1934 "unknown Dell", STAC_922X_DELL_D82),
1935 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1936 "unknown Dell", STAC_922X_DELL_M81),
1937 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1938 "unknown Dell", STAC_922X_DELL_D82),
1939 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1940 "unknown Dell", STAC_922X_DELL_D81),
1941 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1942 "unknown Dell", STAC_922X_DELL_D81),
1943 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1944 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001945 /* ECS/PC Chips boards */
1946 SND_PCI_QUIRK(0x1019, 0x2144,
1947 "ECS/PC chips", STAC_ECS_202),
1948 SND_PCI_QUIRK(0x1019, 0x2608,
1949 "ECS/PC chips", STAC_ECS_202),
1950 SND_PCI_QUIRK(0x1019, 0x2633,
1951 "ECS/PC chips P17G/1333", STAC_ECS_202),
1952 SND_PCI_QUIRK(0x1019, 0x2811,
1953 "ECS/PC chips", STAC_ECS_202),
1954 SND_PCI_QUIRK(0x1019, 0x2812,
1955 "ECS/PC chips", STAC_ECS_202),
1956 SND_PCI_QUIRK(0x1019, 0x2813,
1957 "ECS/PC chips", STAC_ECS_202),
1958 SND_PCI_QUIRK(0x1019, 0x2814,
1959 "ECS/PC chips", STAC_ECS_202),
1960 SND_PCI_QUIRK(0x1019, 0x2815,
1961 "ECS/PC chips", STAC_ECS_202),
1962 SND_PCI_QUIRK(0x1019, 0x2816,
1963 "ECS/PC chips", STAC_ECS_202),
1964 SND_PCI_QUIRK(0x1019, 0x2817,
1965 "ECS/PC chips", STAC_ECS_202),
1966 SND_PCI_QUIRK(0x1019, 0x2818,
1967 "ECS/PC chips", STAC_ECS_202),
1968 SND_PCI_QUIRK(0x1019, 0x2819,
1969 "ECS/PC chips", STAC_ECS_202),
1970 SND_PCI_QUIRK(0x1019, 0x2820,
1971 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01001972 {} /* terminator */
1973};
1974
Matt Porter3cc08dc2006-01-23 15:27:49 +01001975static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02001976 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1977 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1978 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1979 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01001980};
1981
Tobin Davis93ed1502006-09-01 21:03:12 +02001982static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02001983 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1984 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1985 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1986 0x40000100, 0x40000100
1987};
1988
Tobin Davis93ed1502006-09-01 21:03:12 +02001989static unsigned int d965_5st_pin_configs[14] = {
1990 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1991 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1992 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1993 0x40000100, 0x40000100
1994};
1995
Tobin Davis4ff076e2007-08-07 11:48:12 +02001996static unsigned int dell_3st_pin_configs[14] = {
1997 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1998 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001999 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002000 0x40c003fc, 0x40000100
2001};
2002
Tobin Davis93ed1502006-09-01 21:03:12 +02002003static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002004 [STAC_D965_REF] = ref927x_pin_configs,
2005 [STAC_D965_3ST] = d965_3st_pin_configs,
2006 [STAC_D965_5ST] = d965_5st_pin_configs,
2007 [STAC_DELL_3ST] = dell_3st_pin_configs,
2008 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002009};
2010
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002011static const char *stac927x_models[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002012 [STAC_D965_REF] = "ref",
2013 [STAC_D965_3ST] = "3stack",
2014 [STAC_D965_5ST] = "5stack",
2015 [STAC_DELL_3ST] = "dell-3stack",
2016 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002017};
2018
2019static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2020 /* SigmaTel reference board */
2021 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2022 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002023 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002024 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2025 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002026 /* 965 based 3 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002027 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
2028 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
2029 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
2030 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
2031 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
2032 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
2033 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
2034 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
2035 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
2036 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
2037 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
2038 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
2039 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
2040 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
2041 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
2042 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002043 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002044 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002045 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002046 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2047 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002048 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002049 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2050 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002051 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02002052 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002053 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2054 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2055 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2056 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002057 /* 965 based 5 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002058 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2059 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2060 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2061 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2062 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2063 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2064 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2065 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2066 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002067 {} /* terminator */
2068};
2069
Matt Porterf3302a52006-07-31 12:49:34 +02002070static unsigned int ref9205_pin_configs[12] = {
2071 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002072 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002073 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002074};
2075
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002076/*
2077 STAC 9205 pin configs for
2078 102801F1
2079 102801F2
2080 102801FC
2081 102801FD
2082 10280204
2083 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002084 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002085*/
2086static unsigned int dell_9205_m42_pin_configs[12] = {
2087 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2088 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2089 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2090};
2091
2092/*
2093 STAC 9205 pin configs for
2094 102801F9
2095 102801FA
2096 102801FE
2097 102801FF (Dell Precision M4300)
2098 10280206
2099 10280200
2100 10280201
2101*/
2102static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002103 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2104 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2105 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2106};
2107
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002108static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002109 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2110 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2111 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2112};
2113
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002114static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002115 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002116 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2117 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2118 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Matt Porterf3302a52006-07-31 12:49:34 +02002119};
2120
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002121static const char *stac9205_models[STAC_9205_MODELS] = {
2122 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002123 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002124 [STAC_9205_DELL_M43] = "dell-m43",
2125 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002126};
2127
2128static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2129 /* SigmaTel reference board */
2130 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2131 "DFI LanParty", STAC_9205_REF),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002132 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2133 "unknown Dell", STAC_9205_DELL_M42),
2134 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2135 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002136 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002137 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002138 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2139 "Dell Precision", STAC_9205_DELL_M43),
2140 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2141 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002142 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2143 "unknown Dell", STAC_9205_DELL_M42),
2144 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2145 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002146 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2147 "Dell Precision", STAC_9205_DELL_M43),
2148 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002149 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002150 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2151 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002152 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2153 "Dell Precision", STAC_9205_DELL_M43),
2154 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2155 "Dell Precision", STAC_9205_DELL_M43),
2156 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2157 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002158 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2159 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002160 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2161 "Dell Vostro 1500", STAC_9205_DELL_M42),
Matt Porterf3302a52006-07-31 12:49:34 +02002162 {} /* terminator */
2163};
2164
Richard Fish11b44bb2006-08-23 18:31:34 +02002165static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2166{
2167 int i;
2168 struct sigmatel_spec *spec = codec->spec;
2169
2170 if (! spec->bios_pin_configs) {
2171 spec->bios_pin_configs = kcalloc(spec->num_pins,
2172 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
2173 if (! spec->bios_pin_configs)
2174 return -ENOMEM;
2175 }
2176
2177 for (i = 0; i < spec->num_pins; i++) {
2178 hda_nid_t nid = spec->pin_nids[i];
2179 unsigned int pin_cfg;
2180
2181 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2182 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2183 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2184 nid, pin_cfg);
2185 spec->bios_pin_configs[i] = pin_cfg;
2186 }
2187
2188 return 0;
2189}
2190
Matthew Ranostay87d48362007-07-17 11:52:24 +02002191static void stac92xx_set_config_reg(struct hda_codec *codec,
2192 hda_nid_t pin_nid, unsigned int pin_config)
2193{
2194 int i;
2195 snd_hda_codec_write(codec, pin_nid, 0,
2196 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2197 pin_config & 0x000000ff);
2198 snd_hda_codec_write(codec, pin_nid, 0,
2199 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2200 (pin_config & 0x0000ff00) >> 8);
2201 snd_hda_codec_write(codec, pin_nid, 0,
2202 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2203 (pin_config & 0x00ff0000) >> 16);
2204 snd_hda_codec_write(codec, pin_nid, 0,
2205 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2206 pin_config >> 24);
2207 i = snd_hda_codec_read(codec, pin_nid, 0,
2208 AC_VERB_GET_CONFIG_DEFAULT,
2209 0x00);
2210 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2211 pin_nid, i);
2212}
2213
Matt2f2f4252005-04-13 14:45:30 +02002214static void stac92xx_set_config_regs(struct hda_codec *codec)
2215{
2216 int i;
2217 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002218
Matthew Ranostay87d48362007-07-17 11:52:24 +02002219 if (!spec->pin_configs)
2220 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002221
Matthew Ranostay87d48362007-07-17 11:52:24 +02002222 for (i = 0; i < spec->num_pins; i++)
2223 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2224 spec->pin_configs[i]);
Matt2f2f4252005-04-13 14:45:30 +02002225}
Matt2f2f4252005-04-13 14:45:30 +02002226
Matt2f2f4252005-04-13 14:45:30 +02002227/*
2228 * Analog playback callbacks
2229 */
2230static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2231 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002232 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002233{
2234 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002235 if (spec->stream_delay)
2236 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002237 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2238 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002239}
2240
2241static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2242 struct hda_codec *codec,
2243 unsigned int stream_tag,
2244 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002245 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002246{
2247 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002248 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002249}
2250
2251static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2252 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002253 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002254{
2255 struct sigmatel_spec *spec = codec->spec;
2256 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2257}
2258
2259/*
Mattdabbed62005-06-14 10:19:34 +02002260 * Digital playback callbacks
2261 */
2262static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2263 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002264 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002265{
2266 struct sigmatel_spec *spec = codec->spec;
2267 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2268}
2269
2270static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2271 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002272 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002273{
2274 struct sigmatel_spec *spec = codec->spec;
2275 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2276}
2277
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002278static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2279 struct hda_codec *codec,
2280 unsigned int stream_tag,
2281 unsigned int format,
2282 struct snd_pcm_substream *substream)
2283{
2284 struct sigmatel_spec *spec = codec->spec;
2285 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2286 stream_tag, format, substream);
2287}
2288
Mattdabbed62005-06-14 10:19:34 +02002289
2290/*
Matt2f2f4252005-04-13 14:45:30 +02002291 * Analog capture callbacks
2292 */
2293static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2294 struct hda_codec *codec,
2295 unsigned int stream_tag,
2296 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002297 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002298{
2299 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002300 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002301
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002302 if (spec->powerdown_adcs) {
2303 msleep(40);
2304 snd_hda_codec_write_cache(codec, nid, 0,
2305 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2306 }
2307 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002308 return 0;
2309}
2310
2311static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2312 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002313 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002314{
2315 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002316 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002317
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002318 snd_hda_codec_cleanup_stream(codec, nid);
2319 if (spec->powerdown_adcs)
2320 snd_hda_codec_write_cache(codec, nid, 0,
2321 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002322 return 0;
2323}
2324
Mattdabbed62005-06-14 10:19:34 +02002325static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2326 .substreams = 1,
2327 .channels_min = 2,
2328 .channels_max = 2,
2329 /* NID is set in stac92xx_build_pcms */
2330 .ops = {
2331 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002332 .close = stac92xx_dig_playback_pcm_close,
2333 .prepare = stac92xx_dig_playback_pcm_prepare
Mattdabbed62005-06-14 10:19:34 +02002334 },
2335};
2336
2337static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2338 .substreams = 1,
2339 .channels_min = 2,
2340 .channels_max = 2,
2341 /* NID is set in stac92xx_build_pcms */
2342};
2343
Matt2f2f4252005-04-13 14:45:30 +02002344static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2345 .substreams = 1,
2346 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002347 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002348 .nid = 0x02, /* NID to query formats and rates */
2349 .ops = {
2350 .open = stac92xx_playback_pcm_open,
2351 .prepare = stac92xx_playback_pcm_prepare,
2352 .cleanup = stac92xx_playback_pcm_cleanup
2353 },
2354};
2355
Matt Porter3cc08dc2006-01-23 15:27:49 +01002356static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2357 .substreams = 1,
2358 .channels_min = 2,
2359 .channels_max = 2,
2360 .nid = 0x06, /* NID to query formats and rates */
2361 .ops = {
2362 .open = stac92xx_playback_pcm_open,
2363 .prepare = stac92xx_playback_pcm_prepare,
2364 .cleanup = stac92xx_playback_pcm_cleanup
2365 },
2366};
2367
Matt2f2f4252005-04-13 14:45:30 +02002368static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002369 .channels_min = 2,
2370 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002371 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002372 .ops = {
2373 .prepare = stac92xx_capture_pcm_prepare,
2374 .cleanup = stac92xx_capture_pcm_cleanup
2375 },
2376};
2377
2378static int stac92xx_build_pcms(struct hda_codec *codec)
2379{
2380 struct sigmatel_spec *spec = codec->spec;
2381 struct hda_pcm *info = spec->pcm_rec;
2382
2383 codec->num_pcms = 1;
2384 codec->pcm_info = info;
2385
Mattc7d4b2f2005-06-27 14:59:41 +02002386 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002387 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Matt2f2f4252005-04-13 14:45:30 +02002388 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002389 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002390 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002391
2392 if (spec->alt_switch) {
2393 codec->num_pcms++;
2394 info++;
2395 info->name = "STAC92xx Analog Alt";
2396 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2397 }
Matt2f2f4252005-04-13 14:45:30 +02002398
Mattdabbed62005-06-14 10:19:34 +02002399 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2400 codec->num_pcms++;
2401 info++;
2402 info->name = "STAC92xx Digital";
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002403 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Mattdabbed62005-06-14 10:19:34 +02002404 if (spec->multiout.dig_out_nid) {
2405 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2406 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2407 }
2408 if (spec->dig_in_nid) {
2409 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2410 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2411 }
2412 }
2413
Matt2f2f4252005-04-13 14:45:30 +02002414 return 0;
2415}
2416
Takashi Iwaic960a032006-03-23 17:06:28 +01002417static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2418{
2419 unsigned int pincap = snd_hda_param_read(codec, nid,
2420 AC_PAR_PIN_CAP);
2421 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2422 if (pincap & AC_PINCAP_VREF_100)
2423 return AC_PINCTL_VREF_100;
2424 if (pincap & AC_PINCAP_VREF_80)
2425 return AC_PINCTL_VREF_80;
2426 if (pincap & AC_PINCAP_VREF_50)
2427 return AC_PINCTL_VREF_50;
2428 if (pincap & AC_PINCAP_VREF_GRD)
2429 return AC_PINCTL_VREF_GRD;
2430 return 0;
2431}
2432
Matt Porter403d1942005-11-29 15:00:51 +01002433static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2434
2435{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002436 snd_hda_codec_write_cache(codec, nid, 0,
2437 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002438}
2439
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002440#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2441
2442static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2443 struct snd_ctl_elem_value *ucontrol)
2444{
2445 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2446 struct sigmatel_spec *spec = codec->spec;
2447
2448 ucontrol->value.integer.value[0] = spec->hp_switch;
2449 return 0;
2450}
2451
2452static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2453 struct snd_ctl_elem_value *ucontrol)
2454{
2455 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2456 struct sigmatel_spec *spec = codec->spec;
2457
2458 spec->hp_switch = ucontrol->value.integer.value[0];
2459
2460 /* check to be sure that the ports are upto date with
2461 * switch changes
2462 */
2463 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2464
2465 return 1;
2466}
2467
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002468#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002469
2470static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2471{
2472 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2473 struct sigmatel_spec *spec = codec->spec;
2474 int io_idx = kcontrol-> private_value & 0xff;
2475
2476 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2477 return 0;
2478}
2479
2480static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2481{
2482 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2483 struct sigmatel_spec *spec = codec->spec;
2484 hda_nid_t nid = kcontrol->private_value >> 8;
2485 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002486 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002487
2488 spec->io_switch[io_idx] = val;
2489
2490 if (val)
2491 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002492 else {
2493 unsigned int pinctl = AC_PINCTL_IN_EN;
2494 if (io_idx) /* set VREF for mic */
2495 pinctl |= stac92xx_get_vref(codec, nid);
2496 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2497 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002498
2499 /* check the auto-mute again: we need to mute/unmute the speaker
2500 * appropriately according to the pin direction
2501 */
2502 if (spec->hp_detect)
2503 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2504
Matt Porter403d1942005-11-29 15:00:51 +01002505 return 1;
2506}
2507
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002508#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2509
2510static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2511 struct snd_ctl_elem_value *ucontrol)
2512{
2513 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2514 struct sigmatel_spec *spec = codec->spec;
2515
2516 ucontrol->value.integer.value[0] = spec->clfe_swap;
2517 return 0;
2518}
2519
2520static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2521 struct snd_ctl_elem_value *ucontrol)
2522{
2523 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2524 struct sigmatel_spec *spec = codec->spec;
2525 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002526 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002527
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002528 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002529 return 0;
2530
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002531 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002532
2533 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2534 spec->clfe_swap ? 0x4 : 0x0);
2535
2536 return 1;
2537}
2538
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002539#define STAC_CODEC_HP_SWITCH(xname) \
2540 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2541 .name = xname, \
2542 .index = 0, \
2543 .info = stac92xx_hp_switch_info, \
2544 .get = stac92xx_hp_switch_get, \
2545 .put = stac92xx_hp_switch_put, \
2546 }
2547
Matt Porter403d1942005-11-29 15:00:51 +01002548#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2549 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2550 .name = xname, \
2551 .index = 0, \
2552 .info = stac92xx_io_switch_info, \
2553 .get = stac92xx_io_switch_get, \
2554 .put = stac92xx_io_switch_put, \
2555 .private_value = xpval, \
2556 }
2557
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002558#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2559 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2560 .name = xname, \
2561 .index = 0, \
2562 .info = stac92xx_clfe_switch_info, \
2563 .get = stac92xx_clfe_switch_get, \
2564 .put = stac92xx_clfe_switch_put, \
2565 .private_value = xpval, \
2566 }
Matt Porter403d1942005-11-29 15:00:51 +01002567
Mattc7d4b2f2005-06-27 14:59:41 +02002568enum {
2569 STAC_CTL_WIDGET_VOL,
2570 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002571 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002572 STAC_CTL_WIDGET_AMP_MUX,
2573 STAC_CTL_WIDGET_AMP_VOL,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002574 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002575 STAC_CTL_WIDGET_IO_SWITCH,
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002576 STAC_CTL_WIDGET_CLFE_SWITCH
Mattc7d4b2f2005-06-27 14:59:41 +02002577};
2578
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002579static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002580 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2581 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002582 STAC_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002583 STAC_AMP_MUX,
2584 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002585 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002586 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002587 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002588};
2589
2590/* add dynamic controls */
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002591static int stac92xx_add_control_idx(struct sigmatel_spec *spec, int type,
2592 int idx, const char *name, unsigned long val)
Mattc7d4b2f2005-06-27 14:59:41 +02002593{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002594 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002595
Takashi Iwai603c4012008-07-30 15:01:44 +02002596 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2597 knew = snd_array_new(&spec->kctls);
2598 if (!knew)
2599 return -ENOMEM;
Mattc7d4b2f2005-06-27 14:59:41 +02002600 *knew = stac92xx_control_templates[type];
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002601 knew->index = idx;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002602 knew->name = kstrdup(name, GFP_KERNEL);
Mattc7d4b2f2005-06-27 14:59:41 +02002603 if (! knew->name)
2604 return -ENOMEM;
2605 knew->private_value = val;
Mattc7d4b2f2005-06-27 14:59:41 +02002606 return 0;
2607}
2608
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002609
2610/* add dynamic controls */
2611static int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2612 const char *name, unsigned long val)
2613{
2614 return stac92xx_add_control_idx(spec, type, 0, name, val);
2615}
2616
Matt Porter403d1942005-11-29 15:00:51 +01002617/* flag inputs as additional dynamic lineouts */
2618static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2619{
2620 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002621 unsigned int wcaps, wtype;
2622 int i, num_dacs = 0;
2623
2624 /* use the wcaps cache to count all DACs available for line-outs */
2625 for (i = 0; i < codec->num_nodes; i++) {
2626 wcaps = codec->wcaps[i];
2627 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002628
Steve Longerbeam7b043892007-05-03 20:50:03 +02002629 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2630 num_dacs++;
2631 }
Matt Porter403d1942005-11-29 15:00:51 +01002632
Steve Longerbeam7b043892007-05-03 20:50:03 +02002633 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2634
Matt Porter403d1942005-11-29 15:00:51 +01002635 switch (cfg->line_outs) {
2636 case 3:
2637 /* add line-in as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002638 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002639 cfg->line_out_pins[cfg->line_outs] =
2640 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002641 spec->line_switch = 1;
2642 cfg->line_outs++;
2643 }
2644 break;
2645 case 2:
2646 /* add line-in as clfe and mic as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002647 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002648 cfg->line_out_pins[cfg->line_outs] =
2649 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002650 spec->line_switch = 1;
2651 cfg->line_outs++;
2652 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002653 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002654 cfg->line_out_pins[cfg->line_outs] =
2655 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002656 spec->mic_switch = 1;
2657 cfg->line_outs++;
2658 }
2659 break;
2660 case 1:
2661 /* add line-in as surr and mic as clfe */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002662 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002663 cfg->line_out_pins[cfg->line_outs] =
2664 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002665 spec->line_switch = 1;
2666 cfg->line_outs++;
2667 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002668 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002669 cfg->line_out_pins[cfg->line_outs] =
2670 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002671 spec->mic_switch = 1;
2672 cfg->line_outs++;
2673 }
2674 break;
2675 }
2676
2677 return 0;
2678}
2679
Steve Longerbeam7b043892007-05-03 20:50:03 +02002680
2681static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2682{
2683 int i;
2684
2685 for (i = 0; i < spec->multiout.num_dacs; i++) {
2686 if (spec->multiout.dac_nids[i] == nid)
2687 return 1;
2688 }
2689
2690 return 0;
2691}
2692
Matt Porter3cc08dc2006-01-23 15:27:49 +01002693/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02002694 * Fill in the dac_nids table from the parsed pin configuration
2695 * This function only works when every pin in line_out_pins[]
2696 * contains atleast one DAC in its connection list. Some 92xx
2697 * codecs are not connected directly to a DAC, such as the 9200
2698 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002699 */
Takashi Iwai19039bd2006-06-28 15:52:16 +02002700static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaidf802952007-07-02 19:18:00 +02002701 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002702{
2703 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002704 int i, j, conn_len = 0;
2705 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2706 unsigned int wcaps, wtype;
2707
Mattc7d4b2f2005-06-27 14:59:41 +02002708 for (i = 0; i < cfg->line_outs; i++) {
2709 nid = cfg->line_out_pins[i];
Steve Longerbeam7b043892007-05-03 20:50:03 +02002710 conn_len = snd_hda_get_connections(codec, nid, conn,
2711 HDA_MAX_CONNECTIONS);
2712 for (j = 0; j < conn_len; j++) {
2713 wcaps = snd_hda_param_read(codec, conn[j],
2714 AC_PAR_AUDIO_WIDGET_CAP);
2715 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002716 if (wtype != AC_WID_AUD_OUT ||
2717 (wcaps & AC_WCAP_DIGITAL))
2718 continue;
2719 /* conn[j] is a DAC routed to this line-out */
2720 if (!is_in_dac_nids(spec, conn[j]))
2721 break;
2722 }
2723
2724 if (j == conn_len) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002725 if (spec->multiout.num_dacs > 0) {
2726 /* we have already working output pins,
2727 * so let's drop the broken ones again
2728 */
2729 cfg->line_outs = spec->multiout.num_dacs;
2730 break;
2731 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002732 /* error out, no available DAC found */
2733 snd_printk(KERN_ERR
2734 "%s: No available DAC for pin 0x%x\n",
2735 __func__, nid);
2736 return -ENODEV;
2737 }
2738
2739 spec->multiout.dac_nids[i] = conn[j];
2740 spec->multiout.num_dacs++;
2741 if (conn_len > 1) {
2742 /* select this DAC in the pin's input mux */
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002743 snd_hda_codec_write_cache(codec, nid, 0,
2744 AC_VERB_SET_CONNECT_SEL, j);
Steve Longerbeam7b043892007-05-03 20:50:03 +02002745
2746 }
Mattc7d4b2f2005-06-27 14:59:41 +02002747 }
2748
Steve Longerbeam7b043892007-05-03 20:50:03 +02002749 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2750 spec->multiout.num_dacs,
2751 spec->multiout.dac_nids[0],
2752 spec->multiout.dac_nids[1],
2753 spec->multiout.dac_nids[2],
2754 spec->multiout.dac_nids[3],
2755 spec->multiout.dac_nids[4]);
Mattc7d4b2f2005-06-27 14:59:41 +02002756 return 0;
2757}
2758
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002759/* create volume control/switch for the given prefx type */
2760static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2761{
2762 char name[32];
2763 int err;
2764
2765 sprintf(name, "%s Playback Volume", pfx);
2766 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2767 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2768 if (err < 0)
2769 return err;
2770 sprintf(name, "%s Playback Switch", pfx);
2771 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2772 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2773 if (err < 0)
2774 return err;
2775 return 0;
2776}
2777
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002778static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2779{
2780 if (!spec->multiout.hp_nid)
2781 spec->multiout.hp_nid = nid;
2782 else if (spec->multiout.num_dacs > 4) {
2783 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2784 return 1;
2785 } else {
2786 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2787 spec->multiout.num_dacs++;
2788 }
2789 return 0;
2790}
2791
2792static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2793{
2794 if (is_in_dac_nids(spec, nid))
2795 return 1;
2796 if (spec->multiout.hp_nid == nid)
2797 return 1;
2798 return 0;
2799}
2800
Mattc7d4b2f2005-06-27 14:59:41 +02002801/* add playback controls from the parsed DAC table */
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002802static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
Takashi Iwai19039bd2006-06-28 15:52:16 +02002803 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002804{
Takashi Iwai19039bd2006-06-28 15:52:16 +02002805 static const char *chname[4] = {
2806 "Front", "Surround", NULL /*CLFE*/, "Side"
2807 };
Mattc7d4b2f2005-06-27 14:59:41 +02002808 hda_nid_t nid;
2809 int i, err;
2810
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002811 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002812 unsigned int wid_caps, pincap;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002813
2814
Takashi Iwai40ac8c42008-02-29 14:16:17 +01002815 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
Matt Porter403d1942005-11-29 15:00:51 +01002816 if (!spec->multiout.dac_nids[i])
Mattc7d4b2f2005-06-27 14:59:41 +02002817 continue;
2818
2819 nid = spec->multiout.dac_nids[i];
2820
2821 if (i == 2) {
2822 /* Center/LFE */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002823 err = create_controls(spec, "Center", nid, 1);
2824 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002825 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002826 err = create_controls(spec, "LFE", nid, 2);
2827 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002828 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002829
2830 wid_caps = get_wcaps(codec, nid);
2831
2832 if (wid_caps & AC_WCAP_LR_SWAP) {
2833 err = stac92xx_add_control(spec,
2834 STAC_CTL_WIDGET_CLFE_SWITCH,
2835 "Swap Center/LFE Playback Switch", nid);
2836
2837 if (err < 0)
2838 return err;
2839 }
2840
Mattc7d4b2f2005-06-27 14:59:41 +02002841 } else {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002842 err = create_controls(spec, chname[i], nid, 3);
2843 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002844 return err;
2845 }
2846 }
2847
Matthew Ranostayfedb7562008-09-23 21:46:30 -04002848 if ((spec->multiout.num_dacs - cfg->line_outs) > 0 &&
2849 cfg->hp_outs && !spec->multiout.hp_nid)
2850 spec->multiout.hp_nid = nid;
2851
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002852 if (cfg->hp_outs > 1) {
2853 err = stac92xx_add_control(spec,
2854 STAC_CTL_WIDGET_HP_SWITCH,
2855 "Headphone as Line Out Switch", 0);
2856 if (err < 0)
2857 return err;
2858 }
2859
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002860 if (spec->line_switch) {
2861 nid = cfg->input_pins[AUTO_PIN_LINE];
2862 pincap = snd_hda_param_read(codec, nid,
2863 AC_PAR_PIN_CAP);
2864 if (pincap & AC_PINCAP_OUT) {
2865 err = stac92xx_add_control(spec,
2866 STAC_CTL_WIDGET_IO_SWITCH,
2867 "Line In as Output Switch", nid << 8);
2868 if (err < 0)
2869 return err;
2870 }
2871 }
Matt Porter403d1942005-11-29 15:00:51 +01002872
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002873 if (spec->mic_switch) {
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002874 unsigned int def_conf;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002875 unsigned int mic_pin = AUTO_PIN_MIC;
2876again:
2877 nid = cfg->input_pins[mic_pin];
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002878 def_conf = snd_hda_codec_read(codec, nid, 0,
2879 AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002880 /* some laptops have an internal analog microphone
2881 * which can't be used as a output */
2882 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2883 pincap = snd_hda_param_read(codec, nid,
2884 AC_PAR_PIN_CAP);
2885 if (pincap & AC_PINCAP_OUT) {
2886 err = stac92xx_add_control(spec,
2887 STAC_CTL_WIDGET_IO_SWITCH,
2888 "Mic as Output Switch", (nid << 8) | 1);
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002889 nid = snd_hda_codec_read(codec, nid, 0,
2890 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2891 if (!check_in_dac_nids(spec, nid))
2892 add_spec_dacs(spec, nid);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002893 if (err < 0)
2894 return err;
2895 }
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002896 } else if (mic_pin == AUTO_PIN_MIC) {
2897 mic_pin = AUTO_PIN_FRONT_MIC;
2898 goto again;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002899 }
2900 }
Matt Porter403d1942005-11-29 15:00:51 +01002901
Mattc7d4b2f2005-06-27 14:59:41 +02002902 return 0;
2903}
2904
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002905/* add playback controls for Speaker and HP outputs */
2906static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2907 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002908{
2909 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02002910 hda_nid_t nid;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002911 int i, old_num_dacs, err;
Mattc7d4b2f2005-06-27 14:59:41 +02002912
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002913 old_num_dacs = spec->multiout.num_dacs;
2914 for (i = 0; i < cfg->hp_outs; i++) {
2915 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2916 if (wid_caps & AC_WCAP_UNSOL_CAP)
2917 spec->hp_detect = 1;
2918 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2919 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2920 if (check_in_dac_nids(spec, nid))
2921 nid = 0;
2922 if (! nid)
Mattc7d4b2f2005-06-27 14:59:41 +02002923 continue;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002924 add_spec_dacs(spec, nid);
2925 }
2926 for (i = 0; i < cfg->speaker_outs; i++) {
Steve Longerbeam7b043892007-05-03 20:50:03 +02002927 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002928 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2929 if (check_in_dac_nids(spec, nid))
2930 nid = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002931 if (! nid)
2932 continue;
2933 add_spec_dacs(spec, nid);
Mattc7d4b2f2005-06-27 14:59:41 +02002934 }
Matthew Ranostay1b290a52007-07-12 15:17:34 +02002935 for (i = 0; i < cfg->line_outs; i++) {
2936 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2937 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2938 if (check_in_dac_nids(spec, nid))
2939 nid = 0;
2940 if (! nid)
2941 continue;
2942 add_spec_dacs(spec, nid);
2943 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002944 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2945 static const char *pfxs[] = {
2946 "Speaker", "External Speaker", "Speaker2",
2947 };
2948 err = create_controls(spec, pfxs[i - old_num_dacs],
2949 spec->multiout.dac_nids[i], 3);
2950 if (err < 0)
2951 return err;
2952 }
2953 if (spec->multiout.hp_nid) {
Takashi Iwai2626a262008-03-14 09:18:32 +01002954 err = create_controls(spec, "Headphone",
2955 spec->multiout.hp_nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002956 if (err < 0)
2957 return err;
2958 }
Mattc7d4b2f2005-06-27 14:59:41 +02002959
2960 return 0;
2961}
2962
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002963/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002964static const char *stac92xx_mono_labels[4] = {
2965 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002966};
2967
2968/* create mono mux for mono out on capable codecs */
2969static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
2970{
2971 struct sigmatel_spec *spec = codec->spec;
2972 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
2973 int i, num_cons;
2974 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
2975
2976 num_cons = snd_hda_get_connections(codec,
2977 spec->mono_nid,
2978 con_lst,
2979 HDA_MAX_NUM_INPUTS);
2980 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
2981 return -EINVAL;
2982
2983 for (i = 0; i < num_cons; i++) {
2984 mono_mux->items[mono_mux->num_items].label =
2985 stac92xx_mono_labels[i];
2986 mono_mux->items[mono_mux->num_items].index = i;
2987 mono_mux->num_items++;
2988 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01002989
2990 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
2991 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002992}
2993
Matthew Ranostay89385032008-09-11 09:49:39 -04002994/* labels for amp mux outputs */
2995static const char *stac92xx_amp_labels[3] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04002996 "Front Microphone", "Microphone", "Line In",
Matthew Ranostay89385032008-09-11 09:49:39 -04002997};
2998
2999/* create amp out controls mux on capable codecs */
3000static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3001{
3002 struct sigmatel_spec *spec = codec->spec;
3003 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3004 int i, err;
3005
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003006 for (i = 0; i < spec->num_amps; i++) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003007 amp_mux->items[amp_mux->num_items].label =
3008 stac92xx_amp_labels[i];
3009 amp_mux->items[amp_mux->num_items].index = i;
3010 amp_mux->num_items++;
3011 }
3012
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003013 if (spec->num_amps > 1) {
3014 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3015 "Amp Selector Capture Switch", 0);
3016 if (err < 0)
3017 return err;
3018 }
Matthew Ranostay89385032008-09-11 09:49:39 -04003019 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3020 "Amp Capture Volume",
3021 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3022}
3023
3024
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003025/* create PC beep volume controls */
3026static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3027 hda_nid_t nid)
3028{
3029 struct sigmatel_spec *spec = codec->spec;
3030 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3031 int err;
3032
3033 /* check for mute support for the the amp */
3034 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3035 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3036 "PC Beep Playback Switch",
3037 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3038 if (err < 0)
3039 return err;
3040 }
3041
3042 /* check to see if there is volume support for the amp */
3043 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3044 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3045 "PC Beep Playback Volume",
3046 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3047 if (err < 0)
3048 return err;
3049 }
3050 return 0;
3051}
3052
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003053static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3054{
3055 struct sigmatel_spec *spec = codec->spec;
3056 int wcaps, nid, i, err = 0;
3057
3058 for (i = 0; i < spec->num_muxes; i++) {
3059 nid = spec->mux_nids[i];
3060 wcaps = get_wcaps(codec, nid);
3061
3062 if (wcaps & AC_WCAP_OUT_AMP) {
3063 err = stac92xx_add_control_idx(spec,
3064 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3065 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3066 if (err < 0)
3067 return err;
3068 }
3069 }
3070 return 0;
3071};
3072
Matthew Ranostayd9737752008-09-07 12:03:41 +02003073static const char *stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003074 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003075};
3076
3077static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3078{
3079 struct sigmatel_spec *spec = codec->spec;
3080 struct hda_input_mux *spdif_mux = &spec->private_smux;
Matthew Ranostay65973632008-09-16 10:39:37 -04003081 const char **labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003082 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003083 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003084
3085 num_cons = snd_hda_get_connections(codec,
3086 spec->smux_nids[0],
3087 con_lst,
3088 HDA_MAX_NUM_INPUTS);
Matthew Ranostay65973632008-09-16 10:39:37 -04003089 if (!num_cons)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003090 return -EINVAL;
3091
Matthew Ranostay65973632008-09-16 10:39:37 -04003092 if (!labels)
3093 labels = stac92xx_spdif_labels;
3094
Matthew Ranostayd9737752008-09-07 12:03:41 +02003095 for (i = 0; i < num_cons; i++) {
Matthew Ranostay65973632008-09-16 10:39:37 -04003096 spdif_mux->items[spdif_mux->num_items].label = labels[i];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003097 spdif_mux->items[spdif_mux->num_items].index = i;
3098 spdif_mux->num_items++;
3099 }
3100
3101 return 0;
3102}
3103
Matt Porter8b657272006-10-26 17:12:59 +02003104/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003105static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003106 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3107 "Digital Mic 3", "Digital Mic 4"
3108};
3109
3110/* create playback/capture controls for input pins on dmic capable codecs */
3111static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3112 const struct auto_pin_cfg *cfg)
3113{
3114 struct sigmatel_spec *spec = codec->spec;
3115 struct hda_input_mux *dimux = &spec->private_dimux;
3116 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003117 int err, i, j;
3118 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02003119
3120 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3121 dimux->items[dimux->num_items].index = 0;
3122 dimux->num_items++;
3123
3124 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003125 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003126 int index;
3127 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003128 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02003129 unsigned int def_conf;
3130
3131 def_conf = snd_hda_codec_read(codec,
3132 spec->dmic_nids[i],
3133 0,
3134 AC_VERB_GET_CONFIG_DEFAULT,
3135 0);
3136 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3137 continue;
3138
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003139 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02003140 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003141 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02003142 con_lst,
3143 HDA_MAX_NUM_INPUTS);
3144 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003145 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02003146 index = j;
3147 goto found;
3148 }
3149 continue;
3150found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003151 wcaps = get_wcaps(codec, nid) &
3152 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003153
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003154 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003155 sprintf(name, "%s Capture Volume",
3156 stac92xx_dmic_labels[dimux->num_items]);
3157
3158 err = stac92xx_add_control(spec,
3159 STAC_CTL_WIDGET_VOL,
3160 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003161 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3162 (wcaps & AC_WCAP_OUT_AMP) ?
3163 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003164 if (err < 0)
3165 return err;
3166 }
3167
Matt Porter8b657272006-10-26 17:12:59 +02003168 dimux->items[dimux->num_items].label =
3169 stac92xx_dmic_labels[dimux->num_items];
3170 dimux->items[dimux->num_items].index = index;
3171 dimux->num_items++;
3172 }
3173
3174 return 0;
3175}
3176
Mattc7d4b2f2005-06-27 14:59:41 +02003177/* create playback/capture controls for input pins */
3178static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3179{
3180 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003181 struct hda_input_mux *imux = &spec->private_imux;
3182 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3183 int i, j, k;
3184
3185 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003186 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02003187
Takashi Iwai314634b2006-09-21 11:56:18 +02003188 if (!cfg->input_pins[i])
3189 continue;
3190 index = -1;
3191 for (j = 0; j < spec->num_muxes; j++) {
3192 int num_cons;
3193 num_cons = snd_hda_get_connections(codec,
3194 spec->mux_nids[j],
3195 con_lst,
3196 HDA_MAX_NUM_INPUTS);
3197 for (k = 0; k < num_cons; k++)
3198 if (con_lst[k] == cfg->input_pins[i]) {
3199 index = k;
3200 goto found;
3201 }
Mattc7d4b2f2005-06-27 14:59:41 +02003202 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003203 continue;
3204 found:
3205 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3206 imux->items[imux->num_items].index = index;
3207 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003208 }
3209
Steve Longerbeam7b043892007-05-03 20:50:03 +02003210 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003211 /*
3212 * Set the current input for the muxes.
3213 * The STAC9221 has two input muxes with identical source
3214 * NID lists. Hopefully this won't get confused.
3215 */
3216 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003217 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3218 AC_VERB_SET_CONNECT_SEL,
3219 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003220 }
3221 }
3222
Mattc7d4b2f2005-06-27 14:59:41 +02003223 return 0;
3224}
3225
Mattc7d4b2f2005-06-27 14:59:41 +02003226static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3227{
3228 struct sigmatel_spec *spec = codec->spec;
3229 int i;
3230
3231 for (i = 0; i < spec->autocfg.line_outs; i++) {
3232 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3233 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3234 }
3235}
3236
3237static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3238{
3239 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003240 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003241
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003242 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3243 hda_nid_t pin;
3244 pin = spec->autocfg.hp_pins[i];
3245 if (pin) /* connect to front */
3246 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3247 }
3248 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3249 hda_nid_t pin;
3250 pin = spec->autocfg.speaker_pins[i];
3251 if (pin) /* connect to front */
3252 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3253 }
Mattc7d4b2f2005-06-27 14:59:41 +02003254}
3255
Matt Porter3cc08dc2006-01-23 15:27:49 +01003256static 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 +02003257{
3258 struct sigmatel_spec *spec = codec->spec;
3259 int err;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003260 int hp_speaker_swap = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003261
Matt Porter8b657272006-10-26 17:12:59 +02003262 if ((err = snd_hda_parse_pin_def_config(codec,
3263 &spec->autocfg,
3264 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003265 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003266 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003267 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003268
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003269 /* If we have no real line-out pin and multiple hp-outs, HPs should
3270 * be set up as multi-channel outputs.
3271 */
3272 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3273 spec->autocfg.hp_outs > 1) {
3274 /* Copy hp_outs to line_outs, backup line_outs in
3275 * speaker_outs so that the following routines can handle
3276 * HP pins as primary outputs.
3277 */
3278 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3279 sizeof(spec->autocfg.line_out_pins));
3280 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3281 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3282 sizeof(spec->autocfg.hp_pins));
3283 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3284 hp_speaker_swap = 1;
3285 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003286 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003287 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3288 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003289 u32 caps = query_amp_caps(codec,
3290 spec->autocfg.mono_out_pin, dir);
3291 hda_nid_t conn_list[1];
3292
3293 /* get the mixer node and then the mono mux if it exists */
3294 if (snd_hda_get_connections(codec,
3295 spec->autocfg.mono_out_pin, conn_list, 1) &&
3296 snd_hda_get_connections(codec, conn_list[0],
3297 conn_list, 1)) {
3298
3299 int wcaps = get_wcaps(codec, conn_list[0]);
3300 int wid_type = (wcaps & AC_WCAP_TYPE)
3301 >> AC_WCAP_TYPE_SHIFT;
3302 /* LR swap check, some stac925x have a mux that
3303 * changes the DACs output path instead of the
3304 * mono-mux path.
3305 */
3306 if (wid_type == AC_WID_AUD_SEL &&
3307 !(wcaps & AC_WCAP_LR_SWAP))
3308 spec->mono_nid = conn_list[0];
3309 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003310 if (dir) {
3311 hda_nid_t nid = spec->autocfg.mono_out_pin;
3312
3313 /* most mono outs have a least a mute/unmute switch */
3314 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3315 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3316 "Mono Playback Switch",
3317 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003318 if (err < 0)
3319 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003320 /* check for volume support for the amp */
3321 if ((caps & AC_AMPCAP_NUM_STEPS)
3322 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3323 err = stac92xx_add_control(spec,
3324 STAC_CTL_WIDGET_VOL,
3325 "Mono Playback Volume",
3326 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3327 if (err < 0)
3328 return err;
3329 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003330 }
3331
3332 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3333 AC_PINCTL_OUT_EN);
3334 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003335
Matt Porter403d1942005-11-29 15:00:51 +01003336 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
3337 return err;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003338 if (spec->multiout.num_dacs == 0)
3339 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
3340 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003341
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003342 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
3343
3344 if (err < 0)
3345 return err;
3346
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003347 /* setup analog beep controls */
3348 if (spec->anabeep_nid > 0) {
3349 err = stac92xx_auto_create_beep_ctls(codec,
3350 spec->anabeep_nid);
3351 if (err < 0)
3352 return err;
3353 }
3354
3355 /* setup digital beep controls and input device */
3356#ifdef CONFIG_SND_HDA_INPUT_BEEP
3357 if (spec->digbeep_nid > 0) {
3358 hda_nid_t nid = spec->digbeep_nid;
3359
3360 err = stac92xx_auto_create_beep_ctls(codec, nid);
3361 if (err < 0)
3362 return err;
3363 err = snd_hda_attach_beep_device(codec, nid);
3364 if (err < 0)
3365 return err;
3366 }
3367#endif
3368
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003369 if (hp_speaker_swap == 1) {
3370 /* Restore the hp_outs and line_outs */
3371 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3372 sizeof(spec->autocfg.line_out_pins));
3373 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3374 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
3375 sizeof(spec->autocfg.speaker_pins));
3376 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
3377 memset(spec->autocfg.speaker_pins, 0,
3378 sizeof(spec->autocfg.speaker_pins));
3379 spec->autocfg.speaker_outs = 0;
3380 }
3381
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003382 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3383
3384 if (err < 0)
3385 return err;
3386
3387 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3388
3389 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003390 return err;
3391
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003392 if (spec->mono_nid > 0) {
3393 err = stac92xx_auto_create_mono_output_ctls(codec);
3394 if (err < 0)
3395 return err;
3396 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003397 if (spec->num_amps > 0) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003398 err = stac92xx_auto_create_amp_output_ctls(codec);
3399 if (err < 0)
3400 return err;
3401 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003402 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003403 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3404 &spec->autocfg)) < 0)
3405 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003406 if (spec->num_muxes > 0) {
3407 err = stac92xx_auto_create_mux_input_ctls(codec);
3408 if (err < 0)
3409 return err;
3410 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003411 if (spec->num_smuxes > 0) {
3412 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3413 if (err < 0)
3414 return err;
3415 }
Matt Porter8b657272006-10-26 17:12:59 +02003416
Mattc7d4b2f2005-06-27 14:59:41 +02003417 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003418 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003419 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003420
Takashi Iwai82bc9552006-03-21 11:24:42 +01003421 if (spec->autocfg.dig_out_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003422 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003423 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003424 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003425
Takashi Iwai603c4012008-07-30 15:01:44 +02003426 if (spec->kctls.list)
3427 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003428
3429 spec->input_mux = &spec->private_imux;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003430 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003431 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003432 spec->mono_mux = &spec->private_mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -04003433 spec->amp_mux = &spec->private_amp_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003434 return 1;
3435}
3436
Takashi Iwai82bc9552006-03-21 11:24:42 +01003437/* add playback controls for HP output */
3438static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3439 struct auto_pin_cfg *cfg)
3440{
3441 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003442 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003443 unsigned int wid_caps;
3444
3445 if (! pin)
3446 return 0;
3447
3448 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003449 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003450 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003451
3452 return 0;
3453}
3454
Richard Fish160ea0d2006-09-06 13:58:25 +02003455/* add playback controls for LFE output */
3456static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3457 struct auto_pin_cfg *cfg)
3458{
3459 struct sigmatel_spec *spec = codec->spec;
3460 int err;
3461 hda_nid_t lfe_pin = 0x0;
3462 int i;
3463
3464 /*
3465 * search speaker outs and line outs for a mono speaker pin
3466 * with an amp. If one is found, add LFE controls
3467 * for it.
3468 */
3469 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3470 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003471 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003472 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3473 if (wcaps == AC_WCAP_OUT_AMP)
3474 /* found a mono speaker with an amp, must be lfe */
3475 lfe_pin = pin;
3476 }
3477
3478 /* if speaker_outs is 0, then speakers may be in line_outs */
3479 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3480 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3481 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003482 unsigned int defcfg;
Harvey Harrison8b551782008-02-29 11:56:48 +01003483 defcfg = snd_hda_codec_read(codec, pin, 0,
Richard Fish160ea0d2006-09-06 13:58:25 +02003484 AC_VERB_GET_CONFIG_DEFAULT,
3485 0x00);
Harvey Harrison8b551782008-02-29 11:56:48 +01003486 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003487 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003488 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3489 if (wcaps == AC_WCAP_OUT_AMP)
3490 /* found a mono speaker with an amp,
3491 must be lfe */
3492 lfe_pin = pin;
3493 }
3494 }
3495 }
3496
3497 if (lfe_pin) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003498 err = create_controls(spec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003499 if (err < 0)
3500 return err;
3501 }
3502
3503 return 0;
3504}
3505
Mattc7d4b2f2005-06-27 14:59:41 +02003506static int stac9200_parse_auto_config(struct hda_codec *codec)
3507{
3508 struct sigmatel_spec *spec = codec->spec;
3509 int err;
3510
Kailang Yangdf694da2005-12-05 19:42:22 +01003511 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003512 return err;
3513
3514 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3515 return err;
3516
Takashi Iwai82bc9552006-03-21 11:24:42 +01003517 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3518 return err;
3519
Richard Fish160ea0d2006-09-06 13:58:25 +02003520 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3521 return err;
3522
Takashi Iwai82bc9552006-03-21 11:24:42 +01003523 if (spec->autocfg.dig_out_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003524 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003525 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003526 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003527
Takashi Iwai603c4012008-07-30 15:01:44 +02003528 if (spec->kctls.list)
3529 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003530
3531 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003532 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003533
3534 return 1;
3535}
3536
Sam Revitch62fe78e2006-05-10 15:09:17 +02003537/*
3538 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3539 * funky external mute control using GPIO pins.
3540 */
3541
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003542static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003543 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003544{
3545 unsigned int gpiostate, gpiomask, gpiodir;
3546
3547 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3548 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003549 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003550
3551 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3552 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003553 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003554
3555 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3556 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003557 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003558
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003559 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003560 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3561
3562 snd_hda_codec_write(codec, codec->afg, 0,
3563 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003564 snd_hda_codec_read(codec, codec->afg, 0,
3565 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003566
3567 msleep(1);
3568
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003569 snd_hda_codec_read(codec, codec->afg, 0,
3570 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003571}
3572
Takashi Iwai314634b2006-09-21 11:56:18 +02003573static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3574 unsigned int event)
3575{
3576 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003577 snd_hda_codec_write_cache(codec, nid, 0,
3578 AC_VERB_SET_UNSOLICITED_ENABLE,
3579 (AC_USRSP_EN | event));
Takashi Iwai314634b2006-09-21 11:56:18 +02003580}
3581
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003582static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3583{
3584 int i;
3585 for (i = 0; i < cfg->hp_outs; i++)
3586 if (cfg->hp_pins[i] == nid)
3587 return 1; /* nid is a HP-Out */
3588
3589 return 0; /* nid is not a HP-Out */
3590};
3591
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003592static void stac92xx_power_down(struct hda_codec *codec)
3593{
3594 struct sigmatel_spec *spec = codec->spec;
3595
3596 /* power down inactive DACs */
3597 hda_nid_t *dac;
3598 for (dac = spec->dac_list; *dac; dac++)
Matthew Ranostay44510892008-02-21 07:49:31 +01003599 if (!is_in_dac_nids(spec, *dac) &&
3600 spec->multiout.hp_nid != *dac)
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003601 snd_hda_codec_write_cache(codec, *dac, 0,
3602 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3603}
3604
Mattc7d4b2f2005-06-27 14:59:41 +02003605static int stac92xx_init(struct hda_codec *codec)
3606{
3607 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003608 struct auto_pin_cfg *cfg = &spec->autocfg;
3609 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003610
Mattc7d4b2f2005-06-27 14:59:41 +02003611 snd_hda_sequence_write(codec, spec->init);
3612
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003613 /* power down adcs initially */
3614 if (spec->powerdown_adcs)
3615 for (i = 0; i < spec->num_adcs; i++)
3616 snd_hda_codec_write_cache(codec,
3617 spec->adc_nids[i], 0,
3618 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003619 /* set up pins */
3620 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02003621 /* Enable unsolicited responses on the HP widget */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003622 for (i = 0; i < cfg->hp_outs; i++)
Takashi Iwai314634b2006-09-21 11:56:18 +02003623 enable_pin_detect(codec, cfg->hp_pins[i],
3624 STAC_HP_EVENT);
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01003625 /* force to enable the first line-out; the others are set up
3626 * in unsol_event
3627 */
3628 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3629 AC_PINCTL_OUT_EN);
Takashi Iwaieb995a82006-09-21 14:28:21 +02003630 stac92xx_auto_init_hp_out(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003631 /* fake event to set up pins */
3632 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3633 } else {
3634 stac92xx_auto_init_multi_out(codec);
3635 stac92xx_auto_init_hp_out(codec);
3636 }
3637 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01003638 hda_nid_t nid = cfg->input_pins[i];
3639 if (nid) {
Matthew Ranostayb9aea712008-10-09 08:37:28 -04003640 unsigned int pinctl = snd_hda_codec_read(codec, nid,
3641 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3642 /* if PINCTL already set then skip */
3643 if (pinctl & AC_PINCAP_IN)
3644 continue;
3645 pinctl = AC_PINCTL_IN_EN;
Takashi Iwaic960a032006-03-23 17:06:28 +01003646 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
3647 pinctl |= stac92xx_get_vref(codec, nid);
3648 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3649 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01003650 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003651 for (i = 0; i < spec->num_dmics; i++)
3652 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3653 AC_PINCTL_IN_EN);
3654 for (i = 0; i < spec->num_pwrs; i++) {
3655 int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
3656 ? STAC_HP_EVENT : STAC_PWR_EVENT;
3657 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
3658 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003659 int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
3660 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003661 def_conf = get_defcfg_connect(def_conf);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003662 /* outputs are only ports capable of power management
3663 * any attempts on powering down a input port cause the
3664 * referenced VREF to act quirky.
3665 */
3666 if (pinctl & AC_PINCTL_IN_EN)
3667 continue;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003668 /* skip any ports that don't have jacks since presence
3669 * detection is useless */
3670 if (def_conf && def_conf != AC_JACK_PORT_FIXED)
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003671 continue;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003672 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3673 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3674 }
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003675 if (spec->dac_list)
3676 stac92xx_power_down(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003677 if (cfg->dig_out_pin)
3678 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3679 AC_PINCTL_OUT_EN);
3680 if (cfg->dig_in_pin)
3681 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3682 AC_PINCTL_IN_EN);
3683
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003684 stac_gpio_set(codec, spec->gpio_mask,
3685 spec->gpio_dir, spec->gpio_data);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003686
Mattc7d4b2f2005-06-27 14:59:41 +02003687 return 0;
3688}
3689
Takashi Iwai603c4012008-07-30 15:01:44 +02003690static void stac92xx_free_kctls(struct hda_codec *codec)
3691{
3692 struct sigmatel_spec *spec = codec->spec;
3693
3694 if (spec->kctls.list) {
3695 struct snd_kcontrol_new *kctl = spec->kctls.list;
3696 int i;
3697 for (i = 0; i < spec->kctls.used; i++)
3698 kfree(kctl[i].name);
3699 }
3700 snd_array_free(&spec->kctls);
3701}
3702
Matt2f2f4252005-04-13 14:45:30 +02003703static void stac92xx_free(struct hda_codec *codec)
3704{
Mattc7d4b2f2005-06-27 14:59:41 +02003705 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003706
3707 if (! spec)
3708 return;
3709
Richard Fish11b44bb2006-08-23 18:31:34 +02003710 if (spec->bios_pin_configs)
3711 kfree(spec->bios_pin_configs);
3712
Mattc7d4b2f2005-06-27 14:59:41 +02003713 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003714 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02003715}
3716
Matt4e550962005-07-04 17:51:39 +02003717static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3718 unsigned int flag)
3719{
3720 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3721 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02003722
Takashi Iwaif9acba42007-05-29 18:01:06 +02003723 if (pin_ctl & AC_PINCTL_IN_EN) {
3724 /*
3725 * we need to check the current set-up direction of
3726 * shared input pins since they can be switched via
3727 * "xxx as Output" mixer switch
3728 */
3729 struct sigmatel_spec *spec = codec->spec;
3730 struct auto_pin_cfg *cfg = &spec->autocfg;
3731 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3732 spec->line_switch) ||
3733 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3734 spec->mic_switch))
3735 return;
3736 }
3737
Steve Longerbeam7b043892007-05-03 20:50:03 +02003738 /* if setting pin direction bits, clear the current
3739 direction bits first */
3740 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3741 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3742
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003743 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003744 AC_VERB_SET_PIN_WIDGET_CONTROL,
3745 pin_ctl | flag);
3746}
3747
3748static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3749 unsigned int flag)
3750{
3751 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3752 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003753 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003754 AC_VERB_SET_PIN_WIDGET_CONTROL,
3755 pin_ctl & ~flag);
3756}
3757
Jiang Zhe40c1d302007-11-12 13:05:16 +01003758static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02003759{
3760 if (!nid)
3761 return 0;
3762 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Jiang Zhe40c1d302007-11-12 13:05:16 +01003763 & (1 << 31)) {
3764 unsigned int pinctl;
3765 pinctl = snd_hda_codec_read(codec, nid, 0,
3766 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3767 if (pinctl & AC_PINCTL_IN_EN)
3768 return 0; /* mic- or line-input */
3769 else
3770 return 1; /* HP-output */
3771 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003772 return 0;
3773}
3774
3775static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
Matt4e550962005-07-04 17:51:39 +02003776{
3777 struct sigmatel_spec *spec = codec->spec;
3778 struct auto_pin_cfg *cfg = &spec->autocfg;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003779 int nid = cfg->hp_pins[cfg->hp_outs - 1];
Matt4e550962005-07-04 17:51:39 +02003780 int i, presence;
3781
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003782 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003783 if (spec->gpio_mute)
3784 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3785 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3786
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003787 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003788 if (presence)
3789 break;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003790 if (spec->hp_switch && cfg->hp_pins[i] == nid)
3791 break;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003792 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003793 }
Matt4e550962005-07-04 17:51:39 +02003794
3795 if (presence) {
3796 /* disable lineouts, enable hp */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003797 if (spec->hp_switch)
3798 stac92xx_reset_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003799 for (i = 0; i < cfg->line_outs; i++)
3800 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3801 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003802 for (i = 0; i < cfg->speaker_outs; i++)
3803 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3804 AC_PINCTL_OUT_EN);
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003805 if (spec->eapd_mask)
3806 stac_gpio_set(codec, spec->gpio_mask,
3807 spec->gpio_dir, spec->gpio_data &
3808 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003809 } else {
3810 /* enable lineouts, disable hp */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003811 if (spec->hp_switch)
3812 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003813 for (i = 0; i < cfg->line_outs; i++)
3814 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3815 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003816 for (i = 0; i < cfg->speaker_outs; i++)
3817 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3818 AC_PINCTL_OUT_EN);
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003819 if (spec->eapd_mask)
3820 stac_gpio_set(codec, spec->gpio_mask,
3821 spec->gpio_dir, spec->gpio_data |
3822 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003823 }
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003824 if (!spec->hp_switch && cfg->hp_outs > 1 && presence)
3825 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003826}
3827
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003828static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
3829{
3830 struct sigmatel_spec *spec = codec->spec;
3831 hda_nid_t nid = spec->pwr_nids[idx];
3832 int presence, val;
3833 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
3834 & 0x000000ff;
3835 presence = get_hp_pin_presence(codec, nid);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003836
3837 /* several codecs have two power down bits */
3838 if (spec->pwr_mapping)
3839 idx = spec->pwr_mapping[idx];
3840 else
3841 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003842
3843 if (presence)
3844 val &= ~idx;
3845 else
3846 val |= idx;
3847
3848 /* power down unused output ports */
3849 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
3850};
3851
Takashi Iwai314634b2006-09-21 11:56:18 +02003852static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
3853{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003854 struct sigmatel_spec *spec = codec->spec;
3855 int idx = res >> 26 & 0x0f;
3856
Matthew Ranostay72474be2008-10-09 09:32:17 -04003857 switch ((res >> 26) & 0x70) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003858 case STAC_HP_EVENT:
3859 stac92xx_hp_detect(codec, res);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003860 /* fallthru */
3861 case STAC_PWR_EVENT:
3862 if (spec->num_pwrs > 0)
3863 stac92xx_pin_sense(codec, idx);
Matthew Ranostay72474be2008-10-09 09:32:17 -04003864 break;
3865 case STAC_VREF_EVENT: {
3866 int data = snd_hda_codec_read(codec, codec->afg, 0,
3867 AC_VERB_GET_GPIO_DATA, 0);
3868 /* toggle VREF state based on GPIOx status */
3869 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
3870 !!(data & (1 << idx)));
3871 break;
3872 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003873 }
3874}
3875
Takashi Iwaicb53c622007-08-10 17:21:45 +02003876#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02003877static int stac92xx_resume(struct hda_codec *codec)
3878{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003879 struct sigmatel_spec *spec = codec->spec;
3880
Richard Fish11b44bb2006-08-23 18:31:34 +02003881 stac92xx_set_config_regs(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003882 snd_hda_sequence_write(codec, spec->init);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003883 stac_gpio_set(codec, spec->gpio_mask,
3884 spec->gpio_dir, spec->gpio_data);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003885 snd_hda_codec_resume_amp(codec);
3886 snd_hda_codec_resume_cache(codec);
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003887 /* power down inactive DACs */
3888 if (spec->dac_list)
3889 stac92xx_power_down(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003890 /* invoke unsolicited event to reset the HP state */
3891 if (spec->hp_detect)
3892 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
Mattff6fdc32005-06-27 15:06:52 +02003893 return 0;
3894}
3895#endif
3896
Matt2f2f4252005-04-13 14:45:30 +02003897static struct hda_codec_ops stac92xx_patch_ops = {
3898 .build_controls = stac92xx_build_controls,
3899 .build_pcms = stac92xx_build_pcms,
3900 .init = stac92xx_init,
3901 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02003902 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003903#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02003904 .resume = stac92xx_resume,
3905#endif
Matt2f2f4252005-04-13 14:45:30 +02003906};
3907
3908static int patch_stac9200(struct hda_codec *codec)
3909{
3910 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003911 int err;
Matt2f2f4252005-04-13 14:45:30 +02003912
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003913 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02003914 if (spec == NULL)
3915 return -ENOMEM;
3916
3917 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003918 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02003919 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003920 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
3921 stac9200_models,
3922 stac9200_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02003923 if (spec->board_config < 0) {
3924 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
3925 err = stac92xx_save_bios_config_regs(codec);
3926 if (err < 0) {
3927 stac92xx_free(codec);
3928 return err;
3929 }
3930 spec->pin_configs = spec->bios_pin_configs;
3931 } else {
Matt Porter403d1942005-11-29 15:00:51 +01003932 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
3933 stac92xx_set_config_regs(codec);
3934 }
Matt2f2f4252005-04-13 14:45:30 +02003935
3936 spec->multiout.max_channels = 2;
3937 spec->multiout.num_dacs = 1;
3938 spec->multiout.dac_nids = stac9200_dac_nids;
3939 spec->adc_nids = stac9200_adc_nids;
3940 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02003941 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02003942 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003943 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003944 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003945
Tobin Davisbf277782008-02-03 20:31:47 +01003946 if (spec->board_config == STAC_9200_GATEWAY ||
3947 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02003948 spec->init = stac9200_eapd_init;
3949 else
3950 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02003951 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02003952
Takashi Iwai117f2572008-03-18 09:53:23 +01003953 if (spec->board_config == STAC_9200_PANASONIC) {
3954 spec->gpio_mask = spec->gpio_dir = 0x09;
3955 spec->gpio_data = 0x00;
3956 }
3957
Mattc7d4b2f2005-06-27 14:59:41 +02003958 err = stac9200_parse_auto_config(codec);
3959 if (err < 0) {
3960 stac92xx_free(codec);
3961 return err;
3962 }
Matt2f2f4252005-04-13 14:45:30 +02003963
3964 codec->patch_ops = stac92xx_patch_ops;
3965
3966 return 0;
3967}
3968
Tobin Davis8e21c342007-01-08 11:04:17 +01003969static int patch_stac925x(struct hda_codec *codec)
3970{
3971 struct sigmatel_spec *spec;
3972 int err;
3973
3974 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3975 if (spec == NULL)
3976 return -ENOMEM;
3977
3978 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003979 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01003980 spec->pin_nids = stac925x_pin_nids;
3981 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
3982 stac925x_models,
3983 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01003984 again:
Tobin Davis8e21c342007-01-08 11:04:17 +01003985 if (spec->board_config < 0) {
Tobin Davis2c11f952007-05-17 09:36:34 +02003986 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
3987 "using BIOS defaults\n");
Tobin Davis8e21c342007-01-08 11:04:17 +01003988 err = stac92xx_save_bios_config_regs(codec);
3989 if (err < 0) {
3990 stac92xx_free(codec);
3991 return err;
3992 }
3993 spec->pin_configs = spec->bios_pin_configs;
3994 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
3995 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
3996 stac92xx_set_config_regs(codec);
3997 }
3998
3999 spec->multiout.max_channels = 2;
4000 spec->multiout.num_dacs = 1;
4001 spec->multiout.dac_nids = stac925x_dac_nids;
4002 spec->adc_nids = stac925x_adc_nids;
4003 spec->mux_nids = stac925x_mux_nids;
4004 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004005 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004006 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02004007 switch (codec->vendor_id) {
4008 case 0x83847632: /* STAC9202 */
4009 case 0x83847633: /* STAC9202D */
4010 case 0x83847636: /* STAC9251 */
4011 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02004012 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02004013 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004014 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4015 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02004016 break;
4017 default:
4018 spec->num_dmics = 0;
4019 break;
4020 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004021
4022 spec->init = stac925x_core_init;
4023 spec->mixer = stac925x_mixer;
4024
4025 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004026 if (!err) {
4027 if (spec->board_config < 0) {
4028 printk(KERN_WARNING "hda_codec: No auto-config is "
4029 "available, default to model=ref\n");
4030 spec->board_config = STAC_925x_REF;
4031 goto again;
4032 }
4033 err = -EINVAL;
4034 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004035 if (err < 0) {
4036 stac92xx_free(codec);
4037 return err;
4038 }
4039
4040 codec->patch_ops = stac92xx_patch_ops;
4041
4042 return 0;
4043}
4044
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004045static struct hda_input_mux stac92hd73xx_dmux = {
4046 .num_items = 4,
4047 .items = {
4048 { "Analog Inputs", 0x0b },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004049 { "Digital Mic 1", 0x09 },
4050 { "Digital Mic 2", 0x0a },
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004051 { "CD", 0x08 },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004052 }
4053};
4054
4055static int patch_stac92hd73xx(struct hda_codec *codec)
4056{
4057 struct sigmatel_spec *spec;
4058 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4059 int err = 0;
4060
4061 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4062 if (spec == NULL)
4063 return -ENOMEM;
4064
4065 codec->spec = spec;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02004066 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004067 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4068 spec->pin_nids = stac92hd73xx_pin_nids;
4069 spec->board_config = snd_hda_check_board_config(codec,
4070 STAC_92HD73XX_MODELS,
4071 stac92hd73xx_models,
4072 stac92hd73xx_cfg_tbl);
4073again:
4074 if (spec->board_config < 0) {
4075 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4076 " STAC92HD73XX, using BIOS defaults\n");
4077 err = stac92xx_save_bios_config_regs(codec);
4078 if (err < 0) {
4079 stac92xx_free(codec);
4080 return err;
4081 }
4082 spec->pin_configs = spec->bios_pin_configs;
4083 } else {
4084 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
4085 stac92xx_set_config_regs(codec);
4086 }
4087
4088 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
4089 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4090
4091 if (spec->multiout.num_dacs < 0) {
4092 printk(KERN_WARNING "hda_codec: Could not determine "
4093 "number of channels defaulting to DAC count\n");
4094 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
4095 }
4096
4097 switch (spec->multiout.num_dacs) {
4098 case 0x3: /* 6 Channel */
4099 spec->mixer = stac92hd73xx_6ch_mixer;
4100 spec->init = stac92hd73xx_6ch_core_init;
4101 break;
4102 case 0x4: /* 8 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004103 spec->mixer = stac92hd73xx_8ch_mixer;
4104 spec->init = stac92hd73xx_8ch_core_init;
4105 break;
4106 case 0x5: /* 10 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004107 spec->mixer = stac92hd73xx_10ch_mixer;
4108 spec->init = stac92hd73xx_10ch_core_init;
4109 };
4110
4111 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
4112 spec->aloopback_mask = 0x01;
4113 spec->aloopback_shift = 8;
4114
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004115 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004116 spec->mux_nids = stac92hd73xx_mux_nids;
4117 spec->adc_nids = stac92hd73xx_adc_nids;
4118 spec->dmic_nids = stac92hd73xx_dmic_nids;
4119 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004120 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostay89385032008-09-11 09:49:39 -04004121 spec->amp_nids = stac92hd73xx_amp_nids;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004122 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004123
4124 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4125 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01004126 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004127 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4128 sizeof(stac92hd73xx_dmux));
4129
Matthew Ranostaya7662642008-02-21 07:51:14 +01004130 switch (spec->board_config) {
4131 case STAC_DELL_M6:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004132 spec->init = dell_eq_core_init;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004133 spec->num_smuxes = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004134 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4135 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
4136 spec->num_amps = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004137 switch (codec->subsystem_id) {
4138 case 0x1028025e: /* Analog Mics */
4139 case 0x1028025f:
4140 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4141 spec->num_dmics = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004142 spec->private_dimux.num_items = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004143 break;
Matthew Ranostayd654a662008-03-14 08:46:51 +01004144 case 0x10280271: /* Digital Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004145 case 0x10280272:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004146 spec->init = dell_m6_core_init;
4147 /* fall-through */
4148 case 0x10280254:
4149 case 0x10280255:
Matthew Ranostaya7662642008-02-21 07:51:14 +01004150 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4151 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004152 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004153 break;
4154 case 0x10280256: /* Both */
4155 case 0x10280057:
4156 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4157 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4158 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004159 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004160 break;
4161 }
4162 break;
4163 default:
4164 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004165 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostaya7662642008-02-21 07:51:14 +01004166 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004167 if (spec->board_config > STAC_92HD73XX_REF) {
4168 /* GPIO0 High = Enable EAPD */
4169 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4170 spec->gpio_data = 0x01;
4171 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004172 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004173
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004174 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4175 spec->pwr_nids = stac92hd73xx_pwr_nids;
4176
Matthew Ranostayd9737752008-09-07 12:03:41 +02004177 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004178
4179 if (!err) {
4180 if (spec->board_config < 0) {
4181 printk(KERN_WARNING "hda_codec: No auto-config is "
4182 "available, default to model=ref\n");
4183 spec->board_config = STAC_92HD73XX_REF;
4184 goto again;
4185 }
4186 err = -EINVAL;
4187 }
4188
4189 if (err < 0) {
4190 stac92xx_free(codec);
4191 return err;
4192 }
4193
4194 codec->patch_ops = stac92xx_patch_ops;
4195
4196 return 0;
4197}
4198
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004199static struct hda_input_mux stac92hd83xxx_dmux = {
4200 .num_items = 3,
4201 .items = {
4202 { "Analog Inputs", 0x03 },
4203 { "Digital Mic 1", 0x04 },
4204 { "Digital Mic 2", 0x05 },
4205 }
4206};
4207
4208static int patch_stac92hd83xxx(struct hda_codec *codec)
4209{
4210 struct sigmatel_spec *spec;
4211 int err;
4212
4213 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4214 if (spec == NULL)
4215 return -ENOMEM;
4216
4217 codec->spec = spec;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004218 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004219 spec->mono_nid = 0x19;
4220 spec->digbeep_nid = 0x21;
4221 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4222 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4223 spec->adc_nids = stac92hd83xxx_adc_nids;
4224 spec->pwr_nids = stac92hd83xxx_pwr_nids;
4225 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4226 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
4227 spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
4228
4229 spec->init = stac92hd83xxx_core_init;
4230 switch (codec->vendor_id) {
4231 case 0x111d7605:
4232 spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
4233 break;
4234 default:
4235 spec->num_pwrs--;
4236 spec->init++; /* switch to config #2 */
4237 spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
4238 }
4239
4240 spec->mixer = stac92hd83xxx_mixer;
4241 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4242 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4243 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
4244 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4245 spec->dinput_mux = &stac92hd83xxx_dmux;
4246 spec->pin_nids = stac92hd83xxx_pin_nids;
4247 spec->board_config = snd_hda_check_board_config(codec,
4248 STAC_92HD83XXX_MODELS,
4249 stac92hd83xxx_models,
4250 stac92hd83xxx_cfg_tbl);
4251again:
4252 if (spec->board_config < 0) {
4253 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4254 " STAC92HD83XXX, using BIOS defaults\n");
4255 err = stac92xx_save_bios_config_regs(codec);
4256 if (err < 0) {
4257 stac92xx_free(codec);
4258 return err;
4259 }
4260 spec->pin_configs = spec->bios_pin_configs;
4261 } else {
4262 spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config];
4263 stac92xx_set_config_regs(codec);
4264 }
4265
4266 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4267 if (!err) {
4268 if (spec->board_config < 0) {
4269 printk(KERN_WARNING "hda_codec: No auto-config is "
4270 "available, default to model=ref\n");
4271 spec->board_config = STAC_92HD83XXX_REF;
4272 goto again;
4273 }
4274 err = -EINVAL;
4275 }
4276
4277 if (err < 0) {
4278 stac92xx_free(codec);
4279 return err;
4280 }
4281
4282 codec->patch_ops = stac92xx_patch_ops;
4283
4284 return 0;
4285}
4286
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004287#ifdef SND_HDA_NEEDS_RESUME
4288static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr)
4289{
4290 struct sigmatel_spec *spec = codec->spec;
4291 int i;
4292 snd_hda_codec_write_cache(codec, codec->afg, 0,
4293 AC_VERB_SET_POWER_STATE, pwr);
4294
4295 msleep(1);
4296 for (i = 0; i < spec->num_adcs; i++) {
4297 snd_hda_codec_write_cache(codec,
4298 spec->adc_nids[i], 0,
4299 AC_VERB_SET_POWER_STATE, pwr);
4300 }
4301};
4302
4303static int stac92hd71xx_resume(struct hda_codec *codec)
4304{
4305 stac92hd71xx_set_power_state(codec, AC_PWRST_D0);
4306 return stac92xx_resume(codec);
4307}
4308
4309static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state)
4310{
4311 stac92hd71xx_set_power_state(codec, AC_PWRST_D3);
4312 return 0;
4313};
4314
4315#endif
4316
4317static struct hda_codec_ops stac92hd71bxx_patch_ops = {
4318 .build_controls = stac92xx_build_controls,
4319 .build_pcms = stac92xx_build_pcms,
4320 .init = stac92xx_init,
4321 .free = stac92xx_free,
4322 .unsol_event = stac92xx_unsol_event,
4323#ifdef SND_HDA_NEEDS_RESUME
4324 .resume = stac92hd71xx_resume,
4325 .suspend = stac92hd71xx_suspend,
4326#endif
4327};
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004328
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004329static struct hda_input_mux stac92hd71bxx_dmux = {
4330 .num_items = 4,
4331 .items = {
4332 { "Analog Inputs", 0x00 },
4333 { "Mixer", 0x01 },
4334 { "Digital Mic 1", 0x02 },
4335 { "Digital Mic 2", 0x03 },
4336 }
4337};
4338
Matthew Ranostaye035b842007-11-06 11:53:55 +01004339static int patch_stac92hd71bxx(struct hda_codec *codec)
4340{
4341 struct sigmatel_spec *spec;
4342 int err = 0;
4343
4344 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4345 if (spec == NULL)
4346 return -ENOMEM;
4347
4348 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004349 codec->patch_ops = stac92xx_patch_ops;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004350 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004351 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004352 spec->pin_nids = stac92hd71bxx_pin_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004353 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux,
4354 sizeof(stac92hd71bxx_dmux));
Matthew Ranostaye035b842007-11-06 11:53:55 +01004355 spec->board_config = snd_hda_check_board_config(codec,
4356 STAC_92HD71BXX_MODELS,
4357 stac92hd71bxx_models,
4358 stac92hd71bxx_cfg_tbl);
4359again:
4360 if (spec->board_config < 0) {
4361 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4362 " STAC92HD71BXX, using BIOS defaults\n");
4363 err = stac92xx_save_bios_config_regs(codec);
4364 if (err < 0) {
4365 stac92xx_free(codec);
4366 return err;
4367 }
4368 spec->pin_configs = spec->bios_pin_configs;
4369 } else {
4370 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
4371 stac92xx_set_config_regs(codec);
4372 }
4373
Matthew Ranostay541eee82007-12-14 12:08:04 +01004374 switch (codec->vendor_id) {
4375 case 0x111d76b6: /* 4 Port without Analog Mixer */
4376 case 0x111d76b7:
4377 case 0x111d76b4: /* 6 Port without Analog Mixer */
4378 case 0x111d76b5:
4379 spec->mixer = stac92hd71bxx_mixer;
4380 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004381 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004382 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004383 case 0x111d7608: /* 5 Port with Analog Mixer */
Matthew Ranostay72474be2008-10-09 09:32:17 -04004384 switch (codec->subsystem_id) {
4385 case 0x103c361a:
4386 /* Enable VREF power saving on GPIO1 detect */
4387 snd_hda_codec_write(codec, codec->afg, 0,
4388 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
4389 snd_hda_codec_write_cache(codec, codec->afg, 0,
4390 AC_VERB_SET_UNSOLICITED_ENABLE,
4391 (AC_USRSP_EN | STAC_VREF_EVENT | 0x01));
4392 spec->gpio_mask |= 0x02;
4393 break;
4394 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004395 if ((codec->revision_id & 0xf) == 0 ||
4396 (codec->revision_id & 0xf) == 1) {
4397#ifdef SND_HDA_NEEDS_RESUME
4398 codec->patch_ops = stac92hd71bxx_patch_ops;
4399#endif
4400 spec->stream_delay = 40; /* 40 milliseconds */
4401 }
4402
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004403 /* no output amps */
4404 spec->num_pwrs = 0;
4405 spec->mixer = stac92hd71bxx_analog_mixer;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004406 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004407
4408 /* disable VSW */
4409 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
4410 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
4411 break;
4412 case 0x111d7603: /* 6 Port with Analog Mixer */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004413 if ((codec->revision_id & 0xf) == 1) {
4414#ifdef SND_HDA_NEEDS_RESUME
4415 codec->patch_ops = stac92hd71bxx_patch_ops;
4416#endif
4417 spec->stream_delay = 40; /* 40 milliseconds */
4418 }
4419
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004420 /* no output amps */
4421 spec->num_pwrs = 0;
4422 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01004423 default:
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004424 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004425 spec->mixer = stac92hd71bxx_analog_mixer;
4426 spec->init = stac92hd71bxx_analog_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004427 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004428 }
4429
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004430 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004431 spec->aloopback_shift = 0;
4432
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004433 if (spec->board_config > STAC_92HD71BXX_REF) {
4434 /* GPIO0 = EAPD */
4435 spec->gpio_mask = 0x01;
4436 spec->gpio_dir = 0x01;
4437 spec->gpio_data = 0x01;
4438 }
Matthew Ranostaye035b842007-11-06 11:53:55 +01004439
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004440 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004441 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004442 spec->mux_nids = stac92hd71bxx_mux_nids;
4443 spec->adc_nids = stac92hd71bxx_adc_nids;
4444 spec->dmic_nids = stac92hd71bxx_dmic_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004445 spec->dmux_nids = stac92hd71bxx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004446 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004447 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004448
4449 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
4450 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004451
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004452 switch (spec->board_config) {
4453 case STAC_HP_M4:
4454 spec->num_dmics = 0;
Matthew Ranostayb9aea712008-10-09 08:37:28 -04004455 spec->num_smuxes = 0;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004456 spec->num_dmuxes = 0;
4457
4458 /* enable internal microphone */
Matthew Ranostayb9aea712008-10-09 08:37:28 -04004459 stac92xx_set_config_reg(codec, 0x0e, 0x01813040);
4460 stac92xx_auto_set_pinctl(codec, 0x0e,
4461 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004462 break;
4463 default:
4464 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
4465 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
4466 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4467 };
4468
Takashi Iwaiaea7bb02008-02-25 18:26:41 +01004469 spec->multiout.num_dacs = 1;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004470 spec->multiout.hp_nid = 0x11;
4471 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004472 if (spec->dinput_mux)
4473 spec->private_dimux.num_items +=
4474 spec->num_dmics -
4475 (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004476
4477 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
4478 if (!err) {
4479 if (spec->board_config < 0) {
4480 printk(KERN_WARNING "hda_codec: No auto-config is "
4481 "available, default to model=ref\n");
4482 spec->board_config = STAC_92HD71BXX_REF;
4483 goto again;
4484 }
4485 err = -EINVAL;
4486 }
4487
4488 if (err < 0) {
4489 stac92xx_free(codec);
4490 return err;
4491 }
4492
Matthew Ranostaye035b842007-11-06 11:53:55 +01004493 return 0;
4494};
4495
Matt2f2f4252005-04-13 14:45:30 +02004496static int patch_stac922x(struct hda_codec *codec)
4497{
4498 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004499 int err;
Matt2f2f4252005-04-13 14:45:30 +02004500
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004501 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004502 if (spec == NULL)
4503 return -ENOMEM;
4504
4505 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004506 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004507 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004508 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
4509 stac922x_models,
4510 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08004511 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004512 spec->gpio_mask = spec->gpio_dir = 0x03;
4513 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004514 /* Intel Macs have all same PCI SSID, so we need to check
4515 * codec SSID to distinguish the exact models
4516 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004517 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004518 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004519
4520 case 0x106b0800:
4521 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02004522 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004523 case 0x106b0600:
4524 case 0x106b0700:
4525 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004526 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004527 case 0x106b0e00:
4528 case 0x106b0f00:
4529 case 0x106b1600:
4530 case 0x106b1700:
4531 case 0x106b0200:
4532 case 0x106b1e00:
4533 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004534 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004535 case 0x106b1a00:
4536 case 0x00000100:
4537 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02004538 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004539 case 0x106b0a00:
4540 case 0x106b2200:
4541 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02004542 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08004543 default:
4544 spec->board_config = STAC_INTEL_MAC_V3;
4545 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004546 }
4547 }
4548
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004549 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004550 if (spec->board_config < 0) {
4551 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
4552 "using BIOS defaults\n");
4553 err = stac92xx_save_bios_config_regs(codec);
4554 if (err < 0) {
4555 stac92xx_free(codec);
4556 return err;
4557 }
4558 spec->pin_configs = spec->bios_pin_configs;
4559 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
Matt Porter403d1942005-11-29 15:00:51 +01004560 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
4561 stac92xx_set_config_regs(codec);
4562 }
Matt2f2f4252005-04-13 14:45:30 +02004563
Matt2f2f4252005-04-13 14:45:30 +02004564 spec->adc_nids = stac922x_adc_nids;
4565 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004566 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004567 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004568 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004569 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004570
4571 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004572 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004573
4574 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02004575
Matt Porter3cc08dc2006-01-23 15:27:49 +01004576 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004577 if (!err) {
4578 if (spec->board_config < 0) {
4579 printk(KERN_WARNING "hda_codec: No auto-config is "
4580 "available, default to model=ref\n");
4581 spec->board_config = STAC_D945_REF;
4582 goto again;
4583 }
4584 err = -EINVAL;
4585 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004586 if (err < 0) {
4587 stac92xx_free(codec);
4588 return err;
4589 }
4590
4591 codec->patch_ops = stac92xx_patch_ops;
4592
Takashi Iwai807a46362007-05-29 19:01:37 +02004593 /* Fix Mux capture level; max to 2 */
4594 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
4595 (0 << AC_AMPCAP_OFFSET_SHIFT) |
4596 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4597 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4598 (0 << AC_AMPCAP_MUTE_SHIFT));
4599
Matt Porter3cc08dc2006-01-23 15:27:49 +01004600 return 0;
4601}
4602
4603static int patch_stac927x(struct hda_codec *codec)
4604{
4605 struct sigmatel_spec *spec;
4606 int err;
4607
4608 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4609 if (spec == NULL)
4610 return -ENOMEM;
4611
4612 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004613 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004614 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004615 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
4616 stac927x_models,
4617 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004618 again:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004619 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
4620 if (spec->board_config < 0)
4621 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4622 "STAC927x, using BIOS defaults\n");
Richard Fish11b44bb2006-08-23 18:31:34 +02004623 err = stac92xx_save_bios_config_regs(codec);
4624 if (err < 0) {
4625 stac92xx_free(codec);
4626 return err;
4627 }
4628 spec->pin_configs = spec->bios_pin_configs;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004629 } else {
Matt Porter3cc08dc2006-01-23 15:27:49 +01004630 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
4631 stac92xx_set_config_regs(codec);
4632 }
4633
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004634 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004635 spec->adc_nids = stac927x_adc_nids;
4636 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
4637 spec->mux_nids = stac927x_mux_nids;
4638 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004639 spec->smux_nids = stac927x_smux_nids;
4640 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04004641 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004642 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004643 spec->multiout.dac_nids = spec->dac_nids;
4644
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004645 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02004646 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004647 case STAC_D965_5ST:
4648 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004649 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004650 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004651 spec->num_dmics = 0;
4652
Tobin Davis93ed1502006-09-01 21:03:12 +02004653 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004654 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004655 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004656 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02004657 switch (codec->subsystem_id) {
4658 case 0x10280209:
4659 case 0x1028022e:
4660 /* correct the device field to SPDIF out */
4661 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
4662 break;
4663 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01004664 /* configure the analog microphone on some laptops */
4665 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01004666 /* correct the front output jack as a hp out */
Matthew Ranostay7989fba2008-02-21 07:50:12 +01004667 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01004668 /* correct the front input jack as a mic */
4669 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
4670 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004671 case STAC_DELL_3ST:
4672 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004673 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004674 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004675 spec->dmic_nids = stac927x_dmic_nids;
4676 spec->num_dmics = STAC927X_NUM_DMICS;
4677
Tobin Davis93ed1502006-09-01 21:03:12 +02004678 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004679 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004680 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004681 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004682 break;
4683 default:
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004684 if (spec->board_config > STAC_D965_REF) {
4685 /* GPIO0 High = Enable EAPD */
4686 spec->eapd_mask = spec->gpio_mask = 0x01;
4687 spec->gpio_dir = spec->gpio_data = 0x01;
4688 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004689 spec->num_dmics = 0;
4690
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004691 spec->init = stac927x_core_init;
4692 spec->mixer = stac927x_mixer;
4693 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004694
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004695 spec->num_pwrs = 0;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004696 spec->aloopback_mask = 0x40;
4697 spec->aloopback_shift = 0;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004698
Matt Porter3cc08dc2006-01-23 15:27:49 +01004699 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004700 if (!err) {
4701 if (spec->board_config < 0) {
4702 printk(KERN_WARNING "hda_codec: No auto-config is "
4703 "available, default to model=ref\n");
4704 spec->board_config = STAC_D965_REF;
4705 goto again;
4706 }
4707 err = -EINVAL;
4708 }
Mattc7d4b2f2005-06-27 14:59:41 +02004709 if (err < 0) {
4710 stac92xx_free(codec);
4711 return err;
4712 }
Matt2f2f4252005-04-13 14:45:30 +02004713
4714 codec->patch_ops = stac92xx_patch_ops;
4715
Takashi Iwai52987652008-01-16 16:09:47 +01004716 /*
4717 * !!FIXME!!
4718 * The STAC927x seem to require fairly long delays for certain
4719 * command sequences. With too short delays (even if the answer
4720 * is set to RIRB properly), it results in the silence output
4721 * on some hardwares like Dell.
4722 *
4723 * The below flag enables the longer delay (see get_response
4724 * in hda_intel.c).
4725 */
4726 codec->bus->needs_damn_long_delay = 1;
4727
Matt2f2f4252005-04-13 14:45:30 +02004728 return 0;
4729}
4730
Matt Porterf3302a52006-07-31 12:49:34 +02004731static int patch_stac9205(struct hda_codec *codec)
4732{
4733 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02004734 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02004735
4736 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4737 if (spec == NULL)
4738 return -ENOMEM;
4739
4740 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004741 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004742 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004743 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
4744 stac9205_models,
4745 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004746 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004747 if (spec->board_config < 0) {
4748 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
4749 err = stac92xx_save_bios_config_regs(codec);
4750 if (err < 0) {
4751 stac92xx_free(codec);
4752 return err;
4753 }
4754 spec->pin_configs = spec->bios_pin_configs;
4755 } else {
Matt Porterf3302a52006-07-31 12:49:34 +02004756 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
4757 stac92xx_set_config_regs(codec);
4758 }
4759
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004760 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02004761 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004762 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02004763 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004764 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004765 spec->smux_nids = stac9205_smux_nids;
4766 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004767 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02004768 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004769 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004770 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004771 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02004772
4773 spec->init = stac9205_core_init;
4774 spec->mixer = stac9205_mixer;
4775
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004776 spec->aloopback_mask = 0x40;
4777 spec->aloopback_shift = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02004778 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02004779
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004780 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004781 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02004782 /* Enable SPDIF in/out */
4783 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
4784 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01004785
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004786 /* Enable unsol response for GPIO4/Dock HP connection */
4787 snd_hda_codec_write(codec, codec->afg, 0,
4788 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4789 snd_hda_codec_write_cache(codec, codec->afg, 0,
4790 AC_VERB_SET_UNSOLICITED_ENABLE,
4791 (AC_USRSP_EN | STAC_HP_EVENT));
4792
4793 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004794 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004795 spec->gpio_mask = 0x1b;
4796 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01004797 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004798 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02004799 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004800 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004801 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004802 case STAC_9205_REF:
4803 /* SPDIF-In enabled */
4804 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004805 default:
4806 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004807 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004808 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004809 break;
4810 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02004811
Matt Porterf3302a52006-07-31 12:49:34 +02004812 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004813 if (!err) {
4814 if (spec->board_config < 0) {
4815 printk(KERN_WARNING "hda_codec: No auto-config is "
4816 "available, default to model=ref\n");
4817 spec->board_config = STAC_9205_REF;
4818 goto again;
4819 }
4820 err = -EINVAL;
4821 }
Matt Porterf3302a52006-07-31 12:49:34 +02004822 if (err < 0) {
4823 stac92xx_free(codec);
4824 return err;
4825 }
4826
4827 codec->patch_ops = stac92xx_patch_ops;
4828
4829 return 0;
4830}
4831
Matt2f2f4252005-04-13 14:45:30 +02004832/*
Guillaume Munch6d859062006-08-22 17:15:47 +02004833 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01004834 */
4835
Guillaume Munch99ccc562006-08-16 19:35:12 +02004836/* static config for Sony VAIO FE550G and Sony VAIO AR */
Takashi Iwaidb064e52006-03-16 16:04:58 +01004837static hda_nid_t vaio_dacs[] = { 0x2 };
4838#define VAIO_HP_DAC 0x5
4839static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
4840static hda_nid_t vaio_mux_nids[] = { 0x15 };
4841
4842static struct hda_input_mux vaio_mux = {
Takashi Iwaia3a2f422007-10-11 11:21:21 +02004843 .num_items = 3,
Takashi Iwaidb064e52006-03-16 16:04:58 +01004844 .items = {
Takashi Iwaid7737812006-04-25 13:05:43 +02004845 /* { "HP", 0x0 }, */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004846 { "Mic Jack", 0x1 },
4847 { "Internal Mic", 0x2 },
Takashi Iwaidb064e52006-03-16 16:04:58 +01004848 { "PCM", 0x3 },
4849 }
4850};
4851
4852static struct hda_verb vaio_init[] = {
4853 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004854 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
Takashi Iwaidb064e52006-03-16 16:04:58 +01004855 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4856 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4857 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4858 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004859 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01004860 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4861 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4862 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4863 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4864 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4865 {}
4866};
4867
Guillaume Munch6d859062006-08-22 17:15:47 +02004868static struct hda_verb vaio_ar_init[] = {
4869 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
4870 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4871 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4872 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4873/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
4874 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004875 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Guillaume Munch6d859062006-08-22 17:15:47 +02004876 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4877 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4878/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
4879 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4880 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4881 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4882 {}
4883};
4884
Takashi Iwaidb064e52006-03-16 16:04:58 +01004885/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02004886static struct hda_bind_ctls vaio_bind_master_vol = {
4887 .ops = &snd_hda_bind_vol,
4888 .values = {
4889 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4890 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4891 0
4892 },
4893};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004894
4895/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02004896static struct hda_bind_ctls vaio_bind_master_sw = {
4897 .ops = &snd_hda_bind_sw,
4898 .values = {
4899 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4900 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4901 0,
4902 },
4903};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004904
4905static struct snd_kcontrol_new vaio_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02004906 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4907 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Takashi Iwaidb064e52006-03-16 16:04:58 +01004908 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4909 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4910 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4911 {
4912 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4913 .name = "Capture Source",
4914 .count = 1,
4915 .info = stac92xx_mux_enum_info,
4916 .get = stac92xx_mux_enum_get,
4917 .put = stac92xx_mux_enum_put,
4918 },
4919 {}
4920};
4921
Guillaume Munch6d859062006-08-22 17:15:47 +02004922static struct snd_kcontrol_new vaio_ar_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02004923 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4924 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Guillaume Munch6d859062006-08-22 17:15:47 +02004925 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4926 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4927 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4928 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
4929 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
4930 {
4931 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4932 .name = "Capture Source",
4933 .count = 1,
4934 .info = stac92xx_mux_enum_info,
4935 .get = stac92xx_mux_enum_get,
4936 .put = stac92xx_mux_enum_put,
4937 },
4938 {}
4939};
4940
4941static struct hda_codec_ops stac9872_patch_ops = {
Takashi Iwaidb064e52006-03-16 16:04:58 +01004942 .build_controls = stac92xx_build_controls,
4943 .build_pcms = stac92xx_build_pcms,
4944 .init = stac92xx_init,
4945 .free = stac92xx_free,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004946#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaidb064e52006-03-16 16:04:58 +01004947 .resume = stac92xx_resume,
4948#endif
4949};
4950
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004951static int stac9872_vaio_init(struct hda_codec *codec)
4952{
4953 int err;
4954
4955 err = stac92xx_init(codec);
4956 if (err < 0)
4957 return err;
4958 if (codec->patch_ops.unsol_event)
4959 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
4960 return 0;
4961}
4962
4963static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
4964{
Jiang Zhe40c1d302007-11-12 13:05:16 +01004965 if (get_hp_pin_presence(codec, 0x0a)) {
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004966 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4967 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4968 } else {
4969 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4970 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4971 }
4972}
4973
4974static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
4975{
4976 switch (res >> 26) {
4977 case STAC_HP_EVENT:
4978 stac9872_vaio_hp_detect(codec, res);
4979 break;
4980 }
4981}
4982
4983static struct hda_codec_ops stac9872_vaio_patch_ops = {
4984 .build_controls = stac92xx_build_controls,
4985 .build_pcms = stac92xx_build_pcms,
4986 .init = stac9872_vaio_init,
4987 .free = stac92xx_free,
4988 .unsol_event = stac9872_vaio_unsol_event,
4989#ifdef CONFIG_PM
4990 .resume = stac92xx_resume,
4991#endif
4992};
4993
Guillaume Munch6d859062006-08-22 17:15:47 +02004994enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
4995 CXD9872RD_VAIO,
4996 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
4997 STAC9872AK_VAIO,
4998 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
4999 STAC9872K_VAIO,
5000 /* AR Series. id=0x83847664 and subsys=104D1300 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005001 CXD9872AKD_VAIO,
5002 STAC_9872_MODELS,
5003};
Takashi Iwaidb064e52006-03-16 16:04:58 +01005004
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005005static const char *stac9872_models[STAC_9872_MODELS] = {
5006 [CXD9872RD_VAIO] = "vaio",
5007 [CXD9872AKD_VAIO] = "vaio-ar",
5008};
5009
5010static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5011 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
5012 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
5013 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
Tobin Davis68e22542007-03-12 11:36:39 +01005014 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
Takashi Iwaidb064e52006-03-16 16:04:58 +01005015 {}
5016};
5017
Guillaume Munch6d859062006-08-22 17:15:47 +02005018static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01005019{
5020 struct sigmatel_spec *spec;
5021 int board_config;
5022
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005023 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5024 stac9872_models,
5025 stac9872_cfg_tbl);
Takashi Iwaidb064e52006-03-16 16:04:58 +01005026 if (board_config < 0)
5027 /* unknown config, let generic-parser do its job... */
5028 return snd_hda_parse_generic_codec(codec);
5029
5030 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5031 if (spec == NULL)
5032 return -ENOMEM;
5033
5034 codec->spec = spec;
5035 switch (board_config) {
Guillaume Munch6d859062006-08-22 17:15:47 +02005036 case CXD9872RD_VAIO:
5037 case STAC9872AK_VAIO:
5038 case STAC9872K_VAIO:
Takashi Iwaidb064e52006-03-16 16:04:58 +01005039 spec->mixer = vaio_mixer;
5040 spec->init = vaio_init;
5041 spec->multiout.max_channels = 2;
5042 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5043 spec->multiout.dac_nids = vaio_dacs;
5044 spec->multiout.hp_nid = VAIO_HP_DAC;
5045 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5046 spec->adc_nids = vaio_adcs;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005047 spec->num_pwrs = 0;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005048 spec->input_mux = &vaio_mux;
5049 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005050 codec->patch_ops = stac9872_vaio_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005051 break;
Guillaume Munch6d859062006-08-22 17:15:47 +02005052
5053 case CXD9872AKD_VAIO:
5054 spec->mixer = vaio_ar_mixer;
5055 spec->init = vaio_ar_init;
5056 spec->multiout.max_channels = 2;
5057 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5058 spec->multiout.dac_nids = vaio_dacs;
5059 spec->multiout.hp_nid = VAIO_HP_DAC;
5060 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005061 spec->num_pwrs = 0;
Guillaume Munch6d859062006-08-22 17:15:47 +02005062 spec->adc_nids = vaio_adcs;
5063 spec->input_mux = &vaio_mux;
5064 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005065 codec->patch_ops = stac9872_patch_ops;
Guillaume Munch6d859062006-08-22 17:15:47 +02005066 break;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005067 }
5068
Takashi Iwaidb064e52006-03-16 16:04:58 +01005069 return 0;
5070}
5071
5072
5073/*
Matt2f2f4252005-04-13 14:45:30 +02005074 * patch entries
5075 */
5076struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5077 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5078 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5079 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5080 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5081 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5082 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5083 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02005084 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5085 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5086 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5087 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5088 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5089 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01005090 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5091 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5092 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5093 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5094 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5095 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5096 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5097 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5098 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5099 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01005100 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5101 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5102 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5103 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5104 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5105 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02005106 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5107 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02005108 /* The following does not take into account .id=0x83847661 when subsys =
5109 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5110 * currently not fully supported.
5111 */
5112 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5113 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5114 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02005115 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5116 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5117 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5118 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5119 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5120 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5121 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5122 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005123 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005124 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5125 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005126 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01005127 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5128 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005129 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01005130 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5131 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5132 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5133 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5134 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5135 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5136 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5137 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02005138 {} /* terminator */
5139};